#include <ThruputMeter.h>
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 |
|
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 }
|
|
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 }
|
|
00046 { 00047 updateStats(simTime(), msg->length()); 00048 send(msg, "out"); 00049 }
|
|
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 }
|
|
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 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|