Analyzer.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 "Analyzer.hh"
15 
16 // Custom includes
21 
22 #define prefix_
23 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 
26  : AnalyzerBase(configuration)
27 {
28 }
29 
31 {
32 }
33 
34 prefix_ void Analyzer::v_terminate(senf::ClockService::clock_type const & sessionDuration)
35 {
36  SENF_LOG((senf::log::MESSAGE)("session terminated after " << senf::ClockService::in_seconds(sessionDuration) << "s") );
37 }
38 
39 prefix_ void Analyzer::v_timerInterval(senf::ClockService::clock_type const & timestamp, senf::ClockService::clock_type const & actualDuration)
40 {
42  << "ms, actualIntervalDuration " << senf::ClockService::in_milliseconds(actualDuration) << "ms: "
43  << "Some message here...") );
44 }
45 
46 prefix_ void Analyzer::v_80211FrameReceived(std::uint64_t tsft, unsigned frequency, signed rssi, unsigned rate, unsigned length, senf::RadiotapPacket & rt)
47 {
48  // this parses the Radiotap packet to get the Source Mac Address
50  try {
52  if (data && (data.size() >= senf::WLANPacket_DataFrameParser::init_bytes)) {
53  srcAddress = data->sourceAddress();
54  } else {
56  if (mgt && (mgt.size() >= senf::WLANPacket_MgtFrameParser::init_bytes)) {
57  srcAddress = mgt->sourceAddress();
58  } else {
60  if (ctrl && ctrl->is_rts() && (ctrl.size() >= senf::WLANPacket_CtrlFrameParser::init_bytes)) {
61  srcAddress = ctrl->sourceAddress();
62  }
63  }
64  }
65  } catch (...) {
66  // catch any possible exception here.
67  // If we catch one, we assume that we failed to extract a valid/useful source address
68  SENF_LOG( (senf::log::MESSAGE) ("Couldn't parse the source address from Radio packet") );
69  srcAddress = senf::MACAddress::None;
70  }
71 
72  // rough estimate without preamble, padding, FCS, etc !!!
73  senf::ClockService::clock_type airtime (rate ? (senf::ClockService::microseconds((length * 8 * 1000) / rate)) : 0);
74 
75  SENF_LOG((senf::log::MESSAGE) ("tsft " << std::hex << tsft << std::dec << " 80211 frame received.Freqency " << frequency
76  << ", rssi " << rssi << ", rate " << rate << ", length " << length
77  << ", airtime " << senf::ClockService::in_microseconds(airtime) << "us") );
78 }
79 
80 prefix_ void Analyzer::v_SpectralDataReceived(std::uint64_t tsft, unsigned frequency, unsigned bins, fft_sample_ht20 const & sample)
81 {
82  SENF_LOG((senf::log::MESSAGE) ("tsft " << std::hex << tsft << std::dec << " Spectral samples (HT20) received on frequency " << frequency) );
83 }
84 
85 prefix_ void Analyzer::v_SpectralDataReceived(std::uint64_t tsft, unsigned frequency, unsigned bins, fft_sample_ht20_40 const & sample)
86 {
87  SENF_LOG((senf::log::MESSAGE) ("tsft " << std::hex << tsft << std::dec << " Spectral samples (HT20_40) received on frequency " << frequency) );
88 }
89 
90 prefix_ void Analyzer::v_SpectralDataReceived(std::uint64_t tsft, unsigned frequency, unsigned bins, fft_sample_ath10k const & sample)
91 {
92  SENF_LOG((senf::log::MESSAGE) ("tsft " << std::hex << tsft << std::dec << " Spectral samples (ATH10K) received on frequency " << frequency << ", bins " << bins) );
93 }
94 
95 
96 //-/////////////////////////////////////////////////////////////////////////////////////////////////
97 #undef prefix_
config::time_type clock_type
static MACAddress const None
Analyzer(senf::MACAddress const &mac, Configuration const &config)
Definition: Analyzer.cc:125
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_milliseconds(clock_type const &v)
u8 data[SPECTRAL_HT20_NUM_BINS]
Annotations public header.
WLANPacket_DataFrameType::packet WLANPacket_DataFrame
WLANPacket_MgtFrameType::packet WLANPacket_MgtFrame
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_microseconds(clock_type const &v)
~Analyzer()
Definition: Analyzer.cc:30
#define prefix_
Definition: Analyzer.cc:22
static SENF_CLOCKSERVICE_CONSTEXPR clock_type microseconds(int64_type const &v)
WLANPacket_CtrlFrameType::packet WLANPacket_CtrlFrame
nothrow
s8 rssi
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_seconds(clock_type const &v)
#define SENF_LOG(args)
__be16 length