GlobalNodeList Class Reference

Global module (formerly known as GlobalNodeList) that supports the node bootstrap process and contains node specific underlay parameters, malicious node states, etc. More...

#include <GlobalNodeList.h>

List of all members.

Public Types

typedef std::vector< OverlayKeyKeyList
 holds all OverlayKeys

Public Member Functions

 ~GlobalNodeList ()
 Destructor.
void addPeer (const IPvXAddress &ip, PeerInfo *info)
 Adds new peers to the peer set.
void sendNotificationToAllPeers (int category)
 Sends a NotificationBoard message to all registered peers.
virtual void killPeer (const IPvXAddress &ip)
 Removes a peer from the peerSet.
virtual const NodeHandlegetRandomNode (uint32_t nodeType=0, bool bootstrappedNeeded=true, bool inoffensiveNeeded=false)
 Returns a random NodeHandle.
virtual const NodeHandlegetBootstrapNode (const NodeHandle &node=NodeHandle::UNSPECIFIED_NODE)
 Returns a random NodeHandle.
virtual void registerPeer (const TransportAddress &peer)
 Bootstraps peers in the peer set.
virtual void registerPeer (const NodeHandle &peer)
 Bootstraps peers in the peer set.
virtual void refreshEntry (const TransportAddress &peer)
 Update entry to real port without having bootstrapped.
virtual void removePeer (const TransportAddress &peer)
 Debootstraps peers in the peer set.
virtual KeyListgetKeyList (uint32_t maximumKeys)
 Returns a keylist.
virtual const OverlayKeygetRandomKeyListItem () const
 Returns random key from list.
virtual void setOverlayReadyIcon (const TransportAddress &address, bool ready)
 Colors module-icon blue (ready), green (ready, malicious) or red (not ready).
virtual PeerInfogetPeerInfo (const TransportAddress &peer)
 Searches the peerSet for the specified node.
virtual void setMalicious (const TransportAddress &address, bool malicious)
 Set a node to be malicious.
virtual bool isMalicious (const TransportAddress &address)
 Check if a node is malicious.
void setPreKilled (const TransportAddress &address)
 Mark a node for deletion.
TransportAddressgetRandomAliveNode (uint32_t nodeType=0)
 Selects a random node from the peerSet, which is not already marked for deletion.
virtual PeerInfogetRandomPeerInfo (uint32_t nodeType=0, bool bootstrapNeeded=false)
 Selects a random node from the peerSet.
virtual PeerInfogetPeerInfo (const IPvXAddress &ip)
 Searches the peerSet for the specified node.
bool areNodeTypesConnected (uint32_t a, uint32_t b)
void connectNodeTypes (uint32_t a, uint32_t b)
void disconnectNodeTypes (uint32_t a, uint32_t b)
void mergeBootstrapNodes (int toPartition, int fromPartition, int numNodes)
void incLandmarkPeerSize ()
uint16_t getLandmarkPeerSize ()
void incLandmarkPeerSizePerType (uint16_t type)
uint32_t getBootstrappedPeerSize ()

Protected Types

typedef UNORDERED_MAP
< IPvXAddress, bootstrapEntry
PeerHashMap
 Set of nodes participating in the overlay.

Protected Member Functions

virtual void initialize ()
 Init member function of module.
virtual void handleMessage (cMessage *msg)
 HandleMessage member function of module.
virtual void createKeyList (uint32_t size)
 Member function to create keylist.

Protected Attributes

KeyList keyList
 the keylist
uint32_t bootstrappedPeerSize
 number of bootstrapped peers in the peer set
uint32_t bootstrappedPeerSizePerType [MAX_NODETYPES]
 number of bootstrapped peers of all types
uint16_t landmarkPeerSize
uint16_t landmarkPeerSizePerType [MAX_NODETYPES]
uint32_t bootstrappedMaliciousNodes
 number of bootstrapped malicious nodes in the peer set
uint32_t maliciousNodes
 number of malicious nodes in the peer set
uint32_t preKilledNodes
 number of nodes marked for deletion in the peer set
double maliciousNodeRatio
 ratio of current malicious nodes when changing the ratio dynamically
cOutVector maliciousNodesVector
 vector that records the cange of malicious node rate
PeerHashMap peerSet
 Set of nodes participating in the overlay.
uint32_t maxNumberOfKeys
 parameter used by createKeyList()
double keyProbability
 probability of keys to be owned by nodes

Private Attributes

uint32 min_ip
uint32 max_ip
 used for random node choosing
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
bool connectionMatrix [MAX_NODETYPES][MAX_NODETYPES]
 matrix specifices with node types (partitions) can communication


Detailed Description

Global module (formerly known as GlobalNodeList) that supports the node bootstrap process and contains node specific underlay parameters, malicious node states, etc.

..

Author:
Markus Mauch, Robert Palmer

Definition at line 64 of file GlobalNodeList.h.


Member Typedef Documentation

typedef std::vector<OverlayKey> GlobalNodeList::KeyList

holds all OverlayKeys

Definition at line 70 of file GlobalNodeList.h.

typedef UNORDERED_MAP<IPvXAddress, bootstrapEntry> GlobalNodeList::PeerHashMap [protected]

Set of nodes participating in the overlay.

Definition at line 286 of file GlobalNodeList.h.


Constructor & Destructor Documentation

GlobalNodeList::~GlobalNodeList (  ) 

Destructor.

Definition at line 630 of file GlobalNodeList.cc.

00631 {
00632     PeerHashMap::iterator it;
00633     for(it = peerSet.begin(); it != peerSet.end(); ++it) {
00634         delete it->second.node;
00635         delete it->second.info;
00636     }
00637 }


Member Function Documentation

void GlobalNodeList::addPeer ( const IPvXAddress &  ip,
PeerInfo info 
)

Adds new peers to the peer set.

Called automatically by the underlay, when new peers are created.

Parameters:
ip IPvXAddress of the peer to add
info underlay specific info of the peer to add

Definition at line 255 of file GlobalNodeList.cc.

Referenced by SimpleUnderlayConfigurator::createNode(), InetUnderlayConfigurator::createNode(), SingleHostUnderlayConfigurator::initializeUnderlay(), InetUnderlayConfigurator::initializeUnderlay(), SimpleUnderlayConfigurator::migrateNode(), and InetUnderlayConfigurator::migrateNode().

00256 {
00257     bootstrapEntry temp;
00258     temp.node = new TransportAddress(ip);
00259     temp.info = info;
00260     temp.info->setPreKilled(false);
00261 
00262     peerSet.insert(std::make_pair(temp.node->getAddress(), temp));
00263     // set bounds for random node retrieval
00264     if (ip.get4().getInt() < min_ip) min_ip = ip.get4().getInt();
00265     if (ip.get4().getInt() > max_ip) max_ip = ip.get4().getInt();
00266 
00267     if (uniform(0, 1) < (double) par("maliciousNodeProbability") ||
00268             (par("maliciousNodeChange") && uniform(0, 1) < maliciousNodeRatio)) {
00269         setMalicious(*temp.node, true);
00270     }
00271 }

bool GlobalNodeList::areNodeTypesConnected ( uint32_t  a,
uint32_t  b 
)

Definition at line 578 of file GlobalNodeList.cc.

Referenced by SimpleUDP::processMsgFromApp().

00579 {
00580     if ((a > MAX_NODETYPES) || (b > MAX_NODETYPES)) {
00581         throw cRuntimeError("GlobalNodeList::areNodeTypesConnected(): nodeType "
00582               "bigger then MAX_NODETYPES");
00583     }
00584 
00585     return connectionMatrix[a][b];
00586 }

void GlobalNodeList::connectNodeTypes ( uint32_t  a,
uint32_t  b 
)

Definition at line 588 of file GlobalNodeList.cc.

Referenced by GlobalTraceManager::handleMessage().

00589 {
00590     if ((a > MAX_NODETYPES) || (b > MAX_NODETYPES)) {
00591         throw cRuntimeError("GlobalNodeList::connectNodeTypes(): nodeType "
00592               "bigger then MAX_NODETYPES");
00593     }
00594 
00595     connectionMatrix[a][b]=true;
00596 
00597     EV << "[GlobalNodeList::connectNodeTypes()]\n"
00598        << "    Connecting " << a << "->" << b
00599        << endl;
00600 
00601 }

void GlobalNodeList::createKeyList ( uint32_t  size  )  [protected, virtual]

Member function to create keylist.

Parameters:
size size of new keylist

Definition at line 392 of file GlobalNodeList.cc.

Referenced by initialize().

00393 {
00394     for (uint32_t i = 0; i < size; i++)
00395         keyList.push_back(OverlayKey::random());
00396 }

void GlobalNodeList::disconnectNodeTypes ( uint32_t  a,
uint32_t  b 
)

Definition at line 603 of file GlobalNodeList.cc.

Referenced by GlobalTraceManager::handleMessage().

00604 {
00605     if ((a > MAX_NODETYPES) || (b > MAX_NODETYPES)) {
00606         throw cRuntimeError("GlobalNodeList::disconnectNodeTypes(): nodeType "
00607               "bigger then MAX_NODETYPES");
00608     }
00609 
00610     connectionMatrix[a][b]=false;
00611 
00612     EV << "[GlobalNodeList::disconnectNodeTypes()]\n"
00613        << "    Disconnecting " << a << "->" << b
00614        << endl;
00615 
00616 }

const NodeHandle & GlobalNodeList::getBootstrapNode ( const NodeHandle node = NodeHandle::UNSPECIFIED_NODE  )  [virtual]

Returns a random NodeHandle.

Returns a random NodeHandle of an already bootstrapped node from the peerSet if at least one peer has been registered, an empty TransportAddress otherwise. If the optional node parameter is given, try to return a bootstrap node in the same partition.

Parameters:
node Find a bootstrap node in the same partitions as node
Returns:
NodeHandle of the bootstrap node

Definition at line 154 of file GlobalNodeList.cc.

Referenced by BootstrapList::getBootstrapNode(), KBRTestApp::handleTimerEvent(), Gia::handleTimerEvent(), and PubSubMMOG::initializeOverlay().

00155 {
00156     uint32_t nodeType;
00157     PeerHashMap::iterator it;
00158 
00159     // always prefer boot node from the same partition
00160     // if there is no such node, go through all
00161     // connected partitions until a bootstrap node is found
00162     if (!node.isUnspecified()) {
00163         it = peerSet.find(node.getAddress());
00164 
00165         // this should never happen
00166         if (it == peerSet.end()) {
00167            return getRandomNode(0, true);
00168         }
00169 
00170         nodeType = it->second.info->getTypeID();
00171         const NodeHandle &tempNode1 = getRandomNode(nodeType, true);
00172 
00173         if (tempNode1.isUnspecified()) {
00174             for (uint32_t i = 1; i < MAX_NODETYPES; i++) {
00175                 if (i == nodeType)
00176                     continue;
00177 
00178                 if (connectionMatrix[nodeType][i]) {
00179                     const NodeHandle &tempNode2 = getRandomNode(i, true);
00180                     if (!tempNode2.isUnspecified())
00181                         return tempNode2;
00182                 }
00183             }
00184             return NodeHandle::UNSPECIFIED_NODE;
00185         } else {
00186             return tempNode1;
00187         }
00188     } else {
00189         return getRandomNode(0, true);
00190     }
00191 }

uint32_t GlobalNodeList::getBootstrappedPeerSize (  )  [inline]

Definition at line 253 of file GlobalNodeList.h.

00253 { return bootstrappedPeerSize; }

GlobalNodeList::KeyList * GlobalNodeList::getKeyList ( uint32_t  maximumKeys  )  [virtual]

Returns a keylist.

Parameters:
maximumKeys maximum number of keys in new keylist
Returns:
pointer to new keylist

Definition at line 398 of file GlobalNodeList.cc.

Referenced by GIASearchApp::handleTimerEvent().

00399 {
00400     if (maximumKeys > keyList.size()) {
00401         maximumKeys = keyList.size();
00402     }
00403     // copy keylist to temporary keylist
00404     KeyList tmpKeyList;
00405     tmpKeyList.clear();
00406 
00407     for (uint32_t i=0; i < keyList.size(); i++) {
00408         tmpKeyList.push_back(keyList[i]);
00409     }
00410 
00411     KeyList* returnList = new KeyList;
00412 
00413     for (uint32_t i=0; i < ((float)maximumKeys * keyProbability); i++) {
00414         uint32_t index = intuniform(0, tmpKeyList.size()-1);
00415 
00416         returnList->push_back(tmpKeyList[index]);
00417         tmpKeyList.erase(tmpKeyList.begin()+index);
00418     }
00419 
00420     return returnList;
00421 }

uint16_t GlobalNodeList::getLandmarkPeerSize (  )  [inline]

Definition at line 251 of file GlobalNodeList.h.

Referenced by Nps::enoughLandmarks(), and Nps::getLandmarks().

00251 { return landmarkPeerSize; }

PeerInfo * GlobalNodeList::getPeerInfo ( const IPvXAddress &  ip  )  [virtual]

Searches the peerSet for the specified node.

Parameters:
ip IPvXAddress of the specified node
Returns:
PeerInfo of the node or NULL if node is not in peerSet

Definition at line 438 of file GlobalNodeList.cc.

00439 {
00440     PeerHashMap::iterator it = peerSet.find(ip);
00441 
00442     if (it == peerSet.end())
00443         return NULL;
00444     else
00445         return it->second.info;
00446 }

PeerInfo * GlobalNodeList::getPeerInfo ( const TransportAddress peer  )  [virtual]

Searches the peerSet for the specified node.

Parameters:
peer TransportAddress of the specified node
Returns:
PeerInfo of the node or NULL if node is not in peerSet

Definition at line 428 of file GlobalNodeList.cc.

Referenced by TopologyVis::deleteOverlayNeighborArrow(), Nps::getLandmarks(), SimpleUnderlayConfigurator::handleTimerEvent(), InetUnderlayConfigurator::handleTimerEvent(), isMalicious(), killPeer(), SimpleUnderlayConfigurator::migrateNode(), InetUnderlayConfigurator::migrateNode(), SimpleUnderlayConfigurator::preKillNode(), InetUnderlayConfigurator::preKillNode(), SimpleUDP::processMsgFromApp(), setMalicious(), setOverlayReadyIcon(), Nps::setOwnLayer(), setPreKilled(), and TopologyVis::showOverlayNeighborArrow().

00429 {
00430     PeerHashMap::iterator it = peerSet.find(peer.getAddress());
00431 
00432     if (it == peerSet.end())
00433         return NULL;
00434     else
00435         return it->second.info;
00436 }

TransportAddress * GlobalNodeList::getRandomAliveNode ( uint32_t  nodeType = 0  ) 

Selects a random node from the peerSet, which is not already marked for deletion.

Parameters:
nodeType If != 0, return a node of that type
Returns:
A pointer to the TransportAddress of a random alive node

Definition at line 487 of file GlobalNodeList.cc.

Referenced by Nps::getLandmarks(), SimpleUnderlayConfigurator::preKillNode(), and InetUnderlayConfigurator::preKillNode().

00488 {
00489     if (peerSet.size() <= preKilledNodes) {
00490         // all nodes are already marked for deletion;
00491         return NULL;
00492     } else {
00493         // return random address in O(log n)
00494         PeerHashMap::iterator it;
00495         bootstrapEntry tempEntry = {NULL, NULL};
00496 
00497         IPvXAddress randomAddr(intuniform(min_ip, max_ip));
00498 
00499         it = peerSet.find(randomAddr);
00500 
00501         if (it == peerSet.end()) {
00502             it = peerSet.insert(std::make_pair(randomAddr,tempEntry)).first;
00503             peerSet.erase(it++);
00504         }
00505 
00506         if (it == peerSet.end()) {
00507             it = peerSet.begin();
00508         }
00509 
00510         while ((nodeType && (it->second.info->getTypeID() != nodeType))
00511                || it->second.info->isPreKilled()) {
00512             it++;
00513             if (it == peerSet.end()) {
00514                 it = peerSet.begin();
00515             }
00516         }
00517 
00518         return it->second.node;
00519     }
00520 
00521     return NULL;
00522 }

const OverlayKey & GlobalNodeList::getRandomKeyListItem (  )  const [virtual]

Returns random key from list.

Returns:
the key

Definition at line 423 of file GlobalNodeList.cc.

Referenced by GIASearchApp::handleTimerEvent().

00424 {
00425     return keyList[intuniform(0,keyList.size()-1)];
00426 }

const NodeHandle & GlobalNodeList::getRandomNode ( uint32_t  nodeType = 0,
bool  bootstrappedNeeded = true,
bool  inoffensiveNeeded = false 
) [virtual]

Returns a random NodeHandle.

Returns a random NodeHandle from the peerSet if at least one peer has been registered, an empty TransportAddress otherwise.

Parameters:
nodeType If != 0, return a node of that type
bootstrappedNeeded does the node need to be bootstrapped?
inoffensiveNeeded does the node need to be inoffensive?
Returns:
NodeHandle of the node

Definition at line 193 of file GlobalNodeList.cc.

Referenced by KBRTestApp::createDestKey(), getBootstrapNode(), handleMessage(), and mergeBootstrapNodes().

00196 {
00197     if (inoffensiveNeeded &&
00198             ((nodeType != 0) || (bootstrappedNeeded == false))) {
00199         throw cRuntimeError("GlobalNodeList::getRandomNode(): "
00200                             "inoffensiveNeeded must only be used "
00201                             "with nodeType = 0 and bootstrappedNeeded = true!");
00202     }
00203 
00204     if (peerSet.size() == 0)
00205         return NodeHandle::UNSPECIFIED_NODE;
00206     if (bootstrappedNeeded && bootstrappedPeerSize == 0)
00207         return NodeHandle::UNSPECIFIED_NODE;
00208     if (nodeType && bootstrappedPeerSizePerType[nodeType] == 0)
00209         return NodeHandle::UNSPECIFIED_NODE;
00210     if (inoffensiveNeeded &&
00211             (bootstrappedPeerSize - bootstrappedMaliciousNodes <= 0))
00212         return NodeHandle::UNSPECIFIED_NODE;
00213     else {
00214         // return random TransportAddress in O(log n)
00215         PeerHashMap::iterator it = peerSet.end();
00216         bootstrapEntry tempEntry = {NULL, NULL};
00217 
00218         while (it == peerSet.end() ||(nodeType && (it->second.info->getTypeID() != nodeType))
00219                 || (bootstrappedNeeded && !it->second.info->isBootstrapped())
00220                 || (inoffensiveNeeded && it->second.info->isMalicious())) {
00221 
00222             IPvXAddress randomAddr(intuniform(min_ip, max_ip));
00223 
00224             it = peerSet.find(randomAddr);
00225 
00226             if (it == peerSet.end()) {
00227                 it = peerSet.insert(std::make_pair(randomAddr,tempEntry)).first;
00228                 peerSet.erase(it++);
00229             }
00230 
00231             if (it == peerSet.end())
00232                 it = peerSet.begin();
00233         }
00234 
00235         if (dynamic_cast<NodeHandle*>(it->second.node)) {
00236             return *dynamic_cast<NodeHandle*>(it->second.node);
00237         } else {
00238             return NodeHandle::UNSPECIFIED_NODE;
00239         }
00240     }
00241 }

PeerInfo * GlobalNodeList::getRandomPeerInfo ( uint32_t  nodeType = 0,
bool  bootstrapNeeded = false 
) [virtual]

Selects a random node from the peerSet.

Parameters:
nodeType If != 0, return a node of that type
bootstrapNeeded does the node need to be bootstrapped?
Returns:
The peerInfo of a random node

Definition at line 448 of file GlobalNodeList.cc.

Referenced by mergeBootstrapNodes(), and InetUnderlayConfigurator::migrateNode().

00449                                                                       {
00450     // return random TransportAddress in O(log n)
00451     PeerHashMap::iterator it;
00452     bootstrapEntry tempEntry = {NULL, NULL};
00453 
00454     IPvXAddress randomAddr(intuniform(min_ip, max_ip));
00455 
00456     it = peerSet.find(randomAddr);
00457     if (it == peerSet.end()) {
00458         it = peerSet.insert(std::make_pair(randomAddr,tempEntry)).first;
00459         peerSet.erase(it++);
00460     }
00461 
00462     if (it == peerSet.end())
00463         it = peerSet.begin();
00464 
00465     // if nodeType != 0, search for next node with the given type
00466     if (nodeType) {
00467         while((nodeType && (it->second.info->getTypeID() != nodeType))
00468               || (bootstrappedNeeded && !it->second.info->isBootstrapped())) {
00469             ++it;
00470             if (it == peerSet.end()) it = peerSet.begin();
00471         }
00472     }
00473 
00474     return it->second.info;
00475 }

void GlobalNodeList::handleMessage ( cMessage *  msg  )  [protected, virtual]

HandleMessage member function of module.

Parameters:
msg messag to handle

Definition at line 113 of file GlobalNodeList.cc.

00114 {
00115     if (msg->isName("maliciousNodeChange")) {
00116         double newRatio = maliciousNodeRatio + (double) par("maliciousNodeChangeRate"); // ratio to obtain
00117         if (maliciousNodeRatio < (double) par("maliciousNodeChangeStartValue"))
00118             newRatio = (double) par("maliciousNodeChangeStartValue");
00119 
00120         if (newRatio < (double) par("maliciousNodeChangeStopValue")) // schedule next event
00121             scheduleAt(simTime() + (int) par("maliciousNodeChangeInterval"), msg);
00122 
00123         int nodesNeeded = (int) (((double) par("maliciousNodeChangeRate")) * peerSet.size());
00124 
00125         EV << "[GlobalNodeList::handleMessage()]\n"
00126            << "    Changing " << nodesNeeded << " nodes to be malicious"
00127            << endl;
00128 
00129         for (int i = 0; i < nodesNeeded; i++) {
00130             // search a node that is not yet malicious
00131             NodeHandle node;
00132             do {
00133                 node = getRandomNode(0, false);
00134             } while (isMalicious(node));
00135 
00136             setMalicious(node, true);
00137         }
00138 
00139         maliciousNodesVector.record(newRatio);
00140         maliciousNodeRatio = newRatio;
00141 
00142         return;
00143     }
00144 
00145     else if (msg->isName("oracleTimer")) {
00146         RECORD_STATS(globalStatistics->recordOutVector(
00147                      "GlobalNodeList: Number of nodes", peerSet.size()));
00148         scheduleAt(simTime() + 50, msg);
00149     } else {
00150         opp_error("GlobalNodeList::handleMessage: Unknown message type!");
00151     }
00152 }

void GlobalNodeList::incLandmarkPeerSize (  )  [inline]

Definition at line 250 of file GlobalNodeList.h.

Referenced by Nps::setOwnLayer().

00250 { landmarkPeerSize++; }

void GlobalNodeList::incLandmarkPeerSizePerType ( uint16_t  type  )  [inline]

Definition at line 252 of file GlobalNodeList.h.

Referenced by Nps::setOwnLayer().

00252 { landmarkPeerSizePerType[type]++; }

void GlobalNodeList::initialize (  )  [protected, virtual]

Init member function of module.

Definition at line 61 of file GlobalNodeList.cc.

00062 {
00063     maxNumberOfKeys = par("maxNumberOfKeys");
00064     keyProbability = par("keyProbability");
00065 
00066     WATCH_UNORDERED_MAP(peerSet);
00067     WATCH_VECTOR(keyList);
00068     WATCH(bootstrappedPeerSize);
00069     WATCH(bootstrappedMaliciousNodes);
00070     WATCH(maliciousNodes);
00071     WATCH(landmarkPeerSize);
00072 
00073     createKeyList(maxNumberOfKeys);
00074     bootstrappedPeerSize = 0;
00075     landmarkPeerSize = 0;
00076 
00077     for (int i = 0; i < MAX_NODETYPES; i++) {
00078         bootstrappedPeerSizePerType[i] = 0;
00079         landmarkPeerSizePerType[i] = 0;
00080     }
00081 
00082     bootstrappedMaliciousNodes = 0;
00083     maliciousNodes = 0;
00084     preKilledNodes = 0;
00085 
00086     if (par("maliciousNodeChange")) {
00087         if ((double) par("maliciousNodeProbability") > 0)
00088             error("maliciousNodeProbability and maliciousNodeChange are not supported concurrently");
00089 
00090         cMessage* msg = new cMessage("maliciousNodeChange");
00091         scheduleAt(simTime() + (int) par("maliciousNodeChangeStartTime"), msg);
00092         maliciousNodesVector.setName("MaliciousNodeRate");
00093         maliciousNodesVector.record(0);
00094         maliciousNodeRatio = 0;
00095     }
00096 
00097     min_ip = 0xFFFFFFFF;
00098     max_ip = 0x00000000;
00099 
00100     for (int i=0; i<MAX_NODETYPES; i++) {
00101         for (int j=0; j<MAX_NODETYPES; j++) {
00102             connectionMatrix[i][j] = true;
00103         }
00104     }
00105 
00106     globalStatistics = GlobalStatisticsAccess().get();
00107 
00108     cMessage* timer = new cMessage("oracleTimer");
00109 
00110     scheduleAt(simTime(), timer);
00111 }

bool GlobalNodeList::isMalicious ( const TransportAddress address  )  [virtual]

Check if a node is malicious.

Parameters:
address TransportAddress of the node
Returns:
if the node is malicious

Definition at line 546 of file GlobalNodeList.cc.

Referenced by handleMessage(), BaseOverlay::isMalicious(), and setOverlayReadyIcon().

00547 {
00548     PeerInfo* peer = getPeerInfo(address);
00549 
00550     if(peer != NULL)
00551         return peer->isMalicious();
00552 
00553     return false;
00554 }

void GlobalNodeList::killPeer ( const IPvXAddress &  ip  )  [virtual]

Removes a peer from the peerSet.

Called automatically by the underlay, when peers are removed.

Parameters:
ip IPvXAddress of the peer to remove

Definition at line 360 of file GlobalNodeList.cc.

Referenced by SimpleUnderlayConfigurator::handleTimerEvent(), InetUnderlayConfigurator::handleTimerEvent(), SimpleUnderlayConfigurator::migrateNode(), and InetUnderlayConfigurator::migrateNode().

00361 {
00362     PeerHashMap::iterator it = peerSet.find(ip);
00363     if(it != peerSet.end()) {
00364         if(it->second.info->isBootstrapped()) {
00365             bootstrappedPeerSize--;
00366             bootstrappedPeerSizePerType[it->second.info->getTypeID()]--;
00367 
00368             if(it->second.info->isMalicious())
00369                 bootstrappedMaliciousNodes--;
00370 
00371             it->second.info->setBootstrapped(false);
00372         }
00373 
00374         if (it->second.info->isPreKilled()) {
00375             it->second.info->setPreKilled(false);
00376             preKilledNodes--;
00377         }
00378 
00379         // if valid NPS landmark: decrease landmarkPeerSize
00380         PeerInfo* peerInfo = getPeerInfo(ip);
00381         if (peerInfo->getNpsLayer() > -1) {
00382             landmarkPeerSize--;
00383             landmarkPeerSizePerType[it->second.info->getTypeID()]--;
00384         }
00385 
00386         delete it->second.node;
00387         delete it->second.info;
00388         peerSet.erase(it);
00389     }
00390 }

void GlobalNodeList::mergeBootstrapNodes ( int  toPartition,
int  fromPartition,
int  numNodes 
)

Definition at line 618 of file GlobalNodeList.cc.

Referenced by GlobalTraceManager::handleMessage().

00620 {
00621     BootstrapList* bootstrapList =
00622         check_and_cast<BootstrapList*>(simulation.getModule(
00623             getRandomPeerInfo(toPartition, false)->getModuleID())->
00624             getSubmodule("bootstrapList"));
00625 
00626     bootstrapList->insertBootstrapCandidate(getRandomNode(fromPartition, true),
00627                                        DNSSD);
00628 }

void GlobalNodeList::refreshEntry ( const TransportAddress peer  )  [virtual]

Update entry to real port without having bootstrapped.

Parameters:
peer node to refresh

Definition at line 327 of file GlobalNodeList.cc.

Referenced by Landmark::initializeApp(), and Nps::setOwnLayer().

00328 {
00329     PeerHashMap::iterator it = peerSet.find(peer.getAddress());
00330     if (it == peerSet.end()) {
00331         error("unable to refresh entry, peer is not in peer set");
00332     } else {
00333         PeerInfo* info = it->second.info;
00334 
00335         delete it->second.node;
00336         peerSet.erase(it);
00337 
00338         bootstrapEntry temp;
00339         temp.node = new TransportAddress(peer);
00340         temp.info = info;
00341         peerSet.insert(std::make_pair(temp.node->getAddress(), temp));
00342     }
00343 }

void GlobalNodeList::registerPeer ( const NodeHandle peer  )  [virtual]

Bootstraps peers in the peer set.

Parameters:
peer node to register

Definition at line 300 of file GlobalNodeList.cc.

00301 {
00302     PeerHashMap::iterator it = peerSet.find(peer.getAddress());
00303     if (it == peerSet.end())
00304         error("unable to bootstrap peer, peer is not in peer set");
00305     else {
00306         PeerInfo* info = it->second.info;
00307 
00308         if (!info->isBootstrapped()) {
00309             bootstrappedPeerSize++;
00310             bootstrappedPeerSizePerType[info->getTypeID()]++;
00311             info->setBootstrapped();
00312 
00313             if (info->isMalicious())
00314                 bootstrappedMaliciousNodes++;
00315         }
00316 
00317         delete it->second.node;
00318         peerSet.erase(it);
00319 
00320         bootstrapEntry temp;
00321         temp.node = new NodeHandle(peer);
00322         temp.info = info;
00323         peerSet.insert(std::make_pair(temp.node->getAddress(), temp));
00324     }
00325 }

void GlobalNodeList::registerPeer ( const TransportAddress peer  )  [virtual]

Bootstraps peers in the peer set.

Parameters:
peer node to register

Definition at line 273 of file GlobalNodeList.cc.

Referenced by Vast::changeState(), Quon::changeState(), SingleHostUnderlayConfigurator::initializeUnderlay(), and BootstrapList::registerBootstrapNode().

00274 {
00275     PeerHashMap::iterator it = peerSet.find(peer.getAddress());
00276     if (it == peerSet.end())
00277         error("unable to bootstrap peer, peer is not in peer set");
00278     else {
00279         PeerInfo* info = it->second.info;
00280 
00281         if (!info->isBootstrapped()) {
00282             bootstrappedPeerSize++;
00283             bootstrappedPeerSizePerType[info->getTypeID()]++;
00284             info->setBootstrapped();
00285 
00286             if (info->isMalicious())
00287                 bootstrappedMaliciousNodes++;
00288         }
00289 
00290         delete it->second.node;
00291         peerSet.erase(it);
00292 
00293         bootstrapEntry temp;
00294         temp.node = new TransportAddress(peer);
00295         temp.info = info;
00296         peerSet.insert(std::make_pair(temp.node->getAddress(), temp));
00297     }
00298 }

void GlobalNodeList::removePeer ( const TransportAddress peer  )  [virtual]

Debootstraps peers in the peer set.

Parameters:
peer node to remove

Definition at line 345 of file GlobalNodeList.cc.

Referenced by Vast::changeState(), Quon::changeState(), Vast::finishOverlay(), SimpleUnderlayConfigurator::preKillNode(), InetUnderlayConfigurator::preKillNode(), and BootstrapList::removeBootstrapNode().

00346 {
00347     PeerHashMap::iterator it = peerSet.find(peer.getAddress());
00348     if(it != peerSet.end() && it->second.info->isBootstrapped()) {
00349         bootstrappedPeerSize--;
00350         bootstrappedPeerSizePerType[it->second.info->getTypeID()]--;
00351         it->second.info->setBootstrapped(false);
00352 
00353         if(it->second.info->isMalicious())
00354             bootstrappedMaliciousNodes--;
00355 
00356         it->second.info->setBootstrapped(false);
00357     }
00358 }

void GlobalNodeList::sendNotificationToAllPeers ( int  category  ) 

Sends a NotificationBoard message to all registered peers.

Parameters:
category Type of notification

Definition at line 243 of file GlobalNodeList.cc.

00244 {
00245     PeerHashMap::iterator it;
00246     for (it = peerSet.begin(); it != peerSet.end(); it++) {
00247         NotificationBoard* nb = check_and_cast<NotificationBoard*>(
00248                 simulation.getModule(it->second.info->getModuleID())
00249                 ->getSubmodule("notificationBoard"));
00250 
00251         nb->fireChangeNotification(category);
00252     }
00253 }

void GlobalNodeList::setMalicious ( const TransportAddress address,
bool  malicious 
) [virtual]

Set a node to be malicious.

Parameters:
address TransportAddress of the node
malicious state to set

Definition at line 524 of file GlobalNodeList.cc.

Referenced by addPeer(), and handleMessage().

00525 {
00526     PeerInfo* peer = getPeerInfo(address);
00527 
00528     if (peer != NULL) {
00529         if(malicious && !peer->isMalicious()) {
00530             maliciousNodes++;
00531             if (peer->isBootstrapped()) {
00532                 bootstrappedMaliciousNodes++;
00533             }
00534         }
00535 
00536         if (!malicious && peer->isMalicious()) {
00537             maliciousNodes--;
00538             if (peer->isBootstrapped()) {
00539                 bootstrappedMaliciousNodes--;
00540             }
00541         }
00542         peer->setMalicious(malicious);
00543     }
00544 }

void GlobalNodeList::setOverlayReadyIcon ( const TransportAddress address,
bool  ready 
) [virtual]

Colors module-icon blue (ready), green (ready, malicious) or red (not ready).

Parameters:
address TransportAddress of the specified node
ready state to visualize

Definition at line 556 of file GlobalNodeList.cc.

Referenced by BaseOverlay::initialize(), Landmark::initializeApp(), and BaseOverlay::setOverlayReady().

00558 {
00559     if (ev.isGUI()) {
00560         const char* color;
00561 
00562         if (ready) {
00563             // change color if node is malicious
00564             color = isMalicious(address) ? "green" : "";
00565         } else {
00566             color = "red";
00567         }
00568 
00569         PeerInfo* info = getPeerInfo(address);
00570 
00571         if(info != NULL) {
00572             simulation.getModule(info->getModuleID())
00573             ->getDisplayString().setTagArg("i2", 1, color);
00574         }
00575     }
00576 }

void GlobalNodeList::setPreKilled ( const TransportAddress address  ) 

Mark a node for deletion.

Parameters:
address TransportAddress of the node

Definition at line 477 of file GlobalNodeList.cc.

Referenced by SimpleUnderlayConfigurator::preKillNode().

00478 {
00479     PeerInfo* peer = getPeerInfo(address);
00480 
00481     if ((peer != NULL) && !(peer->isPreKilled())) {
00482         preKilledNodes++;
00483         peer->setPreKilled(true);
00484     }
00485 }


Member Data Documentation

number of bootstrapped malicious nodes in the peer set

Definition at line 281 of file GlobalNodeList.h.

Referenced by getRandomNode(), initialize(), killPeer(), registerPeer(), removePeer(), and setMalicious().

number of bootstrapped peers in the peer set

Definition at line 277 of file GlobalNodeList.h.

Referenced by getBootstrappedPeerSize(), getRandomNode(), initialize(), killPeer(), registerPeer(), and removePeer().

uint32_t GlobalNodeList::bootstrappedPeerSizePerType[MAX_NODETYPES] [protected]

number of bootstrapped peers of all types

Definition at line 278 of file GlobalNodeList.h.

Referenced by getRandomNode(), initialize(), killPeer(), registerPeer(), and removePeer().

bool GlobalNodeList::connectionMatrix[MAX_NODETYPES][MAX_NODETYPES] [private]

matrix specifices with node types (partitions) can communication

Definition at line 296 of file GlobalNodeList.h.

Referenced by areNodeTypesConnected(), connectNodeTypes(), disconnectNodeTypes(), getBootstrapNode(), and initialize().

pointer to GlobalStatistics module in this node

Definition at line 295 of file GlobalNodeList.h.

Referenced by handleMessage(), and initialize().

the keylist

Definition at line 276 of file GlobalNodeList.h.

Referenced by createKeyList(), getKeyList(), getRandomKeyListItem(), and initialize().

double GlobalNodeList::keyProbability [protected]

probability of keys to be owned by nodes

Definition at line 291 of file GlobalNodeList.h.

Referenced by getKeyList(), and initialize().

uint16_t GlobalNodeList::landmarkPeerSize [protected]

Definition at line 279 of file GlobalNodeList.h.

Referenced by getLandmarkPeerSize(), incLandmarkPeerSize(), initialize(), and killPeer().

uint16_t GlobalNodeList::landmarkPeerSizePerType[MAX_NODETYPES] [protected]

Definition at line 280 of file GlobalNodeList.h.

Referenced by incLandmarkPeerSizePerType(), initialize(), and killPeer().

ratio of current malicious nodes when changing the ratio dynamically

Definition at line 284 of file GlobalNodeList.h.

Referenced by addPeer(), handleMessage(), and initialize().

uint32_t GlobalNodeList::maliciousNodes [protected]

number of malicious nodes in the peer set

Definition at line 282 of file GlobalNodeList.h.

Referenced by initialize(), and setMalicious().

cOutVector GlobalNodeList::maliciousNodesVector [protected]

vector that records the cange of malicious node rate

Definition at line 285 of file GlobalNodeList.h.

Referenced by handleMessage(), and initialize().

uint32 GlobalNodeList::max_ip [private]

used for random node choosing

Definition at line 294 of file GlobalNodeList.h.

Referenced by addPeer(), getRandomAliveNode(), getRandomNode(), getRandomPeerInfo(), and initialize().

uint32_t GlobalNodeList::maxNumberOfKeys [protected]

parameter used by createKeyList()

Definition at line 290 of file GlobalNodeList.h.

Referenced by initialize().

uint32 GlobalNodeList::min_ip [private]

uint32_t GlobalNodeList::preKilledNodes [protected]

number of nodes marked for deletion in the peer set

Definition at line 283 of file GlobalNodeList.h.

Referenced by getRandomAliveNode(), initialize(), killPeer(), and setPreKilled().


The documentation for this class was generated from the following files:

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