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.

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

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
00117 {
00118     // count the number and size of successfully delivered messages
00119     numDelivered++;
00120     bytesDelivered += bytes;
00121 
00122     // record vectorial data
00123     delayVector.record(timeDelay);
00124     hopCountVector.record(hopCount);
00125 }

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

collects statistical data of derived app

Reimplemented from BaseApp.

00128 {
00129     recordScalar("KBRTestApp: Delivered Messages", numDelivered);
00130     recordScalar("KBRTestApp: Delivered Bytes", bytesDelivered);
00131 
00132     if (numSent != 0)
00133         recordScalar("KBRTestApp: Delivery Ratio",
00134                      (float) numDelivered / (float) numSent);
00135     else
00136         recordScalar("KBRTestApp: Delivery Ratio", 0);
00137 }

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 
00083         callRoute(destKey, testMsg);
00084     }
00085 }

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 Dec 15 17:50:30 2006 for ITM OverSim by  doxygen 1.4.7