17 #include <boost/format.hpp> 18 #include <senf/PPI.hh> 39 for (std::string
const & iface : wnlc.all_interfaces()) {
44 wnlc.del_interface(iface);
47 std::string
name ((boost::format(
"phy%d-mon") % wnlc.phyIndex()).
str());
49 wnlc.add_monInterface(
name,
66 int main(
int argc,
char const * argv[])
72 if (!configuration.
parse( argc, argv)) {
80 handle.protocol().sndbuf(configuration.
sndBuf);
83 senf::RadiotapPacket radiotap (senf::RadiotapPacket::create());
86 radiotap->init_rate() << rate / 500;
89 wlanData->receiverAddress() << configuration.
destination;
90 wlanData->destinationAddress() << configuration.
destination;
95 senf::EthOUIExtensionPacket ouiExt (senf::EthOUIExtensionPacket::createAfter(llc));
97 radiotap.finalizeAll();
98 senf::DataPacket::createAfter(ouiExt, configuration.
txFrameLength - wlanData.size());
99 radiotap->init_dbmTxAttenuation() = configuration.
txPower;
100 radiotap->init_txFlags().noAck(
true);
101 radiotap->txFlags().noSeq(
true);
102 radiotap.finalizeAll();
104 std::cout <<
" * radio " << ifName <<
", frequency " << configuration.
frequency <<
" kHz, txPower " << configuration.
txPower <<
" dBm" << std::endl;
106 std::uint64_t airTime (wlanData.size() * 8 * 1000 / rate);
109 std::cout <<
", rate " << rate <<
" kbps" << std::endl;
110 std::cout <<
" * frameLength (without FCS) " << wlanData.size() <<
" bytes, frameAirTime " << airTime <<
" us, pktBurst " << burst <<
" (" << airTime * burst <<
" us)" << std::endl;
113 handle.blocking(
false);
116 handle.blocking(
true);
119 std::cerr <<
"Invalid TX configuration. Either specify txPeriod and txDuration or set both to 0 for 'send-as-fast-as-possible'" << std::endl;
123 std::uint64_t sent (0), dropped (0);
129 for (
unsigned b = 0; b < burst; b++) {
132 if (write(handle.fd(), radiotap.data().begin(), radiotap.size()) ==
signed(radiotap.size())) {
138 std::cerr <<
"!" << std::flush;
145 if (write(handle.fd(), radiotap.data().begin(), radiotap.size()) ==
signed(radiotap.size())) {
151 std::cerr <<
"!" << std::flush;
160 std::cout <<
"=> pkts sent " << sent <<
", pkts dropped " << dropped <<
", actual txRate (incl. FCS) " << actualTxRate <<
" kbps (" << (actualTxRate * 100) / rate <<
" %)." << std::endl;
senf::ClockService::clock_type duration
config::time_type clock_type
senf::INet4SocketAddress destination
static void logToStderr()
std::string str(T const &t)
static const std::uint32_t OUI_Fraunhofer_FIT
static MACAddress from_string(std::string const &s)
std::string initInterface(Configuration &config)
WLANPacket_DataFrameType::packet WLANPacket_DataFrame
static std::vector< LegacyModulationInfo > getLegacyModulationInfosOFDM()
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_microseconds(clock_type const &v)
senf::ClockService::clock_type txDuration
int main(int argc, char const *argv[])
bool parse(int argc, char const *argv[])
ProtocolClientSocketHandle< PacketSocketProtocol > PacketSocketHandle
senf::ClockService::clock_type txPeriod
WirelessNLController public header.
ConcretePacket< LlcSnapPacketType > LlcSnapPacket
unspecified_keyword_type name
void set_frequency(frequency_type freq, ChannelMode::Enum=ChannelMode::NoHT20)
std::string const & phyName() const
HardwareWLANInterface public header.