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 __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
00035 #include <BinaryValue.h>
00036 #include <NodeHandle.h>
00037 #include <PeerStorage.h>
00038
00039 class BootstrapList;
00040 class TransportAddress;
00041 class OverlayKey;
00042 class GlobalStatistics;
00043
00044
00052 class GlobalNodeList : public cSimpleModule
00053 {
00054 public:
00058 typedef std::vector<OverlayKey> KeyList;
00059
00069 void addPeer(const IPvXAddress& ip, PeerInfo* info);
00070
00076 void sendNotificationToAllPeers(int category);
00077
00086 virtual void killPeer(const IPvXAddress& ip);
00087
00100 virtual const NodeHandle& getRandomNode(int32_t nodeType = -1,
00101 bool bootstrappedNeeded = true,
00102 bool inoffensiveNeeded = false);
00103
00115 virtual const NodeHandle& getBootstrapNode(const NodeHandle &node =
00116 NodeHandle::UNSPECIFIED_NODE);
00117
00123 virtual void registerPeer(const TransportAddress& peer);
00124
00130 virtual void registerPeer(const NodeHandle& peer);
00131
00132
00138 virtual void refreshEntry(const TransportAddress& peer);
00139
00145 virtual void removePeer(const TransportAddress& peer);
00146
00153 virtual KeyList* getKeyList(uint32_t maximumKeys);
00154
00160 virtual const OverlayKey& getRandomKeyListItem();
00161
00168 virtual void setOverlayReadyIcon(const TransportAddress& address, bool ready);
00169
00176 virtual PeerInfo* getPeerInfo(const TransportAddress& peer);
00177
00184 virtual void setMalicious(const TransportAddress& address, bool malicious);
00185
00192 virtual bool isMalicious(const TransportAddress& address);
00193
00194 virtual cObject** getContext(const TransportAddress& address);
00195
00201 void setPreKilled(const TransportAddress& address);
00202
00210 TransportAddress* getRandomAliveNode(int32_t nodeType = -1);
00211
00219 virtual PeerInfo* getRandomPeerInfo(int32_t nodeType = -1,
00220 bool bootstrapNeeded = false);
00221
00228 virtual PeerInfo* getPeerInfo(const IPvXAddress& ip);
00229
00230 size_t getNumNodes() { return peerStorage.size(); };
00231
00232 bool areNodeTypesConnected(int32_t a, int32_t b);
00233 void connectNodeTypes(int32_t a, int32_t b);
00234 void disconnectNodeTypes(int32_t a, int32_t b);
00235 void mergeBootstrapNodes(int toPartition, int fromPartition, int numNodes);
00236
00237 inline void incLandmarkPeerSize() { landmarkPeerSize++; }
00238 inline uint16_t getLandmarkPeerSize() { return landmarkPeerSize; }
00239 inline void incLandmarkPeerSizePerType(uint16_t type) { landmarkPeerSizePerType[type]++; }
00240
00241 protected:
00245 virtual void initialize();
00246
00252 virtual void handleMessage(cMessage* msg);
00253
00259 virtual void createKeyList(uint32_t size);
00260
00261 KeyList keyList;
00262 uint16_t landmarkPeerSize;
00263 uint16_t landmarkPeerSizePerType[MAX_NODETYPES];
00264 uint32_t preKilledNodes;
00265 double maliciousNodeRatio;
00266 cOutVector maliciousNodesVector;
00267 PeerStorage peerStorage;
00269
00270 uint32_t maxNumberOfKeys;
00271 double keyProbability;
00272 bool isKeyListInitialized;
00273
00274 private:
00275 GlobalStatistics* globalStatistics;
00276 bool connectionMatrix[MAX_NODETYPES][MAX_NODETYPES];
00277 };
00278
00279 #endif