Base class for overlays. More...
#include <BaseOverlay.h>
Classes | |
class | BaseOverlayContext |
struct | HopDelayRecord |
Structure for computing the average delay in one specific hop. More... | |
class | lookupHashFcn |
Public Types | |
enum | States { INIT = 0, JOINING_1 = 1, JOINING_2 = 2, JOINING_3 = 3, READY = 4, REFRESH = 5, SHUTDOWN = 6, FAILED = 7, JOINING = JOINING_1, JOIN = JOINING_1, BOOTSTRAP = JOINING_1, RSET = JOINING_2, BSET = JOINING_3 } |
Public Member Functions | |
BaseOverlay () | |
virtual | ~BaseOverlay () |
Virtual destructor. | |
States | getState () |
bool | isMalicious () |
Returns true, if node is malicious. | |
bool | isInSimpleMultiOverlayHost () |
Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost. | |
const simtime_t & | getCreationTime () |
void | join (const OverlayKey &nodeID=OverlayKey::UNSPECIFIED_KEY) |
Join the overlay with a given nodeID. | |
virtual NodeVector * | local_lookup (const OverlayKey &key, int num, bool safe) |
finds nodes closest to the given OverlayKey | |
virtual NodeVector * | neighborSet (int num) |
virtual bool | isSiblingFor (const NodeHandle &node, const OverlayKey &key, int numSiblings, bool *err) |
Query if a node is among the siblings for a given key. | |
virtual int | getMaxNumSiblings () |
Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay protocol. | |
virtual int | getMaxNumRedundantNodes () |
Query the maximum number of redundant next hop nodes that are returned by findNode(). | |
void | sendMessageToUDP (const TransportAddress &dest, cPacket *msg) |
Sends message to underlay. | |
void | sendToKey (const OverlayKey &key, BaseOverlayMessage *message, int numSiblings=1, const std::vector< TransportAddress > &sourceRoute=TransportAddress::UNSPECIFIED_NODES, RoutingType routingType=DEFAULT_ROUTING) |
Sends a message to an overlay node, with the generic routing algorithm. | |
virtual OverlayKey | distance (const OverlayKey &x, const OverlayKey &y, bool useAlternative=false) const |
This method should implement the distance between two keys. | |
void | registerComp (CompType compType, cModule *module) |
cModule * | getCompModule (CompType compType) |
cGate * | getCompRpcGate (CompType compType) |
void | sendMessageToAllComp (cMessage *msg, CompType srcComp) |
bool | providesKbr () |
virtual uint8_t | getBitsPerDigit () |
bool | getMeasureAuthBlock () |
BootstrapList & | getBootstrapList () const |
Protected Types | |
typedef UNORDERED_SET < AbstractLookup *, lookupHashFcn, lookupHashFcn > | LookupSet |
Protected Member Functions | |
int | numInitStages () const |
Sets init stage. | |
virtual void | initializeOverlay (int stage) |
Initializes derived-class-attributes. | |
virtual void | finishOverlay () |
collects statistical data in derived class | |
void | bindToPort (int port) |
Tells UDP we want to get all packets arriving on the given port. | |
virtual void | route (const OverlayKey &key, CompType destComp, CompType srcComp, cPacket *msg, const std::vector< TransportAddress > &sourceRoute=TransportAddress::UNSPECIFIED_NODES, RoutingType routingType=DEFAULT_ROUTING) |
Routes message through overlay. | |
void | callDeliver (BaseOverlayMessage *msg, const OverlayKey &destKey) |
Calls deliver function in application. | |
void | callForward (const OverlayKey &key, BaseRouteMessage *msg, const NodeHandle &nextHopNode) |
Calls forward function in application. | |
void | callUpdate (const NodeHandle &node, bool joined) |
Informs application about state changes of nodes or newly joined nodes. | |
void | handleMessage (cMessage *msg) |
Checks for message type and calls corresponding method. | |
void | handleBaseOverlayMessage (BaseOverlayMessage *msg, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY) |
Handles a BaseOverlayMessage | |
virtual void | handleUDPMessage (BaseOverlayMessage *msg) |
Processes messages from underlay. | |
virtual void | handleAppMessage (cMessage *msg) |
Processes "timer" self-messages. | |
virtual void | receiveChangeNotification (int category, const cPolymorphic *details) |
callback-method for events at the NotificationBoard | |
virtual void | handleTransportAddressChangedNotification () |
This method gets call if the node has a new TransportAddress (IP address) because he changed his access network. | |
virtual void | handleNodeLeaveNotification () |
This method gets call **.gracefulLeaveDelay seconds before it is killed. | |
virtual void | handleNodeGracefulLeaveNotification () |
This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes. | |
virtual void | recordOverlaySentStats (BaseOverlayMessage *msg) |
Collect overlay specific sent messages statistics. | |
void | setOverlayReady (bool ready) |
Sets the overlay ready icon and register/deregisters the node at the GlobalNodeList. | |
virtual AbstractLookup * | createLookup (RoutingType routingType=DEFAULT_ROUTING, const BaseOverlayMessage *msg=NULL, const cPacket *findNodeExt=NULL, bool appLookup=false) |
Creates an abstract iterative lookup instance. | |
virtual void | removeLookup (AbstractLookup *lookup) |
Removes the abstract lookup instance. | |
virtual NodeVector * | findNode (const OverlayKey &key, int numRedundantNodes, int numSiblings, BaseOverlayMessage *msg=NULL) |
Implements the find node call. | |
virtual void | joinOverlay () |
Join the overlay with a given nodeID in thisNode.key. | |
virtual void | joinForeignPartition (const NodeHandle &node) |
Join another overlay partition with the given node as bootstrap node. | |
virtual bool | handleFailedNode (const TransportAddress &failed) |
Handles a failed node. | |
virtual void | lookupRpc (LookupCall *call) |
virtual void | nextHopRpc (NextHopCall *call) |
void | countFindNodeCall (const FindNodeCall *call) |
void | countFailedNodeCall (const FailedNodeCall *call) |
bool | internalHandleRpcCall (BaseCallMessage *msg) |
void | internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt) |
void | internalHandleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey) |
void | internalSendRouteRpc (BaseRpcMessage *message, const OverlayKey &destKey, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType) |
CompType | getThisCompType () |
Protected Attributes | |
int | numAppDataForwarded |
number of forwarded app data packets | |
int | bytesAppDataForwarded |
number of forwarded app data bytes at out-gate | |
int | numAppLookupForwarded |
number of forwarded app lookup packets | |
int | bytesAppLookupForwarded |
number of forwarded app lookup bytes at out-gate | |
int | numMaintenanceForwarded |
number of forwarded maintenance packets | |
int | bytesMaintenanceForwarded |
number of forwarded maintenance bytes at out-gate | |
int | numFindNodeSent |
int | bytesFindNodeSent |
int | numFindNodeResponseSent |
int | bytesFindNodeResponseSent |
int | numFailedNodeSent |
int | bytesFailedNodeSent |
int | numFailedNodeResponseSent |
int | bytesFailedNodeResponseSent |
std::vector< HopDelayRecord * > | singleHopDelays |
simtime_t | creationTime |
simtime when the node has been created | |
GlobalNodeList * | globalNodeList |
pointer to GlobalNodeList in this node | |
NotificationBoard * | notificationBoard |
pointer to NotificationBoard in this node | |
UnderlayConfigurator * | underlayConfigurator |
pointer to UnderlayConfigurator in this node | |
BootstrapList * | bootstrapList |
pointer to the BootstrapList module | |
GlobalParameters * | globalParameters |
pointer to the GlobalParameters module | |
bool | debugOutput |
debug output ? | |
RoutingType | defaultRoutingType |
bool | useCommonAPIforward |
forward messages to applications? | |
bool | collectPerHopDelay |
collect delay for single hops | |
bool | routeMsgAcks |
send ACK when receiving route message | |
uint32_t | recNumRedundantNodes |
numRedundantNodes for recursive routing | |
bool | recordRoute |
record visited hops on route | |
bool | drawOverlayTopology |
bool | rejoinOnFailure |
bool | sendRpcResponseToLastHop |
needed by KBR protocols for NAT support | |
bool | dropFindNodeAttack |
if node is malicious, it tries a findNode attack | |
bool | isSiblingAttack |
if node is malicious, it tries a isSibling attack | |
bool | invalidNodesAttack |
if node is malicious, it tries a invalidNode attack | |
bool | dropRouteMessageAttack |
if node is malicious, it drops all received BaseRouteMessages | |
int | localPort |
used UDP-port | |
int | hopCountMax |
maximum hop count | |
bool | measureAuthBlock |
if true, measure the overhead of signatures in rpc messages | |
bool | restoreContext |
if true, a node rejoins with its old nodeId and malicious state | |
int | numDropped |
number of dropped packets | |
int | bytesDropped |
number of dropped bytes | |
cOutVector | delayVector |
statistical output vector for packet-delays | |
cOutVector | hopCountVector |
statistical output vector for hop-counts | |
States | state |
IterativeLookupConfiguration | iterativeLookupConfig |
RecursiveLookupConfiguration | recursiveLookupConfig |
LookupSet | lookups |
bool | kbr |
set this to true, if the overlay provides KBR services | |
Private Types | |
typedef std::map< CompType, std::pair< cModule *, cGate * > > | CompModuleList |
Private Member Functions | |
void | initialize (int stage) |
initializes base-class-attributes | |
void | finish () |
collects statistical data | |
virtual void | setOwnNodeID () |
Overlay implementations can overwrite this virtual method to set a specific nodeID. | |
void | sendRouteMessage (const TransportAddress &dest, BaseRouteMessage *msg, bool ack) |
bool | checkFindNode (BaseRouteMessage *routeMsg) |
void | initLookups () |
creates a LookupSet | |
void | finishLookups () |
deletes entries in lookups | |
virtual bool | recursiveRoutingHook (const TransportAddress &dest, BaseRouteMessage *msg) |
Hook for forwarded message in recursive lookup mode. | |
void | internalSendRpcResponse (BaseCallMessage *call, BaseResponseMessage *response) |
void | findNodeRpc (FindNodeCall *call) |
void | failedNodeRpc (FailedNodeCall *call) |
Private Attributes | |
int | numAppDataSent |
number of sent app data packets (incl. forwarded packets) | |
int | bytesAppDataSent |
number of sent app data bytes (incl. forwarded bytes) | |
int | numAppLookupSent |
number of sent app loookup packets (incl. forwarded packets) | |
int | bytesAppLookupSent |
number of sent app lookup bytes (incl. forwarded bytes) | |
int | numMaintenanceSent |
number of sent maintenance packets (incl. forwarded packets) | |
int | bytesMaintenanceSent |
number of sent maintenance bytes (incl. forwarded bytes) | |
int | numAppDataReceived |
number of received app data packets (incl. packets to be forwarded ) | |
int | bytesAppDataReceived |
number of received app data bytes (incl. bytes to be forwarded) | |
int | numAppLookupReceived |
number of received app lookup packets (incl. packets to be forwarded) | |
int | bytesAppLookupReceived |
number of received app lookup bytes (incl. bytes to be forwarded) | |
int | numMaintenanceReceived |
number of received maintenance packets (incl. packets to be forwarded) | |
int | bytesMaintenanceReceived |
number of received maintenance bytes (incl. bytes to be forwarded) | |
int | numInternalSent |
number of packets sent to same host but different port (SimpleMultiOverlayHost) | |
int | bytesInternalSent |
number of bytes sent to same host but different port (SimpleMultiOverlayHost) | |
int | numInternalReceived |
number of packets received from same host but different port (SimpleMultiOverlayHost) | |
int | bytesInternalReceived |
number of bytes received from same host but different port (SimpleMultiOverlayHost) | |
int | bytesAuthBlockSent |
number of bytes sent for rpc message signatures | |
int | joinRetries |
number of join retries | |
const cGate * | udpGate |
const cGate * | appGate |
CompModuleList | compModuleList |
bool | internalReadyState |
internal overlay state used for setOverlayReady() | |
Friends | |
class | IterativeLookup |
class | IterativePathLookup |
class | RecursiveLookup |
class | BootstrapList |
class | SendToKeyListener |
Base class for overlays.
Base class for overlay modules, with KBR-API, statistics and pointers to the GlobalNodeList and the UnderlayConfigurator. Derived classes must use BaseOverlayMessage as base class for own message types.
Definition at line 62 of file BaseOverlay.h.
typedef std::map<CompType, std::pair<cModule*, cGate*> > BaseOverlay::CompModuleList [private] |
Definition at line 822 of file BaseOverlay.h.
typedef UNORDERED_SET<AbstractLookup*, lookupHashFcn, lookupHashFcn> BaseOverlay::LookupSet [protected] |
Definition at line 579 of file BaseOverlay.h.
enum BaseOverlay::States |
INIT | |
JOINING_1 | |
JOINING_2 | |
JOINING_3 | |
READY | |
REFRESH | |
SHUTDOWN | |
FAILED | |
JOINING | |
JOIN | |
BOOTSTRAP | |
RSET | |
BSET |
Definition at line 85 of file BaseOverlay.h.
BaseOverlay::BaseOverlay | ( | ) |
Definition at line 57 of file BaseOverlay.cc.
{ globalNodeList = NULL; underlayConfigurator = NULL; notificationBoard = NULL; globalParameters = NULL; bootstrapList = NULL; }
BaseOverlay::~BaseOverlay | ( | ) | [virtual] |
Virtual destructor.
Definition at line 66 of file BaseOverlay.cc.
{ finishLookups(); finishRpcs(); }
void BaseOverlay::bindToPort | ( | int | port | ) | [protected] |
Tells UDP we want to get all packets arriving on the given port.
Definition at line 465 of file BaseOverlay.cc.
Referenced by initialize().
{ EV << "[BaseOverlay::bindToPort() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Binding to UDP port " << port << endl; thisNode.setPort(port); // TODO UDPAppBase should be ported to use UDPSocket sometime, but for now // we just manage the UDP socket by hand... cMessage *msg = new cMessage("UDP_C_BIND", UDP_C_BIND); UDPControlInfo *ctrl = new UDPControlInfo(); ctrl->setSrcPort(port); ctrl->setSockId(UDPSocket::generateSocketId()); msg->setControlInfo(ctrl); send(msg, "udpOut"); }
void BaseOverlay::callDeliver | ( | BaseOverlayMessage * | msg, | |
const OverlayKey & | destKey | |||
) | [protected] |
Calls deliver function in application.
Encapsulates messages in KBRdeliver messages and sends them to application.
msg | delivered message | |
destKey | the destination key of the message |
Definition at line 489 of file BaseOverlay.cc.
Referenced by Gia::forwardMessage(), and handleBaseOverlayMessage().
{ KBRdeliver* deliverMsg = new KBRdeliver(); OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo()); BaseAppDataMessage* appDataMsg = dynamic_cast<BaseAppDataMessage*>(msg); // TODO GIA if (appDataMsg != NULL) { overlayCtrlInfo->setSrcComp(appDataMsg->getSrcComp()); overlayCtrlInfo->setDestComp(appDataMsg->getDestComp()); } deliverMsg->setControlInfo(overlayCtrlInfo); deliverMsg->setDestKey(destKey); deliverMsg->encapsulate(msg->decapsulate()); deliverMsg->setType(KBR_DELIVER); cGate* destGate = getCompRpcGate(static_cast<CompType>( overlayCtrlInfo->getDestComp())); if (destGate == NULL) { throw cRuntimeError("BaseOverlay::callDeliver(): Unknown destComp!"); } sendDirect(deliverMsg, destGate); delete msg; }
void BaseOverlay::callForward | ( | const OverlayKey & | key, | |
BaseRouteMessage * | msg, | |||
const NodeHandle & | nextHopNode | |||
) | [protected] |
Calls forward function in application.
Encapsulates messages in KBRforward messages and sends them to application.
the message to be sent through the API must be encapsulated in msg
.
key | destination key | |
msg | message to forward | |
nextHopNode | next hop |
Definition at line 522 of file BaseOverlay.cc.
Referenced by sendToKey().
{ KBRforward* forwardMsg = new KBRforward(); forwardMsg->setDestKey(msg->getDestKey()); forwardMsg->setNextHopNode(nextHopNode); forwardMsg->encapsulate(msg->getEncapsulatedPacket()->decapsulate()); OverlayCtrlInfo* overlayCtrlInfo = new OverlayCtrlInfo(); overlayCtrlInfo->setTransportType(ROUTE_TRANSPORT); overlayCtrlInfo->setRoutingType(msg->getRoutingType()); overlayCtrlInfo->setHopCount(msg->getHopCount()); overlayCtrlInfo->setSrcNode(msg->getSrcNode()); overlayCtrlInfo->setSrcComp(check_and_cast<BaseAppDataMessage*> (msg->getEncapsulatedPacket())->getSrcComp()); overlayCtrlInfo->setDestComp(check_and_cast<BaseAppDataMessage*> (msg->getEncapsulatedPacket())->getDestComp()); if (msg->getControlInfo() != NULL) { OverlayCtrlInfo* ctrlInfo = check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo()); overlayCtrlInfo->setLastHop(ctrlInfo->getLastHop()); delete ctrlInfo; } forwardMsg->setControlInfo(overlayCtrlInfo); forwardMsg->setType(KBR_FORWARD); send(forwardMsg, "appOut"); delete msg; }
void BaseOverlay::callUpdate | ( | const NodeHandle & | node, | |
bool | joined | |||
) | [protected] |
Informs application about state changes of nodes or newly joined nodes.
Creates a KBRUpdate message and sends it up to the application
node | the node that has joined or changed its state | |
joined | has the node joined or changed its state? |
Definition at line 639 of file BaseOverlay.cc.
Referenced by BrooseBucket::add(), oversim::ChordSuccessorList::addSuccessor(), Gia::changeState(), PastryLeafSet::failedNode(), Kademlia::handleFailedNode(), oversim::ChordSuccessorList::handleFailedNode(), oversim::Chord::handleFailedNode(), oversim::Chord::handleRpcJoinResponse(), oversim::Chord::handleStabilizeTimerExpired(), PastryLeafSet::insertLeaf(), Kademlia::refillSiblingTable(), BrooseBucket::remove(), oversim::ChordSuccessorList::removeOldSuccessors(), Kademlia::routingAdd(), Kademlia::routingTimeout(), oversim::Chord::rpcJoin(), and oversim::Chord::rpcNotify().
{ if ((!node.isUnspecified()) && (node != thisNode)) { if (joined) { EV << "[BaseOverlay::callUpdate() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " (" << node << ", " << joined << ") joined" << endl; } else { EV << "[BaseOverlay::callUpdate() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " (" << node << ", " << joined << ") left" << endl; } } KBRupdate* updateMsg = new KBRupdate("UPDATE"); updateMsg->setNode(node); updateMsg->setJoined(joined); updateMsg->setType(KBR_UPDATE); send(updateMsg, "appOut"); }
bool BaseOverlay::checkFindNode | ( | BaseRouteMessage * | routeMsg | ) | [private] |
Definition at line 1584 of file BaseOverlay.cc.
Referenced by sendToKey().
{ if (dynamic_cast<FindNodeCall*>(routeMsg->getEncapsulatedPacket())) { FindNodeCall* findNodeCall = static_cast<FindNodeCall*>(routeMsg->decapsulate()); findNodeCall ->setControlInfo(check_and_cast<OverlayCtrlInfo*> (routeMsg->removeControlInfo())); findNodeRpc(findNodeCall); return true; } return false; }
void BaseOverlay::countFailedNodeCall | ( | const FailedNodeCall * | call | ) | [protected] |
Definition at line 1833 of file BaseOverlay.cc.
Referenced by Kademlia::handleNodeGracefulLeaveNotification(), and IterativePathLookup::handleTimeout().
{ RECORD_STATS(numFailedNodeSent++; bytesFailedNodeSent += call->getByteLength()); }
void BaseOverlay::countFindNodeCall | ( | const FindNodeCall * | call | ) | [protected] |
Definition at line 1827 of file BaseOverlay.cc.
Referenced by IterativeLookup::sendRpc().
{ RECORD_STATS(numFindNodeSent++; bytesFindNodeSent += call->getByteLength()); }
AbstractLookup * BaseOverlay::createLookup | ( | RoutingType | routingType = DEFAULT_ROUTING , |
|
const BaseOverlayMessage * | msg = NULL , |
|||
const cPacket * | findNodeExt = NULL , |
|||
bool | appLookup = false | |||
) | [protected, virtual] |
Creates an abstract iterative lookup instance.
routingType | The routing type for this lookup (e.g. recursive/iterative) | |
msg | pointer to the message for which the lookup is created. Derived classes can use it to construct an object with additional info for the lookup class. | |
findNodeExt | object that will be sent with the findNodeCalls | |
appLookup | Set to true, if lookup is triggered by application (for statistics) |
Definition at line 1599 of file BaseOverlay.cc.
Referenced by Kademlia::handleBucketRefreshTimerExpired(), Kademlia::handleRpcResponse(), lookupRpc(), and sendToKey().
{ AbstractLookup* newLookup; if (routingType == DEFAULT_ROUTING) { routingType = defaultRoutingType; } switch (routingType) { case ITERATIVE_ROUTING: case EXHAUSTIVE_ITERATIVE_ROUTING: newLookup = new IterativeLookup(this, routingType, iterativeLookupConfig, findNodeExt, appLookup); break; case RECURSIVE_SOURCE_ROUTING: case SEMI_RECURSIVE_ROUTING: case FULL_RECURSIVE_ROUTING: newLookup = new RecursiveLookup(this, routingType, recursiveLookupConfig, appLookup); break; default: throw cRuntimeError("BaseOverlay::createLookup():" " Unknown routingType!"); break; } lookups.insert(newLookup); return newLookup; }
OverlayKey BaseOverlay::distance | ( | const OverlayKey & | x, | |
const OverlayKey & | y, | |||
bool | useAlternative = false | |||
) | const [virtual] |
This method should implement the distance between two keys.
It may be overloaded to implement a new metric. The default implementation uses the standard-metric d = abs(x-y).
x | Left-hand-side Key | |
y | Right-hand-side key | |
useAlternative | use an alternative distance metric |
Definition at line 1640 of file BaseOverlay.cc.
Referenced by IterativeLookup::compare(), oversim::Nice::maintenance(), and DHT::update().
{ throw cRuntimeError("BaseOverlay::distance(): Not implemented!"); return OverlayKey::UNSPECIFIED_KEY; }
void BaseOverlay::failedNodeRpc | ( | FailedNodeCall * | call | ) | [private] |
Definition at line 1917 of file BaseOverlay.cc.
Referenced by internalHandleRpcCall().
{ FailedNodeResponse* failedNodeResponse = new FailedNodeResponse("FailedNodeResponse"); failedNodeResponse->setTryAgain(handleFailedNode(call->getFailedNode())); failedNodeResponse->setBitLength(FAILEDNODERESPONSE_L(failedNodeResponse)); if (call->hasObject("findNodeExt")) { cPacket* findNodeExt = check_and_cast<cPacket*>( call->removeObject("findNodeExt")); failedNodeResponse->addObject(findNodeExt); failedNodeResponse->addBitLength(findNodeExt->getBitLength()); } RECORD_STATS(numFailedNodeResponseSent++; bytesFailedNodeResponseSent += failedNodeResponse->getByteLength()); sendRpcResponse(call, failedNodeResponse); }
NodeVector * BaseOverlay::findNode | ( | const OverlayKey & | key, | |
int | numRedundantNodes, | |||
int | numSiblings, | |||
BaseOverlayMessage * | msg = NULL | |||
) | [protected, virtual] |
Implements the find node call.
This method simply returns the closest nodes known in the corresponding routing topology. If the node is a sibling for this key (isSiblingFor(key) = true), this method returns all numSiblings siblings, with the closest neighbor to the key first.
key | The lookup key. | |
numRedundantNodes | Maximum number of next hop nodes to return. | |
numSiblings | number of siblings to return | |
msg | A pointer to the BaseRouteMessage or FindNodeCall message of this lookup. |
Reimplemented in Broose, and MyOverlay.
Definition at line 1649 of file BaseOverlay.cc.
Referenced by findNodeRpc(), IterativePathLookup::handleTimeout(), local_lookup(), sendToKey(), and IterativeLookup::start().
{ throw cRuntimeError("findNode: Not implemented!"); return NULL; }
void BaseOverlay::findNodeRpc | ( | FindNodeCall * | call | ) | [private] |
Definition at line 1840 of file BaseOverlay.cc.
Referenced by checkFindNode(), and internalHandleRpcCall().
{ // if this node is malicious don't answer a findNodeCall if (isMalicious() && dropFindNodeAttack) { EV << "[BaseOverlay::findNodeRpc() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Node ignores findNodeCall because this node is malicious" << endl; delete call; return; } FindNodeResponse* findNodeResponse = new FindNodeResponse("FindNodeResponse"); findNodeResponse->setBitLength(FINDNODERESPONSE_L(findNodeResponse)); NodeVector* nextHops = findNode(call->getLookupKey(), call->getNumRedundantNodes(), call->getExhaustiveIterative() ? -1 : call->getNumSiblings(), call); findNodeResponse->setClosestNodesArraySize(nextHops->size()); for (uint32_t i=0; i < nextHops->size(); i++) { findNodeResponse->setClosestNodes(i, (*nextHops)[i]); } bool err; if (!call->getExhaustiveIterative() && isSiblingFor(thisNode, call->getLookupKey(), call->getNumSiblings(), &err)) { findNodeResponse->setSiblings(true); } if (isMalicious() && invalidNodesAttack) { if (isSiblingAttack) { findNodeResponse->setSiblings(true); } else { findNodeResponse->setSiblings(false); } int resultSize = isSiblingAttack ? call->getNumSiblings() : call->getNumRedundantNodes(); findNodeResponse->setClosestNodesArraySize(resultSize); for (int i = 0; i < resultSize; i++) { findNodeResponse->setClosestNodes(i, NodeHandle(call->getLookupKey() + i, IPvXAddress(IPAddress( isSiblingAttack ? (424242+i) : intuniform(42,123123))), 42)); #if 0 // was not used for evaluation if ((i == 0) && isSiblingAttack) { findNodeResponse->setClosestNodes(0, thisNode); } #endif } } else if (isMalicious() && isSiblingAttack) { findNodeResponse->setSiblings(true); findNodeResponse->setClosestNodesArraySize(1); findNodeResponse->setClosestNodes(0, thisNode); } findNodeResponse->setBitLength(FINDNODERESPONSE_L(findNodeResponse)); if (call->hasObject("findNodeExt")) { cPacket* findNodeExt = check_and_cast<cPacket*>(call->removeObject("findNodeExt")); findNodeResponse->addObject(findNodeExt); findNodeResponse->addBitLength(findNodeExt->getBitLength()); } RECORD_STATS(numFindNodeResponseSent++; bytesFindNodeResponseSent += findNodeResponse->getByteLength()); delete nextHops; sendRpcResponse(call, findNodeResponse); }
void BaseOverlay::finish | ( | ) | [private] |
collects statistical data
Definition at line 304 of file BaseOverlay.cc.
{ finishOverlay(); simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime); if (time >= GlobalStatistics::MIN_MEASURED) { if (collectPerHopDelay) { std::ostringstream singleHopName; HopDelayRecord* hdrl = NULL; HopDelayRecord* hdr = NULL; for (size_t i = 0; i < singleHopDelays.size();) { hdrl = singleHopDelays[i++]; hdr = hdrl; for (size_t j = 1; j <= i; ++j) { if (hdr->count == 0) continue; singleHopName.str(""); singleHopName << "BaseOverlay: Average Delay in Hop " << j << " of " << i; globalStatistics->addStdDev(singleHopName.str(), SIMTIME_DBL(hdr->val / hdr->count)); ++hdr; } delete[] hdrl; } singleHopDelays.clear(); } globalStatistics->addStdDev("BaseOverlay: Join Retries", joinRetries); globalStatistics->addStdDev("BaseOverlay: Sent App Data Messages/s", numAppDataSent / time); globalStatistics->addStdDev("BaseOverlay: Sent App Data Bytes/s", bytesAppDataSent / time); if (isInSimpleMultiOverlayHost()) { globalStatistics->addStdDev("BaseOverlay: Internal Sent Messages/s", numInternalReceived / time); globalStatistics->addStdDev("BaseOverlay: Internal Sent Bytes/s", bytesInternalReceived / time); } globalStatistics->addStdDev("BaseOverlay: Sent App Lookup Messages/s", numAppLookupSent / time); globalStatistics->addStdDev("BaseOverlay: Sent App Lookup Bytes/s", bytesAppLookupSent / time); globalStatistics->addStdDev("BaseOverlay: Sent Maintenance Messages/s", numMaintenanceSent / time); globalStatistics->addStdDev("BaseOverlay: Sent Maintenance Bytes/s", bytesMaintenanceSent / time); globalStatistics->addStdDev("BaseOverlay: Sent Total Messages/s", (numAppDataSent + numAppLookupSent + numMaintenanceSent) / time); globalStatistics->addStdDev("BaseOverlay: Sent Total Bytes/s", (bytesAppDataSent + bytesAppLookupSent + bytesMaintenanceSent) / time); globalStatistics->addStdDev("BaseOverlay: Sent FindNode Messages/s", numFindNodeSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FindNode Bytes/s", bytesFindNodeSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FindNodeResponse Messages/s", numFindNodeResponseSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FindNodeResponse Bytes/s", bytesFindNodeResponseSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FailedNode Messages/s", numFailedNodeSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FailedNode Bytes/s", bytesFailedNodeSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FailedNodeResponse Messages/s", numFailedNodeResponseSent / time); globalStatistics->addStdDev("BaseOverlay: Sent FailedNodeResponse Bytes/s", bytesFailedNodeResponseSent / time); globalStatistics->addStdDev("BaseOverlay: Received App Data Messages/s", numAppDataReceived / time); globalStatistics->addStdDev("BaseOverlay: Received App Data Bytes/s", bytesAppDataReceived / time); if (isInSimpleMultiOverlayHost()) { globalStatistics->addStdDev("BaseOverlay: Internal Received Messages/s", numInternalReceived / time); globalStatistics->addStdDev("BaseOverlay: Internal Received Bytes/s", bytesInternalReceived / time); } globalStatistics->addStdDev("BaseOverlay: Received App Lookup Messages/s", numAppLookupReceived / time); globalStatistics->addStdDev("BaseOverlay: Received App Lookup Bytes/s", bytesAppLookupReceived / time); globalStatistics->addStdDev("BaseOverlay: Received Maintenance Messages/s", numMaintenanceReceived / time); globalStatistics->addStdDev("BaseOverlay: Received Maintenance Bytes/s", bytesMaintenanceReceived / time); globalStatistics->addStdDev("BaseOverlay: Received Total Messages/s", (numAppDataReceived + numAppLookupReceived + numMaintenanceReceived)/time); globalStatistics->addStdDev("BaseOverlay: Received Total Bytes/s", (bytesAppDataReceived + bytesAppLookupReceived + bytesMaintenanceReceived)/time); globalStatistics->addStdDev("BaseOverlay: Forwarded App Data Messages/s", numAppDataForwarded / time); globalStatistics->addStdDev("BaseOverlay: Forwarded App Data Bytes/s", bytesAppDataForwarded / time); globalStatistics->addStdDev("BaseOverlay: Forwarded App Lookup Messages/s", numAppLookupForwarded / time); globalStatistics->addStdDev("BaseOverlay: Forwarded App Lookup Bytes/s", bytesAppLookupForwarded / time); globalStatistics->addStdDev("BaseOverlay: Forwarded Maintenance Messages/s", numMaintenanceForwarded / time); globalStatistics->addStdDev("BaseOverlay: Forwarded Maintenance Bytes/s", bytesMaintenanceForwarded / time); globalStatistics->addStdDev("BaseOverlay: Forwarded Total Messages/s", (numAppDataForwarded + numAppLookupForwarded + numMaintenanceForwarded) / time); globalStatistics->addStdDev("BaseOverlay: Forwarded Total Bytes/s", (bytesAppDataForwarded + bytesAppLookupForwarded + bytesMaintenanceForwarded) / time); globalStatistics->addStdDev("BaseOverlay: Dropped Messages/s", numDropped / time); globalStatistics->addStdDev("BaseOverlay: Dropped Bytes/s", bytesDropped / time); globalStatistics->addStdDev("BaseOverlay: Measured Session Time", SIMTIME_DBL(simTime() - creationTime)); globalStatistics->addStdDev("BaseOverlay: Sent Ping Messages/s", numPingSent / time); globalStatistics->addStdDev("BaseOverlay: Sent Ping Bytes/s", bytesPingSent / time); globalStatistics->addStdDev("BaseOverlay: Sent Ping Response Messages/s", numPingResponseSent / time); globalStatistics->addStdDev("BaseOverlay: Sent Ping Response Bytes/s", bytesPingResponseSent / time); if (getMeasureAuthBlock()) { globalStatistics->addStdDev("BaseOverlay: Sent AuthBlock Bytes/s", bytesAuthBlockSent / time); } } }
void BaseOverlay::finishLookups | ( | ) | [private] |
deletes entries in lookups
Definition at line 1209 of file BaseOverlay.cc.
Referenced by ~BaseOverlay().
void BaseOverlay::finishOverlay | ( | ) | [protected, virtual] |
collects statistical data in derived class
Reimplemented in Broose, Gia, MyOverlay, oversim::Nice, NTree, PubSubLobby, PubSubMMOG, Quon, and Vast.
Definition at line 445 of file BaseOverlay.cc.
Referenced by finish().
{ }
virtual uint8_t BaseOverlay::getBitsPerDigit | ( | ) | [inline, virtual] |
Definition at line 812 of file BaseOverlay.h.
Referenced by Nps::coordsReqRpcResponse(), and CBRDHT::handleGetCAPIRequest().
{ return 1; };
BootstrapList& BaseOverlay::getBootstrapList | ( | ) | const [inline] |
Definition at line 816 of file BaseOverlay.h.
{ return *bootstrapList;}
cModule * BaseOverlay::getCompModule | ( | CompType | compType | ) |
Definition at line 2017 of file BaseOverlay.cc.
Referenced by XmlRpcInterface::dumpDht(), XmlRpcInterface::get(), initialize(), XmlRpcInterface::initializeApp(), XmlRpcInterface::p2pnsRegister(), XmlRpcInterface::p2pnsResolve(), and XmlRpcInterface::put().
{ CompModuleList::iterator it = compModuleList.find(compType); if (it != compModuleList.end()) return it->second.first; else return NULL; }
cGate * BaseOverlay::getCompRpcGate | ( | CompType | compType | ) |
Definition at line 2027 of file BaseOverlay.cc.
Referenced by callDeliver(), BaseApp::callRoute(), BaseApp::forwardResponse(), and BaseRpc::sendRpcMessageWithTransport().
{ CompModuleList::iterator it = compModuleList.find(compType); if (it != compModuleList.end()) return it->second.second; else return NULL; }
const simtime_t& BaseOverlay::getCreationTime | ( | ) | [inline] |
Definition at line 290 of file BaseOverlay.h.
Referenced by CryptoModule::finish().
{ return creationTime; };
int BaseOverlay::getMaxNumRedundantNodes | ( | ) | [virtual] |
Query the maximum number of redundant next hop nodes that are returned by findNode().
Reimplemented in Broose, and MyOverlay.
Definition at line 684 of file BaseOverlay.cc.
Referenced by local_lookup(), and IterativeLookup::start().
{ Enter_Method("getMaxNumRedundantNodes()"); throw cRuntimeError("getMaxNumRedundantNodes: Not implemented!"); return false; }
int BaseOverlay::getMaxNumSiblings | ( | ) | [virtual] |
Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay protocol.
Reimplemented in Broose, and MyOverlay.
Definition at line 675 of file BaseOverlay.cc.
Referenced by KBRTestApp::handleTimerEvent(), DHT::initializeApp(), CBRDHT::initializeApp(), local_lookup(), BootstrapList::locateBootstrapNode(), XmlRpcInterface::lookup(), and lookupRpc().
{ Enter_Method("getMaxNumSiblings()"); throw cRuntimeError("getMaxNumSiblings: Not implemented!"); return false; }
bool BaseOverlay::getMeasureAuthBlock | ( | ) | [inline] |
Definition at line 814 of file BaseOverlay.h.
Referenced by finish(), and sendMessageToUDP().
{ return measureAuthBlock; }
States BaseOverlay::getState | ( | ) | [inline] |
Reimplemented in Quon.
Definition at line 103 of file BaseOverlay.h.
Referenced by ConnectivityProbe::extractTopology(), and BootstrapList::locateBootstrapNode().
{ return state; };
CompType BaseOverlay::getThisCompType | ( | ) | [protected] |
Definition at line 457 of file BaseOverlay.cc.
Referenced by Vast::changeState(), Quon::changeState(), PubSubMMOG::handleAppMessage(), NTree::handleAppMessage(), Quon::handleNodeGracefulLeaveNotification(), Vast::handleNodeLeaveNotification(), PubSubMMOG::handleSubscriptionResponse(), PubSubMMOG::handleTimerEvent(), NTree::handleTimerEvent(), and initialize().
{
return OVERLAY_COMP;
}
void BaseOverlay::handleAppMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Processes "timer" self-messages.
msg | A self-message Processes non-commonAPI messages | |
msg | non-commonAPIMessage |
Reimplemented in Gia, oversim::Nice, NTree, PubSubMMOG, Quon, and Vast.
Definition at line 1049 of file BaseOverlay.cc.
Referenced by handleMessage().
{
delete msg;
}
void BaseOverlay::handleBaseOverlayMessage | ( | BaseOverlayMessage * | msg, | |
const OverlayKey & | destKey = OverlayKey::UNSPECIFIED_KEY | |||
) | [protected] |
Handles a BaseOverlayMessage
Handles BaseOverlayMessages of type OVERLAYSIGNALING, RPC, APPDATA or OVERLAYROUTE.
msg | The message to be handled | |
destKey | the destination key of the message |
Definition at line 840 of file BaseOverlay.cc.
Referenced by handleMessage(), internalHandleRpcTimeout(), nextHopRpc(), and sendToKey().
{ switch (msg->getType()) { case OVERLAYSIGNALING: handleUDPMessage(msg); return; case RPC: { // process rpc-messages BaseRpcMessage* rpcMsg = check_and_cast<BaseRpcMessage*>(msg); internalHandleRpcMessage(rpcMsg); return; } case APPDATA: { //TODO use route messages? here: set transport type to ROUTE for "naked" // app messages OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*>(msg->getControlInfo()); overlayCtrlInfo->setTransportType(ROUTE_TRANSPORT); BaseAppDataMessage* baseAppDataMsg = check_and_cast<BaseAppDataMessage*>(msg); callDeliver(baseAppDataMsg, destKey); return; } case OVERLAYROUTE: { BaseRouteMessage* baseRouteMsg = check_and_cast<BaseRouteMessage*>(msg); // collect delay-value of completed hop if (collectPerHopDelay) { baseRouteMsg->setHopDelayArraySize(baseRouteMsg-> getHopDelayArraySize() + 1); baseRouteMsg->setHopDelay(baseRouteMsg->getHopDelayArraySize() - 1, simTime() - baseRouteMsg->getHopStamp()); } OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*>(baseRouteMsg ->removeControlInfo()); // set transport type overlayCtrlInfo->setTransportType(ROUTE_TRANSPORT); // source routing: save visited nodes, copy next hops std::vector<TransportAddress> sourceRoute; if ((baseRouteMsg->getNextHopsArraySize() > 0) || (baseRouteMsg->getRoutingType() == RECURSIVE_SOURCE_ROUTING) || recordRoute) { // store the TransportAddress of the sender in the visited list baseRouteMsg->setVisitedHopsArraySize(baseRouteMsg ->getVisitedHopsArraySize() + 1); baseRouteMsg->setVisitedHops(baseRouteMsg ->getVisitedHopsArraySize() - 1, overlayCtrlInfo->getLastHop()); // remove nodes from next hops and copy them to sourceRoute if (baseRouteMsg->getNextHopsArraySize() > 0) { sourceRoute.resize(baseRouteMsg->getNextHopsArraySize()- 1); for (uint32_t i = 1; i < baseRouteMsg->getNextHopsArraySize(); ++i) { sourceRoute[i - 1] = baseRouteMsg->getNextHops(i); } baseRouteMsg->setNextHopsArraySize(0); } } overlayCtrlInfo->setSrcNode(baseRouteMsg->getSrcNode()); // decapsulate msg if node is sibling for destKey // or message is at its destination node bool err; if ((sourceRoute.size() == 0) && (baseRouteMsg->getDestKey().isUnspecified() || isSiblingFor(thisNode, baseRouteMsg->getDestKey(), 1, &err) /*&& !err*/)) { overlayCtrlInfo->setHopCount(baseRouteMsg->getHopCount()); overlayCtrlInfo->setRoutingType(baseRouteMsg->getRoutingType()); if (baseRouteMsg->getVisitedHopsArraySize() > 0) { // recorded route available => add to srcNode NodeHandle srcRoute(baseRouteMsg->getSrcNode().getKey(), baseRouteMsg->getVisitedHops(0)); for (uint32_t i = 0; i < baseRouteMsg->getVisitedHopsArraySize(); ++i) { srcRoute.appendSourceRoute(baseRouteMsg->getVisitedHops(i)); } overlayCtrlInfo->setSrcRoute(srcRoute); } else if (baseRouteMsg->getDestKey().isUnspecified()) { // directly received (neither key routed nor source routed) // TODO: does this happen for a BaseRouteMessage? overlayCtrlInfo->setSrcRoute( NodeHandle(baseRouteMsg->getSrcNode().getKey(), overlayCtrlInfo->getLastHop())); } else { // route to key and no recorded route available overlayCtrlInfo->setSrcRoute(baseRouteMsg->getSrcNode()); } // copy visited nodes to control info overlayCtrlInfo->setVisitedHopsArraySize( baseRouteMsg->getVisitedHopsArraySize()); for (uint32_t i = 0; i < baseRouteMsg->getVisitedHopsArraySize(); ++i) { overlayCtrlInfo->setVisitedHops(i, baseRouteMsg->getVisitedHops(i)); } BaseOverlayMessage* tmpMsg = check_and_cast<BaseOverlayMessage*>(baseRouteMsg ->decapsulate()); tmpMsg->setControlInfo(overlayCtrlInfo); // delay between hops if (collectPerHopDelay) { RECORD_STATS( size_t i; for (i = singleHopDelays.size(); i < baseRouteMsg->getHopDelayArraySize();) { singleHopDelays.push_back(new HopDelayRecord[++i]); } i = baseRouteMsg->getHopDelayArraySize() - 1; HopDelayRecord* hdr = singleHopDelays[i]; for (size_t j = 0; j <= i; ++j) { hdr[j].count++; hdr[j].val += baseRouteMsg->getHopDelay(j); } ); } // handle encapsulated message at destination node if (((baseRouteMsg->getRoutingType() == ITERATIVE_ROUTING) || (baseRouteMsg->getRoutingType() == EXHAUSTIVE_ITERATIVE_ROUTING) ) || recursiveRoutingHook(thisNode, baseRouteMsg)) { handleBaseOverlayMessage(tmpMsg, baseRouteMsg->getDestKey()); delete baseRouteMsg; } return; } else { // forward msg if this node is not responsible for the key baseRouteMsg->setControlInfo(overlayCtrlInfo); // if this node is malicious drop the message if (isMalicious() && dropRouteMessageAttack) { EV << "[BaseOverlay::handleBaseOverlayMessage() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " BaseRouteMessage gets dropped because this node is malicious" << endl; //std::cout << "malicious!" << std::endl; RECORD_STATS(numDropped++; bytesDropped += baseRouteMsg->getByteLength()); delete baseRouteMsg; return; } sendToKey(baseRouteMsg->getDestKey(), baseRouteMsg, 1, sourceRoute); return; } break; } default: EV << "[BaseOverlay::handleBaseOverlayMessage() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Received unknown message from UDP of type " << msg->getName() << endl; break; } }
bool BaseOverlay::handleFailedNode | ( | const TransportAddress & | failed | ) | [protected, virtual] |
Handles a failed node.
This method is called whenever a node given by findNode() was unreachable. The default implementation does nothing at all.
failed | the failed node |
Definition at line 1665 of file BaseOverlay.cc.
Referenced by failedNodeRpc(), IterativePathLookup::handleTimeout(), internalHandleRpcTimeout(), BasePastry::pingTimeout(), and BasePastry::proxCallback().
{ return true; }
void BaseOverlay::handleMessage | ( | cMessage * | msg | ) | [protected] |
Checks for message type and calls corresponding method.
Checks for message type (from UDP/App or selfmessage) and calls corresponding method like getRoute(), get(), put(), remove(), handleTimerEvent(), handleAppMessage() and handleUDPMessage().
msg | The message to be handled |
Definition at line 699 of file BaseOverlay.cc.
{ if (msg->getArrivalGate() == udpGate) { UDPControlInfo* udpControlInfo = check_and_cast<UDPControlInfo*>(msg->removeControlInfo()); OverlayCtrlInfo* overlayCtrlInfo = new OverlayCtrlInfo; overlayCtrlInfo->setLastHop(TransportAddress( udpControlInfo->getSrcAddr(), udpControlInfo->getSrcPort())); overlayCtrlInfo->setSrcRoute(overlayCtrlInfo->getLastHop()); overlayCtrlInfo->setTransportType(UDP_TRANSPORT); msg->setControlInfo(overlayCtrlInfo); delete udpControlInfo; // debug message if (debugOutput) { EV << "[BaseOverlay:handleMessage() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Received " << *msg << " from " << overlayCtrlInfo->getLastHop().getIp() << endl; } BaseOverlayMessage* baseOverlayMsg = dynamic_cast<BaseOverlayMessage*>(msg); if (baseOverlayMsg == NULL) { cPacket* packet = check_and_cast<cPacket*>(msg); RECORD_STATS(numDropped++; bytesDropped += packet->getByteLength()); delete msg; return; } // records stats if message is not a UDP "self message" if (overlayCtrlInfo->getLastHop() != thisNode) { // is this from anywhere else? if (baseOverlayMsg->getStatType() == APP_DATA_STAT) RECORD_STATS(numAppDataReceived++; bytesAppDataReceived += baseOverlayMsg->getByteLength()); else if (baseOverlayMsg->getStatType() == APP_LOOKUP_STAT) RECORD_STATS(numAppLookupReceived++;bytesAppLookupReceived += baseOverlayMsg->getByteLength()); else // MAINTENANCE_STAT RECORD_STATS(numMaintenanceReceived++; bytesMaintenanceReceived += baseOverlayMsg->getByteLength()); } if (overlayCtrlInfo->getLastHop().getIp() == thisNode.getIp()) { // is this from the same node? RECORD_STATS(numInternalReceived++; bytesInternalReceived += baseOverlayMsg->getByteLength()); } else overlayCtrlInfo->setHopCount(1); // process rpc calls/responses or BaseOverlayMessages if (!internalHandleMessage(msg)) { handleBaseOverlayMessage(baseOverlayMsg); } } // process timer events and rpc timeouts else if (internalHandleMessage(msg)) return; // process CommonAPIMessages from App else if (dynamic_cast<CommonAPIMessage*>(msg) != NULL) { if (dynamic_cast<KBRroute*>(msg) != NULL) { KBRroute* apiMsg = static_cast<KBRroute*>(msg); std::vector<TransportAddress> sourceRoute; for (uint32_t i = 0; i < apiMsg->getSourceRouteArraySize(); ++i) sourceRoute.push_back(apiMsg->getSourceRoute(i)); route(apiMsg->getDestKey(), static_cast<CompType>(apiMsg->getDestComp()), static_cast<CompType>(apiMsg->getSrcComp()), apiMsg->decapsulate(), sourceRoute); } else if (dynamic_cast<KBRforward*>(msg) != NULL) { KBRforward* apiMsg = static_cast<KBRforward*>(msg); OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*> (msg->removeControlInfo()); BaseAppDataMessage* dataMsg = new BaseAppDataMessage(); dataMsg->setType(APPDATA); dataMsg->setBitLength(BASEAPPDATA_L(dataMsg)); dataMsg->setName(apiMsg->getEncapsulatedPacket()->getName()); dataMsg->encapsulate(apiMsg->decapsulate()); dataMsg->setSrcComp(overlayCtrlInfo->getSrcComp()); dataMsg->setDestComp(overlayCtrlInfo->getDestComp()); dataMsg->setStatType(APP_DATA_STAT); BaseRouteMessage* routeMsg = new BaseRouteMessage(dataMsg->getName()); routeMsg->setType(OVERLAYROUTE); routeMsg->setBitLength(BASEROUTE_L(routeMsg)); routeMsg->encapsulate(dataMsg); routeMsg->setStatType(APP_DATA_STAT); routeMsg->setRoutingType(overlayCtrlInfo->getRoutingType()); routeMsg->setDestKey(apiMsg->getDestKey()); routeMsg->setSrcNode(overlayCtrlInfo->getSrcNode()); routeMsg->setHopCount(overlayCtrlInfo->getHopCount()); routeMsg->setControlInfo(overlayCtrlInfo); // message marked with this-pointer as already forwarded to tier1 routeMsg->setContextPointer(this); std::vector<TransportAddress> sourceRoute; sourceRoute.push_back(apiMsg->getNextHopNode()); sendToKey(apiMsg->getDestKey(), routeMsg, 1, sourceRoute); } delete msg; } // process other messages from App else if (msg->getArrivalGate() == appGate) { handleAppMessage(msg); } else if(msg->arrivedOn("tcpIn")) { handleTCPMessage(msg); } else if (dynamic_cast<CompReadyMessage*>(msg)) { CompReadyMessage* readyMsg = static_cast<CompReadyMessage*>(msg); if (((bool)par("joinOnApplicationRequest") == false) && readyMsg->getReady() && readyMsg->getComp() == NEIGHBORCACHE_COMP) { cObject** context = globalNodeList->getContext(getThisNode()); if (restoreContext && context && *context) { BaseOverlayContext* overlayContext = static_cast<BaseOverlayContext*>(*context); globalNodeList->setMalicious(getThisNode(), overlayContext->malicious); join(overlayContext->key); } else { join(); } } delete msg; } else { throw cRuntimeError("BaseOverlay::handleMessage(): Received msg with " "unknown type!"); delete msg; } }
void BaseOverlay::handleNodeGracefulLeaveNotification | ( | ) | [protected, virtual] |
This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.
Reimplemented in NTree, Quon, and Vast.
Definition at line 1043 of file BaseOverlay.cc.
Referenced by receiveChangeNotification().
{
// ...
}
void BaseOverlay::handleNodeLeaveNotification | ( | ) | [protected, virtual] |
This method gets call **.gracefulLeaveDelay seconds before it is killed.
Reimplemented in oversim::Nice, and Vast.
Definition at line 1038 of file BaseOverlay.cc.
Referenced by receiveChangeNotification().
{
// ...
}
void BaseOverlay::handleTransportAddressChangedNotification | ( | ) | [protected, virtual] |
This method gets call if the node has a new TransportAddress (IP address) because he changed his access network.
Definition at line 1029 of file BaseOverlay.cc.
Referenced by receiveChangeNotification().
{ // get new ip address thisNode.setIp(IPAddressResolver().addressOf( getParentModule()->getParentModule())); joinOverlay(); }
void BaseOverlay::handleUDPMessage | ( | BaseOverlayMessage * | msg | ) | [protected, virtual] |
Processes messages from underlay.
msg | Message from UDP |
Reimplemented in Gia, oversim::Nice, NTree, PubSubLobby, PubSubMMOG, Quon, and Vast.
Definition at line 1054 of file BaseOverlay.cc.
Referenced by handleBaseOverlayMessage().
{
delete msg;
}
void BaseOverlay::initialize | ( | int | stage | ) | [private] |
initializes base-class-attributes
stage | the init stage |
Definition at line 77 of file BaseOverlay.cc.
{ if (stage == 0) { OverlayKey::setKeyLength(par("keyLength")); } if (stage == REGISTER_STAGE) { registerComp(getThisCompType(), this); return; } if (stage == MIN_STAGE_OVERLAY) { // find friend modules globalNodeList = GlobalNodeListAccess().get(); underlayConfigurator = UnderlayConfiguratorAccess().get(); notificationBoard = NotificationBoardAccess().get(); globalParameters = GlobalParametersAccess().get(); bootstrapList = check_and_cast<BootstrapList*>(getParentModule()-> getParentModule()->getSubmodule("bootstrapList", 0)); udpGate = gate("udpIn"); appGate = gate("appIn"); // fetch some parameters debugOutput = par("debugOutput"); collectPerHopDelay = par("collectPerHopDelay"); localPort = par("localPort"); hopCountMax = par("hopCountMax"); drawOverlayTopology = par("drawOverlayTopology"); rejoinOnFailure = par("rejoinOnFailure"); sendRpcResponseToLastHop = par("sendRpcResponseToLastHop"); dropFindNodeAttack = par("dropFindNodeAttack"); isSiblingAttack = par("isSiblingAttack"); invalidNodesAttack = par("invalidNodesAttack"); dropRouteMessageAttack = par("dropRouteMessageAttack"); measureAuthBlock = par("measureAuthBlock"); restoreContext = par("restoreContext"); // we assume most overlays don't provide KBR services kbr = false; // set routing type std::string temp = par("routingType").stdstringValue(); if (temp == "iterative") defaultRoutingType = ITERATIVE_ROUTING; else if (temp == "exhaustive-iterative") defaultRoutingType = EXHAUSTIVE_ITERATIVE_ROUTING; else if (temp == "semi-recursive") defaultRoutingType = SEMI_RECURSIVE_ROUTING; else if (temp == "full-recursive") defaultRoutingType = FULL_RECURSIVE_ROUTING; else if (temp == "source-routing-recursive") defaultRoutingType = RECURSIVE_SOURCE_ROUTING; else throw cRuntimeError((std::string("Wrong routing type: ") + temp).c_str()); useCommonAPIforward = par("useCommonAPIforward"); routeMsgAcks = par("routeMsgAcks"); recNumRedundantNodes = par("recNumRedundantNodes"); recordRoute = par("recordRoute"); // set base lookup parameters iterativeLookupConfig.redundantNodes = par("lookupRedundantNodes"); iterativeLookupConfig.parallelPaths = par("lookupParallelPaths"); iterativeLookupConfig.parallelRpcs = par("lookupParallelRpcs"); iterativeLookupConfig.verifySiblings = par("lookupVerifySiblings"); iterativeLookupConfig.majoritySiblings = par("lookupMajoritySiblings"); iterativeLookupConfig.merge = par("lookupMerge"); iterativeLookupConfig.failedNodeRpcs = par("lookupFailedNodeRpcs"); iterativeLookupConfig.strictParallelRpcs = par("lookupStrictParallelRpcs"); iterativeLookupConfig.useAllParallelResponses = par("lookupUseAllParallelResponses"); iterativeLookupConfig.newRpcOnEveryTimeout = par("lookupNewRpcOnEveryTimeout"); iterativeLookupConfig.newRpcOnEveryResponse = par("lookupNewRpcOnEveryResponse"); iterativeLookupConfig.finishOnFirstUnchanged = par("lookupFinishOnFirstUnchanged"); iterativeLookupConfig.visitOnlyOnce = par("lookupVisitOnlyOnce"); iterativeLookupConfig.acceptLateSiblings = par("lookupAcceptLateSiblings"); recursiveLookupConfig.redundantNodes = par("lookupRedundantNodes"); recursiveLookupConfig.numRetries = 0; //TODO // statistics numAppDataSent = 0; bytesAppDataSent = 0; numAppLookupSent = 0; bytesAppLookupSent = 0; numMaintenanceSent = 0; bytesMaintenanceSent = 0; numAppDataReceived = 0; bytesAppDataReceived = 0; numAppLookupReceived = 0; bytesAppLookupReceived = 0; numMaintenanceReceived = 0; bytesMaintenanceReceived = 0; numAppDataForwarded = 0; bytesAppDataForwarded = 0; numAppLookupForwarded = 0; bytesAppLookupForwarded = 0; numMaintenanceForwarded = 0; bytesMaintenanceForwarded = 0; bytesAuthBlockSent = 0; numDropped = 0; bytesDropped = 0; numFindNodeSent = 0; bytesFindNodeSent = 0; numFindNodeResponseSent = 0; bytesFindNodeResponseSent = 0; numFailedNodeSent = 0; bytesFailedNodeSent = 0; numFailedNodeResponseSent = 0; bytesFailedNodeResponseSent = 0; joinRetries = 0; numInternalSent = 0; bytesInternalSent = 0; numInternalReceived = 0; bytesInternalReceived = 0; WATCH(numAppDataSent); WATCH(bytesAppDataSent); WATCH(numAppLookupSent); WATCH(bytesAppLookupSent); WATCH(numMaintenanceSent); WATCH(bytesMaintenanceSent); WATCH(numAppDataReceived); WATCH(bytesAppDataReceived); WATCH(numAppLookupReceived); WATCH(bytesAppLookupReceived); WATCH(numMaintenanceReceived); WATCH(bytesMaintenanceReceived); WATCH(numAppDataForwarded); WATCH(bytesAppDataForwarded); WATCH(numAppLookupForwarded); WATCH(bytesAppLookupForwarded); WATCH(numMaintenanceForwarded); WATCH(bytesMaintenanceForwarded); WATCH(numDropped); WATCH(bytesDropped); WATCH(numFindNodeSent); WATCH(bytesFindNodeSent); WATCH(numFindNodeResponseSent); WATCH(bytesFindNodeResponseSent); WATCH(numFailedNodeSent); WATCH(bytesFailedNodeSent); WATCH(numFailedNodeResponseSent); WATCH(bytesFailedNodeResponseSent); WATCH(joinRetries); if (isInSimpleMultiOverlayHost()) { WATCH(numInternalSent); WATCH(bytesInternalSent); WATCH(numInternalReceived); WATCH(bytesInternalReceived); } // set up local nodehandle thisNode.setIp(IPAddressResolver(). addressOf(getParentModule()->getParentModule())); thisNode.setKey(OverlayKey::UNSPECIFIED_KEY); state = INIT; internalReadyState = false; getDisplayString().setTagArg("i", 1, "red"); globalNodeList->setOverlayReadyIcon(getThisNode(), false); // set up UDP bindToPort(localPort); // subscribe to the notification board notificationBoard->subscribe(this, NF_OVERLAY_TRANSPORTADDRESS_CHANGED); notificationBoard->subscribe(this, NF_OVERLAY_NODE_LEAVE); notificationBoard->subscribe(this, NF_OVERLAY_NODE_GRACEFUL_LEAVE); // init visualization with terminal ptr if (drawOverlayTopology) initVis(getParentModule()->getParentModule()); // init rpcs initRpcs(); initLookups(); // set TCP output gate setTcpOut(gate("tcpOut")); // statistics creationTime = simTime(); WATCH(creationTime); } if (stage >= MIN_STAGE_OVERLAY && stage <= MAX_STAGE_OVERLAY) initializeOverlay(stage); if (stage == MAX_STAGE_TIER_1) { // bootstrapList registered its gate to the overlay 0 // if this is not overlay 0, we may not have the gate, so retrieve it // this assumes that the overlay is in a container module! if (!compModuleList.count(BOOTSTRAPLIST_COMP)) { BaseOverlay *firstOverlay = dynamic_cast<BaseOverlay*> (getParentModule()->getParentModule() ->getSubmodule("overlay", 0)->gate("appIn") ->getNextGate()->getOwnerModule()); if (!firstOverlay) { throw cRuntimeError("BaseOverlay.cc: " "Couldn't obtain bootstrap gate"); } registerComp(BOOTSTRAPLIST_COMP, firstOverlay->getCompModule(BOOTSTRAPLIST_COMP)); } } }
void BaseOverlay::initializeOverlay | ( | int | stage | ) | [protected, virtual] |
Initializes derived-class-attributes.
Initializes derived-class-attributes, called by BaseOverlay::initialize(). By default this method is called once. If more stages are needed one can overload numInitStages() and add more stages.
stage | the init stage |
Reimplemented in Broose, Gia, MyOverlay, oversim::Nice, NTree, PubSubLobby, PubSubMMOG, Quon, and Vast.
Definition at line 300 of file BaseOverlay.cc.
Referenced by initialize().
{ }
void BaseOverlay::initLookups | ( | ) | [private] |
bool BaseOverlay::internalHandleRpcCall | ( | BaseCallMessage * | msg | ) | [protected] |
Definition at line 1675 of file BaseOverlay.cc.
{ // call rpc stubs RPC_SWITCH_START( msg ); RPC_DELEGATE( FindNode, findNodeRpc ); RPC_DELEGATE( FailedNode, failedNodeRpc ); RPC_DELEGATE( Lookup, lookupRpc ); RPC_DELEGATE( NextHop, nextHopRpc ); RPC_SWITCH_END( ); // if RPC was handled return true, else tell the parent class to handle it return RPC_HANDLED || BaseRpc::internalHandleRpcCall(msg); }
void BaseOverlay::internalHandleRpcResponse | ( | BaseResponseMessage * | msg, | |
cPolymorphic * | context, | |||
int | rpcId, | |||
simtime_t | rtt | |||
) | [protected] |
Definition at line 1689 of file BaseOverlay.cc.
{ BaseRpc::internalHandleRpcResponse(msg, context, rpcId, rtt); }
void BaseOverlay::internalHandleRpcTimeout | ( | BaseCallMessage * | msg, | |
const TransportAddress & | dest, | |||
cPolymorphic * | context, | |||
int | rpcId, | |||
const OverlayKey & | destKey | |||
) | [protected] |
Definition at line 1696 of file BaseOverlay.cc.
{ RPC_SWITCH_START( msg ) RPC_ON_CALL( NextHop ) { BaseRouteMessage* tempMsg = check_and_cast<BaseRouteMessage*>(msg->decapsulate()); assert(!tempMsg->getControlInfo()); if (!tempMsg->getControlInfo()) { OverlayCtrlInfo* overlayCtrlInfo = new OverlayCtrlInfo; overlayCtrlInfo->setLastHop(thisNode); overlayCtrlInfo->setHopCount(tempMsg->getHopCount()); overlayCtrlInfo->setSrcNode(tempMsg->getSrcNode()); overlayCtrlInfo->setRoutingType(tempMsg->getRoutingType()); overlayCtrlInfo->setTransportType(UDP_TRANSPORT); tempMsg->setControlInfo(overlayCtrlInfo); } // remove node from local routing tables // + route message again if possible assert(!dest.isUnspecified() && destKey.isUnspecified()); if (handleFailedNode(dest)) { if (!tempMsg->getDestKey().isUnspecified()) { // TODO: msg is resent only in recursive mode EV << "[BaseOverlay::internalHandleRpcTimeout() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Resend msg for key " << destKey << endl; handleBaseOverlayMessage(tempMsg, destKey); } else if(tempMsg->getNextHopsArraySize() > 1) { for (uint8_t i = 0; i < tempMsg->getNextHopsArraySize() - 1; ++i) { tempMsg->setNextHops(i, tempMsg->getNextHops(i + 1)); } tempMsg->setNextHopsArraySize(tempMsg->getNextHopsArraySize() - 1); EV << "[BaseOverlay::internalHandleRpcTimeout() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Resend msg to next available node in nextHops[]: " << tempMsg->getNextHops(0).getIp() << std::endl; handleBaseOverlayMessage(tempMsg); } else { EV << "[BaseOverlay::internalHandleRpcTimeout() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " dropping msg for " << dest << endl; RECORD_STATS(numDropped++; bytesDropped += tempMsg->getByteLength()); delete tempMsg; } } else { RECORD_STATS(numDropped++; bytesDropped += tempMsg->getByteLength()); delete tempMsg; join(); } break; } RPC_SWITCH_END( ) BaseRpc::internalHandleRpcTimeout(msg, dest, context, rpcId, destKey); }
void BaseOverlay::internalSendRouteRpc | ( | BaseRpcMessage * | message, | |
const OverlayKey & | destKey, | |||
const std::vector< TransportAddress > & | sourceRoute, | |||
RoutingType | routingType | |||
) | [protected] |
Definition at line 1764 of file BaseOverlay.cc.
{ FindNodeCall* findNodeCall; uint32_t numSiblings = 1; if ((findNodeCall = dynamic_cast<FindNodeCall*>(message))) numSiblings = findNodeCall->getNumSiblings(); sendToKey(destKey, message, numSiblings, sourceRoute, routingType); }
void BaseOverlay::internalSendRpcResponse | ( | BaseCallMessage * | call, | |
BaseResponseMessage * | response | |||
) | [private] |
Definition at line 1777 of file BaseOverlay.cc.
{ OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*>(call->getControlInfo()); TransportType transportType = ROUTE_TRANSPORT; const TransportAddress* destNode; if (overlayCtrlInfo->getSrcNode().isUnspecified()) { if (sendRpcResponseToLastHop) { // used for KBR protocols to deal with NATs // (srcNode in call message may contain private IP address) destNode = &(overlayCtrlInfo->getLastHop()); } else { // used for non-KBR protocols which have to route RPC calls // but can't use BaseRouteMessage (this doesn't work with NATs) destNode = &(call->getSrcNode()); } } else { destNode = &(overlayCtrlInfo->getSrcNode()); } const OverlayKey* destKey = &OverlayKey::UNSPECIFIED_KEY; RoutingType routingType = static_cast<RoutingType>(overlayCtrlInfo->getRoutingType()); assert(overlayCtrlInfo->getTransportType() != INTERNAL_TRANSPORT); if ((overlayCtrlInfo->getTransportType() == UDP_TRANSPORT) || (routingType == SEMI_RECURSIVE_ROUTING) || (routingType == ITERATIVE_ROUTING) || (routingType == EXHAUSTIVE_ITERATIVE_ROUTING) ) { // received by UDP or direct response (IR, EIR or SRR routing) transportType = UDP_TRANSPORT; overlayCtrlInfo->setVisitedHopsArraySize(0); //??? } else if ((static_cast<RoutingType> (overlayCtrlInfo->getRoutingType()) == FULL_RECURSIVE_ROUTING)) { // full recursive routing destKey = &(overlayCtrlInfo->getSrcNode().getKey()); destNode = &NodeHandle::UNSPECIFIED_NODE; } // else: source routing -> route back over visited hops sendRpcResponse(transportType, static_cast<CompType>(overlayCtrlInfo->getSrcComp()), *destNode, *destKey, call, response); }
bool BaseOverlay::isInSimpleMultiOverlayHost | ( | ) |
Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.
Definition at line 2053 of file BaseOverlay.cc.
Referenced by finish(), and initialize().
{
return isVector() || getParentModule()->isVector();
}
bool BaseOverlay::isMalicious | ( | ) |
Returns true, if node is malicious.
Definition at line 452 of file BaseOverlay.cc.
Referenced by findNodeRpc(), handleBaseOverlayMessage(), DHT::handleGetRequest(), join(), DHT::sendMaintenancePutCall(), and setOverlayReady().
{ return globalNodeList->isMalicious(getThisNode()); }
bool BaseOverlay::isSiblingFor | ( | const NodeHandle & | node, | |
const OverlayKey & | key, | |||
int | numSiblings, | |||
bool * | err | |||
) | [virtual] |
Query if a node is among the siblings for a given key.
Query if a node is among the siblings for a given key. This means, that the nodeId of this node is among the closest numSiblings nodes to the key and that by a local findNode() call all other siblings to this key can be retrieved.
node | the NodeHandle | |
key | destination key | |
numSiblings | The nodes knows all numSiblings nodes close to this key | |
err | return false if the range could not be determined |
Reimplemented in Broose, and MyOverlay.
Definition at line 665 of file BaseOverlay.cc.
Referenced by findNodeRpc(), handleBaseOverlayMessage(), DHT::handlePutRequest(), CBRDHT::handlePutRequest(), BaseApp::isSiblingFor(), sendToKey(), IterativeLookup::start(), DHT::update(), and CBRDHT::update().
{ Enter_Method("isSiblingFor()"); throw cRuntimeError("isSiblingFor: Not implemented!"); return false; }
void BaseOverlay::join | ( | const OverlayKey & | nodeID = OverlayKey::UNSPECIFIED_KEY |
) |
Join the overlay with a given nodeID.
Join the overlay with a given nodeID. This method may be called by an application to join the overlay with a specific nodeID. It is also called if the node's IP address changes.
nodeID | The new nodeID for this node. |
Definition at line 580 of file BaseOverlay.cc.
Referenced by Nps::coordsReqRpcResponse(), oversim::Chord::findNode(), Pastry::handleFailedNode(), Bamboo::handleFailedNode(), handleMessage(), oversim::Chord::handleRpcTimeout(), Pastry::handleTimerEvent(), internalHandleRpcTimeout(), XmlRpcInterface::joinOverlay(), and Kademlia::routingTimeout().
{ Enter_Method("join()"); joinRetries++; if (((state == READY) || (state == FAILED)) && !rejoinOnFailure) { state = FAILED; return; } if (state != READY) { // set nodeID and IP thisNode.setIp( IPAddressResolver().addressOf(getParentModule()->getParentModule())); if (!nodeID.isUnspecified()) { thisNode.setKey(nodeID); } else if (thisNode.getKey().isUnspecified()) { std::string nodeIdStr = par("nodeId").stdstringValue(); if (nodeIdStr.size()) { // manual configuration of nodeId in ini file thisNode.setKey(OverlayKey(nodeIdStr)); } else { setOwnNodeID(); } } } cObject** context = globalNodeList->getContext(getThisNode()); if (restoreContext && context) { if (*context == NULL) { *context = new BaseOverlayContext(getThisNode().getKey(), isMalicious()); } } joinOverlay(); }
void BaseOverlay::joinForeignPartition | ( | const NodeHandle & | node | ) | [protected, virtual] |
Join another overlay partition with the given node as bootstrap node.
Join another overlay partition with the given node as bootstrap node. This method is called to join a foreign overlay partition and start the merging process.
node | The foreign bootstrap node |
Definition at line 621 of file BaseOverlay.cc.
Referenced by BootstrapList::handleLookupResponse().
{ throw cRuntimeError("BaseOverlay::joinForeignPartition(): " "This overlay doesn't support merging!"); }
void BaseOverlay::joinOverlay | ( | ) | [protected, virtual] |
Join the overlay with a given nodeID in thisNode.key.
Join the overlay with a given nodeID in thisNode.key. This method may be called by an application to join the overlay with a specific nodeID. It is also called if the node's IP address changes.
Reimplemented in Broose, Gia, MyOverlay, and oversim::Nice.
Definition at line 1659 of file BaseOverlay.cc.
Referenced by handleTransportAddressChangedNotification(), and join().
{ // std::cout << "BaseOverlay::joinOverlay(): Not implemented!" << endl; return; }
NodeVector * BaseOverlay::local_lookup | ( | const OverlayKey & | key, | |
int | num, | |||
bool | safe | |||
) | [virtual] |
finds nodes closest to the given OverlayKey
calls findNode() (that should be overridden in derived overlay) and returns a list with (num) nodes ordered by distance to the node defined by key.
key | the given node | |
num | number of nodes that are returned | |
safe | The safe parameters is not implemented yet |
Definition at line 560 of file BaseOverlay.cc.
Referenced by BaseApp::callLocalLookup(), XmlRpcInterface::localLookup(), neighborSet(), and DHT::update().
{ Enter_Method("local_lookup()"); if (safe == true) { throw cRuntimeError("BaseOverlay::local_lookup(): " "safe flag is not implemented!"); } if (num < 0) num = INT_MAX; NodeVector* nodeVector = findNode(key, min(num, getMaxNumRedundantNodes()), min(num,getMaxNumSiblings())); if (((int)nodeVector->size()) > num) nodeVector->resize(num); return nodeVector; }
void BaseOverlay::lookupRpc | ( | LookupCall * | call | ) | [protected, virtual] |
Definition at line 1937 of file BaseOverlay.cc.
Referenced by internalHandleRpcCall().
{ int numSiblings = call->getNumSiblings(); if (numSiblings < 0) { numSiblings = getMaxNumSiblings(); } if (internalReadyState == false) { // overlay not ready => lookup failed EV << "[BaseOverlay::lookupRpc() @ " << getThisNode().getIp() << " (" << getThisNode().getKey().toString(16) << ")]\n" << " LookupCall " << call->getNonce() << " failed, because overlay module is not ready!" << endl; LookupResponse* response = new LookupResponse(); response->setKey(call->getKey()); response->setIsValid(false); sendRpcResponse(call, response); return; } // create lookup and sent to key AbstractLookup* lookup = createLookup(static_cast<RoutingType>( call->getRoutingType()), call, NULL, true); lookup->lookup(call->getKey(), numSiblings, hopCountMax, 1, new SendToKeyListener( this, call )); }
NodeVector * BaseOverlay::neighborSet | ( | int | num | ) | [virtual] |
Definition at line 632 of file BaseOverlay.cc.
Referenced by BaseApp::callNeighborSet().
{ Enter_Method("neighborSet()"); return local_lookup(thisNode.getKey(), num, false); }
void BaseOverlay::nextHopRpc | ( | NextHopCall * | call | ) | [protected, virtual] |
Definition at line 1970 of file BaseOverlay.cc.
Referenced by internalHandleRpcCall().
{ if (state != READY) { //TODO EV... delete call; return; } BaseRouteMessage* routeMsg = check_and_cast<BaseRouteMessage*>(call->decapsulate()); OverlayCtrlInfo* overlayCtrlInfo = check_and_cast<OverlayCtrlInfo*>(call->getControlInfo()->dup()); overlayCtrlInfo->setHopCount(routeMsg->getHopCount()); overlayCtrlInfo->setSrcNode(routeMsg->getSrcNode()); overlayCtrlInfo->setRoutingType(routeMsg->getRoutingType()); routeMsg->setControlInfo(overlayCtrlInfo); assert(routeMsg->getControlInfo()); std::string temp("ACK: ["); (temp += routeMsg->getName()) += "]"; NextHopResponse* response = new NextHopResponse(temp.c_str()); response->setBitLength(NEXTHOPRESPONSE_L(response)); sendRpcResponse(call, response); handleBaseOverlayMessage(routeMsg, routeMsg->getDestKey()); }
int BaseOverlay::numInitStages | ( | ) | const [protected] |
Sets init stage.
Definition at line 72 of file BaseOverlay.cc.
{
return NUM_STAGES_ALL;
}
bool BaseOverlay::providesKbr | ( | ) | [inline] |
Definition at line 810 of file BaseOverlay.h.
{ return kbr; };
void BaseOverlay::receiveChangeNotification | ( | int | category, | |
const cPolymorphic * | details | |||
) | [protected, virtual] |
callback-method for events at the NotificationBoard
category | ... TODO ... | |
details | ... TODO ... |
Reimplemented in PubSubMMOG.
Definition at line 1017 of file BaseOverlay.cc.
{ Enter_Method_Silent(); if (category == NF_OVERLAY_TRANSPORTADDRESS_CHANGED) { handleTransportAddressChangedNotification(); } else if (category == NF_OVERLAY_NODE_LEAVE) { handleNodeLeaveNotification(); } else if (category == NF_OVERLAY_NODE_GRACEFUL_LEAVE) { handleNodeGracefulLeaveNotification(); } }
void BaseOverlay::recordOverlaySentStats | ( | BaseOverlayMessage * | msg | ) | [protected, virtual] |
Collect overlay specific sent messages statistics.
This method is called from BaseOverlay::sendMessageToUDP() for every overlay message that is sent by a node. Use this to collect statistical data for overlay protocol specific message types.
msg | The overlay message to be sent to the UDP layer |
Reimplemented in Broose.
Definition at line 1060 of file BaseOverlay.cc.
Referenced by sendMessageToUDP().
{
// collect statistics ...
}
bool BaseOverlay::recursiveRoutingHook | ( | const TransportAddress & | dest, | |
BaseRouteMessage * | msg | |||
) | [private, virtual] |
Hook for forwarded message in recursive lookup mode.
This hook is called just before a message is forwarded to a next hop or if the message is at its destination just before it is sent to the app. Default implementation just returns true. This hook can for example be used to detect failed nodes and call handleFailedNode() before the actual forwarding takes place.
dest | destination node | |
msg | message to send |
Definition at line 1360 of file BaseOverlay.cc.
Referenced by handleBaseOverlayMessage(), and sendToKey().
{ return true; }
void BaseOverlay::registerComp | ( | CompType | compType, | |
cModule * | module | |||
) |
Definition at line 2001 of file BaseOverlay.cc.
Referenced by initialize(), and BaseRpc::initRpcs().
{ cGate *gate = NULL; if (module != NULL) { gate = module->gate("direct_in"); if (gate == NULL) { throw cRuntimeError("BaseOverlay::registerComp(): The module " "which tried to register has " "no direct_in gate!"); } } compModuleList[compType] = make_pair<cModule*, cGate*>(module, gate); }
void BaseOverlay::removeLookup | ( | AbstractLookup * | lookup | ) | [protected, virtual] |
Removes the abstract lookup instance.
lookup | the Lookup to remove |
Definition at line 1634 of file BaseOverlay.cc.
Referenced by IterativeLookup::~IterativeLookup(), and RecursiveLookup::~RecursiveLookup().
{ lookups.erase(lookup); }
void BaseOverlay::route | ( | const OverlayKey & | key, | |
CompType | destComp, | |||
CompType | srcComp, | |||
cPacket * | msg, | |||
const std::vector< TransportAddress > & | sourceRoute = TransportAddress::UNSPECIFIED_NODES , |
|||
RoutingType | routingType = DEFAULT_ROUTING | |||
) | [protected, virtual] |
Routes message through overlay.
The default implementation uses FindNode to determine next hops and a generic greedy routing algorithm provides with SendToKey.
key | destination key | |
destComp | the destination component | |
srcComp | the source component | |
msg | message to route | |
sourceRoute | If sourceRoute is given, the message gets sent via all nodes in the list before it is routed (nextHop is used as a proxy) | |
routingType | specifies the routing mode (ITERATIVE_ROUTING, ...) |
Definition at line 1309 of file BaseOverlay.cc.
Referenced by handleMessage().
{ if (key.isUnspecified() && (!sourceRoute.size() || sourceRoute[0].isUnspecified())) throw cRuntimeError("route(): Key and hint unspecified!"); // encapsulate in a app data message for multiplexing // to destination component BaseAppDataMessage* baseAppDataMsg = new BaseAppDataMessage("BaseAppDataMessage"); baseAppDataMsg->setType(APPDATA); baseAppDataMsg->setDestComp(destComp); baseAppDataMsg->setSrcComp(srcComp); baseAppDataMsg->setBitLength(BASEAPPDATA_L(baseAppDataMsg)); baseAppDataMsg->setName(msg->getName()); baseAppDataMsg->setStatType(APP_DATA_STAT); baseAppDataMsg->encapsulate(msg); // debug output if (debugOutput) { EV << "[BaseOverlay::route() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Received message from application" << endl; } if (key.isUnspecified() && sourceRoute.size() <= 1) { sendMessageToUDP(sourceRoute[0], baseAppDataMsg); } else { if (internalReadyState == false) { // overlay not ready => sendToKey doesn't work yet EV << "[BaseOverlay::route() @ " << getThisNode().getIp() << " (" << getThisNode().getKey().toString(16) << ")]\n" << " Couldn't route application message to key " << key.toString(16) << " because the overlay module is not ready!" << endl; RECORD_STATS(numDropped++; bytesDropped += baseAppDataMsg->getByteLength()); delete baseAppDataMsg; return; } sendToKey(key, baseAppDataMsg, 1, sourceRoute, routingType); } }
void BaseOverlay::sendMessageToAllComp | ( | cMessage * | msg, | |
CompType | srcComp | |||
) |
Definition at line 2037 of file BaseOverlay.cc.
Referenced by BaseApp::sendReadyMessage(), and setOverlayReady().
{ Enter_Method_Silent(); take(msg); for (CompModuleList::iterator it = compModuleList.begin(); it != compModuleList.end(); it++) { // don't send message to the origination component if (it->first != srcComp) sendDirect((cMessage*)msg->dup(), it->second.second); } delete msg; }
void BaseOverlay::sendMessageToUDP | ( | const TransportAddress & | dest, | |
cPacket * | msg | |||
) |
Sends message to underlay.
dest | destination node | |
msg | message to send |
Definition at line 1146 of file BaseOverlay.cc.
Referenced by oversim::Nice::BasicJoinLayer(), oversim::Nice::ClusterMergeRequest(), Bamboo::doLocalTuning(), Pastry::doRoutingTableMaintenance(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), PubSubMMOG::handleAdoptChildResponse(), PubSubMMOG::handleBackupCallTimeout(), PubSubMMOG::handleIntermediateResponse(), NTree::handleJoinCall(), PubSubMMOG::handleMove(), PubSubMMOG::handleMoveListMessage(), oversim::Nice::handleNiceQuery(), PubSubMMOG::handlePingCallTimeout(), oversim::Chord::handleRpcJoinResponse(), PubSubMMOG::handleSubscriptionCall(), PubSubMMOG::handleSubscriptionCallTimeout(), Pastry::handleTimerEvent(), oversim::Nice::LeaderTransfer(), PubSubMMOG::publishEvents(), oversim::Nice::Query(), Kademlia::recursiveRoutingHook(), oversim::Nice::Remove(), route(), oversim::Chord::rpcJoin(), oversim::Chord::rpcNotify(), oversim::Nice::sendDataToOverlay(), oversim::Nice::sendHeartbeats(), oversim::Nice::sendHeartbeatTo(), Gia::sendKeyListToNeighbor(), BasePastry::sendLeafset(), Vast::sendMessage(), Quon::sendMessage(), NTree::sendMessage(), Gia::sendMessage_DISCONNECT(), Gia::sendMessage_JOIN_ACK(), Gia::sendMessage_JOIN_DNY(), Gia::sendMessage_JOIN_REQ(), Gia::sendMessage_JOIN_RSP(), Gia::sendMessage_UPDATE(), PubSubMMOG::sendMessageToChildren(), BasePastry::sendRequest(), sendRouteMessage(), BasePastry::sendRoutingRow(), BasePastry::sendStateTables(), Gia::sendToken(), PubSubMMOG::takeOverSubspace(), and PubSubMMOG::unsubscribeChild().
{ // if there's still a control info attached to the message, remove it cPolymorphic* ctrlInfo = msg->removeControlInfo(); if (ctrlInfo != NULL) delete ctrlInfo; // debug message if (debugOutput) { EV << "[BaseOverlay::sendMessageToUDP() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Sending " << *msg << " to " << dest.getIp() << endl; } msg->setKind(UDP_C_DATA); UDPControlInfo* udpControlInfo = new UDPControlInfo(); udpControlInfo->setSrcAddr(thisNode.getIp()); udpControlInfo->setSrcPort(thisNode.getPort()); udpControlInfo->setDestAddr(dest.getIp()); udpControlInfo->setDestPort(dest.getPort()); msg->setControlInfo(udpControlInfo); if (dest != thisNode) { BaseOverlayMessage* baseOverlayMsg = check_and_cast<BaseOverlayMessage*>(msg); // record statistics, if message is not local if (baseOverlayMsg->getStatType() == APP_DATA_STAT) { RECORD_STATS(numAppDataSent++; bytesAppDataSent += msg->getByteLength()); } else if (baseOverlayMsg->getStatType() == APP_LOOKUP_STAT){ RECORD_STATS(numAppLookupSent++; bytesAppLookupSent += msg->getByteLength()); } else { // MAINTENANCE_STAT RECORD_STATS(numMaintenanceSent++; bytesMaintenanceSent += msg->getByteLength()); } recordOverlaySentStats(baseOverlayMsg); if (dynamic_cast<BaseResponseMessage*>(msg) && getMeasureAuthBlock()) { // TODO: Also consider signed DhtPutMessages RECORD_STATS(bytesAuthBlockSent += ceil(AUTHBLOCK_L/8.0)); } } else { if (dest.getIp() == thisNode.getIp()) { // to same node, but different port RECORD_STATS(numInternalSent++; bytesInternalSent += msg->getByteLength()); } } send(msg, "udpOut"); }
void BaseOverlay::sendRouteMessage | ( | const TransportAddress & | dest, | |
BaseRouteMessage * | msg, | |||
bool | ack | |||
) | [private] |
Definition at line 1106 of file BaseOverlay.cc.
Referenced by SendToKeyListener::lookupFinished(), and sendToKey().
{ OverlayCtrlInfo* ctrlInfo = dynamic_cast<OverlayCtrlInfo*>(msg->removeControlInfo()); // records statistics, if we forward this message if (ctrlInfo && ctrlInfo->getLastHop().getIp() != thisNode.getIp()) { if (msg->getStatType() == APP_DATA_STAT) { RECORD_STATS(numAppDataForwarded++; bytesAppDataForwarded += msg->getByteLength()); } else if (msg->getStatType() == APP_LOOKUP_STAT){ RECORD_STATS(numAppLookupForwarded++; bytesAppLookupForwarded += msg->getByteLength()); } else { RECORD_STATS(numMaintenanceForwarded++; bytesMaintenanceForwarded += msg->getByteLength()); } } delete ctrlInfo; if (msg && (dest != thisNode)) { msg->setHopCount(msg->getHopCount() + 1); } if (!ack) sendMessageToUDP(dest, msg); else { NextHopCall* nextHopCall = new NextHopCall(msg->getName()); nextHopCall->setBitLength(NEXTHOPCALL_L(nextHopCall)); nextHopCall->encapsulate(msg); nextHopCall->setStatType(msg->getStatType()); // TODO parameter, in recursive mode routeRetries should be 0, // in iterative mode routeRetries could be more than 0 uint8_t routeRetries = 0; sendUdpRpcCall(dest, nextHopCall, NULL, -1, routeRetries); } }
void BaseOverlay::sendToKey | ( | const OverlayKey & | key, | |
BaseOverlayMessage * | message, | |||
int | numSiblings = 1 , |
|||
const std::vector< TransportAddress > & | sourceRoute = TransportAddress::UNSPECIFIED_NODES , |
|||
RoutingType | routingType = DEFAULT_ROUTING | |||
) |
Sends a message to an overlay node, with the generic routing algorithm.
key | The destination key | |
message | Message to be sent | |
numSiblings | number of siblings to send message to (numSiblings > 1 means multicast) | |
sourceRoute | If sourceRoute is given, the message gets sent via all nodes in the list before it is routed (nextHop is used as a proxy) | |
routingType | specifies the routing mode (ITERATIVE_ROUTING, ...) |
Definition at line 1366 of file BaseOverlay.cc.
Referenced by Pastry::changeState(), Bamboo::changeState(), handleBaseOverlayMessage(), handleMessage(), internalSendRouteRpc(), Kademlia::recursiveRoutingHook(), and route().
{ BaseRouteMessage* routeMsg = NULL; if (routingType == DEFAULT_ROUTING) routingType = defaultRoutingType; if (debugOutput) { EV << "[BaseOverlay::sendToKey() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Sending " << msg << " to " << key << endl; } if (key.isUnspecified() && !(sourceRoute.size() && !sourceRoute[0].isUnspecified())) throw cRuntimeError("BaseOverlay::sendToKey(): " "unspecified destination address and key!"); if (msg->getType() != OVERLAYROUTE) { assert(!msg->getControlInfo()); routeMsg = new BaseRouteMessage("BaseRouteMessage"); routeMsg->setType(OVERLAYROUTE); routeMsg->setRoutingType(routingType); routeMsg->setDestKey(key); routeMsg->setSrcNode(thisNode); routeMsg->setStatType(msg->getStatType()); // copy the name of the inner message routeMsg->setName(msg->getName()); routeMsg->setBitLength(BASEROUTE_L(routeMsg)); routeMsg->encapsulate(msg); OverlayCtrlInfo* routeCtrlInfo = new OverlayCtrlInfo; routeCtrlInfo->setLastHop(thisNode); routeCtrlInfo->setTransportType(ROUTE_TRANSPORT); routeCtrlInfo->setRoutingType(routingType); routeMsg->setControlInfo(routeCtrlInfo); //message marked as not already forwarded to tier1 routeMsg->setContextPointer(NULL); } else { routeMsg = check_and_cast<BaseRouteMessage*>(msg); routingType = static_cast<RoutingType>(routeMsg->getRoutingType()); } // set timestamp for next hop if (collectPerHopDelay) { routeMsg->setHopStamp(simTime()); } if (sourceRoute.size() && !sourceRoute[0].isUnspecified()) { // send msg to nextHop if specified (used for e.g. join rpcs) OverlayCtrlInfo* ctrlInfo = check_and_cast<OverlayCtrlInfo*> (routeMsg->getControlInfo()); ctrlInfo->setTransportType(UDP_TRANSPORT); assert(routeMsg->getNextHopsArraySize() == 0); routeMsg->setNextHopsArraySize(sourceRoute.size()); for (uint32_t i = 0; i < sourceRoute.size(); ++i) routeMsg->setNextHops(i, sourceRoute[i]); if (recursiveRoutingHook(sourceRoute[0], routeMsg)) { //test sendRouteMessage(sourceRoute[0], routeMsg, routeMsgAcks); } return; } if ((routingType == ITERATIVE_ROUTING) || (routingType == EXHAUSTIVE_ITERATIVE_ROUTING) ) { // create lookup and sent to key AbstractLookup* lookup = createLookup(routingType, routeMsg, NULL, (routeMsg->getStatType() == APP_DATA_STAT)); lookup->lookup(routeMsg->getDestKey(), numSiblings, hopCountMax, 0, new SendToKeyListener(this, routeMsg)); } else { // recursive routing NodeVector* nextHops = findNode(routeMsg->getDestKey(), recNumRedundantNodes, numSiblings, routeMsg); if (nextHops->size() == 0) { EV << "[BaseOverlay::sendToKey() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " FindNode() returned NULL - dropping message" << endl; //std::cout << simTime() << " " << thisNode.getIp() << " " << state // << " FindNode() returned NULL - dropping message " // << routeMsg->getName() << " from " // << routeMsg->getSrcNode() << std::endl; // statistics RECORD_STATS(numDropped++; bytesDropped += routeMsg->getByteLength()); delete routeMsg; } else { // delete message if the hop count maximum is exceeded if (routeMsg->getHopCount() >= hopCountMax) { EV << "[BaseOverlay::sendToKey() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Discards " << routeMsg->getName() << " from " << routeMsg->getSrcNode().getIp() << "\n" << " The hop count maximum has been exceeded (" << routeMsg->getHopCount() << ">=" << hopCountMax << ")" << endl; //std::cout << "[BaseOverlay::sendToKey() @ " << thisNode.getIp() // << " (" << thisNode.getKey().toString(16) << ")]\n" // << " Discards " << routeMsg->getName() << " from " // << routeMsg->getSrcNode().getIp() << "\n" // << " The hop count maximum has been exceeded (" // << routeMsg->getHopCount() << ">=" // << hopCountMax << ")" // << std::endl; // statistics RECORD_STATS(numDropped++; bytesDropped += routeMsg->getByteLength()); delete routeMsg; delete nextHops; return; } OverlayCtrlInfo* overlayCtrlInfo = dynamic_cast<OverlayCtrlInfo*>(routeMsg->getControlInfo()); assert(overlayCtrlInfo); // check and choose nextHop candidate NodeHandle* nextHop = NULL; bool err, isSibling; isSibling = isSiblingFor(thisNode, routeMsg->getDestKey(), numSiblings, &err); // if route is recorded we can do a real loop detection std::set<TransportAddress> visitedHops; for (uint32_t i = 0; i < routeMsg->getVisitedHopsArraySize(); ++i) { visitedHops.insert(routeMsg->getVisitedHops(i)); } for (uint32_t index = 0; nextHop == NULL && nextHops->size() > index; ++index) { nextHop = &((*nextHops)[index]); // loop detection if (((overlayCtrlInfo->getLastHop() == *nextHop) && (*nextHop != thisNode)) || (visitedHops.find(*nextHop) != visitedHops.end()) || // do not forward msg to source node ((*nextHop == routeMsg->getSrcNode()) && (thisNode != routeMsg->getSrcNode())) || // nextHop is thisNode, but isSiblingFor() is false ((*nextHop == thisNode) && (!isSibling))) { nextHop = NULL; } } if (nextHop == NULL) { if (!checkFindNode(routeMsg)) { EV << "[BaseOverlay::sendToKey() @ " << thisNode.getIp() << " (" << thisNode.getKey().toString(16) << ")]\n" << " Discards " << routeMsg->getName() << " from " << routeMsg->getSrcNode().getIp() << "\n" << " No useful nextHop found!" << endl; //std::cout << thisNode.getIp() << " packet from " // << routeMsg->getSrcNode().getIp() // << " dropped: " << routeMsg // << " " << state << std::endl; RECORD_STATS(numDropped++; bytesDropped += routeMsg->getByteLength()); } delete routeMsg; delete nextHops; return; } assert(!nextHop->isUnspecified()); // callForward to app if (useCommonAPIforward && dynamic_cast<BaseAppDataMessage*>( routeMsg->getEncapsulatedPacket()) && routeMsg->getContextPointer() == NULL) { callForward(routeMsg->getDestKey(), routeMsg, *nextHop); delete nextHops; return; } //message marked as not already forwarded routeMsg->setContextPointer(NULL); // is this node responsible? if (*nextHop == thisNode) { if (isSibling && !err) { //EV << "[BaseOverlay::sendToKey() @ " << thisNode.getIp() // << " (" << thisNode.getKey().toString(16) << ")]\n" // << " Forwards msg for key " << routeMsg->getDestKey() "\n" // << " to node " << (*nextHops)[0] // << endl; delete nextHops; assert(routeMsg->getControlInfo()); handleBaseOverlayMessage(routeMsg, key); return; } else { throw cRuntimeError("isSiblingsFor() is true with an " "error: Erroneous method " "isSiblingFor()!"); } } // else forward msg if this node is not responsible for the key overlayCtrlInfo->setHopCount(routeMsg->getHopCount()); if (recursiveRoutingHook(*nextHop, routeMsg)) { sendRouteMessage(*nextHop, routeMsg, routeMsgAcks); } } delete nextHops; } }
void BaseOverlay::setOverlayReady | ( | bool | ready | ) | [protected] |
Sets the overlay ready icon and register/deregisters the node at the GlobalNodeList.
ready | true if the overlay changed to ready state (joined successfully) |
Definition at line 1065 of file BaseOverlay.cc.
Referenced by BasePastry::baseChangeState(), NTree::changeState(), oversim::Nice::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), MyOverlay::finishOverlay(), Kademlia::handleBucketRefreshTimerExpired(), MyOverlay::joinOverlay(), Kademlia::joinOverlay(), Kademlia::lookupFinished(), and Kademlia::routingInit().
{ //TODO new setOverlayState(State state) function if ((ready && internalReadyState) || (!ready && !internalReadyState)) { return; } internalReadyState = ready; getDisplayString().setTagArg("i", 1, ready ? "" : "red"); if (isMalicious()) { getDisplayString().setTagArg("i", 1, ready ? "green" : "yellow"); } globalNodeList->setOverlayReadyIcon(getThisNode(), ready); if (ready) { bootstrapList->registerBootstrapNode(thisNode); } else { bootstrapList->removeBootstrapNode(thisNode); } if (globalParameters->getPrintStateToStdOut()) { std::cout << "OVERLAY STATE: " << (ready ? "READY (" : "OFFLINE (") << thisNode << ")" << std::endl; } CompReadyMessage* msg = new CompReadyMessage; msg->setReady(ready); msg->setComp(OVERLAY_COMP); // notify all registered components about new overlay state sendMessageToAllComp(msg, OVERLAY_COMP); }
void BaseOverlay::setOwnNodeID | ( | ) | [private, virtual] |
Overlay implementations can overwrite this virtual method to set a specific nodeID.
The default implementation sets a random nodeID.
Reimplemented in MyOverlay.
Definition at line 627 of file BaseOverlay.cc.
Referenced by join().
{ thisNode.setKey(OverlayKey::random()); }
friend class BootstrapList [friend] |
Definition at line 71 of file BaseOverlay.h.
friend class IterativeLookup [friend] |
Definition at line 68 of file BaseOverlay.h.
Referenced by createLookup().
friend class IterativePathLookup [friend] |
Definition at line 69 of file BaseOverlay.h.
friend class RecursiveLookup [friend] |
Definition at line 70 of file BaseOverlay.h.
Referenced by createLookup().
friend class SendToKeyListener [friend] |
Definition at line 72 of file BaseOverlay.h.
Referenced by lookupRpc(), and sendToKey().
const cGate* BaseOverlay::appGate [private] |
Definition at line 769 of file BaseOverlay.h.
Referenced by handleMessage(), and initialize().
BootstrapList* BaseOverlay::bootstrapList [protected] |
pointer to the BootstrapList module
Definition at line 187 of file BaseOverlay.h.
Referenced by BasePastry::baseChangeState(), BaseOverlay(), oversim::Nice::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Gia::finishOverlay(), oversim::Chord::finishOverlay(), BasePastry::finishOverlay(), getBootstrapList(), NTree::handleAppMessage(), Vast::handleJoin(), Quon::handleJoin(), initialize(), Kademlia::joinOverlay(), and setOverlayReady().
int BaseOverlay::bytesAppDataForwarded [protected] |
number of forwarded app data bytes at out-gate
Definition at line 156 of file BaseOverlay.h.
Referenced by finish(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), initialize(), and sendRouteMessage().
int BaseOverlay::bytesAppDataReceived [private] |
number of received app data bytes (incl. bytes to be forwarded)
Definition at line 128 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::bytesAppDataSent [private] |
number of sent app data bytes (incl. forwarded bytes)
Definition at line 121 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
int BaseOverlay::bytesAppLookupForwarded [protected] |
number of forwarded app lookup bytes at out-gate
Definition at line 158 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendRouteMessage().
int BaseOverlay::bytesAppLookupReceived [private] |
number of received app lookup bytes (incl. bytes to be forwarded)
Definition at line 130 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::bytesAppLookupSent [private] |
number of sent app lookup bytes (incl. forwarded bytes)
Definition at line 123 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
int BaseOverlay::bytesAuthBlockSent [private] |
number of bytes sent for rpc message signatures
Definition at line 139 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
int BaseOverlay::bytesDropped [protected] |
number of dropped bytes
Definition at line 211 of file BaseOverlay.h.
Referenced by finish(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), Gia::getRoute(), handleBaseOverlayMessage(), handleMessage(), Gia::handleUDPMessage(), initialize(), internalHandleRpcTimeout(), SendToKeyListener::lookupFinished(), route(), and sendToKey().
int BaseOverlay::bytesFailedNodeResponseSent [protected] |
Definition at line 169 of file BaseOverlay.h.
Referenced by failedNodeRpc(), finish(), and initialize().
int BaseOverlay::bytesFailedNodeSent [protected] |
Definition at line 167 of file BaseOverlay.h.
Referenced by countFailedNodeCall(), finish(), and initialize().
int BaseOverlay::bytesFindNodeResponseSent [protected] |
Definition at line 165 of file BaseOverlay.h.
Referenced by findNodeRpc(), finish(), and initialize().
int BaseOverlay::bytesFindNodeSent [protected] |
Definition at line 163 of file BaseOverlay.h.
Referenced by countFindNodeCall(), finish(), and initialize().
int BaseOverlay::bytesInternalReceived [private] |
number of bytes received from same host but different port (SimpleMultiOverlayHost)
Definition at line 137 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::bytesInternalSent [private] |
number of bytes sent to same host but different port (SimpleMultiOverlayHost)
Definition at line 135 of file BaseOverlay.h.
Referenced by initialize(), and sendMessageToUDP().
int BaseOverlay::bytesMaintenanceForwarded [protected] |
number of forwarded maintenance bytes at out-gate
Definition at line 160 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendRouteMessage().
int BaseOverlay::bytesMaintenanceReceived [private] |
number of received maintenance bytes (incl. bytes to be forwarded)
Definition at line 132 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::bytesMaintenanceSent [private] |
number of sent maintenance bytes (incl. forwarded bytes)
Definition at line 125 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
bool BaseOverlay::collectPerHopDelay [protected] |
collect delay for single hops
Definition at line 194 of file BaseOverlay.h.
Referenced by finish(), handleBaseOverlayMessage(), initialize(), and sendToKey().
CompModuleList BaseOverlay::compModuleList [private] |
Definition at line 823 of file BaseOverlay.h.
Referenced by getCompModule(), getCompRpcGate(), initialize(), registerComp(), and sendMessageToAllComp().
simtime_t BaseOverlay::creationTime [protected] |
simtime when the node has been created
Definition at line 172 of file BaseOverlay.h.
Referenced by finish(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), NTree::finishOverlay(), oversim::Nice::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), getCreationTime(), and initialize().
bool BaseOverlay::debugOutput [protected] |
debug output ?
Definition at line 191 of file BaseOverlay.h.
Referenced by Gia::acceptNode(), Quon::addSite(), Vast::buildVoronoi(), Vast::changeState(), Quon::changeState(), Gia::changeState(), oversim::Chord::changeState(), Pastry::checkProxCache(), Quon::deleteSite(), Gia::deliverSearchResult(), Gia::forwardMessage(), Vast::handleAppMessage(), Quon::handleAppMessage(), handleMessage(), Vast::handleNodeLeaveNotification(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), Vast::handleUDPMessage(), Quon::handleUDPMessage(), Pastry::handleUDPMessage(), Gia::handleUDPMessage(), Bamboo::handleUDPMessage(), initialize(), Vast::initializeOverlay(), Pastry::mergeState(), Quon::purgeSites(), Gia::removeNeighbor(), Vast::removeNeighbors(), route(), Vast::sendDiscardNode(), Vast::sendMessage(), Quon::sendMessage(), sendMessageToUDP(), Vast::sendToApp(), Quon::sendToApp(), sendToKey(), and Quon::updateThisSite().
RoutingType BaseOverlay::defaultRoutingType [protected] |
Definition at line 192 of file BaseOverlay.h.
Referenced by createLookup(), Kademlia::handleBucketRefreshTimerExpired(), oversim::Chord::handleJoinTimerExpired(), Kademlia::handleRpcResponse(), Pastry::handleUDPMessage(), initialize(), oversim::Chord::joinForeignPartition(), and sendToKey().
cOutVector BaseOverlay::delayVector [protected] |
statistical output vector for packet-delays
Definition at line 213 of file BaseOverlay.h.
bool BaseOverlay::drawOverlayTopology [protected] |
Definition at line 198 of file BaseOverlay.h.
Referenced by initialize().
bool BaseOverlay::dropFindNodeAttack [protected] |
if node is malicious, it tries a findNode attack
Definition at line 201 of file BaseOverlay.h.
Referenced by findNodeRpc(), and initialize().
bool BaseOverlay::dropRouteMessageAttack [protected] |
if node is malicious, it drops all received BaseRouteMessages
Definition at line 204 of file BaseOverlay.h.
Referenced by handleBaseOverlayMessage(), and initialize().
GlobalNodeList* BaseOverlay::globalNodeList [protected] |
pointer to GlobalNodeList in this node
Reimplemented from TopologyVis.
Definition at line 184 of file BaseOverlay.h.
Referenced by BaseOverlay(), Vast::changeState(), Quon::changeState(), Vast::finishOverlay(), BootstrapList::getBootstrapNode(), NTree::getRandomNode(), handleMessage(), Gia::handleTimerEvent(), initialize(), PubSubMMOG::initializeOverlay(), isMalicious(), join(), BootstrapList::removeBootstrapNode(), and setOverlayReady().
GlobalParameters* BaseOverlay::globalParameters [protected] |
pointer to the GlobalParameters module
Definition at line 188 of file BaseOverlay.h.
Referenced by BaseOverlay(), oversim::Chord::handleRpcFixfingersResponse(), initialize(), and setOverlayReady().
int BaseOverlay::hopCountMax [protected] |
maximum hop count
Definition at line 206 of file BaseOverlay.h.
Referenced by Kademlia::handleBucketRefreshTimerExpired(), Kademlia::handleRpcResponse(), initialize(), lookupRpc(), and sendToKey().
cOutVector BaseOverlay::hopCountVector [protected] |
statistical output vector for hop-counts
Definition at line 214 of file BaseOverlay.h.
bool BaseOverlay::internalReadyState [private] |
internal overlay state used for setOverlayReady()
Definition at line 824 of file BaseOverlay.h.
Referenced by initialize(), lookupRpc(), route(), and setOverlayReady().
bool BaseOverlay::invalidNodesAttack [protected] |
if node is malicious, it tries a invalidNode attack
Definition at line 203 of file BaseOverlay.h.
Referenced by findNodeRpc(), and initialize().
bool BaseOverlay::isSiblingAttack [protected] |
if node is malicious, it tries a isSibling attack
Definition at line 202 of file BaseOverlay.h.
Referenced by findNodeRpc(), and initialize().
Definition at line 562 of file BaseOverlay.h.
Referenced by createLookup(), Kademlia::handleBucketRefreshTimerExpired(), initialize(), Kademlia::initializeOverlay(), and oversim::Chord::initializeOverlay().
int BaseOverlay::joinRetries [private] |
number of join retries
Definition at line 141 of file BaseOverlay.h.
Referenced by finish(), initialize(), and join().
bool BaseOverlay::kbr [protected] |
set this to true, if the overlay provides KBR services
Definition at line 762 of file BaseOverlay.h.
Referenced by initialize(), Pastry::initializeOverlay(), Kademlia::initializeOverlay(), oversim::Chord::initializeOverlay(), Broose::initializeOverlay(), Bamboo::initializeOverlay(), and providesKbr().
int BaseOverlay::localPort [protected] |
LookupSet BaseOverlay::lookups [protected] |
Definition at line 581 of file BaseOverlay.h.
Referenced by createLookup(), finishLookups(), initLookups(), and removeLookup().
bool BaseOverlay::measureAuthBlock [protected] |
if true, measure the overhead of signatures in rpc messages
Definition at line 207 of file BaseOverlay.h.
Referenced by getMeasureAuthBlock(), and initialize().
NotificationBoard* BaseOverlay::notificationBoard [protected] |
pointer to NotificationBoard in this node
Definition at line 185 of file BaseOverlay.h.
Referenced by BaseOverlay(), and initialize().
int BaseOverlay::numAppDataForwarded [protected] |
number of forwarded app data packets
Definition at line 155 of file BaseOverlay.h.
Referenced by finish(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), initialize(), and sendRouteMessage().
int BaseOverlay::numAppDataReceived [private] |
number of received app data packets (incl. packets to be forwarded )
Definition at line 127 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::numAppDataSent [private] |
number of sent app data packets (incl. forwarded packets)
Definition at line 120 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
int BaseOverlay::numAppLookupForwarded [protected] |
number of forwarded app lookup packets
Definition at line 157 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendRouteMessage().
int BaseOverlay::numAppLookupReceived [private] |
number of received app lookup packets (incl. packets to be forwarded)
Definition at line 129 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::numAppLookupSent [private] |
number of sent app loookup packets (incl. forwarded packets)
Definition at line 122 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
int BaseOverlay::numDropped [protected] |
number of dropped packets
Reimplemented in MyOverlay.
Definition at line 210 of file BaseOverlay.h.
Referenced by finish(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), Gia::getRoute(), handleBaseOverlayMessage(), handleMessage(), Gia::handleUDPMessage(), initialize(), internalHandleRpcTimeout(), SendToKeyListener::lookupFinished(), route(), and sendToKey().
int BaseOverlay::numFailedNodeResponseSent [protected] |
Definition at line 168 of file BaseOverlay.h.
Referenced by failedNodeRpc(), finish(), and initialize().
int BaseOverlay::numFailedNodeSent [protected] |
Definition at line 166 of file BaseOverlay.h.
Referenced by countFailedNodeCall(), finish(), and initialize().
int BaseOverlay::numFindNodeResponseSent [protected] |
Definition at line 164 of file BaseOverlay.h.
Referenced by findNodeRpc(), finish(), and initialize().
int BaseOverlay::numFindNodeSent [protected] |
Definition at line 162 of file BaseOverlay.h.
Referenced by countFindNodeCall(), finish(), and initialize().
int BaseOverlay::numInternalReceived [private] |
number of packets received from same host but different port (SimpleMultiOverlayHost)
Definition at line 136 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::numInternalSent [private] |
number of packets sent to same host but different port (SimpleMultiOverlayHost)
Definition at line 134 of file BaseOverlay.h.
Referenced by initialize(), and sendMessageToUDP().
int BaseOverlay::numMaintenanceForwarded [protected] |
number of forwarded maintenance packets
Definition at line 159 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendRouteMessage().
int BaseOverlay::numMaintenanceReceived [private] |
number of received maintenance packets (incl. packets to be forwarded)
Definition at line 131 of file BaseOverlay.h.
Referenced by finish(), handleMessage(), and initialize().
int BaseOverlay::numMaintenanceSent [private] |
number of sent maintenance packets (incl. forwarded packets)
Definition at line 124 of file BaseOverlay.h.
Referenced by finish(), initialize(), and sendMessageToUDP().
uint32_t BaseOverlay::recNumRedundantNodes [protected] |
numRedundantNodes for recursive routing
Definition at line 196 of file BaseOverlay.h.
Referenced by initialize(), and sendToKey().
bool BaseOverlay::recordRoute [protected] |
record visited hops on route
Definition at line 197 of file BaseOverlay.h.
Referenced by handleBaseOverlayMessage(), initialize(), and Kademlia::initializeOverlay().
Definition at line 563 of file BaseOverlay.h.
Referenced by createLookup(), and initialize().
bool BaseOverlay::rejoinOnFailure [protected] |
Definition at line 199 of file BaseOverlay.h.
Referenced by initialize(), and join().
bool BaseOverlay::restoreContext [protected] |
if true, a node rejoins with its old nodeId and malicious state
Definition at line 208 of file BaseOverlay.h.
Referenced by handleMessage(), initialize(), and join().
bool BaseOverlay::routeMsgAcks [protected] |
send ACK when receiving route message
Definition at line 195 of file BaseOverlay.h.
Referenced by initialize(), SendToKeyListener::lookupFinished(), and sendToKey().
bool BaseOverlay::sendRpcResponseToLastHop [protected] |
needed by KBR protocols for NAT support
Definition at line 200 of file BaseOverlay.h.
Referenced by initialize(), and internalSendRpcResponse().
std::vector<HopDelayRecord*> BaseOverlay::singleHopDelays [protected] |
Definition at line 170 of file BaseOverlay.h.
Referenced by finish(), and handleBaseOverlayMessage().
States BaseOverlay::state [protected] |
Definition at line 216 of file BaseOverlay.h.
Referenced by BasePastry::baseChangeState(), Pastry::changeState(), NTree::changeState(), oversim::Nice::changeState(), oversim::Koorde::changeState(), Gia::changeState(), oversim::Chord::changeState(), Broose::changeState(), Pastry::checkProxCache(), Bamboo::checkProxCache(), oversim::Koorde::findNode(), oversim::Chord::findNode(), Broose::findNode(), BasePastry::findNode(), BasePastry::finishOverlay(), Gia::getRoute(), getState(), Vast::handleAppMessage(), PubSubMMOG::handleAppMessage(), NTree::handleAppMessage(), Gia::handleAppMessage(), Kademlia::handleBucketRefreshTimerExpired(), Broose::handleBucketRequestRpc(), Broose::handleBucketResponseRpc(), Broose::handleBucketTimeout(), oversim::Koorde::handleDeBruijnTimeout(), oversim::Koorde::handleDeBruijnTimerExpired(), Pastry::handleFailedNode(), oversim::Chord::handleFailedNode(), Bamboo::handleFailedNode(), oversim::Chord::handleFixFingersTimerExpired(), NTree::handleJoinCallTimeout(), PubSubMMOG::handleJoinResponse(), NTree::handleJoinResponse(), oversim::Chord::handleJoinTimerExpired(), Broose::handleJoinTimerExpired(), Vast::handleNodeGracefulLeaveNotification(), Vast::handleNodeLeaveNotification(), BasePastry::handleRequestMessage(), NTree::handleRpcCall(), oversim::Koorde::handleRpcCall(), oversim::Chord::handleRpcCall(), Broose::handleRpcCall(), oversim::Koorde::handleRpcDeBruijnResponse(), oversim::Chord::handleRpcNotifyResponse(), NTree::handleRpcResponse(), Kademlia::handleRpcResponse(), oversim::Chord::handleRpcStabilizeResponse(), NTree::handleRpcTimeout(), Kademlia::handleRpcTimeout(), oversim::Chord::handleStabilizeTimerExpired(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), PubSubMMOG::handleSubscriptionResponse(), NTree::handleTimerEvent(), Vast::handleUDPMessage(), Pastry::handleUDPMessage(), NTree::handleUDPMessage(), Gia::handleUDPMessage(), Bamboo::handleUDPMessage(), initialize(), PubSubMMOG::initializeOverlay(), Broose::initializeOverlay(), Kademlia::isSiblingFor(), oversim::Chord::isSiblingFor(), Broose::isSiblingFor(), join(), Kademlia::joinOverlay(), Kademlia::lookupFinished(), Pastry::mergeState(), nextHopRpc(), Pastry::pingResponse(), BasePastry::pingTimeout(), BasePastry::proxCallback(), PubSubMMOG::receiveChangeNotification(), Kademlia::routingInit(), Vast::setBootstrapedIcon(), PubSubMMOG::setBootstrapedIcon(), and NTree::setBootstrapedIcon().
const cGate* BaseOverlay::udpGate [private] |
Definition at line 768 of file BaseOverlay.h.
Referenced by handleMessage(), and initialize().
UnderlayConfigurator* BaseOverlay::underlayConfigurator [protected] |
pointer to UnderlayConfigurator in this node
Definition at line 186 of file BaseOverlay.h.
Referenced by BaseOverlay(), MyOverlay::handleTimerEvent(), and initialize().
bool BaseOverlay::useCommonAPIforward [protected] |
forward messages to applications?
Definition at line 193 of file BaseOverlay.h.
Referenced by initialize(), oversim::Chord::initializeOverlay(), and sendToKey().