00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __KBRTESTAPP_H_
00025 #define __KBRTESTAPP_H_
00026
00027 #include <omnetpp.h>
00028
00029 #include <OverlayKey.h>
00030
00031 #include "BaseApp.h"
00032
00033 class KBRTestMessage;
00034
00042 class KBRTestApp : public BaseApp
00043 {
00044 public:
00045 KBRTestApp();
00046 ~KBRTestApp();
00047
00048 private:
00049
00054 struct MsgHandle
00055 {
00056 OverlayKey key;
00057 int seqNum;
00058
00059 MsgHandle(void) :
00060 key(OverlayKey::UNSPECIFIED_KEY), seqNum(-1) {};
00061 MsgHandle(const OverlayKey& key, int seqNum) :
00062 key(key), seqNum(seqNum) {};
00063 bool operator==(const MsgHandle& rhs) const {
00064 return ((key == rhs.key) && (seqNum == rhs.seqNum));
00065 };
00066 MsgHandle& operator=(const MsgHandle& rhs) {
00067 key = rhs.key;
00068 seqNum = rhs.seqNum;
00069 return (*this);
00070 };
00071 };
00072 typedef std::vector<MsgHandle> MsgHandleBuf;
00073
00074 void initializeApp(int stage);
00075 void finishApp();
00076 void handleTimerEvent(cMessage* msg);
00077
00078 void deliver(OverlayKey& key, cMessage* msg);
00079
00080 void forward(OverlayKey* key, cPacket** msg, NodeHandle* nextHopNode);
00081
00091 bool checkSeen(const OverlayKey& key, int seqNum);
00092
00103 void evaluateData(simtime_t timeDelay, int hopCount, long int bytes);
00104
00105 void handleRpcResponse(BaseResponseMessage* msg, cPolymorphic* context,
00106 int rpcId, simtime_t rtt);
00107
00108 void handleLookupResponse(LookupResponse* msg);
00109
00110 void pingResponse(PingResponse* response, cPolymorphic* context,
00111 int rpcId, simtime_t rtt);
00112
00113
00114 virtual void handleNodeLeaveNotification();
00115
00116 double mean;
00117 double deviation;
00118 bool activeNetwInitPhase;
00119 bool lookupNodeIds;
00120 bool nodeIsLeavingSoon;
00121
00122 int numDelivered;
00123 int bytesDelivered;
00124 int numDropped;
00125 int bytesDropped;
00126
00127 cMessage* testTimer;
00128 uint32_t sequenceNumber;
00129 int msgHandleBufSize;
00130 MsgHandleBuf mhBuf;
00131 MsgHandleBuf::iterator mhBufBegin;
00132 MsgHandleBuf::iterator mhBufNext;
00133 MsgHandleBuf::iterator mhBufEnd;
00134 };
00135
00136 #endif