GlobalNodeList.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 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 __GLOBALNODELIST_H__
00025 #define __GLOBALNODELIST_H__
00026 
00027 #include <map>
00028 #include <vector>
00029 #include <oversim_mapset.h>
00030 
00031 #include <omnetpp.h>
00032 
00033 #include <ChurnGenerator.h>
00034 #include <HashFunc.h>
00035 #include <BinaryValue.h>
00036 #include <NodeHandle.h>
00037 
00038 class PeerInfo;
00039 class BootstrapList;
00040 class TransportAddress;
00041 class OverlayKey;
00042 class GlobalStatistics;
00043 
00050 struct bootstrapEntry
00051 {
00052     TransportAddress* node;
00053     PeerInfo* info;
00054     friend std::ostream& operator<<(std::ostream& Stream, const bootstrapEntry entry);
00055 };
00056 
00064 class GlobalNodeList : public cSimpleModule
00065 {
00066 public:
00070     typedef std::vector<OverlayKey> KeyList;
00071 
00075     ~GlobalNodeList();
00076 
00086     void addPeer(const IPvXAddress& ip, PeerInfo* info);
00087 
00093     void sendNotificationToAllPeers(int category);
00094 
00103     virtual void killPeer(const IPvXAddress& ip);
00104 
00116     virtual const NodeHandle& getRandomNode(uint32_t nodeType = 0,
00117                                             bool bootstrappedNeeded = true);
00118 
00130     virtual const NodeHandle& getBootstrapNode(
00131                         const NodeHandle &node = NodeHandle::UNSPECIFIED_NODE);
00132 
00138     virtual void registerPeer(const TransportAddress& peer);
00139 
00145     virtual void registerPeer(const NodeHandle& peer);
00146 
00152     virtual void removePeer(const TransportAddress& peer);
00153 
00160     virtual KeyList* getKeyList(uint32_t maximumKeys);
00161 
00167     virtual const OverlayKey& getRandomKeyListItem() const;
00168 
00175     virtual void setOverlayReadyIcon(const TransportAddress& address, bool ready);
00176 
00183     virtual PeerInfo* getPeerInfo(const TransportAddress& peer);
00184 
00191     virtual void setMalicious(const TransportAddress& address, bool malicious);
00192 
00199     virtual bool isMalicious(const TransportAddress& address);
00200 
00206     void setPreKilled(const TransportAddress& address);
00207 
00215      TransportAddress* getRandomAliveNode(uint32_t nodeType = 0);
00216 
00224     virtual PeerInfo* getRandomPeerInfo(uint32_t nodeType = 0,
00225                                         bool bootstrapNeeded = false);
00226 
00233     virtual PeerInfo* getPeerInfo(const IPvXAddress& ip);
00234 
00235     bool areNodeTypesConnected(uint32_t a, uint32_t b);
00236     void connectNodeTypes(uint32_t a, uint32_t b);
00237     void disconnectNodeTypes(uint32_t a, uint32_t b);
00238     void mergeBootstrapNodes(int toPartition, int fromPartition, int numNodes);
00239 
00240 
00241 protected:
00242 
00246     virtual void initialize();
00247 
00253     virtual void handleMessage(cMessage* msg);
00254 
00260     virtual void createKeyList(uint32_t size);
00261 
00262     KeyList keyList; 
00263     uint32_t bootstrappedPeerSize; 
00264     uint32_t bootstrappedPeerSizePerType[MAX_NODETYPES]; 
00265     uint32_t bootstrappedMaliciousNodes; 
00266     uint32_t maliciousNodes; 
00267     uint32_t preKilledNodes; 
00268     double maliciousNodeRatio; 
00269     cOutVector maliciousNodesVector; 
00270     typedef UNORDERED_MAP<IPvXAddress, bootstrapEntry> PeerHashMap; 
00271     PeerHashMap peerSet; 
00273     // OMNeT++ parameters
00274     uint32_t maxNumberOfKeys; 
00275     double keyProbability; 
00277 private:
00278     uint32 min_ip, max_ip; 
00279     GlobalStatistics* globalStatistics; 
00280     bool connectionMatrix[MAX_NODETYPES][MAX_NODETYPES]; 
00282 };
00283 
00284 #endif

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