OverSim
Broose.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 __BROOSE_H_
25 #define __BROOSE_H_
26 
27 #include <omnetpp.h>
28 #include <BaseOverlay.h>
29 #include <RpcListener.h>
30 #include <OverlayKey.h>
31 #include "BrooseHandle.h"
32 #include "BrooseBucket.h"
33 #include "BrooseMessage_m.h"
34 
35 #include <map>
36 #include <vector>
37 
38 class BrooseBucket;
39 
52 class Broose : public BaseOverlay
53 {
54  public:
55  Broose();
56  ~Broose();
57 
58  // see BaseOverlay.h
59  virtual void initializeOverlay(int stage);
60 
61  // see BaseOverlay.h
62  virtual void finishOverlay();
63 
64  // see BaseOverlay.h
65  virtual bool isSiblingFor(const NodeHandle& node,
66  const OverlayKey& key,
67  int numSiblings,
68  bool* err);
69 
70  // see BaseOverlay.h
71  virtual void joinOverlay();
72 
73  // see BaseOverlay.h
74  virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
75 
76  // see BaseOverlay.h
77  virtual bool handleRpcCall(BaseCallMessage* msg);
78 
79  // see BaseOverlay.h
80  virtual void handleTimerEvent(cMessage* msg);
81 
85  void updateTooltip();
86 
87  protected:
88  //parameter
90  simtime_t joinDelay;
98  uint32_t bucketSize;
99  uint32_t rBucketSize;
100  int keyLength;
101  simtime_t refreshTime;
102  uint32_t userDist;
105  bool stab1;
106  bool stab2;
107 
108  //statistics
113  //module references
117  std::vector<BrooseBucket*> bucketVector;
119  // timer
120  cMessage* join_timer;
121  cMessage* bucket_timer;
123  //node handles
126  //functions
127 
133  void handleJoinTimerExpired(cMessage* msg);
134 
140  void handleBucketTimerExpired(cMessage* msg);
141 
152  int getRoutingDistance(const OverlayKey& key, const OverlayKey& node,
153  int dist);
154 
163  bool routingAdd(const NodeHandle& node, bool isAlive,
164  simtime_t rtt = MAXTIME);
165 
171  void changeState(int state);
172 
173  // see BaseOverlay.h
174  NodeVector* findNode(const OverlayKey& key,
175  int numRedundantNodes,
176  int numSiblings,
177  BaseOverlayMessage* msg);
178 
179  // see BaseOverlay.h
180  int getMaxNumSiblings();
181 
182  // see BaseOverlay.h
184 
188  void displayBucketState();
189 
190  // see BaseOverlay.h
192  const RpcState& rpcState,
193  simtime_t rtt);
194 
195  // see BaseOverlay.h
196  void handleRpcTimeout(const RpcState& rpcState);
197 
206  const TransportAddress& dest,
207  const OverlayKey& destKey);
208 
215 
222  void handleBucketResponseRpc(BucketResponse* msg, const RpcState& rpcState);
223 
229  void handleBucketTimeout(BucketCall* msg);
230 
231  void routingTimeout(const BrooseHandle& handle);
232 
233  // see BaseRpc.h
234  virtual void pingResponse(PingResponse* pingResponse,
235  cPolymorphic* context, int rpcId,
236  simtime_t rtt);
237 
238  // see BaseRpc.h
239  virtual void pingTimeout(PingCall* pingCall,
240  const TransportAddress& dest,
241  cPolymorphic* context,
242  int rpcId);
243 
249  void setLastSeen(const NodeHandle& node);
250 
256  void addNode(const NodeHandle& node);
257 
263  void resetFailedResponses(const NodeHandle& node);
264 
271  void setRTT(const NodeHandle& node, simtime_t rtt);
272 
273  friend class BrooseBucket;
274 };
275 
276 
277 
278 #endif