FrameAnalyzer.cc
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 #include "FrameAnalyzer.hh"
15 
16 // Custom includes
19 #include "ChannelAnalyzer.hh"
20 
21 #define prefix_
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
23 
25  : configuration_(configuration),
26  timer_("reportingTimer", senf::membind( &FrameAnalyzer::timerEvent, this)),
27  initWait_("maxWaitTimer", senf::membind( &FrameAnalyzer::initWaitEvent, this)),
28  startTime_(senf::ClockService::milliseconds(0)),
29  nextTimeout_(senf::ClockService::milliseconds(0)),
30  numPackets_(0)
31 {
32  noroute(input);
33  input.onRequest( &FrameAnalyzer::request);
34  input.throttlingDisc( senf::ppi::ThrottlingDiscipline::NONE);
35  if (configuration.maxWait != senf::ClockService::milliseconds(0))
36  initWait_.timeout( senf::scheduler::now() + configuration.maxWait);
37 }
38 
39 prefix_ void FrameAnalyzer::timerEvent()
40 {
41  // get current time
43  // call report with current time and the actual interval duration
44  if (startTime_ > senf::ClockService::clock_type(0)) {
45  report(current - startTime_, configuration_.reportingInterval + (current - nextTimeout_));
46  }
47  // restart timer fixing any potential scheduling issues
48  nextTimeout_ += configuration_.reportingInterval;
49  timer_.timeout( nextTimeout_);
50 }
51 
52 prefix_ void FrameAnalyzer::initWaitEvent()
53 {
54  SENF_LOG((senf::log::IMPORTANT)("No packet received, terminating..."));
55  exitCode(1);
57 }
58 
60 {
61  SENF_LOG((senf::log::IMPORTANT)("Here we go..."));
62 
63  startTime_ = senf::ClockService::now();
64  nextTimeout_ = startTime_ + configuration_.reportingInterval;
65  timer_.timeout( nextTimeout_);
66  initWait_.disable();
67 }
68 
69 prefix_ void FrameAnalyzer::request()
70 {
72  // we've been started
73  if ((senf::scheduler::now() - startTime_) >= configuration_.duration) {
75  }
76  }
77 
78  // Look for the Annotation Packet. If we have one, we have receiving cooked 802.11 frames...
79  senf::EthernetPacket const & ethIn (input());
81  if (!ap) {
82  return;
83  }
84 
85  if (++numPackets_ == 1) {
87  }
88 
89  all.update(ap);
90 
91  if (ap->corrupt()) {
92  corrupt.update(ap);
93  return;
94  }
95 
96  if (senf::emu::WLANModulationParameterRegistry::instance().findModulationById(ap->modulationId()).rate == 0) {
97  norate.update(ap);
98  return;
99  }
100 
102  if (wlanm) {
103  mngt.update(ap);
104  return;
105  }
106 
108  if (wlanc) {
109  ctrl.update(ap);
110  return;
111  }
112 
113  // nonQoSData WLAN frames
115  if (dataf) {
116  data.update(ap);
117  return;
118  }
119 
120  // QoS Data as Ethernet
122  if (eth) {
123  data.update(ap);
124  return;
125  }
126 
127  unknown.update(ap);
128 }
129 
130 prefix_ void FrameAnalyzer::report(senf::ClockService::clock_type const & timestamp, senf::ClockService::clock_type const & actualDuration)
131 {
132  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t All "; all.dump(std::cout, timestamp) ; std::cout << std::endl;
133  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t Data "; data.dump(std::cout, timestamp) ; std::cout << std::endl;
134  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t Mngt "; mngt.dump(std::cout, timestamp) ; std::cout << std::endl;
135  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t Ctrl "; ctrl.dump(std::cout, timestamp) ; std::cout << std::endl;
136  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t NoRate "; norate.dump(std::cout, timestamp) ; std::cout << std::endl;
137  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t Unknown "; unknown.dump(std::cout, timestamp) ; std::cout << std::endl;
138  std::cout << senf::ClockService::in_milliseconds(timestamp) << "\t Corrupt "; corrupt.dump(std::cout, timestamp) ; std::cout << std::endl;
139 }
140 
141 //-/////////////////////////////////////////////////////////////////////////////////////////////////
142 #undef prefix_
senf::ClockService::clock_type duration
config::time_type clock_type
senf::ClockService::clock_type maxWait
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_milliseconds(clock_type const &v)
void dump(std::ostream &os, senf::ClockService::clock_type const &period)
#define prefix_
virtual void terminate() const
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
void exitCode(int code)
80211Analyzer public header
WLANPacket_DataFrameType::packet WLANPacket_DataFrame
WLANPacket_MgtFrameType::packet WLANPacket_MgtFrame
static SENF_CLOCKSERVICE_CONSTEXPR clock_type milliseconds(int64_type const &v)
void timeout(ClockService::clock_type const &timeout, bool initiallyEnabled=true)
Packet next() const
senf::ClockService::clock_type reportingInterval
WLANPacket_CtrlFrameType::packet WLANPacket_CtrlFrame
Configuration const & configuration_
nothrow
WLANInterface public header.
static WLANModulationParameterRegistry & instance()
void update(senf::AnnotationsPacket const &ap)
static clock_type now()
senf::ppi::connector::PassiveInput< senf::EthernetPacket > input
FrameAnalyzer(Configuration const &configuration)
ConcretePacket< EthernetPacketType > EthernetPacket
#define SENF_LOG(args)
void resetStartTime()