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;
00105 bool stab1;
00106 bool stab2;
00107
00108
00109 int bucketCount;
00110 int bucketBytesSent;
00111 int numFailedPackets;
00113
00114 BrooseBucket *lBucket, *bBucket;
00115 BrooseBucket **rBucket;
00117 std::vector<BrooseBucket*> bucketVector;
00119
00120 cMessage* join_timer;
00121 cMessage* bucket_timer;
00123
00124 TransportAddress bootstrapNode;
00126
00127
00133 void handleJoinTimerExpired(cMessage* msg);
00134
00140 void handleBucketTimerExpired(cMessage* msg);
00141
00152 int getRoutingDistance(const OverlayKey& key, const OverlayKey& node,
00153 int dist);
00154
00163 bool routingAdd(const NodeHandle& node, bool isAlive,
00164 simtime_t rtt = MAXTIME);
00165
00171 void changeState(int state);
00172
00173
00174 NodeVector* findNode(const OverlayKey& key,
00175 int numRedundantNodes,
00176 int numSiblings,
00177 BaseOverlayMessage* msg);
00178
00179
00180 int getMaxNumSiblings();
00181
00182
00183 int getMaxNumRedundantNodes();
00184
00188 void displayBucketState();
00189
00190
00191 void handleRpcResponse(BaseResponseMessage* msg,
00192 const RpcState& rpcState,
00193 simtime_t rtt);
00194
00195
00196 void handleRpcTimeout(const RpcState& rpcState);
00197
00205 void handleFindNodeTimeout(FindNodeCall* findNode,
00206 const TransportAddress& dest,
00207 const OverlayKey& destKey);
00208
00214 void handleBucketRequestRpc(BucketCall* msg);
00215
00222 void handleBucketResponseRpc(BucketResponse* msg, const RpcState& rpcState);
00223
00229 void handleBucketTimeout(BucketCall* msg);
00230
00231 void routingTimeout(const BrooseHandle& handle);
00232
00233
00234 virtual void pingResponse(PingResponse* pingResponse,
00235 cPolymorphic* context, int rpcId,
00236 simtime_t rtt);
00237
00238
00239 virtual void pingTimeout(PingCall* pingCall,
00240 const TransportAddress& dest,
00241 cPolymorphic* context,
00242 int rpcId);
00243
00249 void setLastSeen(const NodeHandle& node);
00250
00256 void addNode(const NodeHandle& node);
00257
00263 void resetFailedResponses(const NodeHandle& node);
00264
00271 void setRTT(const NodeHandle& node, simtime_t rtt);
00272
00273 friend class BrooseBucket;
00274 };
00275
00276
00277
00278 #endif