KBRTestApp Class Reference

Test application for KBR interface. More...

#include <KBRTestApp.h>

Inheritance diagram for KBRTestApp:
BaseApp BaseRpc RpcListener

List of all members.

Classes

struct  MsgHandle
 type for storing seen messages in a circular buffer, holds OverlayKey of the sender and SequenceNumber More...

Public Member Functions

 KBRTestApp ()
 ~KBRTestApp ()

Private Types

typedef std::vector< MsgHandleMsgHandleBuf

Private Member Functions

void initializeApp (int stage)
 initializes derived class-attributes
void finishApp ()
 collects statistical data of derived app
void handleTimerEvent (cMessage *msg)
void deliver (OverlayKey &key, cMessage *msg)
 Common API function: handles delivered messages from overlay.
void forward (OverlayKey *key, cPacket **msg, NodeHandle *nextHopNode)
 Common API function: handles messages from overlay to be forwarded.
bool checkSeen (const OverlayKey &key, int seqNum)
 Checks if a message was already seen before.
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.
bool handleRpcCall (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invocation messages.
void kbrTestCall (KbrTestCall *call)
void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
void handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 This method is called if an RPC timeout has been reached.
void handleLookupResponse (LookupResponse *msg, cObject *context, simtime_t latency)
void pingResponse (PingResponse *response, cPolymorphic *context, int rpcId, simtime_t rtt)
virtual void handleNodeLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed.
std::pair< OverlayKey,
TransportAddress
createDestKey ()

Private Attributes

bool kbrOneWayTest
bool kbrRpcTest
bool kbrLookupTest
int testMsgSize
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
bool nodeIsLeavingSoon
 true if the node is going to be killed shortly
bool onlyLookupInoffensiveNodes
 if true only search for inoffensive nodes (use together with lookupNodeIds)
uint32_t numSent
uint32_t bytesSent
uint32_t numDelivered
 number of delivered packets
uint32_t bytesDelivered
 number of delivered bytes
uint32_t numDropped
uint32_t bytesDropped
uint32_t numRpcSent
uint32_t bytesRpcSent
uint32_t numRpcDelivered
 number of delivered packets
uint32_t bytesRpcDelivered
 number of delivered bytes
uint32_t numRpcDropped
uint32_t bytesRpcDropped
simtime_t rpcSuccLatencySum
uint32_t rpcSuccLatencyCount
simtime_t rpcTotalLatencySum
uint32_t rpcTotalLatencyCount
uint32_t numLookupSent
uint32_t numLookupSuccess
uint32_t numLookupFailed
cMessage * onewayTimer
cMessage * rpcTimer
cMessage * lookupTimer
simtime_t failureLatency
 this latency is recorded for failed lookups and RPCs
uint32_t sequenceNumber
int msgHandleBufSize
 how many MsgHandles to store in circular buffer
MsgHandleBuf mhBuf
 circular buffer of MsgHandles
MsgHandleBuf::iterator mhBufBegin
 begin of circular buffer
MsgHandleBuf::iterator mhBufNext
 next element to insert
MsgHandleBuf::iterator mhBufEnd
 end of circular buffer

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.

Definition at line 43 of file KBRTestApp.h.


Member Typedef Documentation

typedef std::vector<MsgHandle> KBRTestApp::MsgHandleBuf [private]

Definition at line 73 of file KBRTestApp.h.


Constructor & Destructor Documentation

KBRTestApp::KBRTestApp (  ) 

Definition at line 35 of file KBRTestApp.cc.

00036 {
00037     onewayTimer = NULL;
00038 }

KBRTestApp::~KBRTestApp (  ) 

Definition at line 40 of file KBRTestApp.cc.

00041 {
00042     cancelAndDelete(onewayTimer);
00043     cancelAndDelete(rpcTimer);
00044     cancelAndDelete(lookupTimer);
00045 }


Member Function Documentation

bool KBRTestApp::checkSeen ( const OverlayKey key,
int  seqNum 
) [private]

Checks if a message was already seen before.

If the sequence number of the message is new for the given sender key, it is stored in a circular buffer and false is returned.

Parameters:
key the OverlayKey of the sender
seqNum sequence number of the message to check
Returns:
true if the message was seen before

Definition at line 456 of file KBRTestApp.cc.

Referenced by deliver().

00457 {
00458     MsgHandle hdl(key, seqNum);
00459 
00460     for (MsgHandleBuf::iterator it = mhBufBegin; it != mhBufEnd; ++it) {
00461         if (it->key.isUnspecified()) {
00462             continue;
00463         }
00464         if (*it == hdl) {
00465             return true;
00466         }
00467     }
00468 
00469     *(mhBufNext++) = hdl;
00470     if (mhBufNext == mhBufEnd) {
00471         mhBufNext = mhBufBegin;
00472     }
00473 
00474     return false;
00475 }

std::pair< OverlayKey, TransportAddress > KBRTestApp::createDestKey (  )  [private]

Definition at line 445 of file KBRTestApp.cc.

Referenced by handleTimerEvent().

00446 {
00447     if (lookupNodeIds) {
00448         const NodeHandle& handle = globalNodeList->getRandomNode(0, true,
00449                                                    onlyLookupInoffensiveNodes);
00450         return std::make_pair(handle.getKey(), handle);
00451     }
00452     // generate random destination key
00453     return std::make_pair(OverlayKey::random(), TransportAddress::UNSPECIFIED_NODE);
00454 }

void KBRTestApp::deliver ( OverlayKey key,
cMessage *  msg 
) [private, 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.

Definition at line 378 of file KBRTestApp.cc.

00379 {
00380     KBRTestMessage* testMsg = check_and_cast<KBRTestMessage*>(msg);
00381     OverlayCtrlInfo* overlayCtrlInfo =
00382         check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00383 
00384     if (overlay->getThisNode().getKey().isUnspecified())
00385         error("key");
00386 
00387     // check for duplicate
00388     if ((msgHandleBufSize > 0 )
00389             && checkSeen(overlayCtrlInfo->getSrcNode().getKey(), testMsg->getSeqNum())) {
00390         EV << "[KBRTestApp::deliver() @ " << overlay->getThisNode().getAddress()
00391            << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
00392            << "    Duplicate dropped."
00393            << endl;
00394         delete overlayCtrlInfo;
00395         delete testMsg;
00396         return;
00397     }
00398 
00399     // Return statistical data to the sender.
00400     if (cModule* mod = simulation.getModule(testMsg->getId())) {
00401         if (KBRTestApp* sender = dynamic_cast<KBRTestApp*>(mod)) {
00402             if ((!lookupNodeIds) || (overlay->getThisNode().getKey() == key)) {
00403                 if (testMsg->getMeasurementPhase() == true) {
00404                         sender->evaluateData((simTime() - testMsg->getCreationTime()),
00405                                              overlayCtrlInfo->getHopCount(),
00406                                              testMsg->getByteLength());
00407                 }
00408             } else if(lookupNodeIds) {
00409                 if (testMsg->getMeasurementPhase() == true) {
00410                     RECORD_STATS(numDropped++;
00411                                  bytesDropped += testMsg->getByteLength());
00412                 }
00413                 EV << "[KBRTestApp::deliver() @ " << overlay->getThisNode().getAddress()
00414                    << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
00415                    << "    Error: Lookup of NodeIDs and KBRTestMessage"
00416                    << " received with different destKey!"
00417                    << endl;
00418             }
00419         }
00420     }
00421 
00422     EV << "[KBRTestApp::deliver() @ " << overlay->getThisNode().getAddress()
00423        << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
00424        << "    Received \"" << testMsg->getName() << "(seqNr: "
00425        << testMsg->getSeqNum() << ")\n"
00426        << "    with destination key: " << key.toString(16)
00427        << endl;
00428 
00429     delete overlayCtrlInfo;
00430     delete testMsg;
00431 }

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

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

Definition at line 477 of file KBRTestApp.cc.

00478 {
00479     // count the number and size of successfully delivered messages
00480     RECORD_STATS(numDelivered++; bytesDelivered += bytes;
00481                  globalStatistics->deliveredKBRTestAppMessages++);
00482 
00483     if (numSent < numDelivered) {
00484         std::ostringstream tempString;
00485         tempString << "KBRTestApp::evaluateData(): numSent ("
00486                    << numSent << ") < numDelivered (" << numDelivered << ")!";
00487         throw cRuntimeError(tempString.str().c_str());
00488     }
00489 
00490     RECORD_STATS(globalStatistics->recordOutVector("KBRTestApp: One-way Hop "
00491                                                    "Count", hopCount));
00492     RECORD_STATS(globalStatistics->recordOutVector("KBRTestApp: One-way Latency",
00493                                                    SIMTIME_DBL(latency)));
00494 }

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

collects statistical data of derived app

Reimplemented from BaseApp.

Definition at line 496 of file KBRTestApp.cc.

00497 {
00498     simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime);
00499 
00500     if (time >= GlobalStatistics::MIN_MEASURED) {
00501         if (kbrOneWayTest) {
00502             globalStatistics->addStdDev("KBRTestApp: One-way Delivered Messages/s",
00503                                         numDelivered / time);
00504             globalStatistics->addStdDev("KBRTestApp: One-way Delivered Bytes/s",
00505                                         bytesDelivered / time);
00506             globalStatistics->addStdDev("KBRTestApp: One-way Dropped Messages/s",
00507                                         numDropped / time);
00508             globalStatistics->addStdDev("KBRTestApp: One-way Dropped Bytes/s",
00509                                         bytesDropped / time);
00510             if (numSent > 0) {
00511                 globalStatistics->addStdDev("KBRTestApp: One-way Delivery Ratio",
00512                                             (float)numDelivered /
00513                                             (float)numSent);
00514             }
00515         }
00516 
00517         if (kbrRpcTest) {
00518             globalStatistics->addStdDev("KBRTestApp: RPC Delivered Messages/s",
00519                                         numRpcDelivered / time);
00520             globalStatistics->addStdDev("KBRTestApp: RPC Delivered Bytes/s",
00521                                         bytesRpcDelivered / time);
00522             globalStatistics->addStdDev("KBRTestApp: RPC Dropped Messages/s",
00523                                         numRpcDropped / time);
00524             globalStatistics->addStdDev("KBRTestApp: RPC Dropped Bytes/s",
00525                                         bytesRpcDropped / time);
00526 #if 0
00527             if (rpcSuccLatencyCount > 0) {
00528                 globalStatistics->addStdDev("KBRTestApp: RPC Success Session Latency",
00529                                         SIMTIME_DBL(rpcSuccLatencySum) / rpcSuccLatencyCount);
00530             }
00531 
00532             if (rpcTotalLatencyCount > 0) {
00533                 globalStatistics->addStdDev("KBRTestApp: RPC Total Session Latency",
00534                                         SIMTIME_DBL(rpcTotalLatencySum) / rpcTotalLatencyCount);
00535             }
00536 #endif
00537 
00538             if (numRpcSent > 0) {
00539                 globalStatistics->addStdDev("KBRTestApp: RPC Delivery Ratio",
00540                                             (float)numRpcDelivered /
00541                                             (float)numRpcSent);
00542             }
00543         }
00544 
00545         if (kbrLookupTest) {
00546             globalStatistics->addStdDev("KBRTestApp: Successful Lookups/s",
00547                                         numLookupSuccess / time);
00548             globalStatistics->addStdDev("KBRTestApp: Failed Lookups/s",
00549                                         numLookupFailed / time);
00550             if (numLookupSent > 0) {
00551                 globalStatistics->addStdDev("KBRTestApp: Lookup Success Ratio",
00552                                             (float)numLookupSuccess /
00553                                             (float)numLookupSent);
00554             }
00555         }
00556     }
00557 }

void KBRTestApp::forward ( OverlayKey key,
cPacket **  msg,
NodeHandle nextHopNode 
) [private, 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.

Definition at line 433 of file KBRTestApp.cc.

00435 {
00436     KBRTestMessage* tempMsg = dynamic_cast<KBRTestMessage*>(*msg);
00437 
00438     if (tempMsg == NULL) return;
00439 
00440     tempMsg->setVisitedNodesArraySize(tempMsg->getVisitedNodesArraySize() + 1);
00441     tempMsg->setVisitedNodes(tempMsg->getVisitedNodesArraySize() - 1,
00442                              overlay->getThisNode().getAddress());
00443 }

void KBRTestApp::handleLookupResponse ( LookupResponse *  msg,
cObject *  context,
simtime_t  latency 
) [private]

Definition at line 329 of file KBRTestApp.cc.

Referenced by handleRpcResponse().

00331 {
00332     EV << "[KBRTestApp::handleLookupResponse() @ " << overlay->getThisNode().getAddress()
00333        << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
00334        << "    Lookup response for key " << msg->getKey()<< " : ";
00335 
00336     KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
00337 
00338     if (kbrRpcContext->getMeasurementPhase() == true) {
00339         if (msg->getIsValid() && (!lookupNodeIds ||
00340                 ((msg->getSiblingsArraySize() > 0) &&
00341                  (msg->getSiblings(0).getKey() == msg->getKey()) &&
00342                  (kbrRpcContext->getDestAddr() == msg->getSiblings(0))))) {
00343             RECORD_STATS(numLookupSuccess++);
00344             RECORD_STATS(globalStatistics->recordOutVector(
00345                    "KBRTestApp: Lookup Success Latency", SIMTIME_DBL(latency)));
00346             RECORD_STATS(globalStatistics->recordOutVector(
00347                    "KBRTestApp: Lookup Total Latency", SIMTIME_DBL(latency)));
00348             RECORD_STATS(globalStatistics->recordOutVector(
00349                     "KBRTestApp: Lookup Hop Count", msg->getHopCount()));
00350         } else {
00351 #if 0
00352             if (!msg->getIsValid()) {
00353                 std::cout << "invalid" << std::endl;
00354             } else if (msg->getSiblingsArraySize() == 0) {
00355                 std::cout << "empty" << std::endl;
00356             } else {
00357                 std::cout << "wrong key" << std::endl;
00358             }
00359 #endif
00360             RECORD_STATS(numLookupFailed++);
00361             // for failed lookups add failureLatency to latency statistics vector
00362             RECORD_STATS(globalStatistics->recordOutVector(
00363                          "KBRTestApp: Lookup Total Latency",
00364                          SIMTIME_DBL(failureLatency)));
00365             RECORD_STATS(globalStatistics->recordOutVector(
00366                     "KBRTestApp: Failed Lookup Hop Count", msg->getHopCount()));
00367         }
00368     }
00369 
00370     delete kbrRpcContext;
00371 }

void KBRTestApp::handleNodeLeaveNotification (  )  [private, virtual]

This method gets call **.gracefulLeaveDelay seconds before it is killed.

Reimplemented from BaseApp.

Definition at line 373 of file KBRTestApp.cc.

00374 {
00375     nodeIsLeavingSoon = true;
00376 }

bool KBRTestApp::handleRpcCall ( BaseCallMessage *  msg  )  [private, virtual]

Processes Remote-Procedure-Call invocation messages.


This method should be overloaded when the overlay provides RPC functionality.

Returns:
true, if rpc has been handled

Reimplemented from BaseRpc.

Definition at line 222 of file KBRTestApp.cc.

00223 {
00224     RPC_SWITCH_START( msg );
00225         RPC_DELEGATE( KbrTest, kbrTestCall );
00226     RPC_SWITCH_END( );
00227 
00228     return RPC_HANDLED;
00229 }

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

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

Parameters:
msg The response message.
context Pointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code
rpcId The RPC id.
rtt The Round-Trip-Time of this RPC

Reimplemented from RpcListener.

Definition at line 237 of file KBRTestApp.cc.

00240 {
00241     RPC_SWITCH_START(msg)
00242     RPC_ON_RESPONSE(Lookup) {
00243         EV << "[KBRTestApp::handleRpcResponse() @ " << overlay->getThisNode().getAddress()
00244            << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
00245            << "    Lookup RPC Response received: id=" << rpcId << "\n"
00246            << "    msg=" << *_LookupResponse << " rtt=" << rtt
00247            << endl;
00248         handleLookupResponse(_LookupResponse, context, rtt);
00249         break;
00250     }
00251     RPC_ON_RESPONSE(KbrTest) {
00252         KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
00253         if (kbrRpcContext->getMeasurementPhase() == true) {
00254             if (!lookupNodeIds ||
00255                 (kbrRpcContext->getDestKey() == msg->getSrcNode().getKey() &&
00256                  kbrRpcContext->getDestAddr() == msg->getSrcNode())) {
00257 
00258                 RECORD_STATS(numRpcDelivered++;
00259                              bytesRpcDelivered += msg->getByteLength());
00260                 RECORD_STATS(globalStatistics->recordOutVector(
00261                         "KBRTestApp: RPC Success Latency", SIMTIME_DBL(rtt)));
00262                 RECORD_STATS(globalStatistics->recordOutVector(
00263                         "KBRTestApp: RPC Total Latency", SIMTIME_DBL(rtt)));
00264                 RECORD_STATS(rpcSuccLatencyCount++;
00265                              rpcSuccLatencySum += SIMTIME_DBL(rtt));
00266                 RECORD_STATS(rpcTotalLatencyCount++;
00267                              rpcTotalLatencySum += SIMTIME_DBL(rtt));
00268                 OverlayCtrlInfo* overlayCtrlInfo =
00269                         dynamic_cast<OverlayCtrlInfo*>(msg->getControlInfo());
00270 
00271                 uint16_t hopSum = msg->getCallHopCount();
00272                 hopSum += (overlayCtrlInfo ? overlayCtrlInfo->getHopCount() : 1);
00273                 RECORD_STATS(globalStatistics->recordOutVector(
00274                         "KBRTestApp: RPC Hop Count", hopSum));
00275             } else {
00276                 RECORD_STATS(numRpcDropped++;
00277                              bytesRpcDropped += msg->getByteLength());
00278                 // for failed RPCs add failureLatency to latency statistics vector
00279                 RECORD_STATS(globalStatistics->recordOutVector(
00280                         "KBRTestApp: RPC Total Latency",
00281                         SIMTIME_DBL(failureLatency)));
00282                 RECORD_STATS(rpcTotalLatencyCount++;
00283                              rpcTotalLatencySum += SIMTIME_DBL(failureLatency));
00284             }
00285         }
00286         delete kbrRpcContext;
00287         break;
00288     }
00289     RPC_SWITCH_END( )
00290 }

void KBRTestApp::handleRpcTimeout ( BaseCallMessage *  msg,
const TransportAddress dest,
cPolymorphic *  context,
int  rpcId,
const OverlayKey destKey 
) [private, virtual]

This method is called if an RPC timeout has been reached.

Parameters:
msg The original RPC message.
dest The destination node
context Pointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code
rpcId The RPC id.
destKey the destination OverlayKey

Reimplemented from RpcListener.

Definition at line 292 of file KBRTestApp.cc.

00296 {
00297     RPC_SWITCH_START(msg)
00298     RPC_ON_CALL(KbrTest) {
00299         KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
00300         if (kbrRpcContext->getMeasurementPhase() == true) {
00301              RECORD_STATS(numRpcDropped++;
00302                           bytesRpcDropped += msg->getByteLength());
00303              // for failed RPCs add failureLatency to latency statistics vector
00304              RECORD_STATS(globalStatistics->recordOutVector(
00305                          "KBRTestApp: RPC Total Latency",
00306                          SIMTIME_DBL(failureLatency)));
00307              RECORD_STATS(rpcTotalLatencyCount++;
00308                           rpcTotalLatencySum += SIMTIME_DBL(failureLatency));
00309 
00310         }
00311         break;
00312     }
00313     RPC_ON_CALL(Lookup) {
00314         KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
00315         if (kbrRpcContext->getMeasurementPhase() == true) {
00316             RECORD_STATS(numLookupFailed++);
00317             // for failed lookups add failureLatency to latency statistics vector
00318             RECORD_STATS(globalStatistics->recordOutVector(
00319                          "KBRTestApp: Lookup Total Latency",
00320                          SIMTIME_DBL(failureLatency)));
00321         }
00322         break;
00323     }
00324     RPC_SWITCH_END()
00325 
00326     delete context;
00327 }

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

Reimplemented from BaseRpc.

Definition at line 142 of file KBRTestApp.cc.

00143 {
00144     // schedule next timer event
00145     scheduleAt(simTime() + truncnormal(mean, deviation), msg);
00146 
00147     // do nothing if the network is still in the initialization phase
00148     if ((!activeNetwInitPhase && underlayConfigurator->isInInitPhase())
00149             || underlayConfigurator->isSimulationEndingSoon()
00150             || nodeIsLeavingSoon) {
00151         return;
00152     }
00153 
00154     std::pair<OverlayKey,TransportAddress> dest = createDestKey();
00155 
00156     if (msg == onewayTimer) {
00157         // TEST 1: route a test message to a key (one-way)
00158         // do nothing if there are currently no nodes in the network
00159         if (!dest.first.isUnspecified()) {
00160             // create a 100 byte test message
00161             KBRTestMessage* testMsg = new KBRTestMessage("KBRTestMessage");
00162             testMsg->setId(getId());
00163             testMsg->setSeqNum(sequenceNumber++);
00164             testMsg->setByteLength(testMsgSize);
00165             testMsg->setMeasurementPhase(globalStatistics->isMeasuring());
00166 
00167             RECORD_STATS(globalStatistics->sentKBRTestAppMessages++;
00168                          numSent++; bytesSent += testMsg->getByteLength());
00169 
00170             callRoute(dest.first, testMsg);
00171         }
00172     } else if (msg == rpcTimer) {
00173         // TEST 2: send a remote procedure call to a specific key and wait for a response
00174         // do nothing if there are currently no nodes in the network
00175         if (!dest.first.isUnspecified()) {
00176             KbrTestCall* call = new KbrTestCall;
00177             call->setByteLength(testMsgSize);
00178             KbrRpcContext* context = new KbrRpcContext;
00179             context->setDestKey(dest.first);
00180             if (lookupNodeIds) {
00181                 context->setDestAddr(dest.second);
00182             }
00183             context->setMeasurementPhase(globalStatistics->isMeasuring());
00184 
00185             RECORD_STATS(numRpcSent++;
00186                          bytesRpcSent += call->getByteLength());
00187 
00188             sendRouteRpcCall(TIER1_COMP, dest.first, call, context);
00189         }
00190     } else /*if (msg == lookupTimer &&)*/ {
00191         // TEST 3: perform a lookup of a specific key
00192         // do nothing if there are currently no nodes in the network
00193         if (!dest.first.isUnspecified()) {
00194             LookupCall* call = new LookupCall();
00195             call->setKey(dest.first);
00196             call->setNumSiblings(overlay->getMaxNumSiblings());
00197             KbrRpcContext* context = new KbrRpcContext;
00198             context->setDestKey(dest.first);
00199             if (lookupNodeIds) {
00200                 context->setDestAddr(dest.second);
00201             }
00202             context->setMeasurementPhase(globalStatistics->isMeasuring());
00203             sendInternalRpcCall(OVERLAY_COMP, call, context);
00204 
00205             RECORD_STATS(numLookupSent++);
00206         }
00207     }
00208 
00209 #if 0
00210     thisNode.setPort(1025);
00211     NodeHandle handle = globalNodeList->getBootstrapNode();
00212     handle.setPort(1025);
00213     pingNode(handle, -1, -1, NULL, "TestPING", NULL, -1, UDP_TRANSPORT);
00214 #endif
00215 
00216 }

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

initializes derived class-attributes

Parameters:
stage the init stage

Reimplemented from BaseApp.

Definition at line 47 of file KBRTestApp.cc.

00048 {
00049     if (stage != MIN_STAGE_APP) {
00050         return;
00051     }
00052 
00053     kbrOneWayTest = par("kbrOneWayTest");
00054     kbrRpcTest = par("kbrRpcTest");
00055     kbrLookupTest = par("kbrLookupTest");
00056 
00057     if (!kbrOneWayTest && !kbrRpcTest && !kbrLookupTest) {
00058         throw cRuntimeError("KBRTestApp::initializeApp(): "
00059                             "no tests are configured!");
00060     }
00061 
00062     failureLatency = par("failureLatency");
00063 
00064     testMsgSize = par("testMsgSize");
00065     lookupNodeIds = par("lookupNodeIds");
00066     mean = par("testMsgInterval");
00067     deviation = mean / 10;
00068     activeNetwInitPhase = par("activeNetwInitPhase");
00069     msgHandleBufSize = par("msgHandleBufSize");
00070     onlyLookupInoffensiveNodes = par("onlyLookupInoffensiveNodes");
00071 
00072     numSent = 0;
00073     bytesSent = 0;
00074     numDelivered = 0;
00075     bytesDelivered = 0;
00076     numDropped = 0;
00077     bytesDropped = 0;
00078     WATCH(numSent);
00079     WATCH(bytesSent);
00080     WATCH(numDelivered);
00081     WATCH(bytesDelivered);
00082     WATCH(numDropped);
00083     WATCH(bytesDropped);
00084 
00085     numRpcSent = 0;
00086     bytesRpcSent = 0;
00087     numRpcDelivered = 0;
00088     bytesRpcDelivered = 0;
00089     numRpcDropped = 0;
00090     bytesRpcDropped = 0;
00091     rpcSuccLatencyCount = 0;
00092     rpcSuccLatencySum = 0;
00093     rpcTotalLatencyCount = 0;
00094     rpcTotalLatencySum = 0;
00095     WATCH(numRpcSent);
00096     WATCH(bytesRpcSent);
00097     WATCH(numRpcDelivered);
00098     WATCH(bytesRpcDelivered);
00099     WATCH(numRpcDropped);
00100     WATCH(bytesRpcDropped);
00101 
00102     numLookupSent = 0;
00103     numLookupSuccess = 0;
00104     numLookupFailed = 0;
00105     WATCH(numLookupSent);
00106     WATCH(numLookupSuccess);
00107     WATCH(numLookupFailed);
00108 
00109     sequenceNumber = 0;
00110 
00111     nodeIsLeavingSoon = false;
00112 
00113     // initialize circular buffer
00114     if (msgHandleBufSize > 0) {
00115         mhBuf.resize(msgHandleBufSize);
00116         mhBufBegin = mhBuf.begin();
00117         mhBufEnd = mhBuf.end();
00118         mhBufNext = mhBufBegin;
00119     }
00120 
00121 #if 0
00122     bindToPort(1025);
00123     thisNode.setPort(1025);
00124 #endif
00125 
00126     // start periodic timer
00127     onewayTimer = new cMessage("onewayTimer");
00128     rpcTimer = new cMessage("rpcTimer");
00129     lookupTimer = new cMessage("lookupTimer");
00130 
00131     if (kbrOneWayTest) {
00132         scheduleAt(simTime() + truncnormal(mean, deviation), onewayTimer);
00133     }
00134     if (kbrRpcTest) {
00135         scheduleAt(simTime() + truncnormal(mean, deviation), rpcTimer);
00136     }
00137     if (kbrLookupTest) {
00138         scheduleAt(simTime() + truncnormal(mean, deviation), lookupTimer);
00139     }
00140 }

void KBRTestApp::kbrTestCall ( KbrTestCall *  call  )  [private]

Definition at line 230 of file KBRTestApp.cc.

Referenced by handleRpcCall().

00231 {
00232     KbrTestResponse* response = new KbrTestResponse;
00233     response->setByteLength(call->getByteLength());
00234     sendRpcResponse(call, response);
00235 }

void KBRTestApp::pingResponse ( PingResponse *  response,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
) [private, virtual]

Reimplemented from BaseRpc.

Definition at line 217 of file KBRTestApp.cc.

00219 {
00220     //std::cout << rtt << std::endl;
00221 }


Member Data Documentation

is app active in network init phase?

Definition at line 135 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::bytesDelivered [private]

number of delivered bytes

Definition at line 143 of file KBRTestApp.h.

Referenced by evaluateData(), finishApp(), and initializeApp().

uint32_t KBRTestApp::bytesDropped [private]

Definition at line 145 of file KBRTestApp.h.

Referenced by deliver(), finishApp(), and initializeApp().

uint32_t KBRTestApp::bytesRpcDelivered [private]

number of delivered bytes

Definition at line 150 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), and initializeApp().

uint32_t KBRTestApp::bytesRpcDropped [private]

Definition at line 152 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), handleRpcTimeout(), and initializeApp().

uint32_t KBRTestApp::bytesRpcSent [private]

Definition at line 148 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::bytesSent [private]

Definition at line 141 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

double KBRTestApp::deviation [private]

deviation of time interval

Definition at line 134 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

simtime_t KBRTestApp::failureLatency [private]

this latency is recorded for failed lookups and RPCs

Definition at line 170 of file KBRTestApp.h.

Referenced by handleLookupResponse(), handleRpcResponse(), handleRpcTimeout(), and initializeApp().

bool KBRTestApp::kbrLookupTest [private]

Definition at line 130 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

bool KBRTestApp::kbrOneWayTest [private]

Definition at line 128 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

bool KBRTestApp::kbrRpcTest [private]

Definition at line 129 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

bool KBRTestApp::lookupNodeIds [private]

lookup only existing nodeIDs

Definition at line 136 of file KBRTestApp.h.

Referenced by createDestKey(), deliver(), handleLookupResponse(), handleRpcResponse(), handleTimerEvent(), and initializeApp().

cMessage* KBRTestApp::lookupTimer [private]

Definition at line 168 of file KBRTestApp.h.

Referenced by initializeApp(), and ~KBRTestApp().

double KBRTestApp::mean [private]

mean time interval between sending test messages

Definition at line 133 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

circular buffer of MsgHandles

Definition at line 174 of file KBRTestApp.h.

Referenced by initializeApp().

MsgHandleBuf::iterator KBRTestApp::mhBufBegin [private]

begin of circular buffer

Definition at line 175 of file KBRTestApp.h.

Referenced by checkSeen(), and initializeApp().

MsgHandleBuf::iterator KBRTestApp::mhBufEnd [private]

end of circular buffer

Definition at line 177 of file KBRTestApp.h.

Referenced by checkSeen(), and initializeApp().

MsgHandleBuf::iterator KBRTestApp::mhBufNext [private]

next element to insert

Definition at line 176 of file KBRTestApp.h.

Referenced by checkSeen(), and initializeApp().

how many MsgHandles to store in circular buffer

Definition at line 173 of file KBRTestApp.h.

Referenced by deliver(), and initializeApp().

true if the node is going to be killed shortly

Definition at line 137 of file KBRTestApp.h.

Referenced by handleNodeLeaveNotification(), handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::numDelivered [private]

number of delivered packets

Definition at line 142 of file KBRTestApp.h.

Referenced by evaluateData(), finishApp(), and initializeApp().

uint32_t KBRTestApp::numDropped [private]

Definition at line 144 of file KBRTestApp.h.

Referenced by deliver(), finishApp(), and initializeApp().

uint32_t KBRTestApp::numLookupFailed [private]

Definition at line 162 of file KBRTestApp.h.

Referenced by finishApp(), handleLookupResponse(), handleRpcTimeout(), and initializeApp().

uint32_t KBRTestApp::numLookupSent [private]

Definition at line 160 of file KBRTestApp.h.

Referenced by finishApp(), handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::numLookupSuccess [private]

Definition at line 161 of file KBRTestApp.h.

Referenced by finishApp(), handleLookupResponse(), and initializeApp().

uint32_t KBRTestApp::numRpcDelivered [private]

number of delivered packets

Definition at line 149 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), and initializeApp().

uint32_t KBRTestApp::numRpcDropped [private]

Definition at line 151 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), handleRpcTimeout(), and initializeApp().

uint32_t KBRTestApp::numRpcSent [private]

Definition at line 147 of file KBRTestApp.h.

Referenced by finishApp(), handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::numSent [private]

Definition at line 140 of file KBRTestApp.h.

Referenced by evaluateData(), finishApp(), handleTimerEvent(), and initializeApp().

cMessage* KBRTestApp::onewayTimer [private]

Definition at line 166 of file KBRTestApp.h.

Referenced by handleTimerEvent(), initializeApp(), KBRTestApp(), and ~KBRTestApp().

if true only search for inoffensive nodes (use together with lookupNodeIds)

Definition at line 138 of file KBRTestApp.h.

Referenced by createDestKey(), and initializeApp().

uint32_t KBRTestApp::rpcSuccLatencyCount [private]

Definition at line 155 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), and initializeApp().

simtime_t KBRTestApp::rpcSuccLatencySum [private]

Definition at line 154 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), and initializeApp().

cMessage* KBRTestApp::rpcTimer [private]

Definition at line 167 of file KBRTestApp.h.

Referenced by handleTimerEvent(), initializeApp(), and ~KBRTestApp().

Definition at line 158 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), handleRpcTimeout(), and initializeApp().

simtime_t KBRTestApp::rpcTotalLatencySum [private]

Definition at line 157 of file KBRTestApp.h.

Referenced by finishApp(), handleRpcResponse(), handleRpcTimeout(), and initializeApp().

uint32_t KBRTestApp::sequenceNumber [private]

Definition at line 172 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int KBRTestApp::testMsgSize [private]

Definition at line 132 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().


The documentation for this class was generated from the following files:
Generated on Wed May 26 16:21:17 2010 for OverSim by  doxygen 1.6.3