KBRTestApp.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
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 class KbrTestCall;
00035 
00043 class KBRTestApp : public BaseApp
00044 {
00045 public:
00046     KBRTestApp();
00047     ~KBRTestApp();
00048 
00049 private:
00050 
00055     struct MsgHandle
00056     {
00057         OverlayKey key;
00058         int seqNum;
00059 
00060         MsgHandle(void) :
00061             key(OverlayKey::UNSPECIFIED_KEY), seqNum(-1) {};
00062         MsgHandle(const OverlayKey& key, int seqNum) :
00063             key(key), seqNum(seqNum) {};
00064         bool operator==(const MsgHandle& rhs) const {
00065             return ((key == rhs.key) && (seqNum == rhs.seqNum));
00066         };
00067         MsgHandle& operator=(const MsgHandle& rhs) {
00068             key = rhs.key;
00069             seqNum = rhs.seqNum;
00070             return (*this);
00071         };
00072     };
00073     typedef std::vector<MsgHandle> MsgHandleBuf;
00074 
00075     void initializeApp(int stage);
00076     void finishApp();
00077     void handleTimerEvent(cMessage* msg);
00078 
00079     void deliver(OverlayKey& key, cMessage* msg);
00080 
00081     void forward(OverlayKey* key, cPacket** msg, NodeHandle* nextHopNode);
00082 
00092     bool checkSeen(const OverlayKey& key, int seqNum);
00093 
00104     void evaluateData(simtime_t timeDelay, int hopCount, long int bytes);
00105 
00106     bool handleRpcCall(BaseCallMessage* msg);
00107     void kbrTestCall(KbrTestCall* call);
00108 
00109     void handleRpcResponse(BaseResponseMessage* msg, cPolymorphic* context,
00110                            int rpcId, simtime_t rtt);
00111 
00112     void handleRpcTimeout(BaseCallMessage* msg,
00113                           const TransportAddress& dest,
00114                           cPolymorphic* context, int rpcId,
00115                           const OverlayKey& destKey);
00116 
00117     void handleLookupResponse(LookupResponse* msg,
00118                               cObject* context, simtime_t latency);
00119 
00120     void pingResponse(PingResponse* response, cPolymorphic* context,
00121                       int rpcId, simtime_t rtt);
00122 
00123     // see BaseApp.h
00124     virtual void handleNodeLeaveNotification();
00125 
00126     OverlayKey createDestKey();
00127 
00128     bool kbrOneWayTest;
00129     bool kbrRpcTest;
00130     bool kbrLookupTest;
00131 
00132     int testMsgSize;
00133     double mean; 
00134     double deviation; 
00135     bool activeNetwInitPhase; 
00136     bool lookupNodeIds;  
00137     bool nodeIsLeavingSoon; 
00138 
00139     uint32_t numSent;
00140     uint32_t bytesSent;
00141     uint32_t numDelivered; 
00142     uint32_t bytesDelivered; 
00143     uint32_t numDropped;
00144     uint32_t bytesDropped;
00145 
00146     uint32_t numRpcSent;
00147     uint32_t bytesRpcSent;
00148     uint32_t numRpcDelivered; 
00149     uint32_t bytesRpcDelivered; 
00150     uint32_t numRpcDropped;
00151     uint32_t bytesRpcDropped;
00152 
00153     simtime_t rpcSuccLatencySum;
00154     uint32_t rpcSuccLatencyCount;
00155 
00156     simtime_t rpcTotalLatencySum;
00157     uint32_t rpcTotalLatencyCount;
00158 
00159     uint32_t numLookupSent;
00160     uint32_t numLookupSuccess;
00161     uint32_t numLookupFailed;
00162 
00163     // TODO lookup stats
00164 
00165     cMessage* onewayTimer;
00166     cMessage* rpcTimer;
00167     cMessage* lookupTimer;
00168 
00169     simtime_t failureLatency; 
00171     uint32_t sequenceNumber;
00172     int msgHandleBufSize; 
00173     MsgHandleBuf mhBuf; 
00174     MsgHandleBuf::iterator mhBufBegin; 
00175     MsgHandleBuf::iterator mhBufNext; 
00176     MsgHandleBuf::iterator mhBufEnd; 
00177 };
00178 
00179 #endif

Generated on Tue Sep 8 17:26:53 2009 for OverSim by  doxygen 1.5.8