#include <ThruputMeter.h>
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 |
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] |
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 }
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] |
Referenced by beginNewInterval(), initialize(), and updateStats().
simtime_t ThruputMeter::intvlLastPkTime [protected] |
Referenced by initialize(), and updateStats().
unsigned long ThruputMeter::intvlNumPackets [protected] |
Referenced by beginNewInterval(), initialize(), and updateStats().
unsigned long ThruputMeter::intvlNumBits [protected] |
Referenced by beginNewInterval(), initialize(), and updateStats().
cOutVector ThruputMeter::bitpersecVector [protected] |
Referenced by beginNewInterval(), and initialize().
cOutVector ThruputMeter::pkpersecVector [protected] |
Referenced by beginNewInterval(), and initialize().