INET Framework for OMNeT++/OMNEST
ThruputMeter Class Reference

#include <ThruputMeter.h>

List of all members.

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
cOutVector pkpersecVector

Detailed Description

Measures and records network thruput


Member Function Documentation

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

Referenced by updateStats().

{
    simtime_t duration = now - intvlStartTime;

    // record measurements
    double bitpersec = intvlNumBits/duration.dbl();
    double pkpersec = intvlNumPackets/duration.dbl();

    bitpersecVector.recordWithTimestamp(intvlStartTime, bitpersec);
    pkpersecVector.recordWithTimestamp(intvlStartTime, pkpersec);

    // restart counters
    intvlStartTime = now;  // FIXME this should be *beginning* of tx of this packet, not end!
    intvlNumPackets = intvlNumBits = 0;
}
void ThruputMeter::finish ( ) [protected, virtual]
{
    simtime_t duration = simTime() - startTime;

    recordScalar("duration", duration);
    recordScalar("total packets", numPackets);
    recordScalar("total bits", numBits);

    recordScalar("avg throughput (bit/s)", numBits/duration.dbl());
    recordScalar("avg packets/s", numPackets/duration.dbl());
}
void ThruputMeter::handleMessage ( cMessage *  msg) [protected, virtual]
{
    updateStats(simTime(), PK(msg)->getBitLength());
    send(msg, "out");
}
void ThruputMeter::initialize ( ) [protected, virtual]
{
    startTime = par("startTime");
    long _batchSize = par("batchSize");
    if((_batchSize < 0) || (((long)(unsigned int)_batchSize) != _batchSize))
        throw cRuntimeError("invalid 'batchSize=%ld' parameter at '%s' module",_batchSize, getFullPath().c_str());
    batchSize = (unsigned int)_batchSize;
    maxInterval = par("maxInterval");

    numPackets = numBits = 0;
    intvlStartTime = intvlLastPkTime = 0;
    intvlNumPackets = intvlNumBits = 0;

    WATCH(numPackets);
    WATCH(numBits);
    WATCH(intvlStartTime);
    WATCH(intvlNumPackets);
    WATCH(intvlNumBits);

    bitpersecVector.setName("thruput (bit/sec)");
    pkpersecVector.setName("packet/sec");
}
void ThruputMeter::updateStats ( simtime_t  now,
unsigned long  bits 
) [protected, virtual]

Referenced by handleMessage().

{
    numPackets++;
    numBits += bits;

    // packet should be counted to new interval
    if (intvlNumPackets >= batchSize || now-intvlStartTime >= maxInterval)
        beginNewInterval(now);

    intvlNumPackets++;
    intvlNumBits += bits;
    intvlLastPkTime = now;
}

Member Data Documentation

unsigned int ThruputMeter::batchSize [protected]

Referenced by initialize(), and updateStats().

cOutVector ThruputMeter::bitpersecVector [protected]

Referenced by beginNewInterval(), and initialize().

simtime_t ThruputMeter::intvlLastPkTime [protected]

Referenced by initialize(), and updateStats().

unsigned long ThruputMeter::intvlNumBits [protected]
unsigned long ThruputMeter::intvlNumPackets [protected]
simtime_t ThruputMeter::intvlStartTime [protected]
simtime_t ThruputMeter::maxInterval [protected]

Referenced by initialize(), and updateStats().

unsigned long ThruputMeter::numBits [protected]

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

unsigned long ThruputMeter::numPackets [protected]

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

cOutVector ThruputMeter::pkpersecVector [protected]

Referenced by beginNewInterval(), and initialize().

simtime_t ThruputMeter::startTime [protected]

Referenced by finish(), and initialize().


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