EthernetFragmenter.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
14 #ifndef HH_WiBACK_Core_Interfaces_EthernetFragmenter_
15 #define HH_WiBACK_Core_Interfaces_EthernetFragmenter_ 1
16 
17 // Custom includes
18 #include <boost/unordered/unordered_map.hpp>
19 #include <senf/PPI/Module.hh>
20 #include <senf/PPI/Connectors.hh>
22 
24 namespace senf {
25 namespace emu {
26 
28  {
29  public:
32 
33  unsigned fragmentationCount();
34 
35  static bool fragmentationRequired(senf::EthernetPacket const & pkt, unsigned threshold);
36 
37  protected:
38  void do_fragmentFrame(senf::EthernetPacket const & eth, unsigned threshold);
39 
40  private:
41  virtual void v_outputFragment(senf::EthernetPacket const & eth) = 0;
42 
43  unsigned fragmentationCount_;
44  };
45 
47  : public EthernetFragmenterBase
48  {
49  public:
51 
52  void fragmentFrame(senf::EthernetPacket const & pkt, unsigned treshold);
53  std::vector<senf::EthernetPacket> & fragments();
54 
55  private:
56  std::vector<senf::EthernetPacket> fragments_;
57  void v_outputFragment(senf::EthernetPacket const & eth) override;
58  };
59 
63  {
65 
66  public:
69 
70  EthernetFragmenterModule(std::uint16_t defaultFragThresh = 1500u);
71 
72  void fragmentationThreshold(std::uint16_t _fragmentationThreshold, senf::MACAddress const & dst = senf::MACAddress::None);
73  std::uint16_t fragmentationThreshold(senf::MACAddress const & dst = senf::MACAddress::None) const;
74  boost::unordered_map<senf::MACAddress,std::uint16_t> const & fragThreshMap() const;
75  void reset();
76  void bypass(bool on);
77  bool bypass() const;
78 
79  private:
80  void v_outputFragment(senf::EthernetPacket const & eth) override;
81 
82  void onRequest();
83  void onRequestBypass();
84 
85  boost::unordered_map<senf::MACAddress,std::uint16_t> fragThreshMap_;
86  std::uint16_t defaultFragThresh_;
87  bool bypass_;
88  };
89 }}
90 
92 //#include "EthernetFragmenter.cci"
93 //#include "EthernetFragmenter.ct"
94 //#include "EthernetFragmenter.cti"
95 #endif
static MACAddress const None
senf::ppi::connector::PassiveInput< senf::EthernetPacket > input
senf::ppi::connector::ActiveOutput< senf::EthernetPacket > output
#define SENF_PPI_MODULE(name)
void do_fragmentFrame(senf::EthernetPacket const &eth, unsigned threshold)
ConcretePacket< EthernetPacketType > EthernetPacket
static bool fragmentationRequired(senf::EthernetPacket const &pkt, unsigned threshold)