KBRTestApp Class Reference

#include <KBRTestApp.h>

Inheritance diagram for KBRTestApp:

BaseApp List of all members.

Detailed Description

Test application for KBR interface.

Test application for KBR interface that sends periodically test messages to random keys or existing nodeIDs. The receiver does not send back any answer, but sender::evaluateDate() is called.


Protected Member Functions

void initializeApp (int stage)
 initializes derived class-attributes
void finishApp ()
 collects statistical data of derived app
void handleTimerEvent (cMessage *msg)
 processes self-messages
void deliver (OverlayKey &key, cMessage *msg)
 handles delivered messages from overlay
void evaluateData (simtime_t timeDelay, int hopCount, long int bytes)
 Analyses and records measuring data handed over from nodes that previously had been the destination for a test message from this module, called by receiver::handleMessage() at sendermodule.

Protected Attributes

double mean
 mean time interval between sending test messages
double deviation
 deviation of time interval
bool activeNetwInitPhase
 is app active in network init phase?
bool lookupNodeIds
 lookup only existing nodeIDs
int numDelivered
 number of delivered packets
int bytesDelivered
 number of delivered bytes
cOutVector delayVector
 statistical output vector for packet-delays
cOutVector hopCountVector
 statistical output vector for hop-counts


Member Function Documentation

void KBRTestApp::deliver ( OverlayKey key,
cMessage *  msg 
) [protected, virtual]

handles delivered messages from overlay

method to handle decapsulated KBRdeliver messages from overlay module, should be overwritten in derived application

Parameters:
key destination key
msg delivered message

Reimplemented from BaseApp.

00089 {
00090     KBRTestMessage* testMsg = check_and_cast<KBRTestMessage*>(msg);
00091     OverlayCtrlInfo* overlayCtrlInfo =
00092         check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00093 
00094     // Return statistical data to the sender.
00095     if(cModule* mod = simulation.module(testMsg->getId())) {
00096         if(KBRTestApp* sender = dynamic_cast<KBRTestApp*>(mod)) {
00097             if((!lookupNodeIds) || (overlayCtrlInfo->getThisNode().key ==
00098                                     overlayCtrlInfo->getDestKey())) {
00099                 sender->evaluateData((simTime() - testMsg->creationTime()),
00100                                      overlayCtrlInfo->getHopCount(),
00101                                      testMsg->byteLength());
00102             }
00103         }
00104     }
00105 
00106     EV << "(KBRTestAPP) received \"" << testMsg->name()
00107     << "\" (seqNr: " << testMsg->getSeqNum()
00108     << ")\n             with destination key: " << key.toString(16)
00109     << "\n             (thisNode.key = "
00110     << overlayCtrlInfo->getThisNode().key.toString(16) << ")"
00111     << endl;
00112 
00113     delete overlayCtrlInfo;
00114     delete testMsg;
00115 }

void KBRTestApp::evaluateData ( simtime_t  timeDelay,
int  hopCount,
long int  bytes 
) [protected]

Analyses and records measuring data handed over from nodes that previously had been the destination for a test message from this module, called by receiver::handleMessage() at sendermodule.

Parameters:
timeDelay packet-delay
hopCount packet hop-count
bytes packet size in bytes
00118 {
00119     // count the number and size of successfully delivered messages
00120     numDelivered++;
00121     bytesDelivered += bytes;
00122     globalStatistics->deliveredKBRTestAppMessages++;
00123 
00124 
00125     // record vectorial data
00126     delayVector.record(timeDelay);
00127     hopCountVector.record(hopCount);
00128     globalStatistics->globalDelayVector.record(timeDelay);
00129 }

void KBRTestApp::finishApp (  )  [protected, virtual]

collects statistical data of derived app

Reimplemented from BaseApp.

00132 {
00133     recordScalar("KBRTestApp: Delivered Messages", numDelivered);
00134     recordScalar("KBRTestApp: Delivered Bytes", bytesDelivered);
00135 
00136     globalStatistics->testCount++;
00137 
00138 
00139     if (numSent != 0)
00140         recordScalar("KBRTestApp: Delivery Ratio",
00141                      (float) numDelivered / (float) numSent);
00142     else
00143         recordScalar("KBRTestApp: Delivery Ratio", 0);
00144 }

void KBRTestApp::handleTimerEvent ( cMessage *  msg  )  [protected, virtual]

processes self-messages

method to handle self-messages should be overwritten in derived application if needed

Parameters:
msg self-message

Reimplemented from BaseApp.

00057 {
00058     if (msg->isName("test_timer")) {
00059         // schedule next timer event
00060         scheduleAt(simulation.simTime() + truncnormal(mean, deviation), msg);
00061 
00062         // do nothing if the network is still in the initialization phase
00063         if((!activeNetwInitPhase) && (underlayConfigurator->isInit()))
00064             return;
00065         OverlayKey destKey;
00066         if ( lookupNodeIds ) {
00067             destKey = bootstrapOracle->getBootstrapNode().key;
00068             // do nothing if there are currently no nodes in the network
00069             if (destKey.isUnspecified())
00070                 return;
00071         } else {
00072             // generate random destination key
00073             destKey = OverlayKey::random();
00074         }
00075 
00076         // create a 100 byte test message
00077         KBRTestMessage* testMsg = new KBRTestMessage("KBRTestMessage");
00078         testMsg->setId(id());
00079         testMsg->setSeqNum(numSent);
00080         testMsg->setByteLength(100);
00081 
00082         globalStatistics->sentKBRTestAppMessages++;
00083 
00084         callRoute(destKey, testMsg);
00085     }
00086 }

void KBRTestApp::initializeApp ( int  stage  )  [protected, virtual]

initializes derived class-attributes

Parameters:
stage the init stage

Reimplemented from BaseApp.

00034 {
00035     if(stage != MIN_STAGE_APP)
00036         return;
00037 
00038     lookupNodeIds = par("lookupNodeIds");
00039     mean = par("messageDelay");
00040     deviation = mean / 10;
00041     activeNetwInitPhase = par("activeNetwInitPhase");
00042 
00043     numDelivered = 0;
00044     bytesDelivered = 0;
00045     WATCH(numDelivered);
00046     WATCH(bytesDelivered);
00047 
00048     delayVector.setName("Delay Time");
00049     hopCountVector.setName("Hop Count");
00050 
00051     // initiate test message emision
00052     cMessage* test_timer = new cMessage("test_timer");
00053     scheduleAt(simulation.simTime() + truncnormal(mean, deviation), test_timer);
00054 }


Member Data Documentation

bool KBRTestApp::activeNetwInitPhase [protected]

is app active in network init phase?

int KBRTestApp::bytesDelivered [protected]

number of delivered bytes

cOutVector KBRTestApp::delayVector [protected]

statistical output vector for packet-delays

double KBRTestApp::deviation [protected]

deviation of time interval

cOutVector KBRTestApp::hopCountVector [protected]

statistical output vector for hop-counts

bool KBRTestApp::lookupNodeIds [protected]

lookup only existing nodeIDs

double KBRTestApp::mean [protected]

mean time interval between sending test messages

int KBRTestApp::numDelivered [protected]

number of delivered packets


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:06 2007 for ITM OverSim by  doxygen 1.4.7