INET Framework for OMNeT++/OMNEST
inet::ThruputMeter Class Reference

Measures and records network thruput. More...

#include <ThruputMeter.h>

Inheritance diagram for inet::ThruputMeter:

Protected Member Functions

virtual void updateStats (simtime_t now, unsigned long bits)
 
virtual void beginNewInterval (simtime_t now)
 
virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void finish () override
 

Protected Attributes

simtime_t startTime
 
unsigned int batchSize
 
simtime_t maxInterval
 
unsigned long numPackets
 
unsigned long numBits
 
simtime_t intvlStartTime
 
simtime_t intvlLastPkTime
 
unsigned long intvlNumPackets
 
unsigned long intvlNumBits
 
cOutVector bitpersecVector
 
cOutVector pkpersecVector
 

Detailed Description

Measures and records network thruput.

Member Function Documentation

void inet::ThruputMeter::beginNewInterval ( simtime_t  now)
protectedvirtual

Referenced by updateStats().

68 {
69  simtime_t duration = now - intvlStartTime;
70 
71  // record measurements
72  double bitpersec = intvlNumBits / duration.dbl();
73  double pkpersec = intvlNumPackets / duration.dbl();
74 
75  bitpersecVector.recordWithTimestamp(intvlStartTime, bitpersec);
76  pkpersecVector.recordWithTimestamp(intvlStartTime, pkpersec);
77 
78  // restart counters
79  intvlStartTime = now; // FIXME this should be *beginning* of tx of this packet, not end!
81 }
cOutVector pkpersecVector
Definition: ThruputMeter.h:52
unsigned long intvlNumPackets
Definition: ThruputMeter.h:47
cOutVector bitpersecVector
Definition: ThruputMeter.h:51
simtime_t intvlStartTime
Definition: ThruputMeter.h:45
unsigned long intvlNumBits
Definition: ThruputMeter.h:48
void inet::ThruputMeter::finish ( )
overrideprotectedvirtual
84 {
85  simtime_t duration = simTime() - startTime;
86 
87  recordScalar("duration", duration);
88  recordScalar("total packets", numPackets);
89  recordScalar("total bits", numBits);
90 
91  recordScalar("avg throughput (bit/s)", numBits / duration.dbl());
92  recordScalar("avg packets/s", numPackets / duration.dbl());
93 }
unsigned long numPackets
Definition: ThruputMeter.h:41
simtime_t startTime
Definition: ThruputMeter.h:34
unsigned long numBits
Definition: ThruputMeter.h:42
void inet::ThruputMeter::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
48 {
49  updateStats(simTime(), PK(msg)->getBitLength());
50  send(msg, "out");
51 }
virtual void updateStats(simtime_t now, unsigned long bits)
Definition: ThruputMeter.cc:53
#define PK(msg)
Definition: INETDefs.h:92
void inet::ThruputMeter::initialize ( )
overrideprotectedvirtual
25 {
26  startTime = par("startTime");
27  long _batchSize = par("batchSize");
28  if ((_batchSize < 0) || (((long)(unsigned int)_batchSize) != _batchSize))
29  throw cRuntimeError("Invalid 'batchSize=%ld' parameter at '%s' module", _batchSize, getFullPath().c_str());
30  batchSize = (unsigned int)_batchSize;
31  maxInterval = par("maxInterval");
32 
33  numPackets = numBits = 0;
36 
37  WATCH(numPackets);
38  WATCH(numBits);
39  WATCH(intvlStartTime);
40  WATCH(intvlNumPackets);
41  WATCH(intvlNumBits);
42 
43  bitpersecVector.setName("thruput (bit/sec)");
44  pkpersecVector.setName("packet/sec");
45 }
unsigned long numPackets
Definition: ThruputMeter.h:41
cOutVector pkpersecVector
Definition: ThruputMeter.h:52
unsigned long intvlNumPackets
Definition: ThruputMeter.h:47
simtime_t startTime
Definition: ThruputMeter.h:34
simtime_t intvlLastPkTime
Definition: ThruputMeter.h:46
unsigned long numBits
Definition: ThruputMeter.h:42
cOutVector bitpersecVector
Definition: ThruputMeter.h:51
simtime_t maxInterval
Definition: ThruputMeter.h:36
simtime_t intvlStartTime
Definition: ThruputMeter.h:45
unsigned long intvlNumBits
Definition: ThruputMeter.h:48
unsigned int batchSize
Definition: ThruputMeter.h:35
void inet::ThruputMeter::updateStats ( simtime_t  now,
unsigned long  bits 
)
protectedvirtual

Referenced by handleMessage().

54 {
55  numPackets++;
56  numBits += bits;
57 
58  // packet should be counted to new interval
60  beginNewInterval(now);
61 
63  intvlNumBits += bits;
64  intvlLastPkTime = now;
65 }
unsigned long numPackets
Definition: ThruputMeter.h:41
unsigned long intvlNumPackets
Definition: ThruputMeter.h:47
simtime_t intvlLastPkTime
Definition: ThruputMeter.h:46
virtual void beginNewInterval(simtime_t now)
Definition: ThruputMeter.cc:67
unsigned long numBits
Definition: ThruputMeter.h:42
simtime_t maxInterval
Definition: ThruputMeter.h:36
simtime_t intvlStartTime
Definition: ThruputMeter.h:45
unsigned long intvlNumBits
Definition: ThruputMeter.h:48
unsigned int batchSize
Definition: ThruputMeter.h:35

Member Data Documentation

unsigned int inet::ThruputMeter::batchSize
protected

Referenced by initialize(), and updateStats().

cOutVector inet::ThruputMeter::bitpersecVector
protected

Referenced by beginNewInterval(), and initialize().

simtime_t inet::ThruputMeter::intvlLastPkTime
protected

Referenced by initialize(), and updateStats().

unsigned long inet::ThruputMeter::intvlNumBits
protected
unsigned long inet::ThruputMeter::intvlNumPackets
protected
simtime_t inet::ThruputMeter::intvlStartTime
protected
simtime_t inet::ThruputMeter::maxInterval
protected

Referenced by initialize(), and updateStats().

unsigned long inet::ThruputMeter::numBits
protected

Referenced by finish(), initialize(), and updateStats().

unsigned long inet::ThruputMeter::numPackets
protected

Referenced by finish(), initialize(), and updateStats().

cOutVector inet::ThruputMeter::pkpersecVector
protected

Referenced by beginNewInterval(), and initialize().

simtime_t inet::ThruputMeter::startTime
protected

Referenced by finish(), and initialize().


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