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 
00066         DHTStatsContext(bool measurementPhase,
00067                         simtime_t requestTime,
00068                         const OverlayKey& key) :
00069             measurementPhase(measurementPhase), requestTime(requestTime),
00070             key(key) {};
00071     };
00072 
00073     void initializeApp(int stage);
00074 
00078     OverlayKey getRandomKey();
00079 
00083     BinaryValue generateRandomValue();
00084 
00085     void finishApp();
00086 
00095     virtual void handleGetResponse(DHTgetCAPIResponse* msg,
00096                                    DHTStatsContext* context);
00097 
00106     virtual void handlePutResponse(DHTputCAPIResponse* msg,
00107                                    DHTStatsContext* context);
00108 
00116     virtual void handleTimerEvent(cMessage* msg);
00117 
00125     virtual void handleTraceMessage(cMessage* msg);
00126 
00127     virtual void handleNodeLeaveNotification();
00128 
00129     void handleRpcResponse(BaseResponseMessage* msg,
00130                            cPolymorphic* context,
00131                            int rpcId,
00132                            simtime_t rtt);
00133 
00134     UnderlayConfigurator* underlayConfigurator; 
00136     GlobalNodeList* globalNodeList; 
00138     GlobalStatistics* globalStatistics; 
00139     GlobalDhtTestMap* globalDhtTestMap; 
00141     // parameters
00142     bool debugOutput; 
00143     double mean; 
00144     double deviation; 
00145     int ttl; 
00146     bool activeNetwInitPhase; 
00147 
00148     // statistics
00149     int numSent; 
00150     int numGetSent; 
00151     int numGetError; 
00152     int numGetSuccess; 
00153     int numPutSent; 
00154     int numPutError; 
00155     int numPutSuccess; 
00157     cMessage *dhttestput_timer, *dhttestget_timer, *dhttestmod_timer;
00158     bool nodeIsLeavingSoon; 
00159 
00160     static const int DHTTESTAPP_VALUE_LEN = 20;
00161 
00162 public:
00163     DHTTestApp();
00164 
00168     virtual ~DHTTestApp();
00169 
00170 };
00171 
00172 #endif

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