72 const cPacket* findNodeExt,
75 routingType(routingType),
83 if (findNodeExt)
firstCallExt =
static_cast<cPacket*
>(findNodeExt->dup());
86 throw cRuntimeError(
"IterativeLookup::IterativeLookup(): "
87 "config.merge must be enabled for "
88 "using parallel paths!");
92 throw cRuntimeError(
"IterativeLookup::IterativeLookup(): "
93 "config.merge must be enabled for "
94 "using secure lookups!");
99 throw cRuntimeError(
"IterativeLookup::IterativeLookup(): "
100 "config.merge must be enabled for "
101 "using majority decision for sibling selection!");
124 for (RpcInfoMap::iterator i =
rpcs.begin(); i !=
rpcs.end(); i++) {
161 if (nextHops->size() == 0) {
173 std::cout <<
"IterativeLookup: numSiblings==0 and no node with this id"
184 for (uint32_t i=0; i<nextHops->size(); i++) {
201 cPacket* findNodeExt = NULL;
202 if (call->hasObject(
"findNodeExt"))
203 findNodeExt = (cPacket*)call->removeObject(
"findNodeExt");
216 paths.push_back(pathLookup);
246 for (uint32_t i=0; i<
paths.size(); i++) {
251 for (RpcInfoMap::iterator i =
rpcs.begin(); i !=
rpcs.end(); i++) {
263 for (uint32_t i = 0; i <
paths.size(); ++i) {
275 <<
" Lookup " << (
isValid() ?
"succeeded\n" :
"failed\n")
291 bool finishLookup =
false;
297 MajoritySiblings::iterator it;
319 for (uint32_t i=0; i<
paths.size(); i++) {
328 if (finishLookup ==
true) {
349 for (RpcInfoMap::iterator i =
rpcs.begin(); i !=
rpcs.end(); i++) {
393 call->addObject(static_cast<cObject*>(findNodeExt->dup()));
394 call->addBitLength(findNodeExt->getBitLength());
422 <<
" Adding potential sibling " << handle
430 int id = intuniform(1, 2147483647);
471 return (
visited.count(addr) != 0);
481 return (
dead.count(addr) != 0);
491 return (
pinged.count(addr) != 0);
499 cPolymorphic* context,
500 int rpcId, simtime_t rtt)
513 if (pingResponse != NULL) {
520 if (findNodeResponse != NULL) {
524 if (
rpcs.count(src) == 0)
532 bool rpcHandled =
false;
534 for (uint32_t i=0; i<infos.size(); i++) {
536 const RpcInfo& info = infos[i];
552 EV <<
"[IterativeLookup::handleRpcResponse()]\n"
553 <<
" Path does not accept message with id " << info.
vrpcId
576 if (failedNodeResponse != NULL) {
577 cPacket* findNodeExt = NULL;
578 if (failedNodeResponse->hasObject(
"findNodeExt")) {
580 (cPacket*)failedNodeResponse->removeObject(
"findNodeExt");
583 for (std::vector<IterativePathLookup*>::iterator i =
paths.begin();
584 i !=
paths.end(); i++) {
586 (*i)->handleFailedNodeResponse(failedNodeResponse->
getSrcNode(),
598 cPolymorphic* context,
int rpcId,
605 if (dynamic_cast<PingCall*>(msg) != NULL) {
612 if (
rpcs.count(dest)==0) {
625 for (uint32_t i=0; i < infos.size(); i++) {
627 const RpcInfo& info = infos[i];
665 if (
rpcs.count(handle) == 0) {
673 rpcs[handle] = newVector;
675 EV <<
"[IterativeLookup::sendRpc()]\n"
676 <<
" RPC already sent...not sent again"
682 rpcs[handle].push_back(info);
694 <<
" Lookup of key " << key
710 throw cRuntimeError(
"IterativeLookup::lookup(): "
711 "With EXHAUSTIVE_ITERATIVE_ROUTING numRedundantNodes "
712 "must be >= numSiblings!");
773 return (rpcId ==
step);
782 EV <<
"[IterativePathLookup::handleResponse()]\n"
783 <<
" Iterative lookup path timed out!"
791 std::map<TransportAddress, NodeHandle>::iterator oldPos;
828 int pos =
add(handle, source);
831 if ((pos >= 0) && (pos < lookup->config.redundantNodes)) {
856 cout <<
"nextHops.size " <<
nextHops.size()
860 cout <<
"looking for " <<
lookup->
key << endl;
866 cout <<
"next Hops " <<
nextHops << endl;
881 cPacket* findNodeExt = NULL;
882 if (msg->hasObject(
"findNodeExt")) {
883 findNodeExt = (cPacket*)msg->removeObject(
"findNodeExt");
916 EV <<
"[IterativePathLookup::handleTimeout()]\n"
917 <<
" Timeout of RPC " << rpcId
928 (dynamic_cast<const NodeHandle&>(dest)).getKey());
934 std::map<TransportAddress, NodeHandle>::iterator oldPos;
940 cPacket* findNodeExt = NULL;
941 if (msg && msg->hasObject(
"findNodeExt")) {
942 findNodeExt =
static_cast<cPacket*
>(
943 msg->removeObject(
"findNodeExt"));
947 EV <<
"[IterativePathLookup::handleTimeout()]\n"
948 <<
" Iterative lookup path timed out!"
960 if (oldPos->second.isUnspecified()) {
987 call->addObject(findNodeExt);
988 call->addBitLength(findNodeExt->getBitLength());
998 cPacket* findNodeExt,
bool retry)
1004 std::map<TransportAddress, NodeHandle>::iterator oldPos;
1006 if ((! oldPos->second.isUnspecified()) &&
1007 (oldPos->second == src))
break;
1014 std::map<TransportAddress, NodeHandle>::iterator oldSrcPos =
1019 oldSrc = &(oldSrcPos->second);
1044 EV <<
"[IterativePathLookup::sendRpc()]\n"
1045 <<
" Max hop count exceeded - lookup failed!"
1074 ((num > 0) && (i < lookup->config.redundantNodes)
1075 && (it !=
nextHops.end())); it++, i++) {
1078 if (it->alreadyUsed ||
lookup->
getDead(it->handle))
continue;
1095 it->alreadyUsed =
true;
1123 && (it !=
nextHops.end())); it++, i++) {
1134 <<
" Path failed (no further nodes to query) "