28 #include <IPAddressResolver.h>
29 #include <IPvXAddress.h>
30 #include <IInterfaceTable.h>
31 #include <IPv4InterfaceData.h>
71 throw cRuntimeError(
"NeighborCache is disabled, which is mandatory "
72 "for Pastry/Bamboo. Activate it by setting "
73 "\"**.neighborCache.enableNeighborCache "
74 "= true\" in your omnetpp.ini!");
80 <<
" Warning: numberOfLeaves must be even - adding 1."
86 (getParentModule()->getSubmodule(
"pastryRoutingTable"));
88 (getParentModule()->getSubmodule(
"pastryLeafSet"));
90 (getParentModule()->getSubmodule(
"pastryNeighborhoodSet"));
210 getParentModule()->getParentModule()->bubble(
"entering INIT state");
227 getParentModule()->getParentModule()->bubble(
"entering JOIN state");
245 getParentModule()->getParentModule()->bubble(
"entering READY state");
267 <<
" newLeafs() called."
274 cPolymorphic *contextPointer,
Prox prox)
276 Enter_Method(
"proxCallback()");
280 <<
" Pong (or timeout) received (from "
281 << node.
getIp() <<
")"
291 rtt : SimTime::getMaxTime());
292 delete contextPointer;
300 delete contextPointer;
311 delete contextPointer;
332 throw cRuntimeError(
"wrong state object type!");
338 delete contextPointer;
348 for (uint32_t i = 0; i < rt_size + ls_size + ns_size; i++) {
353 else if (i < (rt_size + ls_size) ) {
374 if (
stateCache.
msg == NULL)
throw cRuntimeError(
"no state msg");
389 for (uint32_t i = 0; i < rt_size + ls_size + ns_size; i++) {
391 std::vector<simtime_t>::iterator proxPos;
401 }
else if ( i < (rt_size + ls_size) ) {
410 index = i - rt_size - ls_size;
431 throw cRuntimeError(
"Undefined node in STATE message!");
452 for (uint32_t i = 0; i < rt_size + ls_size + ns_size; i++) {
454 std::vector<simtime_t>::iterator tblPos;
458 }
else if ( i < (rt_size + ls_size) ) {
481 <<
" Received RPC call and state != READY"
498 cPolymorphic* context,
int rpcId,
503 EV <<
"[BasePastry::handleRpcResponse() @ " <<
thisNode.
getIp()
505 <<
" Received a RequestLeafSet RPC Response: id=" << rpcId <<
"\n"
506 <<
" msg=" << *_RequestLeafSetResponse <<
" rtt=" << SIMTIME_DBL(rtt)
512 EV <<
"[BasePastry::handleRpcResponse() @ " <<
thisNode.
getIp()
514 <<
" Received a RequestRoutingRow RPC Response: id=" << rpcId <<
"\n"
515 <<
" msg=" << *_RequestRoutingRowResponse <<
" rtt=" << SIMTIME_DBL(rtt)
526 cPolymorphic* context,
int rpcId,
529 EV <<
"[BasePastry::handleRpcTimeout() @ " <<
thisNode.
getIp()
531 <<
" Timeout of RPC Call: id=" << rpcId <<
"\n"
532 <<
" msg=" << *call <<
" key=" << key
545 EV <<
"[BasePastry::handleRequestLeafSetCall() @ " <<
thisNode.
getIp()
553 EV <<
" local node is NOT in READY state (call deleted)!" << endl;
560 response->setTimestamp(simTime());
567 if (call->getEncapsulatedPacket()) {
568 EV <<
" ... it's a leafSet PULL message!" << endl;
581 response->setName(
"LeafSet PUSH");
593 EV <<
"[BasePastry::handleRequestRoutingRowCall() @ " <<
thisNode.
getIp()
603 EV <<
" received request for nonexistent routing"
604 <<
"table row, dropping message!"
612 assert(call->
getRow() >= -1 &&
627 EV <<
" received routing table request before reaching "
628 <<
"READY state, dropping message!" << endl;
636 EV <<
"[BasePastry::handleRequestLeafSetResponse() @ " <<
thisNode.
getIp()
641 response->getByteLength());
651 EV <<
"[BasePastry::handleRequestRoutingRowResponse() @ " <<
thisNode.
getIp()
671 ((row == -1) || (timestamp != -1))) {
672 throw cRuntimeError(
"Creating JOIN State without hopCount"
673 " or with timestamp!");
675 throw cRuntimeError(
"Creating ROUTINGROW State without row!");
678 throw cRuntimeError(
"Creating UPDATE/REPAIR State without timestamp!");
681 ((row != -1) || (timestamp != -1))) {
682 throw cRuntimeError(
"Creating STD/UPDATE State with row/hopCount"
686 std::string typeStr = cEnum::get(
"PastryStateMsgType")->getStringFor(type);
687 typeStr.erase(0, 13);
689 EV <<
"[BasePastry::sendStateTables() @ " <<
thisNode.
getIp()
691 <<
" creating new state message (" << typeStr <<
")"
698 stateMsg->
setTimestamp((timestamp == -1) ? simTime() : timestamp);
748 error(
"Pastry::isSiblingFor(): key is unspecified!");
750 if ((numSiblings == 1) && (node ==
thisNode)) {
762 if (result == NULL) {
788 std::stringstream ttString;
794 getParentModule()->getParentModule()->getDisplayString().
795 setTagArg(
"tt", 0, ttString.str().c_str());
796 getParentModule()->getDisplayString().
797 setTagArg(
"tt", 0, ttString.str().c_str());
798 getDisplayString().setTagArg(
"tt", 0, ttString.str().c_str());
802 "m=m,50,0,50,0;ls=red,1");
804 "m=m,50,100,50,100;ls=green,1");
907 int numRedundantNodes,
914 opp_error(
"(Pastry::findNode()) numRedundantNodes or numSiblings "
976 nextHops->
add(*next);
990 if ( (numRedundantNodes > 1)) {
1005 (*additionalHops)[0] != (*nextHops)[0]) {
1006 for (uint32_t i = 0; i < additionalHops->size(); i++) {
1007 if ((*additionalHops)[i] != (*nextHops)[0])
1008 nextHops->push_back((*additionalHops)[i]);
1010 delete additionalHops;
1013 return additionalHops;
1022 const cPacket* dummy,
1025 assert(dummy == NULL);
1031 dynamic_cast<const PastryJoinCall*>(msg->getEncapsulatedPacket())) {
1033 static_cast<const PastryJoinCall*
>(msg->getEncapsulatedPacket());
1070 std::vector<TransportAddress>* ret =
new std::vector<TransportAddress>;
1079 os <<
"PastryStateMsgProximity {" << endl;
1080 os <<
" pr_rt {" << endl;
1081 for (std::vector<simtime_t>::const_iterator i = pr.
pr_rt.begin();
1082 i != pr.
pr_rt.end(); ++i) {
1083 os <<
" " << *i << endl;
1086 os <<
" pr_ls {" << endl;
1087 for (std::vector<simtime_t>::const_iterator i = pr.
pr_ls.begin();
1088 i != pr.
pr_ls.end(); ++i) {
1089 os <<
" " << *i << endl;
1092 os <<
" pr_ns {" << endl;
1093 for (std::vector<simtime_t>::const_iterator i = pr.
pr_ns.begin();
1094 i != pr.
pr_ns.end(); ++i) {
1095 os <<
" " << *i << endl;
1112 bool useAlternative)
const