14 #include <boost/filesystem.hpp> 30 std::cerr <<
"usage: dfstest \n" 31 <<
" -i, --interface=<adhoc_iface>\n" 32 <<
" -n --nloops=<loops over frequency range>\n" 33 <<
" -w, --wait=<wait time in sec per frequency>\n" 34 <<
" -t, --time=<total time in sec (0 for endless)>\n" 35 <<
" -f, --frequencies=<frequencies to scan>\n" 36 <<
" --htmode=<NoHT|HT20|HT40Minus|HT40Plus>\n" << std::endl;
44 senf::scheduler::process();
50 log <<
"RadarEvent received for frequency " <<
event.frequency
53 case senf::emu::RadarEvent::RadarDetected:
54 log <<
"Radar Detected";
56 case senf::emu::RadarEvent::CACFinished:
57 log <<
"CAC Finished";
58 senf::scheduler::terminate();
60 case senf::emu::RadarEvent::CACAborted:
62 senf::scheduler::terminate();
64 case senf::emu::RadarEvent::RadarNopFinished:
65 log <<
"Radar-Nop Finished";
68 log <<
"Unknown: " << int(event.type);
75 namespace senf {
namespace emu {
78 WirelessNLController::ChannelType, Enum, (NoHT)(HT20)(HT40Minus)(HT40Plus) );
83 int run(
int argc,
char const * argv[])
86 unsigned nloops = 100000000;
87 unsigned waitTime = 60;
88 unsigned totalTime = 0;
90 emu::WirelessNLController::ChannelType::Enum htMode = emu::WirelessNLController::ChannelType::NoHT;
94 senf::console::root().add(
"interface", fty::Variable(iface));
95 senf::console::root().add(
"nloops", fty::Variable(nloops));
96 senf::console::root().add(
"wait", fty::Variable(waitTime));
97 senf::console::root().add(
"time", fty::Variable(totalTime));
98 senf::console::root().add(
"frequencies", fty::Variable(frequencyRange));
99 senf::console::root().add(
"htmode", fty::Variable(htMode));
102 std::vector<std::string> nonOptions;
105 .
alias(
'i',
"--interface",
true)
106 .
alias(
'n',
"--nloops",
true)
107 .
alias(
'w',
"--wait",
true)
108 .
alias(
't',
"--time",
true)
109 .
alias(
'f',
"--frequencies",
true)
112 cmdlineOptions.
parse();
114 std::cerr << e.message() << std::endl;
117 if (not nonOptions.empty())
128 .frequencyRange(5250000, 5330000)
132 .dfsRequired(
true) );
134 .frequencyRange(5490000, 5730000)
138 .dfsRequired(
true) );
141 std::cout <<
"Settings DFS-only regDomain...";
143 std::cout <<
"Failed !" << std::endl;
146 std::cout <<
"OK" << std::endl;
154 std::cout <<
"Requested regDomain does not match the kernel's regDomain !!!" << std::endl;
164 std::set<unsigned> dfsFreqs (frequencies.begin(), frequencies.end());
165 for (
auto f = dfsFreqs.begin(); f != dfsFreqs.end();) {
166 if (*f < frequencyRange.
lower) {
170 if (frequencyRange.
upper != 0 and *f > frequencyRange.
upper) {
181 if (dfsFreqs.empty()) {
182 std::cout <<
"No DFS-required frequencies found; stopping test.";
189 logTarget.showLevel(
false);
190 logTarget.timeFormat(
"%Y-%m-%d %H:%M:%S");
192 SENF_LOG( (
"Running DFS Test on interface " << iface) );
193 SENF_LOG( (
"Using Interfaces " << senf::stringJoin(dfsFreqs,
", ")) );
203 wnlc.
radarEvent.signal.connect(&handleRadarEvent);
208 "dfstest total timeout", boost::bind(::exit, 0),
211 while (nloops-- > 0) {
212 for (
unsigned freq : dfsFreqs) {
215 SENF_LOG( (
"Performing CAC for frequency " <<
freq <<
" (" << senf_console_format_enum(htMode) <<
")") );
220 SENF_LOG( (
"DFS state for frequency " <<
freq <<
" is Unavailable; skipping frequency.") );
223 SENF_LOG( (
"Join cell on frequency " <<
freq <<
" (" << senf_console_format_enum(htMode)
224 <<
") and wait " << waitTime <<
" seconds for radar events.") );
240 int main(
int argc,
char const * argv[])
249 std::cerr <<
"Failed to init CRDA ?!?" << std::endl;
254 return run( argc, argv);
256 std::cerr << e.
message() << std::endl;
config::time_type clock_type
#define SENF_LOG_BLOCK(args)
WirelessExtController public header.
void print_usage_and_exit()
virtual void terminate() const
static SENF_CLOCKSERVICE_CONSTEXPR clock_type seconds(int64_type const &v)
std::pair< DFSState::Enum, std::uint32_t > dfsState(frequency_type freq)
SENF_CONSOLE_REGISTER_ENUM_MEMBER(DVBModulationParameter, fec_rate_t,(FEC_NONE)(FEC_1_2)(FEC_2_3)(FEC_3_4)(FEC_4_5)(FEC_5_6)(FEC_6_7)(FEC_7_8)(FEC_8_9)(FEC_AUTO)(FEC_3_5)(FEC_9_10))
ProgramOptions & nonOptions(Container &container)
std::set< RegulatoryRule > rules
int run(int argc, char const **argv)
int run(int argc, char const *argv[])
NetlinkEvent< RadarEvent > radarEvent
FrequencyRange frequencies()
int main(int argc, char const *argv[])
static ConsoleTarget & instance()
std::string alpha2Country
JoinParameters::ptr ibss_join(std::string const &ssid, frequency_type freq, ChannelMode::Enum channelMode, bool &success)
WirelessNLController public header.
bool init(bool MasterMode=false, std::string const &filename=DEFAULT_CRDA_SYNC_FILE)
bool regDomain(senf::emu::RegulatoryDomain regDomain)
std::string message() const
void start_radarDetection(unsigned int freq, ChannelMode::Enum=ChannelMode::NoHT20)
ProgramOptions & alias(char letter, std::string const &longOpt, bool withArg=false)