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 
00037 class BrooseBucket;
00038 
00051 // protocol states
00052 enum
00053 {
00054     INIT,
00055     RSET,
00056     BSET,
00057     READY
00058 };
00059 
00060 
00061 class Broose : public BaseOverlay
00062 {
00063   public:
00064     ~Broose();
00065 
00066     // see BaseOverlay.h
00067     virtual void initializeOverlay(int stage);
00068 
00069     // see BaseOverlay.h
00070     virtual void finishOverlay();
00071 
00072     // see BaseOverlay.h
00073     virtual bool isSiblingFor(const NodeHandle& node,
00074                               const OverlayKey& key,
00075                               int numSiblings,
00076                               bool* err);
00077 
00078     // see BaseOverlay.h
00079     virtual void joinOverlay();
00080 
00081     // see BaseOverlay.h
00082     virtual void handleUDPMessage(BaseOverlayMessage* msg);
00083 
00084     // see BaseOverlay.h
00085     virtual void recordOverlaySentStats(BaseOverlayMessage* msg);
00086 
00087     // see BaseOverlay.h
00088     virtual bool handleRpc(BaseCallMessage* msg);
00089 
00090     // see BaseOverlay.h
00091     virtual void handleTimerEvent(cMessage* msg);
00092 
00096     void updateTooltip();
00097 
00098   protected:
00099     //parameter
00100     int chooseLookup; 
00101     int joinDelay; 
00102     int protoState; 
00103     int receivedJoinResponse; 
00104     int receivedBBucketLookup; 
00105     int numberBBucketLookup; 
00106     int receivedLBucketLookup; 
00107     int numberLBucketLookup;  
00108     int shiftingBits; 
00109     int powShiftingBits; 
00110     uint32_t bucketSize;  
00111     uint32_t rBucketSize; 
00112     int keyLength; 
00113     bool refresh; 
00114     int pingDelay; 
00115     int refreshTime; 
00116     uint32_t userDist; 
00117     int numPings; 
00118     int maxPings; 
00119     int numberRetries; 
00121     //statistics
00122     int bucketCount; 
00123     int bucketBytesSent; 
00124     int broosePingCount; 
00125     int broosePingBytesSent; 
00126     int numFailedPackets; 
00128     //module references
00129     BrooseBucket *lBucket, *bBucket;  
00130     BrooseBucket **rBucket;  
00132     // timer
00133     cMessage* join_timer;  
00134     cMessage* bucket_timer; 
00136     //node handles
00137     TransportAddress bootstrapNode;  
00138     BrooseHandle thisBrooseNode; 
00140     //functions
00141 
00147     void handleJoinTimerExpired(cMessage* msg);
00148 
00154     void handleBucketTimerExpired(cMessage* msg);
00155 
00161     void changeState(int state);
00162 
00163     // see BaseOverlay.h
00164     NodeVector* findNode(const OverlayKey& key,
00165                          int numRedundantNodes,
00166                          int numSiblings,
00167                          BaseOverlayMessage* msg);
00168 
00169     // see BaseOverlay.h
00170     int getMaxNumSiblings();
00171 
00172     // see BaseOverlay.h
00173     int getMaxNumRedundantNodes();
00174 
00178     void displayBucketState();
00179 
00180     // see BaseOverlay.h
00181     void handleRpcResponse(BaseResponseMessage* msg,
00182                            cPolymorphic* context,
00183                            int rpcId, simtime_t rtt);
00184 
00185     // see BaseOverlay.h
00186     void handleRpcTimeout(BaseCallMessage* msg, const TransportAddress& dest,
00187                           cPolymorphic* context, int rpcId,
00188                           const OverlayKey& destKey);
00189 
00197     void handleFindNodeTimeout(FindNodeCall* findNode,
00198                                const TransportAddress& dest,
00199                                const OverlayKey& destKey);
00200 
00206     void handleBucketRequestRpc(BucketCall* msg);
00207 
00213     void handleBucketResponseRpc(BucketResponse* msg);
00214 
00220     void handleBucketTimeout(BucketCall* msg);
00221 
00227     void handleBroosePingRequestRpc(BroosePingCall* msg);
00228 
00235     void handleBroosePingResponseRpc(BroosePingResponse* msg, simtime_t rtt);
00236 
00244     void handleBroosePingTimeout(BroosePingCall* msg,
00245                                  const TransportAddress& dest,
00246                                  const OverlayKey& destKey);
00247 
00253     void setLastSeen (NodeHandle node);
00254 
00261     void addNode(NodeHandle node, int bucket = 0);
00262 
00268     void resetFailedResponses(NodeHandle node);
00269 
00276     void setRTT(NodeHandle node, simtime_t rtt);
00277 
00278     friend class BrooseBucket;
00279 };
00280 
00281 
00282 
00283 #endif

Generated on Wed Mar 25 16:32:48 2009 for OverSim by  doxygen 1.5.5