OverSim
|
This class implements a basic greedy lookup strategy. More...
#include <IterativeLookup.h>
Classes | |
class | RpcInfo |
class | RpcInfoVector |
Public Member Functions | |
virtual int | compare (const OverlayKey &lhs, const OverlayKey &rhs) const |
compares two OverlayKeys and indicates which one is closer to the key to look up | |
IterativeLookup (BaseOverlay *overlay, RoutingType routingType, const IterativeLookupConfiguration &config, const cPacket *findNodeExt=NULL, bool appLookup=false) | |
virtual | ~IterativeLookup () |
void | lookup (const OverlayKey &key, int numSiblings=1, int hopCountMax=0, int retries=0, LookupListener *listener=NULL) |
Lookup siblings for a key. | |
const NodeVector & | getResult () const |
Returns the result of the lookup. | |
bool | isValid () const |
Returns true, if the lookup was successful. | |
void | abortLookup () |
Aborts a running lookup. | |
uint32_t | getAccumulatedHops () const |
Returns the total number of hops for all lookup paths. | |
Public Member Functions inherited from RpcListener | |
virtual | ~RpcListener () |
destructor | |
Public Member Functions inherited from AbstractLookup | |
virtual | ~AbstractLookup () |
Virtual destructor. | |
Public Member Functions inherited from Comparator< OverlayKey > | |
virtual | ~Comparator () |
virtual destructor |
Protected Types | |
typedef std::map< int, int > | PendingPings |
typedef std::set< NodeHandle > | MajoritySiblings |
typedef UNORDERED_MAP < TransportAddress, RpcInfoVector, TransportAddress::hashFcn > | RpcInfoMap |
Protected Member Functions | |
virtual IterativePathLookup * | createPathLookup () |
This method creates a new path lookup. | |
virtual FindNodeCall * | createFindNodeCall (cPacket *findNodeExt=NULL) |
Creates a find node call message. | |
bool | addSibling (const NodeHandle &handle, bool assured=false) |
adds a node to the siblings NodeVector | |
void | setVisited (const TransportAddress &addr, bool visitedFlag=true) |
adds/deletes visited nodes to/from the visited TransportAddress::Set | |
bool | getVisited (const TransportAddress &addr) |
indicates if the specified node has been visited before | |
void | setPinged (const TransportAddress &addr) |
marks a node as already pinged for authentication | |
bool | getPinged (const TransportAddress &addr) |
verify if this node has already been pinged for authentication | |
void | setDead (const TransportAddress &addr) |
add a dead node to the dead node list | |
bool | getDead (const TransportAddress &addr) |
check if a node seems to be dead | |
virtual void | handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt) |
This method is called if an RPC response has been received. | |
virtual void | handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY) |
This method is called if an RPC timeout has been reached. | |
void | sendRpc (const NodeHandle &handle, FindNodeCall *call, IterativePathLookup *listener, int rpcId) |
virtual void | start () |
void | stop () |
void | checkStop () |
Protected Member Functions inherited from RpcListener | |
virtual void | handleRpcResponse (BaseResponseMessage *msg, const RpcState &rpcState, simtime_t rtt) |
This method is called if an RPC response has been received. | |
virtual void | handleRpcTimeout (const RpcState &rpcState) |
This method is called if an RPC timeout has been reached. |
Protected Attributes | |
OverlayKey | key |
key to lookup | |
BaseOverlay * | overlay |
ptr to overlay | |
LookupListener * | listener |
lookup listener | |
std::vector < IterativePathLookup * > | paths |
parallel paths | |
RoutingType | routingType |
RoutingType for this lookup. | |
IterativeLookupConfiguration | config |
lookup configuration | |
cPacket * | firstCallExt |
additional info for first findNode() | |
uint32_t | finishedPaths |
number of finished paths | |
uint32_t | successfulPaths |
number of successful paths | |
uint32_t | accumulatedHops |
total number of hops (for all paths) | |
bool | finished |
true, if lookup is finished | |
bool | success |
true, if lookup was successful | |
bool | running |
true, if lookup is running | |
int | retries |
number of retries, if lookup fails | |
bool | appLookup |
SimTime | startTime |
time at which the lookup was started | |
NodeVector | siblings |
closest nodes | |
TransportAddress::Set | visited |
nodes already visited | |
TransportAddress::Set | dead |
nodes which seem to be dead | |
TransportAddress::Set | pinged |
nodes already pinged | |
MajoritySiblings | majoritySiblings |
map for majority decision on correct siblings | |
int | numSiblings |
number of siblings | |
int | hopCountMax |
maximum hop count | |
PendingPings | pendingPings |
number of pending ping calls | |
RpcInfoMap | rpcs |
Friends | |
class | IterativePathLookup |
class | BaseOverlay |
This class implements a basic greedy lookup strategy.
It uses the standard metric for greedy behaviour. If another metric is needed, the distance function can be replaced by overriding the distance method.
Definition at line 81 of file IterativeLookup.h.
|
protected |
Definition at line 154 of file IterativeLookup.h.
|
protected |
Definition at line 153 of file IterativeLookup.h.
|
protected |
Definition at line 237 of file IterativeLookup.h.
IterativeLookup::IterativeLookup | ( | BaseOverlay * | overlay, |
RoutingType | routingType, | ||
const IterativeLookupConfiguration & | config, | ||
const cPacket * | findNodeExt = NULL , |
||
bool | appLookup = false |
||
) |
Definition at line 69 of file IterativeLookup.cc.
|
virtual |
Definition at line 111 of file IterativeLookup.cc.
|
virtual |
Aborts a running lookup.
This method aborts a running lookup without calling the listener and delete the lookup object.
Implements AbstractLookup.
Definition at line 118 of file IterativeLookup.cc.
|
protected |
adds a node to the siblings NodeVector
handle | NodeHandle of the node to add |
assured | true, if this node was already authenticated |
Definition at line 416 of file IterativeLookup.cc.
Referenced by IterativePathLookup::handleResponse(), handleRpcResponse(), IterativePathLookup::sendRpc(), and start().
|
protected |
Definition at line 289 of file IterativeLookup.cc.
Referenced by handleRpcResponse(), handleRpcTimeout(), and start().
|
virtual |
compares two OverlayKeys and indicates which one is closer to the key to look up
lhs | the first OverlayKey |
rhs | the second OverlayKey |
Reimplemented from Comparator< OverlayKey >.
Definition at line 404 of file IterativeLookup.cc.
|
protectedvirtual |
Creates a find node call message.
This method can be overridden to add some additional state information to the FindNodeCall message.
findNodeExt | Pointer to a optional cMessage, that may contain overlay specific data to be attached to FindNode RPCs and BaseRouteMessages |
Definition at line 366 of file IterativeLookup.cc.
Referenced by IterativePathLookup::sendRpc(), and start().
|
protectedvirtual |
This method creates a new path lookup.
It may be overloaded to enhance IterativePathLookup with some new information/features.
Definition at line 361 of file IterativeLookup.cc.
|
virtual |
Returns the total number of hops for all lookup paths.
Implements AbstractLookup.
Definition at line 730 of file IterativeLookup.cc.
|
protected |
check if a node seems to be dead
addr | TransportAddress of the node |
Definition at line 479 of file IterativeLookup.cc.
Referenced by IterativePathLookup::handleTimeout(), and IterativePathLookup::sendRpc().
|
protected |
verify if this node has already been pinged for authentication
addr | TransportAddress of the node |
Definition at line 489 of file IterativeLookup.cc.
Referenced by addSibling().
|
virtual |
Returns the result of the lookup.
Implements AbstractLookup.
Definition at line 719 of file IterativeLookup.cc.
|
protected |
indicates if the specified node has been visited before
addr | TransportAddress of the node |
Definition at line 469 of file IterativeLookup.cc.
Referenced by addSibling(), and IterativePathLookup::sendRpc().
|
protectedvirtual |
This method is called if an RPC response has been received.
msg | The response message. |
context | Pointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code |
rpcId | The RPC id. |
rtt | The Round-Trip-Time of this RPC |
Reimplemented from RpcListener.
Definition at line 498 of file IterativeLookup.cc.
|
protectedvirtual |
This method is called if an RPC timeout has been reached.
msg | The original RPC message. |
dest | The destination node |
context | Pointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code |
rpcId | The RPC id. |
destKey | the destination OverlayKey |
Reimplemented from RpcListener.
Definition at line 596 of file IterativeLookup.cc.
|
virtual |
Returns true, if the lookup was successful.
Implements AbstractLookup.
Definition at line 725 of file IterativeLookup.cc.
Referenced by stop().
|
virtual |
Lookup siblings for a key.
key | The key to lookup |
numSiblings | Number of siblings to lookup |
hopCountMax | Maximum hop count |
retries | Number of retries if lookup fails |
listener | Listener to inform, when the lookup is done |
Implements AbstractLookup.
Definition at line 689 of file IterativeLookup.cc.
|
protected |
Definition at line 650 of file IterativeLookup.cc.
Referenced by IterativePathLookup::sendRpc().
|
protected |
add a dead node to the dead node list
addr | TransportAddress of the node to add |
Definition at line 474 of file IterativeLookup.cc.
Referenced by handleRpcTimeout().
|
protected |
marks a node as already pinged for authentication
addr | TransportAddress of the node to mark as already pinged |
Definition at line 484 of file IterativeLookup.cc.
Referenced by addSibling().
|
protected |
adds/deletes visited nodes to/from the visited TransportAddress::Set
addr | TransportAddress of the node to add |
visitedFlag | if true node is added, else node is erased |
Definition at line 461 of file IterativeLookup.cc.
Referenced by IterativePathLookup::handleFailedNodeResponse(), IterativePathLookup::handleResponse(), and start().
|
protectedvirtual |
Definition at line 131 of file IterativeLookup.cc.
Referenced by checkStop(), and lookup().
|
protected |
Definition at line 240 of file IterativeLookup.cc.
Referenced by checkStop(), and ~IterativeLookup().
|
friend |
Definition at line 86 of file IterativeLookup.h.
|
friend |
Definition at line 85 of file IterativeLookup.h.
Referenced by createPathLookup(), and start().
|
protected |
total number of hops (for all paths)
Definition at line 123 of file IterativeLookup.h.
Referenced by getAccumulatedHops(), handleRpcResponse(), handleRpcTimeout(), and start().
|
protected |
Definition at line 128 of file IterativeLookup.h.
Referenced by createFindNodeCall().
|
protected |
lookup configuration
Definition at line 119 of file IterativeLookup.h.
Referenced by IterativePathLookup::accepts(), IterativePathLookup::add(), addSibling(), checkStop(), createFindNodeCall(), IterativePathLookup::handleResponse(), handleRpcResponse(), IterativePathLookup::handleTimeout(), IterativePathLookup::IterativePathLookup(), lookup(), IterativePathLookup::sendNewRpcAfterTimeout(), IterativePathLookup::sendRpc(), and start().
|
protected |
nodes which seem to be dead
Definition at line 151 of file IterativeLookup.h.
|
protected |
true, if lookup is finished
Definition at line 124 of file IterativeLookup.h.
Referenced by handleRpcResponse(), handleRpcTimeout(), isValid(), lookup(), sendRpc(), start(), and stop().
|
protected |
number of finished paths
Definition at line 121 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), handleRpcTimeout(), start(), and stop().
|
protected |
additional info for first findNode()
Definition at line 120 of file IterativeLookup.h.
Referenced by IterativeLookup(), start(), and ~IterativeLookup().
|
protected |
maximum hop count
Definition at line 157 of file IterativeLookup.h.
Referenced by lookup(), and IterativePathLookup::sendRpc().
|
protected |
key to lookup
Definition at line 114 of file IterativeLookup.h.
Referenced by addSibling(), compare(), createFindNodeCall(), IterativePathLookup::handleResponse(), lookup(), and start().
|
protected |
lookup listener
Definition at line 116 of file IterativeLookup.h.
Referenced by abortLookup(), checkStop(), lookup(), sendRpc(), and stop().
|
protected |
map for majority decision on correct siblings
Definition at line 155 of file IterativeLookup.h.
Referenced by addSibling(), and checkStop().
|
protected |
number of siblings
Definition at line 156 of file IterativeLookup.h.
Referenced by addSibling(), checkStop(), createFindNodeCall(), IterativePathLookup::handleResponse(), IterativePathLookup::handleTimeout(), lookup(), and start().
|
protected |
ptr to overlay
Definition at line 115 of file IterativeLookup.h.
Referenced by abortLookup(), addSibling(), checkStop(), compare(), IterativePathLookup::handleResponse(), IterativePathLookup::handleTimeout(), IterativePathLookup::IterativePathLookup(), lookup(), sendRpc(), start(), stop(), and ~IterativeLookup().
|
protected |
parallel paths
Definition at line 117 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), start(), and stop().
|
protected |
number of pending ping calls
Definition at line 158 of file IterativeLookup.h.
Referenced by addSibling(), checkStop(), handleRpcResponse(), handleRpcTimeout(), and stop().
|
protected |
nodes already pinged
Definition at line 152 of file IterativeLookup.h.
Referenced by getPinged(), setPinged(), and start().
|
protected |
number of retries, if lookup fails
Definition at line 127 of file IterativeLookup.h.
Referenced by checkStop(), and lookup().
|
protected |
RoutingType for this lookup.
Definition at line 118 of file IterativeLookup.h.
Referenced by createFindNodeCall(), IterativePathLookup::handleResponse(), handleRpcResponse(), IterativePathLookup::handleTimeout(), IterativePathLookup::IterativePathLookup(), lookup(), IterativePathLookup::sendRpc(), and start().
|
protected |
Definition at line 238 of file IterativeLookup.h.
Referenced by abortLookup(), checkStop(), handleRpcResponse(), handleRpcTimeout(), sendRpc(), and stop().
|
protected |
true, if lookup is running
Definition at line 126 of file IterativeLookup.h.
Referenced by handleRpcResponse(), handleRpcTimeout(), lookup(), sendRpc(), start(), and stop().
|
protected |
closest nodes
Definition at line 149 of file IterativeLookup.h.
Referenced by addSibling(), checkStop(), getResult(), and start().
|
protected |
time at which the lookup was started
Definition at line 129 of file IterativeLookup.h.
Referenced by IterativePathLookup::handleResponse(), IterativePathLookup::handleTimeout(), and start().
|
protected |
true, if lookup was successful
Definition at line 125 of file IterativeLookup.h.
Referenced by checkStop(), isValid(), start(), and stop().
|
protected |
number of successful paths
Definition at line 122 of file IterativeLookup.h.
Referenced by checkStop(), handleRpcResponse(), handleRpcTimeout(), start(), and stop().
|
protected |
nodes already visited
Definition at line 150 of file IterativeLookup.h.
Referenced by getVisited(), setVisited(), and start().