ThrPutMeter Class Reference

#include <ThrPutMeter.h>

Inheritance diagram for ThrPutMeter:
cSimpleModule cModule cComponent cDefaultList cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject

List of all members.

Public Member Functions

virtual double getCurBitRate ()

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
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
cLongHistogram bitpersecStats
cOutVector pkpersecVector
cLongHistogram pkpersecStats
double curBitRate

Detailed Description

Measures and records network thruput


Member Function Documentation

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

00084 {
00085     simtime_t duration = now - intvlStartTime;
00086 
00087     // record measurements
00088     double bitpersec = intvlNumBits/duration.dbl();
00089     double pkpersec = intvlNumPackets/duration.dbl();
00090     curBitRate = intvlNumBits/duration.dbl();
00091 
00092     //Record vector
00093     bitpersecVector.recordWithTimestamp(intvlStartTime, bitpersec);
00094     //Record vector statistics
00095     bitpersecStats.collect(bitpersec);
00096     //Record vector
00097     pkpersecVector.recordWithTimestamp(intvlStartTime, pkpersec);
00098     //Record vector statistics
00099     pkpersecStats.collect(pkpersec);
00100 
00101     // restart counters
00102     intvlStartTime = now;  // FIXME this should be *beginning* of tx of this packet, not end!
00103     intvlNumPackets = intvlNumBits = 0;
00104 }

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

Reimplemented from cComponent.

00108 {
00109     simtime_t duration = simTime() - startTime;
00110 
00111     recordScalar("duration", duration);
00112     recordScalar("total packets", numPackets);
00113     recordScalar("total bits", numBits);
00114 
00115     recordScalar("avg throughput (bit/s)", numBits/duration.dbl());
00116     bitpersecStats.recordAs("throughput (bit/sec)");
00117     recordScalar("avg packets/s", numPackets/duration.dbl());
00118     pkpersecStats.recordAs("packets/sec");
00119 }

virtual double ThrPutMeter::getCurBitRate (  )  [inline, virtual]

00068 {return curBitRate;}

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

Reimplemented from cSimpleModule.

00055 {
00056         //If the received message is the scheduled message for counting the metrics
00057         if (msg->isSelfMessage()) {
00058                 //Start a new measuring interval
00059                 beginNewInterval(simTime());
00060 
00061                 //Reschedule reporting self message
00062                 simtime_t intvl = par("maxInterval").doubleValue();
00063                 scheduleAt(simTime()+intvl, msg);
00064         }
00065         //Else record the packets coming through the Throughput Meter
00066         else {
00067                 updateStats(simTime(), PK(msg)->getBitLength());
00068                 send(msg, "out");
00069         }
00070 }

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

Reimplemented from cComponent.

00026 {
00027     startTime = par("startTime");
00028     long _batchSize = par("batchSize");
00029     if((_batchSize < 0) || (((long)(unsigned int)_batchSize) != _batchSize))
00030         throw cRuntimeError("invalid 'batchSize=%ld' parameter at '%s' module",_batchSize, getFullPath().c_str());
00031     batchSize = (unsigned int)_batchSize;
00032     maxInterval = par("maxInterval");
00033 
00034     numPackets = numBits = 0;
00035     intvlStartTime = intvlLastPkTime = 0;
00036     intvlNumPackets = intvlNumBits = 0;
00037 
00038     WATCH(numPackets);
00039     WATCH(numBits);
00040     WATCH(intvlStartTime);
00041     WATCH(intvlNumPackets);
00042     WATCH(intvlNumBits);
00043 
00044     //Create self message for metric estimation
00045     cMessage *record = new cMessage("Record");
00046         simtime_t intvl = par("maxInterval").doubleValue();
00047         scheduleAt(simTime()+intvl, record);
00048 
00049     bitpersecVector.setName("throughput (bit/sec)");
00050     pkpersecVector.setName("packet/sec");
00051 }

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

00074 {
00075     numPackets++;
00076     numBits += bits;
00077     intvlNumPackets++;
00078     intvlNumBits += bits;
00079     intvlLastPkTime = now;
00080 }


Member Data Documentation

unsigned int ThrPutMeter::batchSize [protected]
double ThrPutMeter::curBitRate [protected]
simtime_t ThrPutMeter::intvlLastPkTime [protected]
unsigned long ThrPutMeter::intvlNumBits [protected]
unsigned long ThrPutMeter::intvlNumPackets [protected]
simtime_t ThrPutMeter::intvlStartTime [protected]
simtime_t ThrPutMeter::maxInterval [protected]
unsigned long ThrPutMeter::numBits [protected]
unsigned long ThrPutMeter::numPackets [protected]
simtime_t ThrPutMeter::startTime [protected]

The documentation for this class was generated from the following files:
Generated on Thu Jun 14 17:12:42 2012 for PAL by  doxygen 1.6.3