OverSim
GlobalNodeList.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __GLOBALNODELIST_H__
25 #define __GLOBALNODELIST_H__
26 
27 #include <map>
28 #include <vector>
29 #include <oversim_mapset.h>
30 
31 #include <omnetpp.h>
32 
33 #include <ChurnGenerator.h>
34 
35 #include <BinaryValue.h>
36 #include <NodeHandle.h>
37 #include <PeerStorage.h>
38 
39 class BootstrapList;
40 class TransportAddress;
41 class OverlayKey;
42 class GlobalStatistics;
43 
44 
52 class GlobalNodeList : public cSimpleModule
53 {
54 public:
58  typedef std::vector<OverlayKey> KeyList;
59 
69  void addPeer(const IPvXAddress& ip, PeerInfo* info);
70 
76  void sendNotificationToAllPeers(int category);
77 
86  virtual void killPeer(const IPvXAddress& ip);
87 
102  virtual const NodeHandle& getRandomNode(int32_t overlayId = -1,
103  int32_t nodeType = -1,
104  bool bootstrappedNeeded = true,
105  bool inoffensiveNeeded = false);
106 
120  virtual const NodeHandle& getBootstrapNode(int32_t overlayId = -1,
121  const NodeHandle &node =
123 
131  virtual void registerPeer(const NodeHandle& peer,
132  int32_t overlayId = 0);
133 
134 
142  virtual void refreshEntry(const TransportAddress& peer,
143  int32_t overlayId = 0);
144 
152  virtual void removePeer(const TransportAddress& peer,
153  int32_t overlayId = 0);
154 
161  virtual KeyList* getKeyList(uint32_t maximumKeys);
162 
168  virtual const OverlayKey& getRandomKeyListItem();
169 
176  virtual void setOverlayReadyIcon(const TransportAddress& address, bool ready);
177 
184  virtual PeerInfo* getPeerInfo(const TransportAddress& peer);
185 
192  virtual void setMalicious(const TransportAddress& address, bool malicious);
193 
200  virtual bool isMalicious(const TransportAddress& address);
201 
202  virtual cObject** getContext(const TransportAddress& address);
203 
209  void setPreKilled(const TransportAddress& address);
210 
218  TransportAddress* getRandomAliveNode(int32_t overlayId = -1,
219  int32_t nodeType = -1);
220 
228  virtual PeerInfo* getRandomPeerInfo(int32_t overlayId = -1,
229  int32_t nodeType = -1,
230  bool bootstrapNeeded = false);
231 
238  virtual PeerInfo* getPeerInfo(const IPvXAddress& ip);
239 
240  size_t getNumNodes() { return peerStorage.size(); };
241 
242  bool areNodeTypesConnected(int32_t a, int32_t b);
243  void connectNodeTypes(int32_t a, int32_t b);
244  void disconnectNodeTypes(int32_t a, int32_t b);
245  void mergeBootstrapNodes(int toPartition, int fromPartition, int numNodes);
246 
248  inline uint16_t getLandmarkPeerSize() { return landmarkPeerSize; }
249  inline void incLandmarkPeerSizePerType(uint16_t type) { landmarkPeerSizePerType[type]++; }
250 
251  std::vector<IPvXAddress>* getAllIps();
252  NodeHandle* getNodeHandle(const IPvXAddress& address);
253 
254 protected:
258  virtual void initialize();
259 
265  virtual void handleMessage(cMessage* msg);
266 
272  virtual void createKeyList(uint32_t size);
273 
277  uint32_t preKilledNodes;
279  cOutVector maliciousNodesVector;
282  // key distribution parameters TODO should be put into an other module
283  uint32_t maxNumberOfKeys;
284  double keyProbability;
286 
287 private:
290 };
291 
292 #endif