Broose.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00024 #ifndef __BROOSE_H_
00025 #define __BROOSE_H_
00026
00027 #include <omnetpp.h>
00028 #include <BaseOverlay.h>
00029 #include <RpcListener.h>
00030 #include <OverlayKey.h>
00031 #include "BrooseHandle.h"
00032 #include "BrooseBucket.h"
00033 #include "BrooseMessage_m.h"
00034
00035 #include <map>
00036 #include <vector>
00037
00038 class BrooseBucket;
00039
00052 class Broose : public BaseOverlay
00053 {
00054 public:
00055 Broose();
00056 ~Broose();
00057
00058
00059 virtual void initializeOverlay(int stage);
00060
00061
00062 virtual void finishOverlay();
00063
00064
00065 virtual bool isSiblingFor(const NodeHandle& node,
00066 const OverlayKey& key,
00067 int numSiblings,
00068 bool* err);
00069
00070
00071 virtual void joinOverlay();
00072
00073
00074 virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
00075
00076
00077 virtual bool handleRpcCall(BaseCallMessage* msg);
00078
00079
00080 virtual void handleTimerEvent(cMessage* msg);
00081
00085 void updateTooltip();
00086
00087 protected:
00088
00089 int chooseLookup;
00090 simtime_t joinDelay;
00091 int receivedJoinResponse;
00092 int receivedBBucketLookup;
00093 int numberBBucketLookup;
00094 int receivedLBucketLookup;
00095 int numberLBucketLookup;
00096 int shiftingBits;
00097 int powShiftingBits;
00098 uint32_t bucketSize;
00099 uint32_t rBucketSize;
00100 int keyLength;
00101 simtime_t refreshTime;
00102 uint32_t userDist;
00103 int numberRetries;
00104 int bucketRetries;
00106
00107 int bucketCount;
00108 int bucketBytesSent;
00109 int numFailedPackets;
00111
00112 BrooseBucket *lBucket, *bBucket;
00113 BrooseBucket **rBucket;
00115 std::vector<BrooseBucket*> bucketVector;
00117
00118 cMessage* join_timer;
00119 cMessage* bucket_timer;
00121
00122 TransportAddress bootstrapNode;
00124
00125
00131 void handleJoinTimerExpired(cMessage* msg);
00132
00138 void handleBucketTimerExpired(cMessage* msg);
00139
00150 int getRoutingDistance(const OverlayKey& key, const OverlayKey& node,
00151 int dist);
00152
00161 bool routingAdd(const NodeHandle& node, bool isAlive,
00162 simtime_t rtt = MAXTIME);
00163
00169 void changeState(int state);
00170
00171
00172 NodeVector* findNode(const OverlayKey& key,
00173 int numRedundantNodes,
00174 int numSiblings,
00175 BaseOverlayMessage* msg);
00176
00177
00178 int getMaxNumSiblings();
00179
00180
00181 int getMaxNumRedundantNodes();
00182
00186 void displayBucketState();
00187
00188
00189 void handleRpcResponse(BaseResponseMessage* msg,
00190 const RpcState& rpcState,
00191 simtime_t rtt);
00192
00193
00194 void handleRpcTimeout(const RpcState& rpcState);
00195
00203 void handleFindNodeTimeout(FindNodeCall* findNode,
00204 const TransportAddress& dest,
00205 const OverlayKey& destKey);
00206
00212 void handleBucketRequestRpc(BucketCall* msg);
00213
00220 void handleBucketResponseRpc(BucketResponse* msg, const RpcState& rpcState);
00221
00227 void handleBucketTimeout(BucketCall* msg);
00228
00229 void routingTimeout(const BrooseHandle& handle);
00230
00231
00232 virtual void pingResponse(PingResponse* pingResponse,
00233 cPolymorphic* context, int rpcId,
00234 simtime_t rtt);
00235
00236
00237 virtual void pingTimeout(PingCall* pingCall,
00238 const TransportAddress& dest,
00239 cPolymorphic* context,
00240 int rpcId);
00241
00247 void setLastSeen(const NodeHandle& node);
00248
00254 void addNode(const NodeHandle& node);
00255
00261 void resetFailedResponses(const NodeHandle& node);
00262
00269 void setRTT(const NodeHandle& node, simtime_t rtt);
00270
00271 friend class BrooseBucket;
00272 };
00273
00274
00275
00276 #endif