KBRTestApp Class Reference

#include <KBRTestApp.h>

Inheritance diagram for KBRTestApp:

BaseApp BaseRpc RpcListener 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.
void handleRpcResponse (BaseResponseMessage *msg, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
void handleLookupResponse (LookupResponse *msg)

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::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 }

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

collects statistical data of derived app

Reimplemented from BaseApp.

00191 {
00192     simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime);
00193     
00194     if(time != 0) {    
00195         globalStatistics->addStdDev("KBRTestApp: Delivered Messages/s",
00196                                     numDelivered / time);
00197         globalStatistics->addStdDev("KBRTestApp: Delivered Bytes/s",
00198                                     bytesDelivered / time);
00199     
00200         if (numSent != 0)
00201             globalStatistics->addStdDev("KBRTestApp: Delivery Ratio",
00202                                         (float) numDelivered / (float) numSent);
00203         else
00204             globalStatistics->addStdDev("KBRTestApp: Delivery Ratio", 0);
00205     }
00206 }

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         testMsg->setMeasurementPhase(globalStatistics->isMeasuring());
00082 
00083         RECORD_STATS(globalStatistics->sentKBRTestAppMessages++);
00084 
00085         callRoute(destKey, testMsg);
00086 /*
00087         LookupCall* call = new LookupCall();
00088         call->setLength(0);
00089         call->setKey(destKey);
00090         call->setNumSiblings(overlay->getMaxNumSiblings());
00091         sendRpcMessage(RPC_TO_LOWERTIER, NodeHandle::UNSPECIFIED_NODE,
00092                        call, NULL, OverlayKey::UNSPECIFIED_KEY, -1, 0);
00093 */
00094     }
00095 }

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.

00127 {
00128     KBRTestMessage* testMsg = check_and_cast<KBRTestMessage*>(msg);
00129     OverlayCtrlInfo* overlayCtrlInfo =
00130         check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00131 
00132     if (thisNode.key.isUnspecified())
00133         error("key");
00134 
00135     // Return statistical data to the sender.
00136     if(cModule* mod = simulation.module(testMsg->getId())) {
00137         if(KBRTestApp* sender = dynamic_cast<KBRTestApp*>(mod)) {
00138             if((!lookupNodeIds) || (thisNode.key ==
00139                                     key /*overlayCtrlInfo->getDestKey()*/))
00140             {
00141                 if (testMsg->getMeasurementPhase() == true) {
00142                     sender->evaluateData((simTime() - testMsg->creationTime()),
00143                                          overlayCtrlInfo->getHopCount(),
00144                                          testMsg->byteLength());
00145                 }
00146             }
00147         }
00148     }
00149 
00150     EV << "(KBRTestAPP) received \"" << testMsg->name()
00151        << "\" (seqNr: " << testMsg->getSeqNum()
00152        << ")\n             with destination key: " << key.toString(16)
00153        << "\n             (thisNode.key = "
00154        << thisNode.key.toString(16) << ")"
00155        << endl;
00156 
00157     delete overlayCtrlInfo;
00158     delete testMsg;
00159 }

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.

00163 {
00164     KBRTestMessage* tempMsg = check_and_cast<KBRTestMessage*>(*msg);
00165 
00166     tempMsg->setVisitedNodesArraySize(tempMsg->getVisitedNodesArraySize() + 1);
00167     tempMsg->setVisitedNodes(tempMsg->getVisitedNodesArraySize() - 1,
00168                              thisNode.ip);
00169 }

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
00172 {
00173     // count the number and size of successfully delivered messages
00174     RECORD_STATS(numDelivered++; bytesDelivered += bytes; globalStatistics->deliveredKBRTestAppMessages++);
00175 
00176     if (numSent < numDelivered)
00177         error("KBRTestApp::evaluateData(): numSent < numDelivered!");
00178 
00179 
00180     // record vectorial data
00181     RECORD_STATS(delayVector.record(timeDelay));
00182     RECORD_STATS(hopCountVector.record(hopCount));
00183 
00184     RECORD_STATS(globalStatistics->recordOutVector("KBRTestApp: Global Hop "
00185                                                    "Count", hopCount));
00186     RECORD_STATS(globalStatistics->recordOutVector("KBRTestApp: Global Time "
00187                                                    "Delay", timeDelay));
00188 }

void KBRTestApp::handleRpcResponse ( BaseResponseMessage *  msg,
int  rpcId,
simtime_t  rtt 
) [protected, virtual]

This method is called if an RPC response has been received.

Parameters:
msg The response message.
rpcId The RPC id.
rtt The Round-Trip-Time of this RPC

Reimplemented from RpcListener.

00099 {
00100     RPC_SWITCH_START(msg)
00101     RPC_ON_RESPONSE(Lookup) {
00102         handleLookupResponse(_LookupResponse);
00103         EV << "Lookup RPC Response received: id=" << rpcId
00104         << " msg=" << *_LookupResponse << " rtt=" << rtt << endl;
00105         break;
00106     }
00107     RPC_SWITCH_END( )
00108 }

void KBRTestApp::handleLookupResponse ( LookupResponse *  msg  )  [protected]

00111 {
00112     EV << "Lookup response for key " << msg->getKey()
00113        << " : ";
00114     if (msg->getIsValid()) {
00115         for (uint i=0; i<msg->getSiblingsArraySize(); i++) {
00116             EV << endl << "    " << msg->getSiblings(i);
00117         }
00118     } else {
00119         EV << "failed!";
00120     }
00121     EV << endl;
00122 }


Member Data Documentation

double KBRTestApp::mean [protected]

mean time interval between sending test messages

double KBRTestApp::deviation [protected]

deviation of time interval

bool KBRTestApp::activeNetwInitPhase [protected]

is app active in network init phase?

bool KBRTestApp::lookupNodeIds [protected]

lookup only existing nodeIDs

int KBRTestApp::numDelivered [protected]

number of delivered packets

int KBRTestApp::bytesDelivered [protected]

number of delivered bytes

cOutVector KBRTestApp::delayVector [protected]

statistical output vector for packet-delays

cOutVector KBRTestApp::hopCountVector [protected]

statistical output vector for hop-counts


The documentation for this class was generated from the following files:
Generated on Tue Jul 24 16:51:18 2007 for ITM OverSim by  doxygen 1.5.1