OverSim
DHTTestApp.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __DHTTESTAPP_H_
25 #define __DHTTESTAPP_H_
26 
27 #include <omnetpp.h>
28 
29 #include <GlobalNodeList.h>
30 #include <GlobalStatistics.h>
31 #include <UnderlayConfigurator.h>
32 #include <TransportAddress.h>
33 #include <OverlayKey.h>
34 #include <InitStages.h>
35 #include <BinaryValue.h>
36 #include <BaseApp.h>
37 #include <set>
38 #include <sstream>
39 
40 class GlobalDhtTestMap;
41 
50 class DHTTestApp : public BaseApp
51 {
52 private:
59  class DHTStatsContext : public cPolymorphic
60  {
61  public:
63  simtime_t requestTime;
66 
68  simtime_t requestTime,
69  const OverlayKey& key,
71  measurementPhase(measurementPhase), requestTime(requestTime),
72  key(key), value(value) {};
73  };
74 
75  void initializeApp(int stage);
76 
81 
86 
87  void finishApp();
88 
97  virtual void handleGetResponse(DHTgetCAPIResponse* msg,
98  DHTStatsContext* context);
99 
108  virtual void handlePutResponse(DHTputCAPIResponse* msg,
109  DHTStatsContext* context);
110 
118  virtual void handleTimerEvent(cMessage* msg);
119 
127  virtual void handleTraceMessage(cMessage* msg);
128 
129  virtual void handleNodeLeaveNotification();
130 
131  // see RpcListener.h
132  void handleRpcResponse(BaseResponseMessage* msg, const RpcState& state,
133  simtime_t rtt);
134 
142  // parameters
143  bool debugOutput;
144  double mean;
145  double deviation;
146  int ttl;
149 
150  // statistics
151  int numSent;
161 
162  static const int DHTTESTAPP_VALUE_LEN = 20;
163 
164 public:
165  DHTTestApp();
166 
170  virtual ~DHTTestApp();
171 
172 };
173 
174 #endif