#include <Kademlia.h>
Inheritance diagram for Kademlia:
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 | |
NodeVector * | findNode (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 () |
Bucket * | routingBucket (const NodeHandle &handle, bool ensure) |
void | routingLearn (const NodeHandle &handle, bool isAlive) |
void | routingSentMessage (const NodeHandle &handle) |
NodeVector * | routingGetClosestNodes (const OverlayKey &key) |
Private Attributes | |
Bucket * | siblingTable |
Bucket ** | routingTable |
int | numBuckets |
Kademlia::~Kademlia | ( | ) |
NodeVector * Kademlia::findNode | ( | const OverlayKey & | key, | |
BaseOverlayMessage * | msg | |||
) | [protected, virtual] |
void Kademlia::finishOverlay | ( | ) | [virtual] |
void Kademlia::handleRpc | ( | BaseCallMessage * | msg | ) | [virtual] |
void Kademlia::handleRpcResponse | ( | BaseResponseMessage * | msg, | |
int | rpcId, | |||
simtime_t | rtt | |||
) | [protected, virtual] |
In Kademlia this method is used to maintain the routing table.
Reimplemented from RpcListener.
void Kademlia::handleRpcTimeout | ( | BaseCallMessage * | msg, | |
const NodeHandle & | dest, | |||
int | rpcId | |||
) | [protected, virtual] |
In Kademlia this method is used to maintain the routing table.
Reimplemented from RpcListener.
void Kademlia::handleStabilizeTimerExpired | ( | cMessage * | msg | ) | [protected] |
void Kademlia::handleTimerEvent | ( | cMessage * | msg | ) | [virtual] |
void Kademlia::handleUDPMessage | ( | BaseOverlayMessage * | msg | ) | [virtual] |
void Kademlia::initializeOverlay | ( | int | stage | ) | [virtual] |
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] |
void Kademlia::receiveChangeNotification | ( | int | category, | |
cPolymorphic * | details | |||
) |
Bucket * Kademlia::routingBucket | ( | const NodeHandle & | handle, | |
bool | ensure | |||
) | [private] |
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] |
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] |
void Kademlia::routingSentMessage | ( | const NodeHandle & | handle | ) | [private] |
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] |