BootstrapOracle Class Reference

#include <BootstrapOracle.h>

List of all members.


Detailed Description

Global modul that supports bootstrap process and key distribution.

Author:
Markus Mauch, Robert Palmer


Public Types

typedef std::vector< OverlayKeyKeyList

Public Member Functions

virtual const NodeHandlegetBootstrapNode ()
 Returns a random node handle.
virtual void registerPeer (const NodeHandle &peer)
 Adds new peers to the peer set.
virtual void removePeer (const NodeHandle &peer)
 Removes a peer from the peer set.
virtual KeyListgetKeyList (uint maximumKeys)
 Returns a keylist.
virtual const OverlayKeygetRandomKeyListItem () const
 Returns random key from list.

Protected Member Functions

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

Protected Attributes

KeyList keyList
 the keylist
std::set< NodeHandlepeerSet
 Set of nodes participating the overlay.
uint maxNumberOfKeys
 parameter used by createKeyList()
double keyProbability
 probability of keys to be owned by nodes


Member Typedef Documentation

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


Member Function Documentation

void BootstrapOracle::createKeyList ( uint  size  )  [protected, virtual]

Member function to create keylist.

Parameters:
size size of new keylist
00084 {
00085     for(uint i = 0; i < size; i++)
00086         keyList.push_back(OverlayKey::random());
00087 }

const NodeHandle & BootstrapOracle::getBootstrapNode (  )  [virtual]

Returns a random node handle.

Returns a random node handle from the peer set if at least one peer has been registered, and an empty node handle otherwise.

Returns:
bootstrap node
00048 {
00049     if(peerSet.size() == 0)
00050         return NodeHandle::UNSPECIFIED_NODE;
00051     else {
00052         // return random NodeHandle in O(log n)
00053 
00054         //NodeHandle tmpHandle(OverlayKey::random(), IPvXAddress(), 0, 0);
00055         NodeHandle tmpHandle(OverlayKey::random(),
00056                              IPAddress::UNSPECIFIED_ADDRESS, 0, 0);
00057         //std::set<NodeHandle>::iterator it = peerSet.find(tmpHandle);
00058 
00059         //if (it == peerSet.end()) {
00060         //it = peerSet.insert(tmpHandle).first;
00061         std::set
00062             <NodeHandle>::iterator it = peerSet.insert(tmpHandle).first;
00063         peerSet.erase(it++);
00064 
00065         if (it == peerSet.end())
00066             it = peerSet.begin();
00067         //}
00068 
00069         return *it;
00070     }
00071 }

BootstrapOracle::KeyList * BootstrapOracle::getKeyList ( uint  maximumKeys  )  [virtual]

Returns a keylist.

Parameters:
maximumKeys maximum number of keys in new keylist
Returns:
pointer to new keylist
00090 {
00091     // copy keylist to temporary keylist
00092     KeyList tmpKeyList;
00093     tmpKeyList.clear();
00094     for ( uint i=0; i < keyList.size(); i++ )
00095         tmpKeyList.push_back(keyList[i]);
00096 
00097     KeyList* returnList = new KeyList;
00098 
00099     for ( uint i=0; i < ((float)maximumKeys * keyProbability); i++) {
00100         uint index = intuniform(0, tmpKeyList.size()-1);
00101         returnList->push_back(tmpKeyList[index]);
00102         tmpKeyList.erase(tmpKeyList.begin()+index);
00103     }
00104 
00105     return returnList;
00106 }

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

Returns random key from list.

Returns:
the key
00109 {
00110     return keyList[intuniform(0,keyList.size()-1)];
00111 }

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

HandleMessage member function of module.

00043 {
00044     error("this module doesn't handle messages, it runs only in initialize()");
00045 }

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

Init member function of module.

00034 {
00035     maxNumberOfKeys = par("maxNumberOfKeys");
00036     keyProbability = par("keyProbability");
00037     WATCH_SET(peerSet);
00038     WATCH_VECTOR(keyList);
00039     createKeyList(maxNumberOfKeys);
00040 }

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

Adds new peers to the peer set.

Parameters:
peer node to register
00074 {
00075     peerSet.insert(peer);
00076 }

void BootstrapOracle::removePeer ( const NodeHandle peer  )  [virtual]

Removes a peer from the peer set.

Parameters:
peer node to remove
00079 {
00080     peerSet.erase(peer);
00081 }


Member Data Documentation

KeyList BootstrapOracle::keyList [protected]

the keylist

double BootstrapOracle::keyProbability [protected]

probability of keys to be owned by nodes

uint BootstrapOracle::maxNumberOfKeys [protected]

parameter used by createKeyList()

std::set<NodeHandle> BootstrapOracle::peerSet [protected]

Set of nodes participating the overlay.


The documentation for this class was generated from the following files:
Generated on Fri Dec 15 17:50:30 2006 for ITM OverSim by  doxygen 1.4.7