OverSim
KBRTestApp Class Reference

Test application for KBR interface. More...

#include <KBRTestApp.h>

Inheritance diagram for KBRTestApp:
BaseApp BaseRpc BaseTcpSupport RpcListener

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 ()
- Public Member Functions inherited from BaseApp
 BaseApp ()
virtual ~BaseApp ()
 virtual destructor
- Public Member Functions inherited from BaseRpc
 BaseRpc ()
const NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
simtime_t getUdpTimeout ()
- Public Member Functions inherited from RpcListener
virtual ~RpcListener ()
 destructor
- Public Member Functions inherited from BaseTcpSupport
virtual void socketDataArrived (int connId, void *yourPtr, cPacket *msg, bool urgent)
virtual void socketEstablished (int connId, void *yourPtr)
virtual void socketPeerClosed (int connId, void *yourPtr)
virtual void socketFailure (int connId, void *yourPtr, int code)
virtual void socketStatusArrived (int connId, void *yourPtr, TCPStatusInfo *status)

Private Types

typedef std::vector< MsgHandleMsgHandleBuf

Private Member Functions

void initializeApp (int stage)
void finishApp ()
void handleTimerEvent (cMessage *msg)
void deliver (OverlayKey &key, cMessage *msg)
void forward (OverlayKey *key, cPacket **msg, NodeHandle *nextHopNode)
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 underlayTestCall (UnderlayTestCall *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 ()
std::pair< OverlayKey,
TransportAddress
createDestKey ()

Private Attributes

bool kbrOneWayTest
bool kbrRpcTest
bool kbrLookupTest
bool underlayTest
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)
int rpcRetries
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
uint32_t numUnderlaySent
uint32_t bytesUnderlaySent
uint32_t numUnderlayDelivered
 number of delivered packets
uint32_t bytesUnderlayDelivered
 number of delivered bytes
cMessage * onewayTimer
cMessage * rpcTimer
cMessage * lookupTimer
cMessage * underlayTimer
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

Additional Inherited Members

- Public Types inherited from BaseTcpSupport
enum  EvCode {
  NO_EST_CONNECTION, PEER_CLOSED, PEER_TIMEDOUT, PEER_REFUSED,
  CONNECTION_RESET, CONNECTION_SUCC_ClOSED
}
- Protected Member Functions inherited from BaseApp
int numInitStages () const
 method to set InitStage
void initialize (int stage)
 initializes base class-attributes
virtual void initializeApp (int stage)
 initializes derived class-attributes
void handleMessage (cMessage *msg)
 checks for message type and calls corresponding method
virtual void receiveChangeNotification (int category, const cPolymorphic *details)
 callback-method for events at the NotificationBoard
virtual void handleTransportAddressChangedNotification ()
 This method gets call if the node has a new TransportAddress (IP address) because he changed his access network.
virtual void handleNodeLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed.
virtual void handleNodeGracefulLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.
void finish ()
 collects statistical data
virtual void finishApp ()
 collects statistical data of derived app
void callRoute (const OverlayKey &key, cPacket *msg, const TransportAddress &hint=TransportAddress::UNSPECIFIED_NODE, RoutingType routingType=DEFAULT_ROUTING)
 Common API function: calls route-method in overlay.
void callRoute (const OverlayKey &key, cPacket *msg, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType=DEFAULT_ROUTING)
virtual void deliver (OverlayKey &key, cMessage *msg)
 Common API function: handles delivered messages from overlay.
virtual void forward (OverlayKey *key, cPacket **msg, NodeHandle *nextHopNode)
 Common API function: handles messages from overlay to be forwarded.
virtual void update (const NodeHandle &node, bool joined)
 Common API function: informs application about neighbors and own nodeID.
NodeVectorcallLocalLookup (const OverlayKey &key, int num, bool safe)
 Common API function: produces a list of nodes that can be used as next hops towards key.
NodeVectorcallNeighborSet (int num)
 Common API function: produces a list of neighbor nodes.
bool isSiblingFor (const NodeHandle &node, const OverlayKey &key, int numSiblings, bool *err)
 Query if a node is among the siblings for a given key.
virtual void handleLowerMessage (cMessage *msg)
 processes self-messages
virtual void handleUpperMessage (cMessage *msg)
 handleUpperMessage gets called of handleMessage(cMessage* msg) if msg arrivedOn from_upperTier (currently msg gets deleted in this function)
virtual void handleUDPMessage (cMessage *msg)
 method to handle messages that come directly from the UDP gate
virtual void handleReadyMessage (CompReadyMessage *msg)
 method to handle ready messages from the overlay
virtual void bindToPort (int port)
 Tells UDP we want to get all packets arriving on the given port.
virtual void sendMessageToUDP (const TransportAddress &destAddr, cPacket *msg, simtime_t delay=SIMTIME_ZERO)
 Sends a packet over UDP.
virtual void handleTraceMessage (cMessage *msg)
 handleTraceMessage gets called of handleMessage(cMessage* msg) if a message arrives at trace_in.
void sendMessageToLowerTier (cPacket *msg)
 sends non-commonAPI message to the lower tier
bool internalHandleRpcCall (BaseCallMessage *msg)
 Handles internal rpc requests.
void internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 Handles rpc responses internal in base classes

void internalSendRouteRpc (BaseRpcMessage *message, const OverlayKey &destKey, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType)
virtual CompType getThisCompType ()
 Return the component type of this module.
void sendReadyMessage (bool ready=true, const OverlayKey &nodeId=OverlayKey::UNSPECIFIED_KEY)
- Protected Attributes inherited from BaseApp
UnderlayConfiguratorunderlayConfigurator
 pointer to UnderlayConfigurator in this node
GlobalNodeListglobalNodeList
 pointer to GlobalNodeList in this node
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
NotificationBoard * notificationBoard
 pointer to NotificationBoard in this node
bool debugOutput
 debug output yes/no?
int numOverlaySent
 number of sent packets to overlay
int bytesOverlaySent
 number of sent bytes to overlay
int numOverlayReceived
 number of received packets from overlay
int bytesOverlayReceived
 number of received bytes from overlay
int numUdpSent
 number of sent packets to UDP
int bytesUdpSent
 number of sent bytes to UDP
int numUdpReceived
 number of received packets from UDP
int bytesUdpReceived
 number of received bytes from UDP
simtime_t creationTime
 simTime when the App has been created

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 44 of file KBRTestApp.h.

Member Typedef Documentation

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

Definition at line 74 of file KBRTestApp.h.

Constructor & Destructor Documentation

KBRTestApp::KBRTestApp ( )

Definition at line 35 of file KBRTestApp.cc.

{
onewayTimer = NULL;
rpcTimer = NULL;
lookupTimer = NULL;
underlayTimer = NULL;
}
KBRTestApp::~KBRTestApp ( )

Definition at line 43 of file KBRTestApp.cc.

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

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
keythe OverlayKey of the sender
seqNumsequence number of the message to check
Returns
true if the message was seen before

Definition at line 555 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) {
}
return false;
}
std::pair< OverlayKey, TransportAddress > KBRTestApp::createDestKey ( )
private

Definition at line 542 of file KBRTestApp.cc.

Referenced by handleTimerEvent().

{
// TODO parameter to choose only nodes with own nodeType
// getPeerInfo(getThisNode())->getTypeID()
const NodeHandle& handle = globalNodeList->getRandomNode(-1, -1, true,
return std::make_pair(handle.getKey(), handle);
}
// generate random destination key
}
void KBRTestApp::deliver ( OverlayKey key,
cMessage *  msg 
)
private

Definition at line 475 of file KBRTestApp.cc.

{
KBRTestMessage* testMsg = check_and_cast<KBRTestMessage*>(msg);
OverlayCtrlInfo* overlayCtrlInfo =
check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
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) {
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
timeDelaypacket-delay
hopCountpacket hop-count
bytespacket size in bytes

Definition at line 576 of file KBRTestApp.cc.

{
// count the number and size of successfully delivered messages
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

Definition at line 595 of file KBRTestApp.cc.

{
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);
/* globalStatistics->addStdDev("KBRTestApp: One-way Total Latency",
globalStatistics->getv * (1 - ((float)numDelivered /
(float)numSent)));*/
}
}
if (kbrRpcTest) {
globalStatistics->addStdDev("KBRTestApp: RPC Delivered Messages/s",
numRpcDelivered / time);
globalStatistics->addStdDev("KBRTestApp: RPC Delivered Bytes/s",
globalStatistics->addStdDev("KBRTestApp: RPC Dropped Messages/s",
numRpcDropped / time);
globalStatistics->addStdDev("KBRTestApp: RPC Dropped Bytes/s",
bytesRpcDropped / time);
#if 0
globalStatistics->addStdDev("KBRTestApp: RPC Success Session Latency",
}
globalStatistics->addStdDev("KBRTestApp: RPC Total Session Latency",
}
#endif
if (numRpcSent > 0) {
globalStatistics->addStdDev("KBRTestApp: RPC Delivery Ratio",
(float)numRpcDelivered /
(float)numRpcSent);
}
}
globalStatistics->addStdDev("KBRTestApp: Successful Lookups/s",
globalStatistics->addStdDev("KBRTestApp: Failed Lookups/s",
numLookupFailed / time);
if (numLookupSent > 0) {
globalStatistics->addStdDev("KBRTestApp: Lookup Success Ratio",
(float)numLookupSent);
}
}
if (underlayTest) {
if (numUnderlaySent > 0) {
globalStatistics->addStdDev("KBRTestApp: Underlay Delivery Ratio",
(float)numUnderlaySent);
}
}
}
}
void KBRTestApp::forward ( OverlayKey key,
cPacket **  msg,
NodeHandle nextHopNode 
)
private

Definition at line 530 of file KBRTestApp.cc.

{
KBRTestMessage* tempMsg = dynamic_cast<KBRTestMessage*>(*msg);
if (tempMsg == NULL) return;
tempMsg->setVisitedNodes(tempMsg->getVisitedNodesArraySize() - 1,
}
void KBRTestApp::handleLookupResponse ( LookupResponse msg,
cObject *  context,
simtime_t  latency 
)
private

Definition at line 426 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))))) {
"KBRTestApp: Lookup Success Latency", SIMTIME_DBL(latency)));
"KBRTestApp: Lookup Total Latency", SIMTIME_DBL(latency)));
"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
// for failed lookups add failureLatency to latency statistics vector
"KBRTestApp: Lookup Total Latency",
SIMTIME_DBL(failureLatency)));
"KBRTestApp: Failed Lookup Hop Count", msg->getHopCount()));
}
}
delete kbrRpcContext;
}
void KBRTestApp::handleNodeLeaveNotification ( )
privatevirtual

Definition at line 470 of file KBRTestApp.cc.

{
}
bool KBRTestApp::handleRpcCall ( BaseCallMessage msg)
private

Definition at line 273 of file KBRTestApp.cc.

{
RPC_DELEGATE( UnderlayTest, underlayTestCall );
return RPC_HANDLED;
}
void KBRTestApp::handleRpcResponse ( BaseResponseMessage msg,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
)
private

Definition at line 301 of file KBRTestApp.cc.

{
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())) {
bytesRpcDelivered += msg->getByteLength());
"KBRTestApp: RPC Success Latency", SIMTIME_DBL(rtt)));
"KBRTestApp: RPC Total Latency", SIMTIME_DBL(rtt)));
rpcSuccLatencySum += SIMTIME_DBL(rtt));
rpcTotalLatencySum += SIMTIME_DBL(rtt));
OverlayCtrlInfo* overlayCtrlInfo =
dynamic_cast<OverlayCtrlInfo*>(msg->getControlInfo());
uint16_t hopSum = msg->getCallHopCount();
hopSum += (overlayCtrlInfo ? overlayCtrlInfo->getHopCount() : 1);
"KBRTestApp: RPC Hop Count", hopSum));
// RECORD_STATS(globalStatistics->recordHistogram(
// "KBRTestApp: RPC Hop Count Histogram", hopSum));
} else {
//std::cout << simTime() << " " << thisNode.getAddress()
// << " " << msg->getSrcNode().getAddress()
// << " " << kbrRpcContext->getDestKey() << std::endl;
bytesRpcDropped += msg->getByteLength());
// for failed RPCs add failureLatency to latency statistics vector
"KBRTestApp: RPC Total Latency",
SIMTIME_DBL(failureLatency)));
rpcTotalLatencySum += SIMTIME_DBL(failureLatency));
}
}
delete kbrRpcContext;
break;
}
RPC_ON_RESPONSE(UnderlayTest) {
KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
if (kbrRpcContext->getMeasurementPhase() == true) {
bytesUnderlayDelivered += msg->getByteLength());
"KBRTestApp: Underlay RTT", SIMTIME_DBL(rtt)));
"KBRTestApp: Underlay One-way Latency",
SIMTIME_DBL(_UnderlayTestResponse->getOneWayLatency())));
}
delete kbrRpcContext;
break;
}
}
void KBRTestApp::handleRpcTimeout ( BaseCallMessage msg,
const TransportAddress dest,
cPolymorphic *  context,
int  rpcId,
const OverlayKey destKey 
)
private

Definition at line 375 of file KBRTestApp.cc.

{
RPC_ON_CALL(KbrTest) {
EV << "[KBRTestApp::handleRpcTimeout() @ "
<< " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
<< " KBR-Test RPC Response timeout: id=" << rpcId
<< endl;
/*
std::cout << simTime() << ": [KBRTestApp::handleRpcTimeout() @ "
<< overlay->getThisNode().getIp()
<< " (" << overlay->getThisNode().getKey().toString(16) << ")]\n"
<< " KBR-Test RPC Response (" << *msg << ") timeout: id=" << rpcId
<< std::endl;
*/
KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
if (kbrRpcContext->getMeasurementPhase() == true) {
bytesRpcDropped += msg->getByteLength());
// for failed RPCs add failureLatency to latency statistics vector
"KBRTestApp: RPC Total Latency",
SIMTIME_DBL(failureLatency)));
}
break;
}
KbrRpcContext* kbrRpcContext = check_and_cast<KbrRpcContext*>(context);
if (kbrRpcContext->getMeasurementPhase() == true) {
// for failed lookups add failureLatency to latency statistics vector
"KBRTestApp: Lookup Total Latency",
SIMTIME_DBL(failureLatency)));
}
break;
}
delete context;
}
void KBRTestApp::handleTimerEvent ( cMessage *  msg)
private

Definition at line 160 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
return;
}
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
std::pair<OverlayKey,TransportAddress> dest = createDestKey();
if (!dest.first.isUnspecified()) {
// create a 100 byte test message
KBRTestMessage* testMsg = new KBRTestMessage("KBRTestMessage");
testMsg->setId(getId());
testMsg->setByteLength(testMsgSize);
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
std::pair<OverlayKey,TransportAddress> dest = createDestKey();
if (!dest.first.isUnspecified()) {
KbrTestCall* call = new KbrTestCall;
call->setByteLength(testMsgSize);
KbrRpcContext* context = new KbrRpcContext;
context->setDestKey(dest.first);
context->setDestAddr(dest.second);
}
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
std::pair<OverlayKey,TransportAddress> dest = createDestKey();
if (!dest.first.isUnspecified()) {
LookupCall* call = new LookupCall();
call->setKey(dest.first);
KbrRpcContext* context = new KbrRpcContext;
context->setDestKey(dest.first);
context->setDestAddr(dest.second);
}
}
} else /*if (msg == underlayRpcTimer)*/ {
// TEST 4: send a remote procedure call to a specific transportAddress
// and wait for a response, do nothing if there are currently no nodes
// in the network
TransportAddress* address =
if (address == NULL) {
EV << "no node!!!" << std::endl;
return;
}
address->setPort(thisNode.getPort());
if (!address->isUnspecified()) {
call->setByteLength(testMsgSize);
call->setSendTime(simTime());
KbrRpcContext* context = new KbrRpcContext;
bytesUnderlaySent += call->getByteLength());
//dest.second.setPort(thisNode.getPort());
sendUdpRpcCall(*address, call, context,
}
}
#if 0
handle.setPort(1025);
pingNode(handle, -1, -1, NULL, "TestPING", NULL, -1, UDP_TRANSPORT);
#endif
}
void KBRTestApp::initializeApp ( int  stage)
private

Definition at line 51 of file KBRTestApp.cc.

{
if (stage != MIN_STAGE_APP) {
return;
}
kbrOneWayTest = par("kbrOneWayTest");
kbrRpcTest = par("kbrRpcTest");
kbrLookupTest = par("kbrLookupTest");
underlayTest = par("underlayTest");
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");
//rpcTimeout = par("rpcTimeout");
rpcRetries = par("rpcRetries");
numSent = 0;
bytesSent = 0;
WATCH(numSent);
WATCH(bytesSent);
WATCH(numDelivered);
WATCH(numDropped);
WATCH(bytesDropped);
WATCH(numRpcSent);
WATCH(bytesRpcSent);
WATCH(numRpcDropped);
WATCH(numLookupSent);
// initialize circular buffer
if (msgHandleBufSize > 0) {
mhBufBegin = mhBuf.begin();
mhBufEnd = mhBuf.end();
}
bindToPort(1025);
// start periodic timer
onewayTimer = new cMessage("onewayTimer");
scheduleAt(simTime() + truncnormal(mean, deviation), onewayTimer);
}
if (kbrRpcTest) {
rpcTimer = new cMessage("rpcTimer");
scheduleAt(simTime() + truncnormal(mean, deviation), rpcTimer);
}
lookupTimer = new cMessage("lookupTimer");
scheduleAt(simTime() + truncnormal(mean, deviation), lookupTimer);
}
if (underlayTest) {
underlayTimer = new cMessage("underlayTimer");
scheduleAt(simTime() + truncnormal(mean, deviation), underlayTimer);
}
}
void KBRTestApp::kbrTestCall ( KbrTestCall call)
private

Definition at line 284 of file KBRTestApp.cc.

Referenced by handleRpcCall().

{
response->setByteLength(call->getByteLength());
sendRpcResponse(call, response);
}
void KBRTestApp::pingResponse ( PingResponse response,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
)
private

Definition at line 266 of file KBRTestApp.cc.

{
//std::cout << rtt << std::endl;
}
void KBRTestApp::underlayTestCall ( UnderlayTestCall call)
private

Definition at line 292 of file KBRTestApp.cc.

Referenced by handleRpcCall().

{
response->setByteLength(call->getByteLength());
response->setOneWayLatency(simTime() - call->getSendTime());
sendRpcResponse(call, response);
}

Member Data Documentation

bool KBRTestApp::activeNetwInitPhase
private

is app active in network init phase?

Definition at line 138 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::bytesDelivered
private

number of delivered bytes

Definition at line 149 of file KBRTestApp.h.

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

uint32_t KBRTestApp::bytesDropped
private

Definition at line 151 of file KBRTestApp.h.

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

uint32_t KBRTestApp::bytesRpcDelivered
private

number of delivered bytes

Definition at line 156 of file KBRTestApp.h.

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

uint32_t KBRTestApp::bytesRpcDropped
private

Definition at line 158 of file KBRTestApp.h.

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

uint32_t KBRTestApp::bytesRpcSent
private

Definition at line 154 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::bytesSent
private

Definition at line 147 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::bytesUnderlayDelivered
private

number of delivered bytes

Definition at line 173 of file KBRTestApp.h.

Referenced by handleRpcResponse(), and initializeApp().

uint32_t KBRTestApp::bytesUnderlaySent
private

Definition at line 171 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

double KBRTestApp::deviation
private

deviation of time interval

Definition at line 137 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 182 of file KBRTestApp.h.

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

bool KBRTestApp::kbrLookupTest
private

Definition at line 132 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

bool KBRTestApp::kbrOneWayTest
private

Definition at line 130 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

bool KBRTestApp::kbrRpcTest
private

Definition at line 131 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

bool KBRTestApp::lookupNodeIds
private

lookup only existing nodeIDs

Definition at line 139 of file KBRTestApp.h.

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

cMessage* KBRTestApp::lookupTimer
private

Definition at line 179 of file KBRTestApp.h.

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

double KBRTestApp::mean
private

mean time interval between sending test messages

Definition at line 136 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

MsgHandleBuf KBRTestApp::mhBuf
private

circular buffer of MsgHandles

Definition at line 186 of file KBRTestApp.h.

Referenced by initializeApp().

MsgHandleBuf::iterator KBRTestApp::mhBufBegin
private

begin of circular buffer

Definition at line 187 of file KBRTestApp.h.

Referenced by checkSeen(), and initializeApp().

MsgHandleBuf::iterator KBRTestApp::mhBufEnd
private

end of circular buffer

Definition at line 189 of file KBRTestApp.h.

Referenced by checkSeen(), and initializeApp().

MsgHandleBuf::iterator KBRTestApp::mhBufNext
private

next element to insert

Definition at line 188 of file KBRTestApp.h.

Referenced by checkSeen(), and initializeApp().

int KBRTestApp::msgHandleBufSize
private

how many MsgHandles to store in circular buffer

Definition at line 185 of file KBRTestApp.h.

Referenced by deliver(), and initializeApp().

bool KBRTestApp::nodeIsLeavingSoon
private

true if the node is going to be killed shortly

Definition at line 140 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numDelivered
private

number of delivered packets

Definition at line 148 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numDropped
private

Definition at line 150 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numLookupFailed
private

Definition at line 168 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numLookupSent
private

Definition at line 166 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numLookupSuccess
private

Definition at line 167 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numRpcDelivered
private

number of delivered packets

Definition at line 155 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numRpcDropped
private

Definition at line 157 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numRpcSent
private

Definition at line 153 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numSent
private

Definition at line 146 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numUnderlayDelivered
private

number of delivered packets

Definition at line 172 of file KBRTestApp.h.

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

uint32_t KBRTestApp::numUnderlaySent
private

Definition at line 170 of file KBRTestApp.h.

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

cMessage* KBRTestApp::onewayTimer
private

Definition at line 177 of file KBRTestApp.h.

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

bool KBRTestApp::onlyLookupInoffensiveNodes
private

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

Definition at line 141 of file KBRTestApp.h.

Referenced by createDestKey(), and initializeApp().

int KBRTestApp::rpcRetries
private

Definition at line 144 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

uint32_t KBRTestApp::rpcSuccLatencyCount
private

Definition at line 161 of file KBRTestApp.h.

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

simtime_t KBRTestApp::rpcSuccLatencySum
private

Definition at line 160 of file KBRTestApp.h.

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

cMessage* KBRTestApp::rpcTimer
private

Definition at line 178 of file KBRTestApp.h.

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

uint32_t KBRTestApp::rpcTotalLatencyCount
private

Definition at line 164 of file KBRTestApp.h.

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

simtime_t KBRTestApp::rpcTotalLatencySum
private

Definition at line 163 of file KBRTestApp.h.

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

uint32_t KBRTestApp::sequenceNumber
private

Definition at line 184 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

int KBRTestApp::testMsgSize
private

Definition at line 135 of file KBRTestApp.h.

Referenced by handleTimerEvent(), and initializeApp().

bool KBRTestApp::underlayTest
private

Definition at line 133 of file KBRTestApp.h.

Referenced by finishApp(), and initializeApp().

cMessage* KBRTestApp::underlayTimer
private

Definition at line 180 of file KBRTestApp.h.

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


The documentation for this class was generated from the following files: