OverSim
BaseOverlay Class Reference

Base class for overlays. More...

#include <BaseOverlay.h>

Inheritance diagram for BaseOverlay:
BaseRpc BaseTcpSupport TopologyVis RpcListener BasePastry Broose Gia Kademlia MyOverlay NTree OverlayDummy oversim::Chord oversim::Nice PubSubLobby PubSubMMOG Quon Vast

Classes

class  BaseOverlayContext
struct  HopDelayRecord
 Structure for computing the average delay in one specific hop. More...
class  lookupHashFcn

Public Types

enum  States {
  INIT = 0, BOOTSTRAP = 1, DISCOVERY = 2, PREJOIN = 3,
  JOIN = 4, POSTJOIN = 5, READY = 6, REFRESH = 7,
  SHUTDOWN = 8, FAILED = 9, RSET = JOIN, BSET = POSTJOIN
}
- Public Types inherited from BaseTcpSupport
enum  EvCode {
  NO_EST_CONNECTION, PEER_CLOSED, PEER_TIMEDOUT, PEER_REFUSED,
  CONNECTION_RESET, CONNECTION_SUCC_ClOSED
}

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 NodeVectorlocal_lookup (const OverlayKey &key, int num, bool safe)
 finds nodes closest to the given OverlayKey
virtual NodeVectorneighborSet (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, simtime_t delay=SIMTIME_ZERO)
 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 ()
BootstrapListgetBootstrapList () const
virtual OverlayKey estimateMeanDistance ()
 returns mean distance between OverlayKeys in the network
virtual uint32_t estimateOverlaySize ()
 estimates the current number of nodes online
- Public Member Functions inherited from BaseRpc
 BaseRpc ()
const NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
simtime_t getUdpTimeout ()
- Public Member Functions inherited from RpcListener
virtual ~RpcListener ()
 destructor
- Public Member Functions inherited from BaseTcpSupport
virtual void socketDataArrived (int connId, void *yourPtr, cPacket *msg, bool urgent)
virtual void socketEstablished (int connId, void *yourPtr)
virtual void socketPeerClosed (int connId, void *yourPtr)
virtual void socketFailure (int connId, void *yourPtr, int code)
virtual void socketStatusArrived (int connId, void *yourPtr, TCPStatusInfo *status)
- Public Member Functions inherited from TopologyVis
 TopologyVis ()
void showOverlayNeighborArrow (const NodeHandle &neighbor, bool flush=true, const char *displayString=NULL)
 Draws an arrow from this node to neighbor.
void deleteOverlayNeighborArrow (const NodeHandle &neighbor)
 Removes an arrow from this node to neighbor.

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 AbstractLookupcreateLookup (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 NodeVectorfindNode (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)
 Handles internal rpc requests.
void internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 Handles rpc responses internal in base classes

void internalHandleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 Handles rpc timeouts internal in base classes

void internalSendRouteRpc (BaseRpcMessage *message, const OverlayKey &destKey, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType)
CompType getThisCompType ()
 Return the component type of this module.
- Protected Member Functions inherited from BaseRpc
void initRpcs ()
 Initializes Remote-Procedure state.
void finishRpcs ()
 Deinitializes Remote-Procedure state.
virtual void internalHandleRpcMessage (BaseRpcMessage *msg)
 Handles incoming rpc messages and delegates them to the corresponding listeners or handlers.
uint32_t sendRouteRpcCall (CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Routes a Remote-Procedure-Call message to an OverlayKey.
uint32_t sendRouteRpcCall (CompType destComp, const OverlayKey &destKey, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Routes a Remote-Procedure-Call message to an OverlayKey.
uint32_t sendRouteRpcCall (CompType destComp, const TransportAddress &dest, BaseCallMessage *msg, cPolymorphic *context=NULL, RoutingType routingType=DEFAULT_ROUTING, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Sends a Remote-Procedure-Call message using the overlay's UDP port
This replaces ROUTE_DIRECT calls!
uint32_t sendUdpRpcCall (const TransportAddress &dest, BaseCallMessage *msg, cPolymorphic *context=NULL, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Sends a Remote-Procedure-Call message to the underlay

uint32_t sendInternalRpcCall (CompType destComp, BaseCallMessage *msg, cPolymorphic *context=NULL, simtime_t timeout=-1, int retries=0, int rpcId=-1, RpcListener *rpcListener=NULL)
 Sends an internal Remote-Procedure-Call between two tiers

void cancelRpcMessage (uint32_t nonce)
 Cancels a Remote-Procedure-Call.
void cancelAllRpcs ()
 Cancels all RPCs.
void sendRpcResponse (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseCallMessage *call, BaseResponseMessage *response)
 Send Remote-Procedure response message and deletes call message.
void sendRpcResponse (BaseCallMessage *call, BaseResponseMessage *response)
 Send Remote-Procedure response message to UDP and deletes call message.
int pingNode (const TransportAddress &dest, simtime_t timeout=-1, int retries=0, cPolymorphic *context=NULL, const char *caption="PING", RpcListener *rpcListener=NULL, int rpcId=-1, TransportType transportType=INVALID_TRANSPORT)
 ping a node by its TransportAddress
virtual bool handleRpcCall (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invocation messages.
virtual void pingResponse (PingResponse *pingResponse, cPolymorphic *context, int rpcId, simtime_t rtt)
virtual void pingTimeout (PingCall *pingCall, const TransportAddress &dest, cPolymorphic *context, int rpcId)
bool internalHandleMessage (cMessage *msg)
- Protected Member Functions inherited from RpcListener
virtual void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
virtual void handleRpcResponse (BaseResponseMessage *msg, const RpcState &rpcState, simtime_t rtt)
 This method is called if an RPC response has been received.
virtual void handleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 This method is called if an RPC timeout has been reached.
virtual void handleRpcTimeout (const RpcState &rpcState)
 This method is called if an RPC timeout has been reached.
- Protected Member Functions inherited from BaseTcpSupport
void handleTCPMessage (cMessage *msg)
 Member function to handle incoming TCP messages.
void bindAndListenTcp (int port)
 Member function to bind service to the specified port and listen afterwards.
bool isAlreadyConnected (TransportAddress address)
 Member function to check if the service is already connected.
void establishTcpConnection (TransportAddress address)
 Member function to establish a connection to the specified node.
void sendTcpData (cPacket *msg, TransportAddress address)
 Member function to send TCP data to the specified node.
virtual void handleConnectionEvent (EvCode code, TransportAddress address)
 Member function to handle passive connection events.
virtual void handleDataReceived (TransportAddress address, cPacket *msg, bool urgent)
 Member function to handle incoming data.
virtual void handleIncomingConnection (TransportAddress address)
 Member function to handle newly opened connections.
void closeTcpConnection (TransportAddress address)
 Member function to close an established connection.
void setTcpOut (cGate *gate)
 Member function to set local gate towards the TCP module during init phase.
cGate * getTcpOut ()
 Member function to get local gate towards the TCP module.
- Protected Member Functions inherited from TopologyVis
void initVis (cModule *terminal)

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
GlobalNodeListglobalNodeList
 pointer to GlobalNodeList in this node
NotificationBoard * notificationBoard
 pointer to NotificationBoard in this node
UnderlayConfiguratorunderlayConfigurator
 pointer to UnderlayConfigurator in this node
BootstrapListbootstrapList
 pointer to the BootstrapList module
GlobalParametersglobalParameters
 pointer to the GlobalParameters module
uint32_t overlayId
 identifies the overlay this node belongs to (used for multiple overlays)
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
- Protected Attributes inherited from BaseRpc
NodeHandle thisNode
 NodeHandle to this node.
BaseOverlayoverlay
bool debugOutput
 debug output ?
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
CompType thisCompType
NeighborCacheneighborCache
 pointer to the neighbor cache
CryptoModulecryptoModule
 pointer to CryptoModule
int numPingSent
int bytesPingSent
int numPingResponseSent
int bytesPingResponseSent
- Protected Attributes inherited from TopologyVis
cModule * thisTerminal
GlobalNodeListglobalNodeList
 pointer to corresponding node

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()
int socketId

Friends

class IterativeLookup
class IterativePathLookup
class RecursiveLookup
class BootstrapList
class SendToKeyListener

Detailed Description

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.

Author
Ingmar Baumgart
Bernhard Heep
Stephan Krause
Sebastian Mies

Definition at line 62 of file BaseOverlay.h.

Member Typedef Documentation

typedef std::map<CompType, std::pair<cModule*, cGate*> > BaseOverlay::CompModuleList
private

Definition at line 837 of file BaseOverlay.h.

Member Enumeration Documentation

Enumerator:
INIT 
BOOTSTRAP 
DISCOVERY 
PREJOIN 
JOIN 
POSTJOIN 
READY 
REFRESH 
SHUTDOWN 
FAILED 
RSET 
BSET 

Definition at line 85 of file BaseOverlay.h.

{
INIT = 0,
BOOTSTRAP = 1,
DISCOVERY = 2,
PREJOIN = 3,
JOIN = 4,
POSTJOIN = 5,
READY = 6,
REFRESH = 7,
SHUTDOWN = 8,
FAILED = 9,
//some aliases for compatibility
};

Constructor & Destructor Documentation

BaseOverlay::BaseOverlay ( )

Definition at line 57 of file BaseOverlay.cc.

BaseOverlay::~BaseOverlay ( )
virtual

Virtual destructor.

Definition at line 66 of file BaseOverlay.cc.

Member Function Documentation

void BaseOverlay::bindToPort ( int  port)
protected

Tells UDP we want to get all packets arriving on the given port.

Definition at line 466 of file BaseOverlay.cc.

{
EV << "[BaseOverlay::bindToPort() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Binding to UDP port " << port
<< endl;
// 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);
socketId = UDPSocket::generateSocketId();
UDPControlInfo *ctrl = new UDPControlInfo();
ctrl->setSrcPort(port);
ctrl->setSockId(socketId);
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.

Parameters
msgdelivered message
destKeythe destination key of the message

Definition at line 491 of file BaseOverlay.cc.

Referenced by Gia::forwardMessage().

{
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.

Parameters
keydestination key
msgmessage to forward
nextHopNodenext hop

Definition at line 524 of file BaseOverlay.cc.

{
KBRforward* forwardMsg = new KBRforward();
forwardMsg->setDestKey(msg->getDestKey());
forwardMsg->setNextHopNode(nextHopNode);
forwardMsg->encapsulate(msg->getEncapsulatedPacket()->decapsulate());
OverlayCtrlInfo* 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

Parameters
nodethe node that has joined or changed its state
joinedhas the node joined or changed its state?

Definition at line 669 of file BaseOverlay.cc.

Referenced by BrooseBucket::add(), Gia::changeState(), PastryLeafSet::failedNode(), Kademlia::handleFailedNode(), PastryLeafSet::mergeState(), Kademlia::refillSiblingTable(), BrooseBucket::remove(), Kademlia::routingAdd(), and Kademlia::routingTimeout().

{
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 1629 of file BaseOverlay.cc.

{
if (dynamic_cast<FindNodeCall*>(routeMsg->getEncapsulatedPacket())) {
FindNodeCall* findNodeCall =
static_cast<FindNodeCall*>(routeMsg->decapsulate());
findNodeCall
->setControlInfo(check_and_cast<OverlayCtrlInfo*>
(routeMsg->removeControlInfo()));
if (findNodeCall->getSrcNode() != thisNode) {
findNodeRpc(findNodeCall);
return true;
} //else std::cout << " autsch!! " << std::endl;
}
return false;
}
void BaseOverlay::countFailedNodeCall ( const FailedNodeCall call)
protected
void BaseOverlay::countFindNodeCall ( const FindNodeCall call)
protected

Definition at line 1878 of file BaseOverlay.cc.

Referenced by IterativeLookup::sendRpc().

{
bytesFindNodeSent += call->getByteLength());
}
AbstractLookup * BaseOverlay::createLookup ( RoutingType  routingType = DEFAULT_ROUTING,
const BaseOverlayMessage msg = NULL,
const cPacket *  findNodeExt = NULL,
bool  appLookup = false 
)
protectedvirtual

Creates an abstract iterative lookup instance.

Parameters
routingTypeThe routing type for this lookup (e.g. recursive/iterative)
msgpointer 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.
findNodeExtobject that will be sent with the findNodeCalls
appLookupSet to true, if lookup is triggered by application (for statistics)
Returns
AbstractLookup* The new lookup instance.

Reimplemented in BasePastry.

Definition at line 1646 of file BaseOverlay.cc.

Referenced by Kademlia::handleBucketRefreshTimerExpired(), and Kademlia::handleRpcResponse().

{
AbstractLookup* newLookup;
if (routingType == DEFAULT_ROUTING) {
routingType = defaultRoutingType;
}
switch (routingType) {
newLookup = new IterativeLookup(this, routingType,
iterativeLookupConfig, findNodeExt,
appLookup);
break;
newLookup = new RecursiveLookup(this, routingType,
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).

Parameters
xLeft-hand-side Key
yRight-hand-side key
useAlternativeuse an alternative distance metric
Returns
OverlayKey Distance between x and y

Reimplemented in BasePastry, Kademlia, and oversim::Chord.

Definition at line 1687 of file BaseOverlay.cc.

Referenced by IterativeLookup::compare(), oversim::Nice::handleNicePingProbeResponse(), and oversim::Nice::maintenance().

{
throw cRuntimeError("BaseOverlay::distance(): Not implemented!");
}
OverlayKey BaseOverlay::estimateMeanDistance ( )
virtual

returns mean distance between OverlayKeys in the network

Returns
mean distance

Reimplemented in BasePastry.

Definition at line 582 of file BaseOverlay.cc.

{
throw cRuntimeError("BaseOverlays::estimate_mean_distance(): "
"Function not implemented for this Overlay!");
}
uint32_t BaseOverlay::estimateOverlaySize ( )
virtual

estimates the current number of nodes online

Returns
estimated number current nodes

Definition at line 588 of file BaseOverlay.cc.

{
OverlayKey start = mean;
OverlayKey count = mean;
uint32_t number = 1;
while (count >= start) {
number++;
count += mean;
}
return number;
}
void BaseOverlay::failedNodeRpc ( FailedNodeCall call)
private

Definition at line 1968 of file BaseOverlay.cc.

{
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());
}
failedNodeResponse->getByteLength());
sendRpcResponse(call, failedNodeResponse);
}
NodeVector * BaseOverlay::findNode ( const OverlayKey key,
int  numRedundantNodes,
int  numSiblings,
BaseOverlayMessage msg = NULL 
)
protectedvirtual

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.

Parameters
keyThe lookup key.
numRedundantNodesMaximum number of next hop nodes to return.
numSiblingsnumber of siblings to return
msgA pointer to the BaseRouteMessage or FindNodeCall message of this lookup.
Returns
NodeVector with closest nodes.

Reimplemented in oversim::Chord, Broose, oversim::Koorde, Kademlia, and BasePastry.

Definition at line 1696 of file BaseOverlay.cc.

Referenced by IterativePathLookup::handleTimeout(), and IterativeLookup::start().

{
throw cRuntimeError("findNode: Not implemented!");
return NULL;
}
void BaseOverlay::findNodeRpc ( FindNodeCall call)
private

Definition at line 1891 of file BaseOverlay.cc.

{
// if this node is malicious don't answer a findNodeCall
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->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() &&
&err)) {
findNodeResponse->setSiblings(true);
}
findNodeResponse->setSiblings(true);
} else {
findNodeResponse->setSiblings(false);
}
int resultSize = isSiblingAttack ? call->getNumSiblings() :
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());
}
findNodeResponse->getByteLength());
delete nextHops;
sendRpcResponse(call, findNodeResponse);
}
void BaseOverlay::finish ( )
private

collects statistical data

Definition at line 305 of file BaseOverlay.cc.

{
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",
globalStatistics->addStdDev("BaseOverlay: Internal Sent Messages/s",
globalStatistics->addStdDev("BaseOverlay: Internal Sent Bytes/s",
}
globalStatistics->addStdDev("BaseOverlay: Sent App Lookup Messages/s",
globalStatistics->addStdDev("BaseOverlay: Sent App Lookup Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent Maintenance Messages/s",
globalStatistics->addStdDev("BaseOverlay: Sent Maintenance Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent Total Messages/s",
globalStatistics->addStdDev("BaseOverlay: Sent Total Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent FindNode Messages/s",
numFindNodeSent / time);
globalStatistics->addStdDev("BaseOverlay: Sent FindNode Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent FindNodeResponse Messages/s",
globalStatistics->addStdDev("BaseOverlay: Sent FindNodeResponse Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent FailedNode Messages/s",
globalStatistics->addStdDev("BaseOverlay: Sent FailedNode Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent FailedNodeResponse Messages/s",
globalStatistics->addStdDev("BaseOverlay: Sent FailedNodeResponse Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Received App Data Messages/s",
globalStatistics->addStdDev("BaseOverlay: Received App Data Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Internal Received Messages/s",
globalStatistics->addStdDev("BaseOverlay: Internal Received Bytes/s",
}
globalStatistics->addStdDev("BaseOverlay: Received App Lookup Messages/s",
globalStatistics->addStdDev("BaseOverlay: Received App Lookup Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Received Maintenance Messages/s",
globalStatistics->addStdDev("BaseOverlay: Received Maintenance Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Received Total Messages/s",
globalStatistics->addStdDev("BaseOverlay: Received Total Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded App Data Messages/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded App Data Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded App Lookup Messages/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded App Lookup Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded Maintenance Messages/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded Maintenance Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded Total Messages/s",
globalStatistics->addStdDev("BaseOverlay: Forwarded Total Bytes/s",
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",
globalStatistics->addStdDev("BaseOverlay: Sent Ping Response Bytes/s",
globalStatistics->addStdDev("BaseOverlay: Sent AuthBlock Bytes/s",
}
}
}
void BaseOverlay::finishLookups ( )
private

deletes entries in lookups

Definition at line 1249 of file BaseOverlay.cc.

{
while (lookups.size() > 0) {
(*lookups.begin())->abortLookup();
}
lookups.clear();
}
void BaseOverlay::finishOverlay ( )
protectedvirtual

collects statistical data in derived class

Reimplemented in Kademlia, BasePastry, oversim::Nice, Gia, oversim::Koorde, oversim::Chord, Broose, NTree, Quon, Vast, PubSubLobby, and PubSubMMOG.

Definition at line 446 of file BaseOverlay.cc.

{
}
virtual uint8_t BaseOverlay::getBitsPerDigit ( )
inlinevirtual

Reimplemented in BasePastry.

Definition at line 813 of file BaseOverlay.h.

Referenced by NeighborCache::setCbrNodeId(), and GlobalViewBuilder::spreadGlobalView().

{ return 1; };
BootstrapList& BaseOverlay::getBootstrapList ( ) const
inline

Definition at line 817 of file BaseOverlay.h.

Referenced by NeighborCache::handleReadyMessage(), and NeighborCache::prepareOverlay().

{ return *bootstrapList;}
cModule * BaseOverlay::getCompModule ( CompType  compType)

Definition at line 2069 of file BaseOverlay.cc.

Referenced by initialize().

{
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 2079 of file BaseOverlay.cc.

Referenced by 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.

{ return creationTime; };
int BaseOverlay::getMaxNumRedundantNodes ( )
virtual

Query the maximum number of redundant next hop nodes that are returned by findNode().

Returns
int number of redundant nodes returned by findNode().

Reimplemented in oversim::Chord, Broose, Kademlia, and BasePastry.

Definition at line 714 of file BaseOverlay.cc.

Referenced by 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.

Returns
int number of siblings.

Reimplemented in oversim::Chord, Broose, Kademlia, and BasePastry.

Definition at line 705 of file BaseOverlay.cc.

Referenced by KBRTestApp::handleTimerEvent().

{
Enter_Method("getMaxNumSiblings()");
throw cRuntimeError("getMaxNumSiblings: Not implemented!");
return false;
}
bool BaseOverlay::getMeasureAuthBlock ( )
inline

Definition at line 815 of file BaseOverlay.h.

{ return measureAuthBlock; }
States BaseOverlay::getState ( )
inline

Reimplemented in Quon.

Definition at line 102 of file BaseOverlay.h.

Referenced by ConnectivityProbe::extractTopology().

{ return state; };
CompType BaseOverlay::getThisCompType ( )
protectedvirtual

Return the component type of this module.

This method is overloaded by BaseOverlay/BaseApp and returns the appropriate component type of this module.

Returns
the component type of this module

Implements BaseRpc.

Definition at line 458 of file BaseOverlay.cc.

Referenced by Quon::changeState(), Vast::changeState(), Quon::handleNodeGracefulLeaveNotification(), and Vast::handleNodeLeaveNotification().

{
return OVERLAY_COMP;
}
void BaseOverlay::handleAppMessage ( cMessage *  msg)
protectedvirtual

Processes "timer" self-messages.

Parameters
msgA self-message Processes non-commonAPI messages
msgnon-commonAPIMessage

Reimplemented in Gia, oversim::Nice, NTree, Quon, Vast, and PubSubMMOG.

Definition at line 1087 of file BaseOverlay.cc.

{
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.

Parameters
msgThe message to be handled
destKeythe destination key of the message

Definition at line 877 of file BaseOverlay.cc.

{
switch (msg->getType()) {
return;
case RPC: {
// process rpc-messages
BaseRpcMessage* rpcMsg = check_and_cast<BaseRpcMessage*>(msg);
// TODO destKey -> overlayCtrlInfo
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
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) ||
// 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));
}
= check_and_cast<BaseOverlayMessage*>(baseRouteMsg
->decapsulate());
tmpMsg->setControlInfo(overlayCtrlInfo);
// delay between hops
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)
)
|| 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
EV << "[BaseOverlay::handleBaseOverlayMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " BaseRouteMessage gets dropped because this node is malicious"
<< endl;
//std::cout << "malicious!" << std::endl;
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)
protectedvirtual

Handles a failed node.

This method is called whenever a node given by findNode() was unreachable. The default implementation does nothing at all.

Parameters
failedthe failed node
Returns
true if lookup should retry here

Reimplemented in oversim::Chord, and oversim::Koorde.

Definition at line 1712 of file BaseOverlay.cc.

Referenced by BasePastry::handleRpcTimeout(), IterativePathLookup::handleTimeout(), and BasePastry::proxCallback().

{
//std::cout << "Mooooo" << std::endl;
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().

Parameters
msgThe message to be handled

Definition at line 729 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)
baseOverlayMsg->getByteLength());
else if (baseOverlayMsg->getStatType() == APP_LOOKUP_STAT)
baseOverlayMsg->getByteLength());
else // MAINTENANCE_STAT
baseOverlayMsg->getByteLength());
}
if (overlayCtrlInfo->getLastHop().getIp() == thisNode.getIp()) {
// is this from the same node?
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 =
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->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) {
} else if(msg->arrivedOn("tcpIn")) {
} 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);
overlayContext->malicious);
join(overlayContext->key);
} else if (!readyMsg->getNodeId().isUnspecified()) {
//std::cout << "readymsg at BO" << std::endl;
join(readyMsg->getNodeId());
} else {
join();
}
} /*else if (!readyMsg->getReady() &&
readyMsg->getComp() == NEIGHBORCACHE_COMP) {
//STATE =
setOverlayReady(false);
} */
delete msg;
} else {
throw cRuntimeError("BaseOverlay::handleMessage(): Received msg with "
"unknown type!");
delete msg;
}
}
void BaseOverlay::handleNodeGracefulLeaveNotification ( )
protectedvirtual

This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.

Reimplemented in NTree, Kademlia, Quon, and Vast.

Definition at line 1081 of file BaseOverlay.cc.

{
// ...
}
void BaseOverlay::handleNodeLeaveNotification ( )
protectedvirtual

This method gets call **.gracefulLeaveDelay seconds before it is killed.

Reimplemented in oversim::Nice, and Vast.

Definition at line 1076 of file BaseOverlay.cc.

{
// ...
}
void BaseOverlay::handleTransportAddressChangedNotification ( )
protectedvirtual

This method gets call if the node has a new TransportAddress (IP address) because he changed his access network.

Definition at line 1067 of file BaseOverlay.cc.

{
// get new ip address
thisNode.setIp(IPAddressResolver().addressOf(
getParentModule()->getParentModule()));
}
void BaseOverlay::handleUDPMessage ( BaseOverlayMessage msg)
protectedvirtual

Processes messages from underlay.

Parameters
msgMessage from UDP

Reimplemented in Kademlia, Gia, oversim::Nice, Pastry, oversim::Koorde, oversim::Chord, NTree, Quon, Vast, PubSubLobby, and PubSubMMOG.

Definition at line 1092 of file BaseOverlay.cc.

{
delete msg;
}
void BaseOverlay::initialize ( int  stage)
private

initializes base-class-attributes

Parameters
stagethe init stage

Definition at line 77 of file BaseOverlay.cc.

{
if (stage == 0) {
OverlayKey::setKeyLength(par("keyLength"));
}
if (stage == REGISTER_STAGE) {
return;
}
if (stage == MIN_STAGE_OVERLAY) {
// find friend modules
notificationBoard = NotificationBoardAccess().get();
bootstrapList = check_and_cast<BootstrapList*>(getParentModule()->
getParentModule()->getSubmodule("bootstrapList", 0));
udpGate = gate("udpIn");
appGate = gate("appIn");
// fetch some parameters
overlayId = par ("overlayId");
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")
else if (temp == "exhaustive-iterative")
else if (temp == "semi-recursive")
else if (temp == "full-recursive")
else if (temp == "source-routing-recursive")
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");
par("lookupStrictParallelRpcs");
par("lookupUseAllParallelResponses");
par("lookupNewRpcOnEveryTimeout");
par("lookupNewRpcOnEveryResponse");
par("lookupFinishOnFirstUnchanged");
par("lookupVisitOnlyOnce");
par("lookupAcceptLateSiblings");
recursiveLookupConfig.redundantNodes = par("lookupRedundantNodes");
// statistics
WATCH(numDropped);
WATCH(bytesDropped);
WATCH(joinRetries);
}
// set up local nodehandle
thisNode.setIp(IPAddressResolver().
addressOf(getParentModule()->getParentModule()));
getDisplayString().setTagArg("i", 1, "red");
// set up UDP
// 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
initVis(getParentModule()->getParentModule());
// init rpcs
// set TCP output gate
setTcpOut(gate("tcpOut"));
// statistics
creationTime = simTime();
WATCH(creationTime);
}
if (stage >= MIN_STAGE_OVERLAY && stage <= MAX_STAGE_OVERLAY)
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!
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");
}
}
}
}
void BaseOverlay::initializeOverlay ( int  stage)
protectedvirtual

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.

Parameters
stagethe init stage

Reimplemented in Kademlia, oversim::Nice, Gia, Bamboo, Broose, Pastry, oversim::Koorde, oversim::Chord, NTree, Quon, Vast, PubSubLobby, and PubSubMMOG.

Definition at line 301 of file BaseOverlay.cc.

{
}
void BaseOverlay::initLookups ( )
private

creates a LookupSet

Definition at line 1244 of file BaseOverlay.cc.

{
}
bool BaseOverlay::internalHandleRpcCall ( BaseCallMessage msg)
protectedvirtual

Handles internal rpc requests.


This method is used to implement basic functionality in the BaseRpc.

Parameters
msgThe call message
Returns
bool true, if call has been handled.

Reimplemented from BaseRpc.

Definition at line 1723 of file BaseOverlay.cc.

{
// call rpc stubs
RPC_DELEGATE( FindNode, findNodeRpc );
RPC_DELEGATE( FailedNode, failedNodeRpc );
RPC_DELEGATE( NextHop, nextHopRpc );
// if RPC was handled return true, else tell the parent class to handle it
}
void BaseOverlay::internalHandleRpcResponse ( BaseResponseMessage msg,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
)
protectedvirtual

Handles rpc responses internal in base classes

This method is used to implement basic functionality in the BaseRpc.

Parameters
msgThe call message
contextPointer to an optional state object. The object has to be handled/deleted by the internalHandleRpcResponse() code
rpcIdThe ID of the call
rttthe time between sending the call and receiving the response

Reimplemented from BaseRpc.

Definition at line 1737 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 
)
protectedvirtual

Handles rpc timeouts internal in base classes

This method is used to implement basic functionality in the BaseRpc.

Parameters
msgThe call message
destThe node that did not response
contextPointer to an optional state object. The object has to be handled/deleted by the internalHandleRpcResponse() code
rpcIdThe ID of the call
destKeyThe key of the call if used
Returns
bool true, if call has been handled.
Todo:
return bool?

Reimplemented from BaseRpc.

Definition at line 1744 of file BaseOverlay.cc.

{
RPC_ON_CALL( NextHop )
{
= 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.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.getKey().toString(16) << ")]\n"
<< " Resend msg to next available node in nextHops[]: "
<< tempMsg->getNextHops(0).getIp()
<< std::endl;
} else {
EV << "[BaseOverlay::internalHandleRpcTimeout() @ "
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " dropping msg for " << dest
<< endl;
bytesDropped += tempMsg->getByteLength());
delete tempMsg;
}
} else {
bytesDropped += tempMsg->getByteLength());
//std::cout << thisNode.getIp() << " BaseOverlay::internalHandleRpcTimeout() 2 " << msg->getName() << std::endl;
delete tempMsg;
join();
}
break;
}
BaseRpc::internalHandleRpcTimeout(msg, dest, context, rpcId, destKey);
}
void BaseOverlay::internalSendRouteRpc ( BaseRpcMessage message,
const OverlayKey destKey,
const std::vector< TransportAddress > &  sourceRoute,
RoutingType  routingType 
)
protectedvirtual

Implements BaseRpc.

Definition at line 1815 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 1828 of file BaseOverlay.cc.

{
OverlayCtrlInfo* overlayCtrlInfo =
check_and_cast<OverlayCtrlInfo*>(call->getControlInfo());
TransportType transportType = ROUTE_TRANSPORT;
const TransportAddress* destNode;
if (overlayCtrlInfo->getSrcNode().isUnspecified()) {
// 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());
}
RoutingType routingType
= static_cast<RoutingType>(overlayCtrlInfo->getRoutingType());
assert(overlayCtrlInfo->getTransportType() != INTERNAL_TRANSPORT);
if ((overlayCtrlInfo->getTransportType() == UDP_TRANSPORT) ||
(routingType == SEMI_RECURSIVE_ROUTING) ||
(routingType == 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
destKey = &(overlayCtrlInfo->getSrcNode().getKey());
}
// 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.

Returns
true, if overlay is in a SimpleMultiOverlayHost

Definition at line 2105 of file BaseOverlay.cc.

{
return isVector() || getParentModule()->isVector();
}
bool BaseOverlay::isMalicious ( )

Returns true, if node is malicious.

Returns
true, if node is malicious.

Definition at line 453 of file BaseOverlay.cc.

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.

Parameters
nodethe NodeHandle
keydestination key
numSiblingsThe nodes knows all numSiblings nodes close to this key
errreturn false if the range could not be determined
Returns
bool true, if the node is responsible for the key.

Reimplemented in oversim::Chord, Kademlia, BasePastry, and Broose.

Definition at line 695 of file BaseOverlay.cc.

Referenced by TreeManagement::checkParentValid(), TreeManagement::getResponsibleDomainKey(), BaseApp::isSiblingFor(), and IterativeLookup::start().

{
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.

Parameters
nodeIDThe new nodeID for this node.

Definition at line 602 of file BaseOverlay.cc.

Referenced by Bamboo::handleFailedNode(), Pastry::handleFailedNode(), Pastry::handleRpcTimeout(), BasePastry::handleRpcTimeout(), Pastry::handleTimerEvent(), NeighborCache::handleTimerEvent(), and Kademlia::routingTimeout().

{
Enter_Method("join()");
if (((state == READY) || (state == FAILED)) && !rejoinOnFailure) {
return;
}
if (state != READY) {
// set nodeID and IP
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 {
}
}
} else if (state == READY && !nodeID.isUnspecified()) { // TODO dCBR
cMessage *msg = new cMessage("UDP_C_UNBIND", UDP_C_UNBIND);
UDPControlInfo *ctrl = new UDPControlInfo();
ctrl->setSrcPort(thisNode.getPort());
ctrl->setSockId(socketId);
msg->setControlInfo(ctrl);
send(msg, "udpOut");
bindToPort((thisNode.getPort() + 10) % 0xFFFF); // test
thisNode.setKey(nodeID);
}
cObject** context = globalNodeList->getContext(getThisNode());
if (restoreContext && context) {
if (*context == NULL) {
*context = new BaseOverlayContext(getThisNode().getKey(),
}
}
}
void BaseOverlay::joinForeignPartition ( const NodeHandle node)
protectedvirtual

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.

Parameters
nodeThe foreign bootstrap node

Reimplemented in oversim::Chord.

Definition at line 651 of file BaseOverlay.cc.

{
throw cRuntimeError("BaseOverlay::joinForeignPartition(): "
"This overlay doesn't support merging!");
}
void BaseOverlay::joinOverlay ( )
protectedvirtual

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 oversim::Chord, Gia, Kademlia, oversim::Nice, and Broose.

Definition at line 1706 of file BaseOverlay.cc.

{
// 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.

Parameters
keythe given node
numnumber of nodes that are returned
safeThe safe parameters is not implemented yet

Definition at line 562 of file BaseOverlay.cc.

Referenced by BaseApp::callLocalLookup().

{
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)
protectedvirtual

Definition at line 1988 of file BaseOverlay.cc.

{
int numSiblings = call->getNumSiblings();
if (numSiblings < 0) {
numSiblings = getMaxNumSiblings();
}
if (internalReadyState == false) {
// overlay not ready => lookup failed
EV << "[BaseOverlay::lookupRpc() @ "
<< " (" << 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 662 of file BaseOverlay.cc.

Referenced by BaseApp::callNeighborSet().

{
Enter_Method("neighborSet()");
return local_lookup(thisNode.getKey(), num, false);
}
void BaseOverlay::nextHopRpc ( NextHopCall call)
protectedvirtual

Definition at line 2021 of file BaseOverlay.cc.

{
if (state != READY) {
//TODO EV...
//std::cout << "BaseOverlay::nextHopRpc() (state != READY) " << state << " " << call->getName() << std::endl;
//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()) += "]";
handleBaseOverlayMessage(routeMsg, routeMsg->getDestKey());
NextHopResponse* response
= new NextHopResponse(temp.c_str());
response->setBitLength(NEXTHOPRESPONSE_L(response));
sendRpcResponse(call, response);
}
int BaseOverlay::numInitStages ( ) const
protected

Sets init stage.

See Also
InitStages.h for more information about the used stage numbers

Definition at line 72 of file BaseOverlay.cc.

{
}
bool BaseOverlay::providesKbr ( )
inline

Definition at line 811 of file BaseOverlay.h.

{ return kbr; };
void BaseOverlay::receiveChangeNotification ( int  category,
const cPolymorphic *  details 
)
protectedvirtual

callback-method for events at the NotificationBoard

Parameters
category... TODO ...
details... TODO ...

Reimplemented in PubSubMMOG.

Definition at line 1055 of file BaseOverlay.cc.

{
Enter_Method_Silent();
if (category == NF_OVERLAY_TRANSPORTADDRESS_CHANGED) {
} else if (category == NF_OVERLAY_NODE_LEAVE) {
} else if (category == NF_OVERLAY_NODE_GRACEFUL_LEAVE) {
}
}
void BaseOverlay::recordOverlaySentStats ( BaseOverlayMessage msg)
protectedvirtual

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.

Parameters
msgThe overlay message to be sent to the UDP layer

Reimplemented in Broose, oversim::Koorde, and oversim::Chord.

Definition at line 1098 of file BaseOverlay.cc.

{
// collect statistics ...
}
bool BaseOverlay::recursiveRoutingHook ( const TransportAddress dest,
BaseRouteMessage msg 
)
privatevirtual

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.

Parameters
destdestination node
msgmessage to send
Returns
true, if message should be forwarded; false, if message will be forwarded later by an other function or message has been discarded

Reimplemented in Pastry.

Definition at line 1405 of file BaseOverlay.cc.

{
return true;
}
void BaseOverlay::registerComp ( CompType  compType,
cModule *  module 
)

Definition at line 2053 of file BaseOverlay.cc.

Referenced by BaseApp::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)
protectedvirtual

Removes the abstract lookup instance.

Parameters
lookupthe Lookup to remove

Definition at line 1681 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 
)
protectedvirtual

Routes message through overlay.

The default implementation uses FindNode to determine next hops and a generic greedy routing algorithm provides with SendToKey.

Parameters
keydestination key
destCompthe destination component
srcCompthe source component
msgmessage to route
sourceRouteIf sourceRoute is given, the message gets sent via all nodes in the list before it is routed (nextHop is used as a proxy)
routingTypespecifies the routing mode (ITERATIVE_ROUTING, ...)

Definition at line 1354 of file BaseOverlay.cc.

{
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().getKey().toString(16) << ")]\n"
<< " Couldn't route application message to key "
<< key.toString(16)
<< " because the overlay module is not ready!" << endl;
bytesDropped += baseAppDataMsg->getByteLength());
delete baseAppDataMsg;
return;
}
sendToKey(key, baseAppDataMsg, 1, sourceRoute, routingType);
}
}
void BaseOverlay::sendMessageToAllComp ( cMessage *  msg,
CompType  srcComp 
)

Definition at line 2089 of file BaseOverlay.cc.

{
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,
simtime_t  delay = SIMTIME_ZERO 
)
virtual

Sends message to underlay.

Parameters
destdestination node
msgmessage to send

Reimplemented from BaseRpc.

Definition at line 1186 of file BaseOverlay.cc.

Referenced by oversim::Nice::BasicJoinLayer(), oversim::Nice::checkLeaderHeartbeatsForCollisions(), oversim::Nice::ClusterMergeRequest(), Pastry::doJoinUpdate(), Pastry::endProcessingState(), Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), oversim::Nice::handleNiceClusterMergeRequest(), oversim::Nice::handleNiceJoinCluster(), oversim::Nice::handleNiceJoineval(), oversim::Nice::handleNicePingProbe(), oversim::Nice::handleNicePollRp(), oversim::Nice::handleNiceQuery(), oversim::Nice::handleNiceQueryResponse(), oversim::Nice::handleNiceRemove(), Pastry::handleTimerEvent(), Pastry::iterativeJoinHook(), oversim::Nice::JoinCluster(), oversim::Nice::LeaderTransfer(), oversim::Nice::pollRP(), oversim::Nice::Query(), Pastry::recursiveRoutingHook(), Kademlia::recursiveRoutingHook(), oversim::Nice::Remove(), oversim::Nice::sendDataToOverlay(), oversim::Nice::sendHeartbeats(), oversim::Nice::sendHeartbeatTo(), Gia::sendKeyListToNeighbor(), Quon::sendMessage(), Vast::sendMessage(), Gia::sendMessage_DISCONNECT(), Gia::sendMessage_JOIN_ACK(), Gia::sendMessage_JOIN_DNY(), Gia::sendMessage_JOIN_REQ(), Gia::sendMessage_JOIN_RSP(), Gia::sendMessage_UPDATE(), oversim::Nice::sendRemoveTo(), and Gia::sendToken().

{
// 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) {
bytesAppDataSent += msg->getByteLength());
} else if (baseOverlayMsg->getStatType() == APP_LOOKUP_STAT){
msg->getByteLength());
} else { // MAINTENANCE_STAT
msg->getByteLength());
}
recordOverlaySentStats(baseOverlayMsg);
if (dynamic_cast<BaseResponseMessage*>(msg) && getMeasureAuthBlock()) {
// TODO: Also consider signed DhtPutMessages
}
} else {
if (dest.getIp() == thisNode.getIp()) { // to same node, but different port
RECORD_STATS(numInternalSent++; bytesInternalSent += msg->getByteLength());
}
}
sendDelayed(msg, delay, "udpOut");
}
void BaseOverlay::sendRouteMessage ( const TransportAddress dest,
BaseRouteMessage msg,
bool  ack 
)
private

Definition at line 1144 of file BaseOverlay.cc.

{
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) {
bytesAppDataForwarded += msg->getByteLength());
} else if (msg->getStatType() == APP_LOOKUP_STAT){
bytesAppLookupForwarded += msg->getByteLength());
} else {
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.

Parameters
keyThe destination key
messageMessage to be sent
numSiblingsnumber of siblings to send message to (numSiblings > 1 means multicast)
sourceRouteIf sourceRoute is given, the message gets sent via all nodes in the list before it is routed (nextHop is used as a proxy)
routingTypespecifies the routing mode (ITERATIVE_ROUTING, ...)

Definition at line 1411 of file BaseOverlay.cc.

Referenced by Kademlia::recursiveRoutingHook().

{
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->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
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());
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(),
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
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;
bytesDropped += routeMsg->getByteLength());
}
delete routeMsg;
delete nextHops;
return;
}
assert(!nextHop->isUnspecified());
// callForward to app
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.

Parameters
readytrue if the overlay changed to ready state (joined successfully)

Definition at line 1103 of file BaseOverlay.cc.

Referenced by BasePastry::baseChangeState(), Gia::changeState(), oversim::Nice::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;
}
getDisplayString().setTagArg("i", 1, ready ? "" : "red");
if (isMalicious()) {
getDisplayString().setTagArg("i", 1, ready ? "green" : "yellow");
}
if (ready) {
} else {
}
std::cout << "OVERLAY STATE: " << (ready ? "READY (" : "OFFLINE (")
<< thisNode << ")" << std::endl;
}
msg->setReady(ready);
// notify all registered components about new overlay state
}
void BaseOverlay::setOwnNodeID ( )
privatevirtual

Overlay implementations can overwrite this virtual method to set a specific nodeID.

The default implementation sets a random nodeID.

Definition at line 657 of file BaseOverlay.cc.

Friends And Related Function Documentation

friend class BootstrapList
friend

Definition at line 71 of file BaseOverlay.h.

friend class IterativeLookup
friend

Definition at line 68 of file BaseOverlay.h.

friend class IterativePathLookup
friend

Definition at line 69 of file BaseOverlay.h.

friend class RecursiveLookup
friend

Definition at line 70 of file BaseOverlay.h.

friend class SendToKeyListener
friend

Definition at line 72 of file BaseOverlay.h.

Member Data Documentation

const cGate* BaseOverlay::appGate
private

Definition at line 770 of file BaseOverlay.h.

int BaseOverlay::bytesAppDataForwarded
protected

number of forwarded app data bytes at out-gate

Definition at line 155 of file BaseOverlay.h.

Referenced by Gia::forwardMessage(), and Gia::forwardSearchResponseMessage().

int BaseOverlay::bytesAppDataReceived
private

number of received app data bytes (incl. bytes to be forwarded)

Definition at line 127 of file BaseOverlay.h.

int BaseOverlay::bytesAppDataSent
private

number of sent app data bytes (incl. forwarded bytes)

Definition at line 120 of file BaseOverlay.h.

int BaseOverlay::bytesAppLookupForwarded
protected

number of forwarded app lookup bytes at out-gate

Definition at line 157 of file BaseOverlay.h.

int BaseOverlay::bytesAppLookupReceived
private

number of received app lookup bytes (incl. bytes to be forwarded)

Definition at line 129 of file BaseOverlay.h.

int BaseOverlay::bytesAppLookupSent
private

number of sent app lookup bytes (incl. forwarded bytes)

Definition at line 122 of file BaseOverlay.h.

int BaseOverlay::bytesAuthBlockSent
private

number of bytes sent for rpc message signatures

Definition at line 138 of file BaseOverlay.h.

int BaseOverlay::bytesDropped
protected

number of dropped bytes

Definition at line 211 of file BaseOverlay.h.

Referenced by Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), Gia::getRoute(), and Gia::handleUDPMessage().

int BaseOverlay::bytesFailedNodeResponseSent
protected

Definition at line 168 of file BaseOverlay.h.

int BaseOverlay::bytesFailedNodeSent
protected

Definition at line 166 of file BaseOverlay.h.

int BaseOverlay::bytesFindNodeResponseSent
protected

Definition at line 164 of file BaseOverlay.h.

int BaseOverlay::bytesFindNodeSent
protected

Definition at line 162 of file BaseOverlay.h.

int BaseOverlay::bytesInternalReceived
private

number of bytes received from same host but different port (SimpleMultiOverlayHost)

Definition at line 136 of file BaseOverlay.h.

int BaseOverlay::bytesInternalSent
private

number of bytes sent to same host but different port (SimpleMultiOverlayHost)

Definition at line 134 of file BaseOverlay.h.

int BaseOverlay::bytesMaintenanceForwarded
protected

number of forwarded maintenance bytes at out-gate

Definition at line 159 of file BaseOverlay.h.

int BaseOverlay::bytesMaintenanceReceived
private

number of received maintenance bytes (incl. bytes to be forwarded)

Definition at line 131 of file BaseOverlay.h.

int BaseOverlay::bytesMaintenanceSent
private

number of sent maintenance bytes (incl. forwarded bytes)

Definition at line 124 of file BaseOverlay.h.

bool BaseOverlay::collectPerHopDelay
protected

collect delay for single hops

Definition at line 194 of file BaseOverlay.h.

CompModuleList BaseOverlay::compModuleList
private

Definition at line 838 of file BaseOverlay.h.

simtime_t BaseOverlay::creationTime
protected

simtime when the node has been created

Definition at line 171 of file BaseOverlay.h.

Referenced by oversim::Nice::finishOverlay(), BasePastry::finishOverlay(), Kademlia::finishOverlay(), and getCreationTime().

RoutingType BaseOverlay::defaultRoutingType
protected
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.

bool BaseOverlay::dropFindNodeAttack
protected

if node is malicious, it tries a findNode attack

Definition at line 201 of file BaseOverlay.h.

bool BaseOverlay::dropRouteMessageAttack
protected

if node is malicious, it drops all received BaseRouteMessages

Definition at line 204 of file BaseOverlay.h.

GlobalNodeList* BaseOverlay::globalNodeList
protected

pointer to GlobalNodeList in this node

Definition at line 183 of file BaseOverlay.h.

Referenced by Quon::changeState(), Vast::changeState(), Vast::finishOverlay(), and Gia::handleTimerEvent().

GlobalParameters* BaseOverlay::globalParameters
protected

pointer to the GlobalParameters module

Definition at line 187 of file BaseOverlay.h.

int BaseOverlay::hopCountMax
protected

maximum hop count

Definition at line 206 of file BaseOverlay.h.

Referenced by Kademlia::handleBucketRefreshTimerExpired(), and Kademlia::handleRpcResponse().

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 839 of file BaseOverlay.h.

bool BaseOverlay::invalidNodesAttack
protected

if node is malicious, it tries a invalidNode attack

Definition at line 203 of file BaseOverlay.h.

bool BaseOverlay::isSiblingAttack
protected

if node is malicious, it tries a isSibling attack

Definition at line 202 of file BaseOverlay.h.

IterativeLookupConfiguration BaseOverlay::iterativeLookupConfig
protected
int BaseOverlay::joinRetries
private

number of join retries

Definition at line 140 of file BaseOverlay.h.

bool BaseOverlay::kbr
protected

set this to true, if the overlay provides KBR services

Definition at line 763 of file BaseOverlay.h.

Referenced by Pastry::initializeOverlay(), Bamboo::initializeOverlay(), Kademlia::initializeOverlay(), and providesKbr().

int BaseOverlay::localPort
protected

used UDP-port

Definition at line 205 of file BaseOverlay.h.

LookupSet BaseOverlay::lookups
protected

Definition at line 582 of file BaseOverlay.h.

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().

NotificationBoard* BaseOverlay::notificationBoard
protected

pointer to NotificationBoard in this node

Definition at line 184 of file BaseOverlay.h.

int BaseOverlay::numAppDataForwarded
protected

number of forwarded app data packets

Definition at line 154 of file BaseOverlay.h.

Referenced by Gia::forwardMessage(), and Gia::forwardSearchResponseMessage().

int BaseOverlay::numAppDataReceived
private

number of received app data packets (incl. packets to be forwarded )

Definition at line 126 of file BaseOverlay.h.

int BaseOverlay::numAppDataSent
private

number of sent app data packets (incl. forwarded packets)

Definition at line 119 of file BaseOverlay.h.

int BaseOverlay::numAppLookupForwarded
protected

number of forwarded app lookup packets

Definition at line 156 of file BaseOverlay.h.

int BaseOverlay::numAppLookupReceived
private

number of received app lookup packets (incl. packets to be forwarded)

Definition at line 128 of file BaseOverlay.h.

int BaseOverlay::numAppLookupSent
private

number of sent app loookup packets (incl. forwarded packets)

Definition at line 121 of file BaseOverlay.h.

int BaseOverlay::numDropped
protected

number of dropped packets

Definition at line 210 of file BaseOverlay.h.

Referenced by Gia::forwardMessage(), Gia::forwardSearchResponseMessage(), Gia::getRoute(), and Gia::handleUDPMessage().

int BaseOverlay::numFailedNodeResponseSent
protected

Definition at line 167 of file BaseOverlay.h.

int BaseOverlay::numFailedNodeSent
protected

Definition at line 165 of file BaseOverlay.h.

int BaseOverlay::numFindNodeResponseSent
protected

Definition at line 163 of file BaseOverlay.h.

int BaseOverlay::numFindNodeSent
protected

Definition at line 161 of file BaseOverlay.h.

int BaseOverlay::numInternalReceived
private

number of packets received from same host but different port (SimpleMultiOverlayHost)

Definition at line 135 of file BaseOverlay.h.

int BaseOverlay::numInternalSent
private

number of packets sent to same host but different port (SimpleMultiOverlayHost)

Definition at line 133 of file BaseOverlay.h.

int BaseOverlay::numMaintenanceForwarded
protected

number of forwarded maintenance packets

Definition at line 158 of file BaseOverlay.h.

int BaseOverlay::numMaintenanceReceived
private

number of received maintenance packets (incl. packets to be forwarded)

Definition at line 130 of file BaseOverlay.h.

int BaseOverlay::numMaintenanceSent
private

number of sent maintenance packets (incl. forwarded packets)

Definition at line 123 of file BaseOverlay.h.

uint32_t BaseOverlay::overlayId
protected

identifies the overlay this node belongs to (used for multiple overlays)

Definition at line 190 of file BaseOverlay.h.

uint32_t BaseOverlay::recNumRedundantNodes
protected

numRedundantNodes for recursive routing

Definition at line 196 of file BaseOverlay.h.

bool BaseOverlay::recordRoute
protected

record visited hops on route

Definition at line 197 of file BaseOverlay.h.

Referenced by Kademlia::initializeOverlay().

RecursiveLookupConfiguration BaseOverlay::recursiveLookupConfig
protected

Definition at line 564 of file BaseOverlay.h.

bool BaseOverlay::rejoinOnFailure
protected

Definition at line 199 of file BaseOverlay.h.

bool BaseOverlay::restoreContext
protected

if true, a node rejoins with its old nodeId and malicious state

Definition at line 208 of file BaseOverlay.h.

bool BaseOverlay::routeMsgAcks
protected

send ACK when receiving route message

Definition at line 195 of file BaseOverlay.h.

bool BaseOverlay::sendRpcResponseToLastHop
protected

needed by KBR protocols for NAT support

Definition at line 200 of file BaseOverlay.h.

std::vector<HopDelayRecord*> BaseOverlay::singleHopDelays
protected

Definition at line 169 of file BaseOverlay.h.

int BaseOverlay::socketId
private

Definition at line 841 of file BaseOverlay.h.

States BaseOverlay::state
protected

Definition at line 216 of file BaseOverlay.h.

Referenced by BasePastry::baseChangeState(), Gia::changeState(), oversim::Nice::changeState(), Pastry::changeState(), Bamboo::checkProxCache(), Pastry::checkProxCache(), BasePastry::findNode(), BasePastry::finishOverlay(), Gia::getRoute(), getState(), Vast::handleAppMessage(), Gia::handleAppMessage(), Kademlia::handleBucketRefreshTimerExpired(), Bamboo::handleFailedNode(), Pastry::handleFailedNode(), Vast::handleNodeGracefulLeaveNotification(), Vast::handleNodeLeaveNotification(), Pastry::handlePastryJoinCall(), Pastry::handlePastryJoinResponse(), BasePastry::handleRequestLeafSetCall(), Bamboo::handleRequestLeafSetResponse(), Pastry::handleRequestLeafSetResponse(), BasePastry::handleRequestLeafSetResponse(), Pastry::handleRequestRepairCall(), Pastry::handleRequestRepairResponse(), BasePastry::handleRequestRoutingRowCall(), Pastry::handleRequestRoutingRowResponse(), BasePastry::handleRequestRoutingRowResponse(), Pastry::handleRequestStateCall(), Pastry::handleRequestStateResponse(), Pastry::handleRpcCall(), BasePastry::handleRpcCall(), Kademlia::handleRpcResponse(), Pastry::handleRpcTimeout(), Kademlia::handleRpcTimeout(), BasePastry::handleRpcTimeout(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), Vast::handleUDPMessage(), Gia::handleUDPMessage(), Kademlia::isSiblingFor(), Kademlia::joinOverlay(), Kademlia::lookupFinished(), Pastry::mergeState(), Pastry::pingResponse(), BasePastry::proxCallback(), Kademlia::routingInit(), and Vast::setBootstrapedIcon().

const cGate* BaseOverlay::udpGate
private

Definition at line 769 of file BaseOverlay.h.

UnderlayConfigurator* BaseOverlay::underlayConfigurator
protected

pointer to UnderlayConfigurator in this node

Definition at line 185 of file BaseOverlay.h.

Referenced by MyOverlay::handleTimerEvent().

bool BaseOverlay::useCommonAPIforward
protected

forward messages to applications?

Definition at line 193 of file BaseOverlay.h.


The documentation for this class was generated from the following files: