GlobalNodeList Class Reference

#include <GlobalNodeList.h>

List of all members.


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.


Public Types

typedef std::vector< OverlayKey > KeyList
 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 NodeHandle & getRandomNode (uint32_t nodeType=0, bool bootstrappedNeeded=true)
 Returns a random NodeHandle.
virtual const NodeHandle & getBootstrapNode (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 removePeer (const TransportAddress &peer)
 Debootstraps peers in the peer set.
virtual KeyList * getKeyList (uint32_t maximumKeys)
 Returns a keylist.
virtual const OverlayKey & getRandomKeyListItem () 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 PeerInfo * getPeerInfo (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.
TransportAddress * getRandomAliveNode (uint32_t nodeType=0)
 Selects a random node from the peerSet, which is not already marked for deletion.
virtual PeerInfo * getRandomPeerInfo (uint32_t nodeType=0, bool bootstrapNeeded=false)
 Selects a random node from the peerSet.
virtual PeerInfo * getPeerInfo (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)

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
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
GlobalStatistics * globalStatistics
 pointer to GlobalStatistics module in this node
bool connectionMatrix [MAX_NODETYPES][MAX_NODETYPES]
 matrix specifices with node types (partitions) can communication

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 270 of file GlobalNodeList.h.


Constructor & Destructor Documentation

GlobalNodeList::~GlobalNodeList (  ) 

Destructor.

Definition at line 582 of file GlobalNodeList.cc.

00583 {
00584     PeerHashMap::iterator it;
00585     for(it = peerSet.begin(); it != peerSet.end(); ++it) {
00586         delete it->second.node;
00587         delete it->second.info;
00588     }
00589 }


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 232 of file GlobalNodeList.cc.

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

00233 {
00234     bootstrapEntry temp;
00235     temp.node = new TransportAddress(ip);
00236     temp.info = info;
00237     temp.info->setPreKilled(false);
00238 
00239     peerSet.insert(std::make_pair(temp.node->ip, temp));
00240     // set bounds for random node retrieval
00241     if (ip.get4().getInt() < min_ip) min_ip = ip.get4().getInt();
00242     if (ip.get4().getInt() > max_ip) max_ip = ip.get4().getInt();
00243 
00244     if (uniform(0, 1) < (double) par("maliciousNodeProbability") ||
00245             (par("maliciousNodeChange") && uniform(0, 1) < maliciousNodeRatio)) {
00246         setMalicious(*temp.node, true);
00247     }
00248 }

void GlobalNodeList::sendNotificationToAllPeers ( int  category  ) 

Sends a NotificationBoard message to all registered peers.

Parameters:
category Type of notification

Definition at line 220 of file GlobalNodeList.cc.

00221 {
00222     PeerHashMap::iterator it;
00223     for (it = peerSet.begin(); it != peerSet.end(); it++) {
00224         NotificationBoard* nb = check_and_cast<NotificationBoard*>(
00225                 simulation.getModule(it->second.info->getModuleID())
00226                 ->getSubmodule("notificationBoard"));
00227 
00228         nb->fireChangeNotification(category);
00229     }
00230 }

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 319 of file GlobalNodeList.cc.

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

00320 {
00321     PeerHashMap::iterator it = peerSet.find(ip);
00322     if(it != peerSet.end()) {
00323         if(it->second.info->isBootstrapped()) {
00324             bootstrappedPeerSize--;
00325             bootstrappedPeerSizePerType[it->second.info->getTypeID()]--;
00326 
00327             if(it->second.info->isMalicious())
00328                 bootstrappedMaliciousNodes--;
00329 
00330             it->second.info->setBootstrapped(false);
00331         }
00332 
00333         if (it->second.info->isPreKilled()) {
00334             it->second.info->setPreKilled(false);
00335             preKilledNodes--;
00336         }
00337 
00338         delete it->second.node;
00339         delete it->second.info;
00340         peerSet.erase(it);
00341     }
00342 }

const NodeHandle & GlobalNodeList::getRandomNode ( uint32_t  nodeType = 0,
bool  bootstrappedNeeded = true 
) [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?
Returns:
NodeHandle of the node

Definition at line 184 of file GlobalNodeList.cc.

Referenced by getBootstrapNode(), handleMessage(), and mergeBootstrapNodes().

00185 {
00186     if (peerSet.size() == 0)
00187         return NodeHandle::UNSPECIFIED_NODE;
00188     if (bootstrappedNeeded && bootstrappedPeerSize == 0)
00189         return NodeHandle::UNSPECIFIED_NODE;
00190     if (nodeType && bootstrappedPeerSizePerType[nodeType] == 0)
00191         return NodeHandle::UNSPECIFIED_NODE;
00192     else {
00193         // return random TransportAddress in O(log n)
00194         PeerHashMap::iterator it = peerSet.end();
00195         bootstrapEntry tempEntry = {NULL, NULL};
00196 
00197         while(it == peerSet.end() ||(nodeType && (it->second.info->getTypeID() != nodeType))
00198                 || (bootstrappedNeeded && !it->second.info->isBootstrapped())) {
00199             IPvXAddress randomAddr(intuniform(min_ip, max_ip));
00200 
00201             it = peerSet.find(randomAddr);
00202 
00203             if (it == peerSet.end()) {
00204                 it = peerSet.insert(std::make_pair(randomAddr,tempEntry)).first;
00205                 peerSet.erase(it++);
00206             }
00207 
00208             if (it == peerSet.end())
00209                 it = peerSet.begin();
00210         }
00211 
00212         if (dynamic_cast<NodeHandle*>(it->second.node)) {
00213             return *dynamic_cast<NodeHandle*>(it->second.node);
00214         } else {
00215             return NodeHandle::UNSPECIFIED_NODE;
00216         }
00217     }
00218 }

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 145 of file GlobalNodeList.cc.

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

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

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

Bootstraps peers in the peer set.

Parameters:
peer node to register

Definition at line 250 of file GlobalNodeList.cc.

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

00251 {
00252     PeerHashMap::iterator it = peerSet.find(peer.ip);
00253     if (it == peerSet.end())
00254         error("unable to bootstrap peer, peer is not in peer set");
00255     else {
00256         PeerInfo* info = it->second.info;
00257 
00258         if (!info->isBootstrapped()) {
00259             bootstrappedPeerSize++;
00260             bootstrappedPeerSizePerType[info->getTypeID()]++;
00261             info->setBootstrapped();
00262 
00263             if (info->isMalicious())
00264                 bootstrappedMaliciousNodes++;
00265         }
00266 
00267         delete it->second.node;
00268         peerSet.erase(it);
00269 
00270         bootstrapEntry temp;
00271         temp.node = new TransportAddress(peer);
00272         temp.info = info;
00273         peerSet.insert(std::make_pair(temp.node->ip, temp));
00274     }
00275 }

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

Bootstraps peers in the peer set.

Parameters:
peer node to register

Definition at line 277 of file GlobalNodeList.cc.

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

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

Debootstraps peers in the peer set.

Parameters:
peer node to remove

Definition at line 304 of file GlobalNodeList.cc.

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

00305 {
00306     PeerHashMap::iterator it = peerSet.find(peer.ip);
00307     if(it != peerSet.end() && it->second.info->isBootstrapped()) {
00308         bootstrappedPeerSize--;
00309         bootstrappedPeerSizePerType[it->second.info->getTypeID()]--;
00310         it->second.info->setBootstrapped(false);
00311 
00312         if(it->second.info->isMalicious())
00313             bootstrappedMaliciousNodes--;
00314 
00315         it->second.info->setBootstrapped(false);
00316     }
00317 }

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 350 of file GlobalNodeList.cc.

Referenced by GIASearchApp::handleTimerEvent().

00351 {
00352     if (maximumKeys > keyList.size()) {
00353         maximumKeys = keyList.size();
00354     }
00355     // copy keylist to temporary keylist
00356     KeyList tmpKeyList;
00357     tmpKeyList.clear();
00358 
00359     for (uint32_t i=0; i < keyList.size(); i++) {
00360         tmpKeyList.push_back(keyList[i]);
00361     }
00362 
00363     KeyList* returnList = new KeyList;
00364 
00365     for (uint32_t i=0; i < ((float)maximumKeys * keyProbability); i++) {
00366         uint32_t index = intuniform(0, tmpKeyList.size()-1);
00367 
00368         returnList->push_back(tmpKeyList[index]);
00369         tmpKeyList.erase(tmpKeyList.begin()+index);
00370     }
00371 
00372     return returnList;
00373 }

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

Returns random key from list.

Returns:
the key

Definition at line 375 of file GlobalNodeList.cc.

Referenced by GIASearchApp::handleTimerEvent().

00376 {
00377     return keyList[intuniform(0,keyList.size()-1)];
00378 }

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 508 of file GlobalNodeList.cc.

Referenced by BaseOverlay::setOverlayReady().

00510 {
00511     if (ev.isGUI()) {
00512         const char* color;
00513 
00514         if (ready) {
00515             // change color if node is malicious
00516             color = isMalicious(address) ? "green" : "";
00517         } else {
00518             color = "red";
00519         }
00520 
00521         PeerInfo* info = getPeerInfo(address);
00522 
00523         if(info != NULL) {
00524             simulation.getModule(info->getModuleID())
00525             ->getDisplayString().setTagArg("i2", 1, color);
00526         }
00527     }
00528 }

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 380 of file GlobalNodeList.cc.

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

00381 {
00382     PeerHashMap::iterator it = peerSet.find(peer.ip);
00383 
00384     if (it == peerSet.end())
00385         return NULL;
00386     else
00387         return it->second.info;
00388 }

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 476 of file GlobalNodeList.cc.

Referenced by addPeer(), and handleMessage().

00477 {
00478     PeerInfo* peer = getPeerInfo(address);
00479 
00480     if (peer != NULL) {
00481         if(malicious && !peer->isMalicious()) {
00482             maliciousNodes++;
00483             if (peer->isBootstrapped()) {
00484                 bootstrappedMaliciousNodes++;
00485             }
00486         }
00487 
00488         if (!malicious && peer->isMalicious()) {
00489             maliciousNodes--;
00490             if (peer->isBootstrapped()) {
00491                 bootstrappedMaliciousNodes--;
00492             }
00493         }
00494         peer->setMalicious(malicious);
00495     }
00496 }

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 498 of file GlobalNodeList.cc.

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

00499 {
00500     PeerInfo* peer = getPeerInfo(address);
00501 
00502     if(peer != NULL)
00503         return peer->isMalicious();
00504 
00505     return false;
00506 }

void GlobalNodeList::setPreKilled ( const TransportAddress &  address  ) 

Mark a node for deletion.

Parameters:
address TransportAddress of the node

Definition at line 429 of file GlobalNodeList.cc.

Referenced by SimpleUnderlayConfigurator::preKillNode().

00430 {
00431     PeerInfo* peer = getPeerInfo(address);
00432 
00433     if ((peer != NULL) && !(peer->isPreKilled())) {
00434         preKilledNodes++;
00435         peer->setPreKilled(true);
00436     }
00437 }

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 439 of file GlobalNodeList.cc.

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

00440 {
00441     if (peerSet.size() <= preKilledNodes) {
00442         // all nodes are already marked for deletion;
00443         return NULL;
00444     } else {
00445         // return random address in O(log n)
00446         PeerHashMap::iterator it;
00447         bootstrapEntry tempEntry = {NULL, NULL};
00448 
00449         IPvXAddress randomAddr(intuniform(min_ip, max_ip));
00450 
00451         it = peerSet.find(randomAddr);
00452 
00453         if (it == peerSet.end()) {
00454             it = peerSet.insert(std::make_pair(randomAddr,tempEntry)).first;
00455             peerSet.erase(it++);
00456         }
00457 
00458         if (it == peerSet.end()) {
00459             it = peerSet.begin();
00460         }
00461 
00462         while ((nodeType && (it->second.info->getTypeID() != nodeType))
00463                || it->second.info->isPreKilled()) {
00464             it++;
00465             if (it == peerSet.end()) {
00466                 it = peerSet.begin();
00467             }
00468         }
00469 
00470         return it->second.node;
00471     }
00472 
00473     return NULL;
00474 }

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 400 of file GlobalNodeList.cc.

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

00401                                                                       {
00402     // return random TransportAddress in O(log n)
00403     PeerHashMap::iterator it;
00404     bootstrapEntry tempEntry = {NULL, NULL};
00405 
00406     IPvXAddress randomAddr(intuniform(min_ip, max_ip));
00407 
00408     it = peerSet.find(randomAddr);
00409     if (it == peerSet.end()) {
00410         it = peerSet.insert(std::make_pair(randomAddr,tempEntry)).first;
00411         peerSet.erase(it++);
00412     }
00413 
00414     if (it == peerSet.end())
00415         it = peerSet.begin();
00416 
00417     // if nodeType != 0, search for next node with the given type
00418     if (nodeType) {
00419         while((nodeType && (it->second.info->getTypeID() != nodeType))
00420               || (bootstrappedNeeded && !it->second.info->isBootstrapped())) {
00421             ++it;
00422             if (it == peerSet.end()) it = peerSet.begin();
00423         }
00424     }
00425 
00426     return it->second.info;
00427 }

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 390 of file GlobalNodeList.cc.

00391 {
00392     PeerHashMap::iterator it = peerSet.find(ip);
00393 
00394     if (it == peerSet.end())
00395         return NULL;
00396     else
00397         return it->second.info;
00398 }

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

Definition at line 530 of file GlobalNodeList.cc.

Referenced by SimpleUDP::processMsgFromApp().

00531 {
00532     if ((a > MAX_NODETYPES) || (b > MAX_NODETYPES)) {
00533         throw cRuntimeError("GlobalNodeList::areNodeTypesConnected(): nodeType "
00534               "bigger then MAX_NODETYPES");
00535     }
00536 
00537     return connectionMatrix[a][b];
00538 }

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

Definition at line 540 of file GlobalNodeList.cc.

Referenced by GlobalTraceManager::handleMessage().

00541 {
00542     if ((a > MAX_NODETYPES) || (b > MAX_NODETYPES)) {
00543         throw cRuntimeError("GlobalNodeList::connectNodeTypes(): nodeType "
00544               "bigger then MAX_NODETYPES");
00545     }
00546 
00547     connectionMatrix[a][b]=true;
00548 
00549     EV << "[GlobalNodeList::connectNodeTypes()]\n"
00550        << "    Connecting " << a << "->" << b
00551        << endl;
00552 
00553 }

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

Definition at line 555 of file GlobalNodeList.cc.

Referenced by GlobalTraceManager::handleMessage().

00556 {
00557     if ((a > MAX_NODETYPES) || (b > MAX_NODETYPES)) {
00558         throw cRuntimeError("GlobalNodeList::disconnectNodeTypes(): nodeType "
00559               "bigger then MAX_NODETYPES");
00560     }
00561 
00562     connectionMatrix[a][b]=false;
00563 
00564     EV << "[GlobalNodeList::disconnectNodeTypes()]\n"
00565        << "    Disconnecting " << a << "->" << b
00566        << endl;
00567 
00568 }

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

Definition at line 570 of file GlobalNodeList.cc.

Referenced by GlobalTraceManager::handleMessage().

00572 {
00573     BootstrapList* bootstrapList =
00574         check_and_cast<BootstrapList*>(simulation.getModule(
00575             getRandomPeerInfo(toPartition, false)->getModuleID())->
00576             getSubmodule("bootstrapList"));
00577 
00578     bootstrapList->insertBootstrapCandidate(getRandomNode(fromPartition, true),
00579                                        DNSSD);
00580 }

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

Init member function of module.

Definition at line 60 of file GlobalNodeList.cc.

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

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

HandleMessage member function of module.

Parameters:
msg messag to handle

Definition at line 104 of file GlobalNodeList.cc.

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

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

Member function to create keylist.

Parameters:
size size of new keylist

Definition at line 344 of file GlobalNodeList.cc.

Referenced by initialize().

00345 {
00346     for (uint32_t i = 0; i < size; i++)
00347         keyList.push_back(OverlayKey::random());
00348 }


Member Data Documentation

the keylist

Definition at line 262 of file GlobalNodeList.h.

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

number of bootstrapped peers in the peer set

Definition at line 263 of file GlobalNodeList.h.

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

uint32_t GlobalNodeList::bootstrappedPeerSizePerType[MAX_NODETYPES] [protected]

number of bootstrapped peers of all types

Definition at line 264 of file GlobalNodeList.h.

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

number of bootstrapped malicious nodes in the peer set

Definition at line 265 of file GlobalNodeList.h.

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

uint32_t GlobalNodeList::maliciousNodes [protected]

number of malicious nodes in the peer set

Definition at line 266 of file GlobalNodeList.h.

Referenced by initialize(), and setMalicious().

uint32_t GlobalNodeList::preKilledNodes [protected]

number of nodes marked for deletion in the peer set

Definition at line 267 of file GlobalNodeList.h.

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

ratio of current malicious nodes when changing the ratio dynamically

Definition at line 268 of file GlobalNodeList.h.

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

cOutVector GlobalNodeList::maliciousNodesVector [protected]

vector that records the cange of malicious node rate

Definition at line 269 of file GlobalNodeList.h.

Referenced by handleMessage(), and initialize().

uint32_t GlobalNodeList::maxNumberOfKeys [protected]

parameter used by createKeyList()

Definition at line 274 of file GlobalNodeList.h.

Referenced by initialize().

double GlobalNodeList::keyProbability [protected]

probability of keys to be owned by nodes

Definition at line 275 of file GlobalNodeList.h.

Referenced by getKeyList(), and initialize().

uint32 GlobalNodeList::min_ip [private]

uint32 GlobalNodeList::max_ip [private]

used for random node choosing

Definition at line 278 of file GlobalNodeList.h.

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

pointer to GlobalStatistics module in this node

Definition at line 279 of file GlobalNodeList.h.

Referenced by handleMessage(), and initialize().

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

matrix specifices with node types (partitions) can communication

Definition at line 280 of file GlobalNodeList.h.

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


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

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