Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes

KBRTestApp Class Reference

Test application for KBR interface. More...

#include <KBRTestApp.h>

Inheritance diagram for KBRTestApp:
BaseApp BaseRpc BaseTcpSupport 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)
void kbrTestCall (KbrTestCall *call)
void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
void handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
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.

{
    onewayTimer = NULL;
}

KBRTestApp::~KBRTestApp (  ) 

Definition at line 40 of file KBRTestApp.cc.

{
    cancelAndDelete(onewayTimer);
    cancelAndDelete(rpcTimer);
    cancelAndDelete(lookupTimer);
}


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 458 of file KBRTestApp.cc.

Referenced by deliver().

{
    MsgHandle hdl(key, seqNum);

    for (MsgHandleBuf::iterator it = mhBufBegin; it != mhBufEnd; ++it) {
        if (it->key.isUnspecified()) {
            continue;
        }
        if (*it == hdl) {
            return true;
        }
    }

    *(mhBufNext++) = hdl;
    if (mhBufNext == mhBufEnd) {
        mhBufNext = mhBufBegin;
    }

    return false;
}

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

Definition at line 447 of file KBRTestApp.cc.

Referenced by handleTimerEvent().

{
    if (lookupNodeIds) {
        const NodeHandle& handle = globalNodeList->getRandomNode(0, true,
                                                   onlyLookupInoffensiveNodes);
        return std::make_pair(handle.getKey(), handle);
    }
    // generate random destination key
    return std::make_pair(OverlayKey::random(), TransportAddress::UNSPECIFIED_NODE);
}

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 380 of file KBRTestApp.cc.

{
    KBRTestMessage* testMsg = check_and_cast<KBRTestMessage*>(msg);
    OverlayCtrlInfo* overlayCtrlInfo =
        check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());

    if (overlay->getThisNode().getKey().isUnspecified())
        error("key");

    // check for duplicate
    if ((msgHandleBufSize > 0 )
            && checkSeen(overlayCtrlInfo->getSrcNode().getKey(), testMsg->getSeqNum())) {
        EV << "[KBRTestApp::deliver() @ " << overlay->getThisNode().getIp()
           << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
           << "    Duplicate dropped."
           << endl;
        delete overlayCtrlInfo;
        delete testMsg;
        return;
    }

    // Return statistical data to the sender.
    if (cModule* mod = simulation.getModule(testMsg->getId())) {
        if (KBRTestApp* sender = dynamic_cast<KBRTestApp*>(mod)) {
            if ((!lookupNodeIds) || (overlay->getThisNode().getKey() == key)) {
                if (testMsg->getMeasurementPhase() == true) {
                        sender->evaluateData((simTime() - testMsg->getCreationTime()),
                                             overlayCtrlInfo->getHopCount(),
                                             testMsg->getByteLength());
                }
            } else if(lookupNodeIds) {
                if (testMsg->getMeasurementPhase() == true) {
                    RECORD_STATS(numDropped++;
                                 bytesDropped += testMsg->getByteLength());
                }
                EV << "[KBRTestApp::deliver() @ " << overlay->getThisNode().getIp()
                   << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
                   << "    Error: Lookup of NodeIDs and KBRTestMessage"
                   << " received with different destKey!"
                   << endl;
            }
        }
    }

    EV << "[KBRTestApp::deliver() @ " << overlay->getThisNode().getIp()
       << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
       << "    Received \"" << testMsg->getName() << "(seqNr: "
       << testMsg->getSeqNum() << ")\n"
       << "    with destination key: " << key.toString(16)
       << endl;

    delete overlayCtrlInfo;
    delete testMsg;
}

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 479 of file KBRTestApp.cc.

{
    // count the number and size of successfully delivered messages
    RECORD_STATS(numDelivered++; bytesDelivered += bytes;
                 globalStatistics->deliveredKBRTestAppMessages++);

    if (numSent < numDelivered) {
        std::ostringstream tempString;
        tempString << "KBRTestApp::evaluateData(): numSent ("
                   << numSent << ") < numDelivered (" << numDelivered << ")!";
        throw cRuntimeError(tempString.str().c_str());
    }

    RECORD_STATS(globalStatistics->recordOutVector("KBRTestApp: One-way Hop "
                                                   "Count", hopCount));
    RECORD_STATS(globalStatistics->recordOutVector("KBRTestApp: One-way Latency",
                                                   SIMTIME_DBL(latency)));
}

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

collects statistical data of derived app

Reimplemented from BaseApp.

Definition at line 498 of file KBRTestApp.cc.

{
    simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime);

    if (time >= GlobalStatistics::MIN_MEASURED) {
        if (kbrOneWayTest) {
            globalStatistics->addStdDev("KBRTestApp: One-way Delivered Messages/s",
                                        numDelivered / time);
            globalStatistics->addStdDev("KBRTestApp: One-way Delivered Bytes/s",
                                        bytesDelivered / time);
            globalStatistics->addStdDev("KBRTestApp: One-way Dropped Messages/s",
                                        numDropped / time);
            globalStatistics->addStdDev("KBRTestApp: One-way Dropped Bytes/s",
                                        bytesDropped / time);
            if (numSent > 0) {
                globalStatistics->addStdDev("KBRTestApp: One-way Delivery Ratio",
                                            (float)numDelivered /
                                            (float)numSent);
            }
        }

        if (kbrRpcTest) {
            globalStatistics->addStdDev("KBRTestApp: RPC Delivered Messages/s",
                                        numRpcDelivered / time);
            globalStatistics->addStdDev("KBRTestApp: RPC Delivered Bytes/s",
                                        bytesRpcDelivered / time);
            globalStatistics->addStdDev("KBRTestApp: RPC Dropped Messages/s",
                                        numRpcDropped / time);
            globalStatistics->addStdDev("KBRTestApp: RPC Dropped Bytes/s",
                                        bytesRpcDropped / time);
#if 0
            if (rpcSuccLatencyCount > 0) {
                globalStatistics->addStdDev("KBRTestApp: RPC Success Session Latency",
                                        SIMTIME_DBL(rpcSuccLatencySum) / rpcSuccLatencyCount);
            }

            if (rpcTotalLatencyCount > 0) {
                globalStatistics->addStdDev("KBRTestApp: RPC Total Session Latency",
                                        SIMTIME_DBL(rpcTotalLatencySum) / rpcTotalLatencyCount);
            }
#endif

            if (numRpcSent > 0) {
                globalStatistics->addStdDev("KBRTestApp: RPC Delivery Ratio",
                                            (float)numRpcDelivered /
                                            (float)numRpcSent);
            }
        }

        if (kbrLookupTest) {
            globalStatistics->addStdDev("KBRTestApp: Successful Lookups/s",
                                        numLookupSuccess / time);
            globalStatistics->addStdDev("KBRTestApp: Failed Lookups/s",
                                        numLookupFailed / time);
            if (numLookupSent > 0) {
                globalStatistics->addStdDev("KBRTestApp: Lookup Success Ratio",
                                            (float)numLookupSuccess /
                                            (float)numLookupSent);
            }
        }
    }
}

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 435 of file KBRTestApp.cc.

{
    KBRTestMessage* tempMsg = dynamic_cast<KBRTestMessage*>(*msg);

    if (tempMsg == NULL) return;

    tempMsg->setVisitedNodesArraySize(tempMsg->getVisitedNodesArraySize() + 1);
    tempMsg->setVisitedNodes(tempMsg->getVisitedNodesArraySize() - 1,
                             overlay->getThisNode().getIp());
}

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

Definition at line 331 of file KBRTestApp.cc.

Referenced by handleRpcResponse().

{
    EV << "[KBRTestApp::handleLookupResponse() @ " << overlay->getThisNode().getIp()
       << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
       << "    Lookup response for key " << msg->getKey()<< " : ";

    KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);

    if (kbrRpcContext->getMeasurementPhase() == true) {
        if (msg->getIsValid() && (!lookupNodeIds ||
                ((msg->getSiblingsArraySize() > 0) &&
                 (msg->getSiblings(0).getKey() == msg->getKey()) &&
                 (kbrRpcContext->getDestAddr() == msg->getSiblings(0))))) {
            RECORD_STATS(numLookupSuccess++);
            RECORD_STATS(globalStatistics->recordOutVector(
                   "KBRTestApp: Lookup Success Latency", SIMTIME_DBL(latency)));
            RECORD_STATS(globalStatistics->recordOutVector(
                   "KBRTestApp: Lookup Total Latency", SIMTIME_DBL(latency)));
            RECORD_STATS(globalStatistics->recordOutVector(
                    "KBRTestApp: Lookup Hop Count", msg->getHopCount()));
        } else {
#if 0
            if (!msg->getIsValid()) {
                std::cout << "invalid" << std::endl;
            } else if (msg->getSiblingsArraySize() == 0) {
                std::cout << "empty" << std::endl;
            } else {
                std::cout << "wrong key" << std::endl;
            }
#endif
            RECORD_STATS(numLookupFailed++);
            // for failed lookups add failureLatency to latency statistics vector
            RECORD_STATS(globalStatistics->recordOutVector(
                         "KBRTestApp: Lookup Total Latency",
                         SIMTIME_DBL(failureLatency)));
            RECORD_STATS(globalStatistics->recordOutVector(
                    "KBRTestApp: Failed Lookup Hop Count", msg->getHopCount()));
        }
    }

    delete kbrRpcContext;
}

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

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

Reimplemented from BaseApp.

Definition at line 375 of file KBRTestApp.cc.

{
    nodeIsLeavingSoon = true;
}

bool KBRTestApp::handleRpcCall ( BaseCallMessage msg  )  [private]

Definition at line 222 of file KBRTestApp.cc.

{
    RPC_SWITCH_START( msg );
        RPC_DELEGATE( KbrTest, kbrTestCall );
    RPC_SWITCH_END( );

    return RPC_HANDLED;
}

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

Definition at line 237 of file KBRTestApp.cc.

{
    RPC_SWITCH_START(msg)
    RPC_ON_RESPONSE(Lookup) {
        EV << "[KBRTestApp::handleRpcResponse() @ " << overlay->getThisNode().getIp()
           << " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
           << "    Lookup RPC Response received: id=" << rpcId << "\n"
           << "    msg=" << *_LookupResponse << " rtt=" << rtt
           << endl;
        handleLookupResponse(_LookupResponse, context, rtt);
        break;
    }
    RPC_ON_RESPONSE(KbrTest) {
        KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
        if (kbrRpcContext->getMeasurementPhase() == true) {
            if (!lookupNodeIds ||
                (kbrRpcContext->getDestKey() == msg->getSrcNode().getKey() &&
                 kbrRpcContext->getDestAddr() == msg->getSrcNode())) {

                RECORD_STATS(numRpcDelivered++;
                             bytesRpcDelivered += msg->getByteLength());
                RECORD_STATS(globalStatistics->recordOutVector(
                        "KBRTestApp: RPC Success Latency", SIMTIME_DBL(rtt)));
                RECORD_STATS(globalStatistics->recordOutVector(
                        "KBRTestApp: RPC Total Latency", SIMTIME_DBL(rtt)));
                RECORD_STATS(rpcSuccLatencyCount++;
                             rpcSuccLatencySum += SIMTIME_DBL(rtt));
                RECORD_STATS(rpcTotalLatencyCount++;
                             rpcTotalLatencySum += SIMTIME_DBL(rtt));
                OverlayCtrlInfo* overlayCtrlInfo =
                        dynamic_cast<OverlayCtrlInfo*>(msg->getControlInfo());

                uint16_t hopSum = msg->getCallHopCount();
                hopSum += (overlayCtrlInfo ? overlayCtrlInfo->getHopCount() : 1);
                RECORD_STATS(globalStatistics->recordOutVector(
                        "KBRTestApp: RPC Hop Count", hopSum));
//              RECORD_STATS(globalStatistics->recordHistogram(
//                      "KBRTestApp: RPC Hop Count Histogram", hopSum));
            } else {
                RECORD_STATS(numRpcDropped++;
                             bytesRpcDropped += msg->getByteLength());
                // for failed RPCs add failureLatency to latency statistics vector
                RECORD_STATS(globalStatistics->recordOutVector(
                        "KBRTestApp: RPC Total Latency",
                        SIMTIME_DBL(failureLatency)));
                RECORD_STATS(rpcTotalLatencyCount++;
                             rpcTotalLatencySum += SIMTIME_DBL(failureLatency));
            }
        }
        delete kbrRpcContext;
        break;
    }
    RPC_SWITCH_END( )
}

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

Definition at line 294 of file KBRTestApp.cc.

{
    RPC_SWITCH_START(msg)
    RPC_ON_CALL(KbrTest) {
        KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
        if (kbrRpcContext->getMeasurementPhase() == true) {
             RECORD_STATS(numRpcDropped++;
                          bytesRpcDropped += msg->getByteLength());
             // for failed RPCs add failureLatency to latency statistics vector
             RECORD_STATS(globalStatistics->recordOutVector(
                         "KBRTestApp: RPC Total Latency",
                         SIMTIME_DBL(failureLatency)));
             RECORD_STATS(rpcTotalLatencyCount++;
                          rpcTotalLatencySum += SIMTIME_DBL(failureLatency));

        }
        break;
    }
    RPC_ON_CALL(Lookup) {
        KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
        if (kbrRpcContext->getMeasurementPhase() == true) {
            RECORD_STATS(numLookupFailed++);
            // for failed lookups add failureLatency to latency statistics vector
            RECORD_STATS(globalStatistics->recordOutVector(
                         "KBRTestApp: Lookup Total Latency",
                         SIMTIME_DBL(failureLatency)));
        }
        break;
    }
    RPC_SWITCH_END()

    delete context;
}

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

Definition at line 142 of file KBRTestApp.cc.

{
    // schedule next timer event
    scheduleAt(simTime() + truncnormal(mean, deviation), msg);

    // do nothing if the network is still in the initialization phase
    if ((!activeNetwInitPhase && underlayConfigurator->isInInitPhase())
            || underlayConfigurator->isSimulationEndingSoon()
            || nodeIsLeavingSoon) {
        return;
    }

    std::pair<OverlayKey,TransportAddress> dest = createDestKey();

    if (msg == onewayTimer) {
        // TEST 1: route a test message to a key (one-way)
        // do nothing if there are currently no nodes in the network
        if (!dest.first.isUnspecified()) {
            // create a 100 byte test message
            KBRTestMessage* testMsg = new KBRTestMessage("KBRTestMessage");
            testMsg->setId(getId());
            testMsg->setSeqNum(sequenceNumber++);
            testMsg->setByteLength(testMsgSize);
            testMsg->setMeasurementPhase(globalStatistics->isMeasuring());

            RECORD_STATS(globalStatistics->sentKBRTestAppMessages++;
                         numSent++; bytesSent += testMsg->getByteLength());

            callRoute(dest.first, testMsg);
        }
    } else if (msg == rpcTimer) {
        // TEST 2: send a remote procedure call to a specific key and wait for a response
        // do nothing if there are currently no nodes in the network
        if (!dest.first.isUnspecified()) {
            KbrTestCall* call = new KbrTestCall;
            call->setByteLength(testMsgSize);
            KbrRpcContext* context = new KbrRpcContext;
            context->setDestKey(dest.first);
            if (lookupNodeIds) {
                context->setDestAddr(dest.second);
            }
            context->setMeasurementPhase(globalStatistics->isMeasuring());

            RECORD_STATS(numRpcSent++;
                         bytesRpcSent += call->getByteLength());

            sendRouteRpcCall(TIER1_COMP, dest.first, call, context);
        }
    } else /*if (msg == lookupTimer &&)*/ {
        // TEST 3: perform a lookup of a specific key
        // do nothing if there are currently no nodes in the network
        if (!dest.first.isUnspecified()) {
            LookupCall* call = new LookupCall();
            call->setKey(dest.first);
            call->setNumSiblings(overlay->getMaxNumSiblings());
            KbrRpcContext* context = new KbrRpcContext;
            context->setDestKey(dest.first);
            if (lookupNodeIds) {
                context->setDestAddr(dest.second);
            }
            context->setMeasurementPhase(globalStatistics->isMeasuring());
            sendInternalRpcCall(OVERLAY_COMP, call, context);

            RECORD_STATS(numLookupSent++);
        }
    }

#if 0
    thisNode.setPort(1025);
    NodeHandle handle = globalNodeList->getBootstrapNode();
    handle.setPort(1025);
    pingNode(handle, -1, -1, NULL, "TestPING", NULL, -1, UDP_TRANSPORT);
#endif

}

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.

{
    if (stage != MIN_STAGE_APP) {
        return;
    }

    kbrOneWayTest = par("kbrOneWayTest");
    kbrRpcTest = par("kbrRpcTest");
    kbrLookupTest = par("kbrLookupTest");

    if (!kbrOneWayTest && !kbrRpcTest && !kbrLookupTest) {
        throw cRuntimeError("KBRTestApp::initializeApp(): "
                            "no tests are configured!");
    }

    failureLatency = par("failureLatency");

    testMsgSize = par("testMsgSize");
    lookupNodeIds = par("lookupNodeIds");
    mean = par("testMsgInterval");
    deviation = mean / 10;
    activeNetwInitPhase = par("activeNetwInitPhase");
    msgHandleBufSize = par("msgHandleBufSize");
    onlyLookupInoffensiveNodes = par("onlyLookupInoffensiveNodes");

    numSent = 0;
    bytesSent = 0;
    numDelivered = 0;
    bytesDelivered = 0;
    numDropped = 0;
    bytesDropped = 0;
    WATCH(numSent);
    WATCH(bytesSent);
    WATCH(numDelivered);
    WATCH(bytesDelivered);
    WATCH(numDropped);
    WATCH(bytesDropped);

    numRpcSent = 0;
    bytesRpcSent = 0;
    numRpcDelivered = 0;
    bytesRpcDelivered = 0;
    numRpcDropped = 0;
    bytesRpcDropped = 0;
    rpcSuccLatencyCount = 0;
    rpcSuccLatencySum = 0;
    rpcTotalLatencyCount = 0;
    rpcTotalLatencySum = 0;
    WATCH(numRpcSent);
    WATCH(bytesRpcSent);
    WATCH(numRpcDelivered);
    WATCH(bytesRpcDelivered);
    WATCH(numRpcDropped);
    WATCH(bytesRpcDropped);

    numLookupSent = 0;
    numLookupSuccess = 0;
    numLookupFailed = 0;
    WATCH(numLookupSent);
    WATCH(numLookupSuccess);
    WATCH(numLookupFailed);

    sequenceNumber = 0;

    nodeIsLeavingSoon = false;

    // initialize circular buffer
    if (msgHandleBufSize > 0) {
        mhBuf.resize(msgHandleBufSize);
        mhBufBegin = mhBuf.begin();
        mhBufEnd = mhBuf.end();
        mhBufNext = mhBufBegin;
    }

#if 0
    bindToPort(1025);
    thisNode.setPort(1025);
#endif

    // start periodic timer
    onewayTimer = new cMessage("onewayTimer");
    rpcTimer = new cMessage("rpcTimer");
    lookupTimer = new cMessage("lookupTimer");

    if (kbrOneWayTest) {
        scheduleAt(simTime() + truncnormal(mean, deviation), onewayTimer);
    }
    if (kbrRpcTest) {
        scheduleAt(simTime() + truncnormal(mean, deviation), rpcTimer);
    }
    if (kbrLookupTest) {
        scheduleAt(simTime() + truncnormal(mean, deviation), lookupTimer);
    }
}

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

Definition at line 230 of file KBRTestApp.cc.

Referenced by handleRpcCall().

{
    KbrTestResponse* response = new KbrTestResponse;
    response->setByteLength(call->getByteLength());
    sendRpcResponse(call, response);
}

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

Definition at line 217 of file KBRTestApp.cc.

{
    //std::cout << rtt << std::endl;
}


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: