14 #include <linux/net_tstamp.h> 49 numPkts_(config.numPackets),
56 auto ouiExt (senf::EthOUIExtensionPacket::createAfter(eth));
58 senf::DataPacket
data(senf::DataPacket::createAfter(testPkt, config.
pktSize - eth.size()));
62 testPkt->magic() << 0xaffe;
68 <<
", pktSize " << config.
pktSize 80 for (
unsigned n = 0; n <
numPkts_; n++) {
81 testPkt->seqNo() << n;
86 std::cout <<
"FIN Sequence..." << std::endl;
123 unsigned OLd_numPkts=50;
128 verbose_(config.verbose)
143 if (eth->destination() == ourMAC_) {
146 if (sessionId_ == 0 and testPkt->seqNo() < testPkt->numPkts())
147 sessionId_ = testPkt->sessionId();
148 if (sessionId_ != testPkt->sessionId()) {
149 if (testPkt->seqNo() != testPkt->numPkts()) {
160 <<
", timestamp " << rxTstamp) );
163 if (testPkt->seqNo() < testPkt->numPkts()) {
164 tstamps.insert(std::make_pair(testPkt->seqNo(), rxTstamp));
167 analyzeData(testPkt->numPkts(), eth.size());
181 if (tstamps.size() < 2) {
182 std::cerr <<
"Insufficient data for evaluation" << std::endl;
185 std::map<std::int32_t,std::uint32_t> distribution;
188 auto start (tstamps.begin());
189 for (
auto it (std::next(start)); it != tstamps.end(); it++, start++) {
191 if (it->first - start->first == 1) {
192 std::cout <<
"(" << start->first <<
" " << it->second - start->second <<
")";
193 txTime.accumulate(it->second - start->second);
194 distribution[(it->second - start->second)/1000]++;
197 std::cout <<
"(loss after " << start->first <<
", diff=" << it->first - start->first <<
")";
200 std::cout << std::endl;
202 std::cout <<
"Sample distribution in us: ";
203 std::uint64_t avg (0),
count (0);
206 for (
auto const & d : distribution) {
207 std::cout <<
"(" << d.first <<
" => " << d.second <<
")" << std::endl;
208 avg += d.first * d.second;
214 float Throughput_avg,Throughput_deviation;
216 Link_Capacity = (float(pktSize * 8) / txTime.data().avg);
218 if(OLd_numPkts==numPkts){
223 std::cout <<
"Results="<<
" " << OLd_numPkts <<
" " << (Throughput_avg=
data.avg) <<
" " << (Throughput_deviation=
data.stddev) << std::endl;
231 ThroughputDiffs.
clear();
237 std::cout <<
", avg " << (avg /
count) << std::endl;
238 std::cout <<
"stats " << txTime.data() <<
", Link_Capacity " << Link_Capacity <<
" Gbps" << std::endl;
247 int main(
int argc,
char const * argv[])
251 if (!configuration.
parse( argc, argv)) {
263 socket.protocol().sndbuf(configuration.
sendBuffer);
264 std::cout <<
"*** Using sndBuf size of " << socket.protocol().sndbuf() <<
" bytes. Max burstLength is " << socket.protocol().sndbuf() / configuration.
pktSize << std::endl;
266 Generator generator(macAddr, configuration);
267 senf::ppi::connect( generator, sink);
271 auto ts (socket.protocol().txStats());
272 ts.dump(std::cout); std::cout << std::endl;
277 socket.protocol().timestamping(SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE);
278 netdevCtrl.
timestamping(HWTSTAMP_TX_OFF, HWTSTAMP_FILTER_ALL);
279 std::cerr <<
"Switching to RX_HARDWARE timestamping" << std::endl;
281 std::cerr <<
"Can not enable hw rx timestamping to due " << ex.
what() << std::endl;
282 std::cerr <<
"Switching to RX_SOFTWARE timestamping" << std::endl;
284 socket.protocol().timestamping(SOF_TIMESTAMPING_RX_SOFTWARE);
286 std::cerr <<
"Can not enable software rx timestamping to due " << ex.
what() << std::endl;
287 std::cerr <<
"Continueing with kernel defaults" << std::endl;
291 Analyzer analyzer(macAddr, configuration);
292 senf::ppi::connect( source, analyzer);
senf::INet4SocketAddress destination
Analyzer(senf::MACAddress const &mac, Configuration const &config)
void timestamping(int txType, int rxFilter)
void data(StatisticsData &data_) const
virtual void terminate() const
void accumulate(T const &value)
senf::StatisticAccumulator< float > ThroughputDiffs
QueueReadPolicy::Buffer const * value
u8 data[SPECTRAL_HT20_NUM_BINS]
static SENF_CLOCKSERVICE_CONSTEXPR clock_type seconds(int64_type const &v)
Annotations public header.
void noroute(connector::Connector &connector)
senf::ppi::connector::PassiveInput< senf::EthernetPacket > input
senf::scheduler::TimerEvent timer
Generator(senf::MACAddress const &mac, Configuration const &config)
static SENF_CLOCKSERVICE_CONSTEXPR clock_type milliseconds(int64_type const &v)
static SENF_CLOCKSERVICE_CONSTEXPR int64_type in_nanoseconds(clock_type const &v)
void timeout(ClockService::clock_type const &timeout, bool initiallyEnabled=true)
int run(int argc, char const *argv[])
Incoming packet timestamp.
senf::ClockService::clock_type as_clock_type() const
void action(Callback const &cb)
void analyzeData(unsigned numPkts, unsigned pktSize)
#define SENF_PPI_MODULE(name)
bool parse(int argc, char const *argv[])
void onRequest(Handler handler)
MACAddress hardwareAddress() const
virtual char const * what() const
std::map< std::uint32_t, std::int64_t > tstamps
ProtocolClientSocketHandle< ConnectedMMapPacketSocketProtocol< QueueReadPolicy, QueueWritePolicy > > ConnectedMMapPacketSocketHandle
senf::ppi::connector::ActiveOutput< senf::EthernetPacket > output
ConcretePacket< EthernetPacketType > EthernetPacket
unsigned maxBurst() const
static ConcretePacket createAfter(Packet const &packet)
int main(int argc, char const *argv[])