00001 // 00002 // Copyright (C) 2007 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 __DHTTESTAPP_H_ 00025 #define __DHTTESTAPP_H_ 00026 00027 #include <omnetpp.h> 00028 00029 #include <GlobalNodeList.h> 00030 #include <GlobalStatistics.h> 00031 #include <UnderlayConfigurator.h> 00032 #include <TransportAddress.h> 00033 #include <OverlayKey.h> 00034 #include <InitStages.h> 00035 #include <BinaryValue.h> 00036 #include <BaseApp.h> 00037 #include <set> 00038 #include <sstream> 00039 00040 class GlobalDhtTestMap; 00041 00050 class DHTTestApp : public BaseApp 00051 { 00052 private: 00059 class DHTStatsContext : public cPolymorphic 00060 { 00061 public: 00062 bool measurementPhase; 00063 simtime_t requestTime; 00064 00065 DHTStatsContext(bool measurementPhase, 00066 simtime_t requestTime) : 00067 measurementPhase(measurementPhase), requestTime(requestTime) {}; 00068 }; 00069 00070 void initializeApp(int stage); 00071 00075 OverlayKey getRandomKey(); 00076 00080 BinaryValue generateRandomValue(); 00081 00082 void finishApp(); 00083 00092 virtual void handleGetResponse(DHTgetCAPIResponse* msg, 00093 DHTStatsContext* context); 00094 00103 virtual void handlePutResponse(DHTputCAPIResponse* msg, 00104 DHTStatsContext* context); 00105 00113 virtual void handleTimerEvent(cMessage* msg); 00114 00122 virtual void handleTraceMessage(cMessage* msg); 00123 00124 virtual void handleNodeLeaveNotification(); 00125 00126 void handleRpcResponse(BaseResponseMessage* msg, 00127 cPolymorphic* context, 00128 int rpcId, 00129 simtime_t rtt); 00130 00131 UnderlayConfigurator* underlayConfigurator; 00133 GlobalNodeList* globalNodeList; 00135 GlobalStatistics* globalStatistics; 00136 GlobalDhtTestMap* globalDhtTestMap; 00138 // parameters 00139 bool debugOutput; 00140 double mean; 00141 double deviation; 00142 int ttl; 00143 bool activeNetwInitPhase; 00144 00145 // statistics 00146 int numSent; 00147 int numGetSent; 00148 int numGetError; 00149 int numGetSuccess; 00150 int numPutSent; 00151 int numPutError; 00152 int numPutSuccess; 00154 cMessage *dhttestput_timer, *dhttestget_timer, *dhttestmod_timer; 00155 bool nodeIsLeavingSoon; 00156 00157 static const int DHTTESTAPP_VALUE_LEN = 20; 00158 00159 public: 00160 DHTTestApp(); 00161 00165 virtual ~DHTTestApp(); 00166 00167 }; 00168 00169 #endif
1.5.5