Rx.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 
17 //#include "main.hh"
18 //#include "main.ih"
19 
20 // Custom includes
21 #include <boost/lexical_cast.hpp>
22 #include <iostream>
23 #include <senf/PPI.hh>
34 #include <senf/Utils/Logger.hh>
35 #include <senf/Utils/Console.hh>
36 
37 #include "MPLSPacket.hh"
38 #include "TIMPacket.hh"
39 
40 //#include "main.mpp"
41 #define prefix_
42 
44 namespace module = senf::ppi::module;
46 namespace ppi = senf::ppi;
47 namespace emu = senf::emu;
48 
49 namespace {
50 
51  class Receiver : public module::Module
52  {
53  SENF_PPI_MODULE(Receiver);
54  public:
56  std::uint32_t label;
57  wiback::TIMSeqNoStats e2eStats;
58  wiback::TIMSeqNoStats llStats;
59  std::uint32_t ignored;
60 
61  Receiver(senf::MACAddress const & src, senf::MACAddress const & dst)
62  : src_ (src), dst_(dst)
63  {
64  noroute(input);
66  input.onRequest(&Receiver::request);
67 
68  reset();
69  }
70 
71  private:
72  void request()
73  {
74  senf::EthernetPacket const & eth (input());
75  if ((!src_ or eth->source() == src_) and eth->destination() == dst_) {
77  if (mpls) {
78  if (label == 0xffffffff or label != mpls->label()) {
79  reset();
80  label = mpls->label();
81  }
83  if (tim) {
84  e2eStats.processSeqNo(tim);
85  llStats.processLLSeqNo(tim);
86  return;
87  }
88  }
89  }
90  ignored++;
91  }
92 
93  void reset() {
94  label = 0xffffffff;
95  e2eStats.reset();
96  llStats.reset();
97  ignored = 0;
98  }
99 
100  public:
101  void clear() {
102  e2eStats.clear();
103  llStats.clear();
104  ignored = 0;
105  }
106 
107  void report(std::ostream & os, senf::ClockService::clock_type const & period) {
108  os << "Label " << label;
109  os << "; E2E stats: "; e2eStats.dump(os, period);
110  os << "; LL stats: "; llStats.dump(os, period);
111  os << "; ignored " << ignored;
112  }
113 
114  senf::MACAddress src_;
115  senf::MACAddress dst_;
116  };
117 }
118 
120 #undef prefix_
121 //#include "main.mpp"
122 
123 
124 // Local Variables:
125 // mode: c++
126 // indent-tabs-mode: nil
127 // End:
config::time_type clock_type
WirelessExtController public header.
bool processLLSeqNo(TIMPacket const &tim)
Definition: TIMPacket.hh:136
Packet next() const
#define SENF_PPI_MODULE(name)
nothrow
bool processSeqNo(TIMPacket const &tim)
Definition: TIMPacket.hh:132
ConcretePacket< EthernetPacketType > EthernetPacket
::phoenix::function< detail::clear > const clear
void dump(std::ostream &os, senf::ClockService::clock_type const &period=senf::ClockService::clock_type(0))
Definition: TIMPacket.hh:140
HardwareEthernetInterface public header.
HardwareWLANInterface public header.
void throttlingDisc(ThrottlingDisc const &disc)