ThruputMeter Class Reference

#include <ThruputMeter.h>

List of all members.


Detailed Description

Measures and records network thruput


Protected Member Functions

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

Private 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::beginNewInterval ( simtime_t  now  )  [protected]

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

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

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

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

00046 {
00047     updateStats(simTime(), msg->length());
00048     send(msg, "out");
00049 }

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

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

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

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


Member Data Documentation

int ThruputMeter::batchSize [private]

cOutVector ThruputMeter::bitpersecVector [private]

simtime_t ThruputMeter::intvlLastPkTime [private]

unsigned long ThruputMeter::intvlNumBits [private]

unsigned long ThruputMeter::intvlNumPackets [private]

simtime_t ThruputMeter::intvlStartTime [private]

int ThruputMeter::maxInterval [private]

unsigned long ThruputMeter::numBits [private]

unsigned long ThruputMeter::numPackets [private]

cOutVector ThruputMeter::pkpersecVector [private]

simtime_t ThruputMeter::startTime [private]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:24 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7