FrameAnalyzer.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 __FRAMEANALYZER_HH__
15 #define __FRAMEANALYZER_HH__
16 
17 // Custom includes
18 #include <boost/ptr_container/ptr_map.hpp>
24 #include <senf/PPI/Module.hh>
25 #include "Configuration.hh"
26 
28 
29 struct FrameStats
30 {
31  unsigned pktCnt;
32  unsigned byteCnt;
33  unsigned airTime;
36 
38  clear();
39  };
40 
41  void clear() {
42  pktCnt = byteCnt = airTime = 0;
43  rssi.clear();
44  rate.clear();
45  }
46 
47  void update (senf::AnnotationsPacket const & ap) {
48  pktCnt++;
49  byteCnt += ap->length();
50  airTime += ap->airTime();
51  if (ap->rssi() != 0)
52  rssi.accumulate(ap->rssi());
53  rate.accumulate(senf::emu::WLANModulationParameterRegistry::instance().findModulationById(ap->modulationId()).rate);
54  }
55 
56  void dump(std::ostream & os, senf::ClockService::clock_type const & period) {
57  os << "pktCnt " << pktCnt << ", byteCnt " << byteCnt << ", airTime " << airTime
58  << ", airTimeFraction " << float(airTime) / float(senf::ClockService::in_microseconds(period))
59  << ", rssi " << rssi.data() << ", rate" << rate.data();
60  }
61 };
62 
63 class FrameAnalyzer
65 {
67 
68 public:
70 
71  FrameAnalyzer(Configuration const & configuration);
72 
73 protected:
74  Configuration const & configuration_;
75 
76  void resetStats();
77 
78  void resetStartTime();
80  return startTime_;
81  }
82 
83 private:
87  senf::ClockService::clock_type nextTimeout_;
88  std::uint64_t numPackets_;
89 
91  FrameStats ctrl;
92  FrameStats mngt;
93  FrameStats unknown;
94  FrameStats norate;
95  FrameStats corrupt;
96  FrameStats all;
97 
98  void request();
99  void timerEvent();
100  void initWaitEvent();
101 
102  void report(senf::ClockService::clock_type const & timestamp, senf::ClockService::clock_type const & actualDuration);
103 };
104 
106 #endif
107 
config::time_type clock_type
void clear()
senf::ClockService::clock_type const & startTime()
void data(StatisticsData &data_) const
void dump(std::ostream &os, senf::ClockService::clock_type const &period)
void accumulate(T const &value)
u8 data[SPECTRAL_HT20_NUM_BINS]
unsigned airTime
senf::StatisticAccumulator< float > rssi
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_microseconds(clock_type const &v)
unsigned byteCnt
#define SENF_PPI_MODULE(name)
WLANInterface public header.
static WLANModulationParameterRegistry & instance()
void update(senf::AnnotationsPacket const &ap)
senf::StatisticAccumulator< float > rate
unsigned pktCnt
AnnotationsPacket public header.