DHTTestApp.h

Go to the documentation of this file.
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         OverlayKey key;
00065         BinaryValue value;
00066 
00067         DHTStatsContext(bool measurementPhase,
00068                         simtime_t requestTime,
00069                         const OverlayKey& key,
00070                         const BinaryValue& value = BinaryValue::UNSPECIFIED_VALUE) :
00071             measurementPhase(measurementPhase), requestTime(requestTime),
00072             key(key), value(value) {};
00073     };
00074 
00075     void initializeApp(int stage);
00076 
00080     OverlayKey getRandomKey();
00081 
00085     BinaryValue generateRandomValue();
00086 
00087     void finishApp();
00088 
00097     virtual void handleGetResponse(DHTgetCAPIResponse* msg,
00098                                    DHTStatsContext* context);
00099 
00108     virtual void handlePutResponse(DHTputCAPIResponse* msg,
00109                                    DHTStatsContext* context);
00110 
00118     virtual void handleTimerEvent(cMessage* msg);
00119 
00127     virtual void handleTraceMessage(cMessage* msg);
00128 
00129     virtual void handleNodeLeaveNotification();
00130 
00131     // see RpcListener.h
00132     void handleRpcResponse(BaseResponseMessage* msg, const RpcState& state,
00133                            simtime_t rtt);
00134 
00135     UnderlayConfigurator* underlayConfigurator; 
00137     GlobalNodeList* globalNodeList; 
00139     GlobalStatistics* globalStatistics; 
00140     GlobalDhtTestMap* globalDhtTestMap; 
00142     // parameters
00143     bool debugOutput; 
00144     double mean; 
00145     double deviation; 
00146     int ttl; 
00147     bool p2pnsTraffic; 
00148     bool activeNetwInitPhase; 
00149 
00150     // statistics
00151     int numSent; 
00152     int numGetSent; 
00153     int numGetError; 
00154     int numGetSuccess; 
00155     int numPutSent; 
00156     int numPutError; 
00157     int numPutSuccess; 
00159     cMessage *dhttestput_timer, *dhttestget_timer, *dhttestmod_timer;
00160     bool nodeIsLeavingSoon; 
00161 
00162     static const int DHTTESTAPP_VALUE_LEN = 20;
00163 
00164 public:
00165     DHTTestApp();
00166 
00170     virtual ~DHTTestApp();
00171 
00172 };
00173 
00174 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3