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

◆ beginNewInterval()

void inet::ThruputMeter::beginNewInterval ( simtime_t  now)
protectedvirtual
58 {
59  simtime_t duration = now - intvlStartTime;
60 
61  // record measurements
62  double bitpersec = intvlNumBits / duration.dbl();
63  double pkpersec = intvlNumPackets / duration.dbl();
64 
65  bitpersecVector.recordWithTimestamp(intvlStartTime, bitpersec);
66  pkpersecVector.recordWithTimestamp(intvlStartTime, pkpersec);
67 
68  // restart counters
69  intvlStartTime = now; // FIXME this should be *beginning* of tx of this packet, not end!
71 }

Referenced by updateStats().

◆ finish()

void inet::ThruputMeter::finish ( )
overrideprotectedvirtual
74 {
75  simtime_t duration = simTime() - startTime;
76 
77  recordScalar("duration", duration);
78  recordScalar("total packets", numPackets);
79  recordScalar("total bits", numBits);
80 
81  recordScalar("avg throughput (bit/s)", numBits / duration.dbl());
82  recordScalar("avg packets/s", numPackets / duration.dbl());
83 }

◆ handleMessage()

void inet::ThruputMeter::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
38 {
39  updateStats(simTime(), PK(msg)->getBitLength());
40  send(msg, "out");
41 }

◆ initialize()

void inet::ThruputMeter::initialize ( )
overrideprotectedvirtual
15 {
16  startTime = par("startTime");
17  long _batchSize = par("batchSize");
18  if ((_batchSize < 0) || (((long)(unsigned int)_batchSize) != _batchSize))
19  throw cRuntimeError("Invalid 'batchSize=%ld' parameter at '%s' module", _batchSize, getFullPath().c_str());
20  batchSize = (unsigned int)_batchSize;
21  maxInterval = par("maxInterval");
22 
23  numPackets = numBits = 0;
26 
27  WATCH(numPackets);
28  WATCH(numBits);
29  WATCH(intvlStartTime);
30  WATCH(intvlNumPackets);
31  WATCH(intvlNumBits);
32 
33  bitpersecVector.setName("thruput (bit/sec)");
34  pkpersecVector.setName("packet/sec");
35 }

◆ updateStats()

void inet::ThruputMeter::updateStats ( simtime_t  now,
unsigned long  bits 
)
protectedvirtual
44 {
45  numPackets++;
46  numBits += bits;
47 
48  // packet should be counted to new interval
50  beginNewInterval(now);
51 
53  intvlNumBits += bits;
54  intvlLastPkTime = now;
55 }

Referenced by handleMessage().

Member Data Documentation

◆ batchSize

unsigned int inet::ThruputMeter::batchSize
protected

Referenced by initialize(), and updateStats().

◆ bitpersecVector

cOutVector inet::ThruputMeter::bitpersecVector
protected

Referenced by beginNewInterval(), and initialize().

◆ intvlLastPkTime

simtime_t inet::ThruputMeter::intvlLastPkTime
protected

Referenced by initialize(), and updateStats().

◆ intvlNumBits

unsigned long inet::ThruputMeter::intvlNumBits
protected

◆ intvlNumPackets

unsigned long inet::ThruputMeter::intvlNumPackets
protected

◆ intvlStartTime

simtime_t inet::ThruputMeter::intvlStartTime
protected

◆ maxInterval

simtime_t inet::ThruputMeter::maxInterval
protected

Referenced by initialize(), and updateStats().

◆ numBits

unsigned long inet::ThruputMeter::numBits
protected

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

◆ numPackets

unsigned long inet::ThruputMeter::numPackets
protected

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

◆ pkpersecVector

cOutVector inet::ThruputMeter::pkpersecVector
protected

Referenced by beginNewInterval(), and initialize().

◆ startTime

simtime_t inet::ThruputMeter::startTime
protected

Referenced by finish(), and initialize().


The documentation for this class was generated from the following files:
inet::ThruputMeter::numBits
unsigned long numBits
Definition: ThruputMeter.h:32
inet::ThruputMeter::startTime
simtime_t startTime
Definition: ThruputMeter.h:24
inet::ThruputMeter::beginNewInterval
virtual void beginNewInterval(simtime_t now)
Definition: ThruputMeter.cc:57
inet::ThruputMeter::maxInterval
simtime_t maxInterval
Definition: ThruputMeter.h:26
inet::ThruputMeter::bitpersecVector
cOutVector bitpersecVector
Definition: ThruputMeter.h:41
inet::ThruputMeter::intvlStartTime
simtime_t intvlStartTime
Definition: ThruputMeter.h:35
inet::ThruputMeter::batchSize
unsigned int batchSize
Definition: ThruputMeter.h:25
inet::ThruputMeter::updateStats
virtual void updateStats(simtime_t now, unsigned long bits)
Definition: ThruputMeter.cc:43
inet::ThruputMeter::intvlNumBits
unsigned long intvlNumBits
Definition: ThruputMeter.h:38
PK
#define PK(msg)
Definition: INETDefs.h:89
inet::ThruputMeter::numPackets
unsigned long numPackets
Definition: ThruputMeter.h:31
inet::ThruputMeter::intvlNumPackets
unsigned long intvlNumPackets
Definition: ThruputMeter.h:37
inet::ThruputMeter::pkpersecVector
cOutVector pkpersecVector
Definition: ThruputMeter.h:42
inet::ThruputMeter::intvlLastPkTime
simtime_t intvlLastPkTime
Definition: ThruputMeter.h:36