Broose.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 __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     // see BaseOverlay.h
00059     virtual void initializeOverlay(int stage);
00060 
00061     // see BaseOverlay.h
00062     virtual void finishOverlay();
00063 
00064     // see BaseOverlay.h
00065     virtual bool isSiblingFor(const NodeHandle& node,
00066                               const OverlayKey& key,
00067                               int numSiblings,
00068                               bool* err);
00069 
00070     // see BaseOverlay.h
00071     virtual void joinOverlay();
00072 
00073     // see BaseOverlay.h
00074     virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
00075 
00076     // see BaseOverlay.h
00077     virtual bool handleRpcCall(BaseCallMessage* msg);
00078 
00079     // see BaseOverlay.h
00080     virtual void handleTimerEvent(cMessage* msg);
00081 
00085     void updateTooltip();
00086 
00087   protected:
00088     //parameter
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     //statistics
00109     int bucketCount; 
00110     int bucketBytesSent; 
00111     int numFailedPackets; 
00113     //module references
00114     BrooseBucket *lBucket, *bBucket;  
00115     BrooseBucket **rBucket;  
00117     std::vector<BrooseBucket*> bucketVector; 
00119     // timer
00120     cMessage* join_timer;  
00121     cMessage* bucket_timer; 
00123     //node handles
00124     TransportAddress bootstrapNode;  
00126     //functions
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     // see BaseOverlay.h
00174     NodeVector* findNode(const OverlayKey& key,
00175                          int numRedundantNodes,
00176                          int numSiblings,
00177                          BaseOverlayMessage* msg);
00178 
00179     // see BaseOverlay.h
00180     int getMaxNumSiblings();
00181 
00182     // see BaseOverlay.h
00183     int getMaxNumRedundantNodes();
00184 
00188     void displayBucketState();
00189 
00190     // see BaseOverlay.h
00191     void handleRpcResponse(BaseResponseMessage* msg,
00192                            const RpcState& rpcState,
00193                            simtime_t rtt);
00194 
00195     // see BaseOverlay.h
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     // see BaseRpc.h
00234     virtual void pingResponse(PingResponse* pingResponse,
00235                               cPolymorphic* context, int rpcId,
00236                               simtime_t rtt);
00237 
00238     // see BaseRpc.h
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
Generated on Wed May 26 16:21:13 2010 for OverSim by  doxygen 1.6.3