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)
 Common API function: handles delivered messages from overlay.
void forward (OverlayKey *key, cMessage *msg, NodeHandle *nextHopNode)
 Common API function: handles messages from overlay to be forwarded.
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]

Common API function: 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) || (thisNode.key ==
00098                                     key /*overlayCtrlInfo->getDestKey()*/))
00099             {
00100                 sender->evaluateData((simTime() - testMsg->creationTime()),
00101                                      overlayCtrlInfo->getHopCount(),
00102                                      testMsg->byteLength());
00103             }
00104         }
00105     }
00106 
00107     EV << "(KBRTestAPP) received \"" << testMsg->name()
00108        << "\" (seqNr: " << testMsg->getSeqNum()
00109        << ")\n             with destination key: " << key.toString(16)
00110        << "\n             (thisNode.key = "
00111        << thisNode.key.toString(16) << ")"
00112        << endl;
00113 
00114     delete overlayCtrlInfo;
00115     delete testMsg;
00116 }

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
00127 {
00128     // count the number and size of successfully delivered messages
00129     numDelivered++;
00130     bytesDelivered += bytes;
00131     globalStatistics->deliveredKBRTestAppMessages++;
00132 
00133     if (numSent < numDelivered)
00134         error("KBRTestApp::evaluateData(): numSent < numDelivered!");
00135 
00136 
00137     // record vectorial data
00138     delayVector.record(timeDelay);
00139     hopCountVector.record(hopCount);
00140     globalStatistics->globalDelayVector.record(timeDelay);
00141 }

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

collects statistical data of derived app

Reimplemented from BaseApp.

00144 {
00145     recordScalar("KBRTestApp: Delivered Messages", numDelivered);
00146     recordScalar("KBRTestApp: Delivered Bytes", bytesDelivered);
00147 
00148     globalStatistics->testCount++;
00149 
00150 
00151     if (numSent != 0)
00152         recordScalar("KBRTestApp: Delivery Ratio",
00153                      (float) numDelivered / (float) numSent);
00154     else
00155         recordScalar("KBRTestApp: Delivery Ratio", 0);
00156 }

void KBRTestApp::forward ( OverlayKey key,
cMessage *  msg,
NodeHandle nextHopNode 
) [protected, virtual]

Common API function: handles messages from overlay to be forwarded.

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

Parameters:
key destination key
msg message to forward
nextHopNode next hop

Reimplemented from BaseApp.

00119 {
00120     KBRTestMessage* tempMsg = check_and_cast<KBRTestMessage*>(msg);
00121 
00122     tempMsg->setVisitedNodesArraySize(tempMsg->getVisitedNodesArraySize() + 1);
00123     tempMsg->setVisitedNodes(tempMsg->getVisitedNodesArraySize() - 1, thisNode.ip);
00124 }

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 Fri May 11 14:52:40 2007 for ITM OverSim by  doxygen 1.4.7