Kademlia Class Reference

#include <Kademlia.h>

Inheritance diagram for Kademlia:

BaseOverlay RpcListener List of all members.

Detailed Description

Kademlia overlay module.

Author:
Sebastian Mies


Public Member Functions

 ~Kademlia ()
void initializeOverlay (int stage)
void finishOverlay ()
void receiveChangeNotification (int category, cPolymorphic *details)
bool isResponsible (const OverlayKey &key)
void handleTimerEvent (cMessage *msg)
void handleUDPMessage (BaseOverlayMessage *msg)
void handleRpc (BaseCallMessage *msg)

Protected Member Functions

NodeVectorfindNode (const OverlayKey &key, BaseOverlayMessage *msg)
void handleRpcResponse (BaseResponseMessage *msg, int rpcId, simtime_t rtt)
 In Kademlia this method is used to maintain the routing table.
void handleRpcTimeout (BaseCallMessage *msg, const NodeHandle &dest, int rpcId)
 In Kademlia this method is used to maintain the routing table.
void handleStabilizeTimerExpired (cMessage *msg)
 handle a expired stabilize timer

Protected Attributes

int k
int b
int s
int keyLength
double stabilizeDelay
cMessage * stabilizeTimer

Private Member Functions

void routingInit ()
void routingDeinit ()
BucketroutingBucket (const NodeHandle &handle, bool ensure)
void routingLearn (const NodeHandle &handle, bool isAlive)
void routingSentMessage (const NodeHandle &handle)
NodeVectorroutingGetClosestNodes (const OverlayKey &key)

Private Attributes

BucketsiblingTable
Bucket ** routingTable
int numBuckets


Constructor & Destructor Documentation

Kademlia::~Kademlia (  ) 

See also:
BaseOverlay.h
00049 {
00050     // deinitialize routing
00051     routingDeinit();
00052 }


Member Function Documentation

NodeVector * Kademlia::findNode ( const OverlayKey key,
BaseOverlayMessage *  msg 
) [protected, virtual]

See also:
BaseOverlay.h

Reimplemented from BaseOverlay.

00144 {
00145     return NULL;
00146 }

void Kademlia::finishOverlay (  )  [virtual]

See also:
BaseOverlay.h

Reimplemented from BaseOverlay.

00055 {
00056     
00057 }

void Kademlia::handleRpc ( BaseCallMessage *  msg  )  [virtual]

See also:
BaseOverlay.h

Reimplemented from BaseOverlay.

00139 {
00140 }

void Kademlia::handleRpcResponse ( BaseResponseMessage *  msg,
int  rpcId,
simtime_t  rtt 
) [protected, virtual]

In Kademlia this method is used to maintain the routing table.

See also:
BaseOverlay.h

Reimplemented from RpcListener.

00150 {
00151 }

void Kademlia::handleRpcTimeout ( BaseCallMessage *  msg,
const NodeHandle dest,
int  rpcId 
) [protected, virtual]

In Kademlia this method is used to maintain the routing table.

See also:
BaseOverlay.h

Reimplemented from RpcListener.

00155 {
00156 }

void Kademlia::handleStabilizeTimerExpired ( cMessage *  msg  )  [protected]

handle a expired stabilize timer

Parameters:
msg the timer self-message
00160 {
00161 }

void Kademlia::handleTimerEvent ( cMessage *  msg  )  [virtual]

See also:
BaseOverlay.h

Reimplemented from BaseOverlay.

00131 {
00132 }

void Kademlia::handleUDPMessage ( BaseOverlayMessage *  msg  )  [virtual]

See also:
BaseOverlay.h

Implements BaseOverlay.

00135 {
00136 }

void Kademlia::initializeOverlay ( int  stage  )  [virtual]

See also:
BaseOverlay.h

Reimplemented from BaseOverlay.

00032 {
00033     if(stage != MIN_STAGE_OVERLAY) return;
00034 
00035     // setup kademlia parameters
00036     this->stabilizeDelay = par("stabilizeDelay");
00037     this->k = par("k"); 
00038     this->b = par("b"); 
00039     this->s = par("s");
00040 
00041     // initialize routing
00042     routingInit();
00043     
00044     // self-messages
00045     stabilizeTimer = new cMessage("stabilize_timer");
00046 }

bool Kademlia::isResponsible ( const OverlayKey key  )  [virtual]

See also:
BaseOverlay.h

Reimplemented from BaseOverlay.

00126 {
00127     return false;
00128 }

void Kademlia::receiveChangeNotification ( int  category,
cPolymorphic *  details 
)

See also:
BaseOverlay.h
00122 {
00123 }

Bucket * Kademlia::routingBucket ( const NodeHandle handle,
bool  ensure 
) [private]

00102 {
00103     return NULL;
00104 }

void Kademlia::routingDeinit (  )  [private]

00078 {
00079     // clear routing table
00080     if (this->routingTable != NULL) {
00081 
00082         // delete buckets
00083         for (int i=0; i<this->numBuckets; i++) 
00084             if ( this->routingTable[i] != NULL ) {
00085                 delete this->routingTable[i];
00086                 this->routingTable[i] = NULL;
00087             }
00088 
00089         // delete routing table
00090         delete [] this->routingTable;
00091         this->routingTable = NULL;
00092     }
00093 
00094     // clear sibling table
00095     if (this->siblingTable != NULL) {
00096         delete this->siblingTable;
00097         this->siblingTable = NULL;
00098     }
00099 }

NodeVector * Kademlia::routingGetClosestNodes ( const OverlayKey key  )  [private]

00115 {
00116     return NULL;
00117 }

void Kademlia::routingInit (  )  [private]

00062 {
00063     // set key length
00064     this->keyLength = OverlayKey::getLength();
00065 
00066     // calculate number of buckets
00067     this->numBuckets = ( (1L << b) - 1L ) * ( keyLength / b );
00068 
00069     // init routing and sibling table
00070     this->routingTable = new Bucket*[ this->numBuckets ];
00071     this->siblingTable = new Bucket ( s * 5 );
00072 
00073     // initialize pointers
00074     for (int i=0; i<this->numBuckets; i++) this->routingTable[i] = NULL;
00075 }

void Kademlia::routingLearn ( const NodeHandle handle,
bool  isAlive 
) [private]

00107 {
00108 }

void Kademlia::routingSentMessage ( const NodeHandle handle  )  [private]

00111 {
00112 }


Member Data Documentation

int Kademlia::b [protected]

int Kademlia::k [protected]

int Kademlia::keyLength [protected]

int Kademlia::numBuckets [private]

Bucket** Kademlia::routingTable [private]

int Kademlia::s [protected]

Bucket* Kademlia::siblingTable [private]

double Kademlia::stabilizeDelay [protected]

cMessage* Kademlia::stabilizeTimer [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:06 2007 for ITM OverSim by  doxygen 1.4.7