ThruputMeter Class Reference

#include <ThruputMeter.h>

List of all members.


Detailed Description

Measures and records network thruput

Protected Member Functions

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

Protected Attributes

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

Member Function Documentation

void ThruputMeter::updateStats ( simtime_t  now,
unsigned long  bits 
) [protected, virtual]

Referenced by handleMessage().

00051 {
00052     numPackets++;
00053     numBits += bits;
00054 
00055     // packet should be counted to new interval
00056     if (intvlNumPackets >= batchSize || now-intvlStartTime >= maxInterval)
00057         beginNewInterval(now);
00058 
00059     intvlNumPackets++;
00060     intvlNumBits += bits;
00061     intvlLastPkTime = now;
00062 }

void ThruputMeter::beginNewInterval ( simtime_t  now  )  [protected, virtual]

Referenced by updateStats().

00065 {
00066     simtime_t duration = now - intvlStartTime;
00067 
00068     // record measurements
00069     double bitpersec = intvlNumBits/duration.dbl();
00070     double pkpersec = intvlNumPackets/duration.dbl();
00071 
00072     bitpersecVector.recordWithTimestamp(intvlStartTime, bitpersec);
00073     pkpersecVector.recordWithTimestamp(intvlStartTime, pkpersec);
00074 
00075     // restart counters
00076     intvlStartTime = now;  // FIXME this should be *beginning* of tx of this packet, not end!
00077     intvlNumPackets = intvlNumBits = 0;
00078 }

void ThruputMeter::initialize (  )  [protected, virtual]

00025 {
00026     startTime = par("startTime");
00027     batchSize = par("batchSize");
00028     maxInterval = par("maxInterval");
00029 
00030     numPackets = numBits = 0;
00031     intvlStartTime = intvlLastPkTime = 0;
00032     intvlNumPackets = intvlNumBits = 0;
00033 
00034     WATCH(numPackets);
00035     WATCH(numBits);
00036     WATCH(intvlStartTime);
00037     WATCH(intvlNumPackets);
00038     WATCH(intvlNumBits);
00039 
00040     bitpersecVector.setName("thruput (bit/sec)");
00041     pkpersecVector.setName("packet/sec");
00042 }

void ThruputMeter::handleMessage ( cMessage *  msg  )  [protected, virtual]

00045 {
00046     updateStats(simTime(), PK(msg)->getBitLength());
00047     send(msg, "out");
00048 }

void ThruputMeter::finish (  )  [protected, virtual]

00081 {
00082     simtime_t duration = simTime() - startTime;
00083 
00084     recordScalar("duration", duration);
00085     recordScalar("total packets", numPackets);
00086     recordScalar("total bits", numBits);
00087 
00088     recordScalar("avg throughput (bit/s)", numBits/duration.dbl());
00089     recordScalar("avg packets/s", numPackets/duration.dbl());
00090 }


Member Data Documentation

simtime_t ThruputMeter::startTime [protected]

Referenced by finish(), and initialize().

int ThruputMeter::batchSize [protected]

Referenced by initialize(), and updateStats().

int ThruputMeter::maxInterval [protected]

Referenced by initialize(), and updateStats().

unsigned long ThruputMeter::numPackets [protected]

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

unsigned long ThruputMeter::numBits [protected]

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

simtime_t ThruputMeter::intvlStartTime [protected]

simtime_t ThruputMeter::intvlLastPkTime [protected]

Referenced by initialize(), and updateStats().

unsigned long ThruputMeter::intvlNumPackets [protected]

unsigned long ThruputMeter::intvlNumBits [protected]

cOutVector ThruputMeter::bitpersecVector [protected]

Referenced by beginNewInterval(), and initialize().

cOutVector ThruputMeter::pkpersecVector [protected]

Referenced by beginNewInterval(), and initialize().


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

Generated on Fri Mar 20 18:51:22 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5