INET Framework for OMNeT++/OMNEST
inet::utils::filters::ThroughputFilter Class Reference

Filter that expects a cPacket and outputs the throughput as double. More...

#include <ResultFilters.h>

Inheritance diagram for inet::utils::filters::ThroughputFilter:

Public Member Functions

virtual void receiveSignal (cResultFilter *prev, simtime_t_cref t, cObject *object, cObject *details) override
 

Protected Attributes

simtime_t interval = 0.1
 
int packetLimit = 100
 
bool emitIntermediateZeros = true
 
simtime_t lastSignal = 0
 
double bytes = 0
 
int packets = 0
 

Detailed Description

Filter that expects a cPacket and outputs the throughput as double.

Member Function Documentation

void inet::utils::filters::ThroughputFilter::receiveSignal ( cResultFilter *  prev,
simtime_t_cref  t,
cObject *  object,
cObject *  details 
)
overridevirtual
110 {
111  if (auto packet = dynamic_cast<cPacket *>(object)) {
112  const simtime_t now = simTime();
113  packets++;
114  if (packets >= packetLimit) {
115  bytes += packet->getByteLength();
116  double throughput = 8 * bytes / (now - lastSignal).dbl();
117  fire(this, now, throughput, details);
118  lastSignal = now;
119  bytes = 0;
120  packets = 0;
121  }
122  else if (now - lastSignal >= interval) {
123  double throughput = 8 * bytes / interval.dbl();
124  fire(this, lastSignal + interval, throughput, details);
126  bytes = 0;
127  packets = 0;
128  if (emitIntermediateZeros) {
129  while (now - lastSignal >= interval) {
130  fire(this, lastSignal + interval, 0.0, details);
132  }
133  }
134  else {
135  if (now - lastSignal >= interval) { // no packets arrived for a long period
136  // zero should have been signaled at the beginning of this packet (approximation)
137  fire(this, now - interval, 0.0, details);
138  lastSignal = now - interval;
139  }
140  }
141  bytes += packet->getByteLength();
142  }
143  else
144  bytes += packet->getByteLength();
145  }
146 }
bool emitIntermediateZeros
Definition: ResultFilters.h:111
double bytes
Definition: ResultFilters.h:114
simtime_t lastSignal
Definition: ResultFilters.h:113
int packetLimit
Definition: ResultFilters.h:110
int packets
Definition: ResultFilters.h:115
simtime_t interval
Definition: ResultFilters.h:109

Member Data Documentation

double inet::utils::filters::ThroughputFilter::bytes = 0
protected
bool inet::utils::filters::ThroughputFilter::emitIntermediateZeros = true
protected
simtime_t inet::utils::filters::ThroughputFilter::interval = 0.1
protected
simtime_t inet::utils::filters::ThroughputFilter::lastSignal = 0
protected
int inet::utils::filters::ThroughputFilter::packetLimit = 100
protected
int inet::utils::filters::ThroughputFilter::packets = 0
protected

The documentation for this class was generated from the following files: