AthSpectralTool.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 <fstream>
15 
16 // Custom includes
17 #include <boost/format.hpp>
18 #include <senf/PPI.hh>
25 
26 #include "Analyzer.hh"
27 
28 #define prefix_
29 //-/////////////////////////////////////////////////////////////////////////////////////////////////
30 
31 void handleSignal(siginfo_t const &)
32 {
34 }
35 
36 namespace {
37  int exitCode_ (0);
38 }
39 
40 void exitCode(int code)
41 {
42  exitCode_ = code;
43 }
44 
45 prefix_ std::string initInterface(Configuration & config)
46 {
48 
49  // first, remove all existing interfaces of the phy device
50  for (std::string const & iface : wnlc.all_interfaces()) {
51  {
52  senf::NetdeviceController netdevCtrl (iface);
53  netdevCtrl.down();
54  }
55  wnlc.del_interface(iface);
56  }
57 
58  std::string name ((boost::format("phy%d-mon") % wnlc.phyIndex()).str());
59 
60  wnlc.add_monInterface(name,
65 
67 
69 
70  return name;
71 }
72 
73 int main(int argc, char const * argv[])
74 {
76 
77  Configuration configuration;
78 
79  if (!configuration.parse( argc, argv)) {
80  exit(1);
81  }
82 
83  std::string ifName (initInterface(configuration));
84 
87  socket.protocol().rcvbuf(SENF_EMU_MAXMTU);
88 
89  Analyzer analyzer (configuration);
90 
91  senf::ppi::connect( source, analyzer);
92 
94  senf::scheduler::SignalEvent sigterm (SIGTERM, handleSignal);
95 
96  if (!analyzer.startSpectralScan()) {
97  SENF_LOG((senf::log::IMPORTANT)("Failed to setup/start the spectral scanner") );
98  exit(1);
99  }
100 
101  SENF_LOG((senf::log::IMPORTANT)("Specral settings"
102  << ": period (atk9k)" << analyzer.athSpectralScan().spectralPeriod()
103  << ", fft-period (ath9k)" << analyzer.athSpectralScan().spectralFFTPeriod()
104  << ", short-repeat (ath9k)" << analyzer.athSpectralScan().spectralShortRepeat()
105  << ", bins (ath10k)" << analyzer.athSpectralScan().spectralBins()
106  << ", count " << analyzer.athSpectralScan().spectralCount() ) );
107 
108  senf::ppi::run();
109 
110  unsigned dropped (socket.protocol().rxQueueDropped());
111  if (dropped > 0) {
112  SENF_LOG((senf::log::IMPORTANT)("Dropped " << dropped << " frames during the capture! CPU overload ?"));
113  }
114 
115  SENF_LOG((senf::log::MESSAGE) (analyzer.stats()) );
116 
117  return exitCode_;
118 }
119 
120 
121 //-/////////////////////////////////////////////////////////////////////////////////////////////////
122 #undef prefix_
123 
124 
125 // Local Variables:
126 // mode: c++
127 // fill-column: 100
128 // c-file-style: "senf"
129 // indent-tabs-mode: nil
130 // ispell-local-dictionary: "american"
131 // compile-command: "scons -u"
132 // comment-column: 40
133 // End:
#define SENF_EMU_MAXMTU
Definition: config.hh:40
unsigned spectralShortRepeat() const
static void logToStderr()
unsigned spectralCount() const
std::string str(T const &t)
std::string phyName
virtual void terminate() const
unsigned spectralFFTPeriod() const
#define prefix_
unsigned frequency
std::string stats()
void exitCode(int code)
void handleSignal(siginfo_t const &)
int run(int argc, char const *argv[])
Definition: dfstest.cc:83
bool parse(int argc, char const *argv[])
ProtocolClientSocketHandle< ConnectedMMapPacketSocketProtocol< QueueReadPolicy > > ConnectedMMapReadPacketSocketHandle
senf::emu::AthSpectralScan & athSpectralScan()
Definition: AnalyzerBase.cc:51
WirelessNLController public header.
unspecified_keyword_type name
int main(int argc, char const *argv[])
std::string const & phyName() const
bool startSpectralScan()
Definition: AnalyzerBase.cc:72
#define SENF_LOG(args)
std::string initInterface(Configuration &config)
unsigned spectralPeriod() const