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; 
00106     //statistics
00107     int bucketCount; 
00108     int bucketBytesSent; 
00109     int numFailedPackets; 
00111     //module references
00112     BrooseBucket *lBucket, *bBucket;  
00113     BrooseBucket **rBucket;  
00115     std::vector<BrooseBucket*> bucketVector; 
00117     // timer
00118     cMessage* join_timer;  
00119     cMessage* bucket_timer; 
00121     //node handles
00122     TransportAddress bootstrapNode;  
00124     //functions
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     // see BaseOverlay.h
00172     NodeVector* findNode(const OverlayKey& key,
00173                          int numRedundantNodes,
00174                          int numSiblings,
00175                          BaseOverlayMessage* msg);
00176 
00177     // see BaseOverlay.h
00178     int getMaxNumSiblings();
00179 
00180     // see BaseOverlay.h
00181     int getMaxNumRedundantNodes();
00182 
00186     void displayBucketState();
00187 
00188     // see BaseOverlay.h
00189     void handleRpcResponse(BaseResponseMessage* msg,
00190                            const RpcState& rpcState,
00191                            simtime_t rtt);
00192 
00193     // see BaseOverlay.h
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     // see BaseRpc.h
00232     virtual void pingResponse(PingResponse* pingResponse,
00233                               cPolymorphic* context, int rpcId,
00234                               simtime_t rtt);
00235 
00236     // see BaseRpc.h
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

Generated on Tue Sep 8 17:26:51 2009 for OverSim by  doxygen 1.5.8