BaseOverlay Class Reference

#include <BaseOverlay.h>

Inheritance diagram for BaseOverlay:

BaseRpc TopologyVis RpcListener Broose Chord Gia Kademlia Pastry Vast Koorde

List of all members.


Detailed Description

Base class for overlays.

Base class for overlay modules, with KBR-API, statistics and pointers to the BootstrapOracle and the UnderlayConfigurator. Derived classes must use BaseOverlayMessage as base class for own message types.

Author:
Bernhard Heep (initial)

Sebastian Mies (rpc, lookup)


Public Types

enum  States {
  INIT = 0, JOINING_1 = 1, JOINING_2 = 2, JOINING_3 = 3,
  READY = 4, REFRESH = 5, SHUTDOWN = 6, JOINING = JOINING_1,
  JOIN = JOINING_1, BOOTSTRAP = JOINING_1, RSET = JOINING_2, BSET = JOINING_3
}

Public Member Functions

 BaseOverlay ()
virtual ~BaseOverlay ()
 Virtual destructor.
States getState ()
bool isMalicious ()
 Returns true, if node is malicious.
NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
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, BaseOverlayMessage *msg)
 Sends message to underlay.
void pingKey (const OverlayKey &destKey, simtime_t timeout=-1, int retries=0, const char *caption=NULL, RpcListener *rpcListener=NULL, int rpcId=-1)
 ping a node by its OverlayKey
void sendToKey (const OverlayKey &key, BaseOverlayMessage *message, int numSiblings=1, const TransportAddress &nextHop=TransportAddress::UNSPECIFIED_NODE)
 Sends a message to an overlay node, with the generic routing algorithm.
void insertBootstrapNode (const NodeHandle &node)
void registerComp (CompType compType, cModule *module)
cModule * getCompModule (CompType compType)
cGate * getCompRpcGate (CompType compType)

Protected Types

typedef hash_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, cMessage *msg, const TransportAddress &hint=TransportAddress::UNSPECIFIED_NODE)
 Sends a packet over UDP.
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 removeBootstrapNode (const NodeHandle &node)
const NodeHandlegetBootstrapNode ()
void registerBootstrapNode (const NodeHandle &node)
virtual void handleUDPMessage (BaseOverlayMessage *msg)
 Processes messages from underlay.
virtual void handleTimerEvent (cMessage *msg)
 Processes "timer" self-messages.
virtual void handleAppMessage (cMessage *msg)
 Processes non-commonAPI messages.
virtual void receiveChangeNotification (int category, 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 BootstrapOracle.
virtual AbstractLookupcreateLookup (const BaseOverlayMessage *msg=NULL, const cObject *findNodeExt=NULL)
 Creates an abstract iterative lookup instance.
virtual void removeLookup (AbstractLookup *lookup)
 Removes the abstract lookup instance.
virtual OverlayKey distance (const OverlayKey &x, const OverlayKey &y) const
 This method should implement the distance between two keys.
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 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)
virtual void sendRpcMessageWithTransport (TransportType transportType, CompType destComp, const TransportAddress &dest, const OverlayKey &destKey, BaseRpcMessage *message)
bool internalHandleRpc (BaseCallMessage *msg)
 Handles internal rpc requests.
bool internalHandleRpcResponse (BaseResponseMessage *msg, int rpcId, simtime_t rtt)
 Handles rpc responses internal in base classes
.
void internalHandleRpcTimeout (BaseCallMessage *msg, const TransportAddress &dest, int rpcId, const OverlayKey &destKey)
 Handles rpc timeouts internal in base classes
.
CompType getThisCompType ()
 Return the component type of this module.

Protected Attributes

int numForwarded
int bytesForwarded
int numSignalingForwarded
int bytesSignalingForwarded
int numFindNodeSent
int bytesFindNodeSent
int numFindNodeResponseSent
int bytesFindNodeResponseSent
int numFailedNodeSent
int bytesFailedNodeSent
int numFailedNodeResponseSent
int bytesFailedNodeResponseSent
std::vector
< HopDelayRecord * > 
singleHopDelays
simtime_t creationTime
BootstrapOraclebootstrapOracle
 pointer to BootstrapOracle in this node
NotificationBoard * notificationBoard
 pointer to NotificationBoard in this node
UnderlayConfiguratorunderlayConfigurator
 pointer to UnderlayConfigurator in this node
bool debugOutput
 debug output ?
bool measureNetwInitPhase
 fetch statistics in init phase ?
bool iterativeLookup
 do iterative instead of recursive lookups
bool useCommonAPIforward
 forward messages to applications?
bool collectPerHopDelay
 collect delay for single hops
bool useNextHopRpc
 send ACK when receiving route message
bool drawOverlayTopology
int localPort
 used UDP-port
int hopCountMax
 maximum hop count
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
BaseLookupConfiguration baseLookupConfig
LookupSet lookups

Private Types

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

Private Member Functions

void initialize (int stage)
 initializes base-class-attributes
void finish ()
 collects statistical data
virtual void setOwnNodeID ()
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
.
void sendRouteMessage (const TransportAddress &dest, BaseRouteMessage *msg, bool ack)
void initLookups ()
 creates a LookupSet
void finishLookups ()
 deletes entries in lookups
virtual bool forwardMessageRecursive (const TransportAddress &dest, BaseRouteMessage *msg)
 Hook for forwarded message in recursive lookup mode.
void findNodeRpc (FindNodeCall *call)
void failedNodeRpc (FailedNodeCall *call)

Private Attributes

int numSent
int bytesSent
int numSignalingSent
int bytesSignalingSent
int numReceived
int bytesReceived
int numSignalingReceived
int bytesSignalingReceived
int numOutbound
int bytesOutbound
int numInbound
int bytesInbound
CompModuleList compModuleList

Friends

class BaseLookup
class RecursiveLookup
class BasePathLookup
class BootstrapList
class SendToKeyListener

Classes

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

Member Typedef Documentation

typedef hash_set<AbstractLookup*, lookupHashFcn, lookupHashFcn> BaseOverlay::LookupSet [protected]

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


Member Enumeration Documentation

enum BaseOverlay::States

Enumerator:
INIT 
JOINING_1 
JOINING_2 
JOINING_3 
READY 
REFRESH 
SHUTDOWN 
JOINING 
JOIN 
BOOTSTRAP 
RSET 
BSET 
00092                 {
00093         INIT = 0,
00094         JOINING_1 = 1,
00095         JOINING_2 = 2,
00096         JOINING_3 = 3,
00097         READY = 4,
00098         REFRESH = 5,
00099         SHUTDOWN = 6,
00100 
00101         //some aliases for compatibility
00102         JOINING = JOINING_1,
00103         JOIN = JOINING_1,
00104         BOOTSTRAP = JOINING_1,
00105         RSET = JOINING_2,
00106         BSET = JOINING_3
00107     };


Constructor & Destructor Documentation

BaseOverlay::BaseOverlay (  ) 

00046 {
00047     bootstrapOracle = NULL;
00048     underlayConfigurator = NULL;
00049     notificationBoard = NULL;
00050 }

BaseOverlay::~BaseOverlay (  )  [virtual]

Virtual destructor.

00053 {
00054     finishLookups();
00055     finishRpcs();
00056 }


Member Function Documentation

States BaseOverlay::getState (  )  [inline]

00109 { return state; };

void BaseOverlay::initialize ( int  stage  )  [private]

initializes base-class-attributes

Parameters:
stage the init stage
00064 {
00065     if (stage == MIN_STAGE_OVERLAY) {
00066         OverlayKey::setKeyLength(par("keyLength"));
00067 
00068         // fetch some parameters
00069         debugOutput = par("debugOutput");
00070         measureNetwInitPhase = par("measureNetwInitPhase");
00071         collectPerHopDelay = par("collectPerHopDelay");
00072         localPort = par("localPort");
00073         hopCountMax = par("hopCountMax");
00074         drawOverlayTopology = par("drawOverlayTopology");
00075         iterativeLookup = par("iterativeLookup");
00076         collectPerHopDelay = par("collectPerHopDelay");
00077         useCommonAPIforward = par("useCommonAPIforward");
00078         useNextHopRpc = par("useNextHopRpc");
00079 
00080         // set base lookup parameters
00081         baseLookupConfig.redundantNodes = par("lookupRedundantNodes");
00082         baseLookupConfig.parallelPaths = par("lookupParallelPaths");
00083         baseLookupConfig.parallelRpcs = par("lookupParallelRpcs");
00084         baseLookupConfig.secure = par("lookupSecure");
00085         baseLookupConfig.merge = par("lookupMerge");
00086         baseLookupConfig.failedNodeRpcs = par("lookupFailedNodeRpcs");
00087 
00088         // statistics
00089         numSent = 0;
00090         bytesSent = 0;
00091         numSignalingSent = 0;
00092         bytesSignalingSent = 0;
00093         numReceived = 0;
00094         bytesReceived = 0;
00095         numOutbound = 0;
00096         bytesOutbound = 0;
00097         numInbound = 0;
00098         bytesInbound = 0;
00099         numSignalingReceived = 0;
00100         bytesSignalingReceived = 0;
00101         numForwarded = 0;
00102         bytesForwarded = 0;
00103         numSignalingForwarded = 0;
00104         bytesSignalingForwarded = 0;
00105         numDropped = 0;
00106         bytesDropped = 0;
00107         numFindNodeSent = 0;
00108         bytesFindNodeSent = 0;
00109         numFindNodeResponseSent = 0;
00110         bytesFindNodeResponseSent = 0;
00111         numFailedNodeSent = 0;
00112         bytesFailedNodeSent = 0;
00113         numFailedNodeResponseSent = 0;
00114         bytesFailedNodeResponseSent = 0;
00115 
00116         WATCH(numSent);
00117         WATCH(bytesSent);
00118         WATCH(numOutbound);
00119         WATCH(bytesOutbound);
00120         WATCH(numSignalingSent);
00121         WATCH(bytesSignalingSent);
00122         WATCH(numReceived);
00123         WATCH(bytesReceived);
00124         WATCH(numInbound);
00125         WATCH(bytesInbound);
00126         WATCH(numSignalingReceived);
00127         WATCH(bytesSignalingReceived);
00128         WATCH(numForwarded);
00129         WATCH(bytesForwarded);
00130         WATCH(numSignalingForwarded);
00131         WATCH(bytesSignalingForwarded);
00132         WATCH(numDropped);
00133         WATCH(bytesDropped);
00134         WATCH(numFindNodeSent);
00135         WATCH(bytesFindNodeSent);
00136         WATCH(numFindNodeResponseSent);
00137         WATCH(bytesFindNodeResponseSent);
00138         WATCH(numFailedNodeSent);
00139         WATCH(bytesFailedNodeSent);
00140         WATCH(numFailedNodeResponseSent);
00141         WATCH(bytesFailedNodeResponseSent);
00142 
00143         // set up UDP
00144         bindToPort(localPort);
00145 
00146         // find friend modules
00147         bootstrapOracle = BootstrapOracleAccess().get();
00148         underlayConfigurator = UnderlayConfiguratorAccess().get();
00149         notificationBoard = NotificationBoardAccess().get();
00150 
00151         // set up local nodehandle
00152         thisNode.ip = IPAddressResolver().
00153                       addressOf(parentModule()->parentModule()).get4();
00154         thisNode.port = localPort;
00155         thisNode.key = OverlayKey::UNSPECIFIED_KEY;
00156 
00157         // subscribe to the notification board
00158         notificationBoard->subscribe(this, NF_OVERLAY_TRANSPORTADDRESS_CHANGED);
00159         notificationBoard->subscribe(this, NF_OVERLAY_NODE_LEAVE);
00160         notificationBoard->subscribe(this, NF_OVERLAY_NODE_GRACEFUL_LEAVE);
00161 
00162         // set overlay pointer
00163         //overlay = this;
00164 
00165         // init visualization with terminal ptr
00166         if (drawOverlayTopology)
00167             initVis(parentModule()->parentModule());
00168 
00169         // register component
00170         registerComp(getThisCompType(), this);
00171 
00172         // init rpcs
00173         initRpcs();
00174         initLookups();
00175 
00176         // statistics
00177         globalStatistics->nodesInitialized++;
00178         creationTime = simTime();
00179     }
00180 
00181     if (stage >= MIN_STAGE_OVERLAY && stage <= MAX_STAGE_OVERLAY)
00182         initializeOverlay(stage);
00183 
00184     if (stage == MAX_STAGE_OVERLAY) {
00185         if ((bool)par("joinOnApplicationRequest") == false) {
00186             join();
00187         }
00188     }
00189 }

void BaseOverlay::finish (  )  [private]

collects statistical data

00196 {
00197     finishOverlay();
00198 
00199     globalStatistics->nodesFinished++;
00200     recordScalar("BaseOverlay: Sent FindNode Responses",
00201                  numFindNodeResponseSent);
00202     recordScalar("BaseOverlay: Sent FindNodeResponse Bytes",
00203                  bytesFindNodeResponseSent);
00204     recordScalar("BaseOverlay: Sent FailedNode Messages", numFailedNodeSent);
00205     recordScalar("BaseOverlay: Sent FailedNode Bytes", bytesFailedNodeSent);
00206     recordScalar("BaseOverlay: Sent FailedNode Responses",
00207                  numFailedNodeResponseSent);
00208     recordScalar("BaseOverlay: Sent FailedNodeResponse Bytes",
00209                  bytesFailedNodeResponseSent);
00210 
00211     recordScalar("BaseOverlay: Sent Packets", numSent + numSignalingSent);
00212     recordScalar("BaseOverlay: Outbound Packets", numOutbound);
00213     recordScalar("BaseOverlay: Sent Bytes", bytesSent + bytesSignalingSent);
00214     recordScalar("BaseOverlay: Outbound Bytes", bytesOutbound);
00215     recordScalar("BaseOverlay: Received Packets", numReceived + numSignalingReceived);
00216     recordScalar("BaseOverlay: Inbound Packets", numInbound);
00217     recordScalar("BaseOverlay: Received Bytes", bytesReceived + bytesSignalingReceived);
00218     recordScalar("BaseOverlay: Inbound Bytes", bytesInbound);
00219 
00220     simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime);
00221     if (time == 0) return;
00222 
00223     if (collectPerHopDelay) {
00224         std::ostringstream singleHopName;
00225         HopDelayRecord* hdrl = NULL;
00226         HopDelayRecord* hdr = NULL;
00227         for (size_t i = 0; i < singleHopDelays.size();) {
00228             hdrl = singleHopDelays[i++];
00229             hdr = hdrl;
00230             for (size_t j = 1; j <= i; ++j) {
00231                 if (hdr->count == 0) continue;
00232                 singleHopName.str("");
00233                 singleHopName << "BaseOverlay: Average Delay in Hop "
00234                               << j << " of " << i;
00235                 globalStatistics->addStdDev(singleHopName.str(),
00236                                             hdr->val / hdr->count);
00237                 ++hdr;
00238             }
00239             delete[] hdrl;
00240         }
00241         singleHopDelays.clear();
00242     }
00243 
00244     globalStatistics->addStdDev("BaseOverlay: Sent User Messages/s", numSent / time);
00245     globalStatistics->addStdDev("BaseOverlay: Sent User Bytes/s", bytesSent / time);
00246     globalStatistics->addStdDev("BaseOverlay: Sent Outbound Messages/s", numOutbound / time);
00247     globalStatistics->addStdDev("BaseOverlay: Sent Outbound Bytes/s", bytesOutbound / time);
00248     globalStatistics->addStdDev("BaseOverlay: Sent Signaling Messages/s", numSignalingSent / time);
00249     globalStatistics->addStdDev("BaseOverlay: Sent Signaling Bytes/s", bytesSignalingSent / time);
00250     globalStatistics->addStdDev("BaseOverlay: Sent Total Messages/s", (numSent + numSignalingSent)/time);
00251     globalStatistics->addStdDev("BaseOverlay: Sent Total Bytes/s", (bytesSent + bytesSignalingSent)/time);
00252     globalStatistics->addStdDev("BaseOverlay: Sent FindNode Messages/s", numFindNodeSent / time);
00253     globalStatistics->addStdDev("BaseOverlay: Sent FindNode Bytes/s", bytesFindNodeSent / time);
00254 
00255     globalStatistics->addStdDev("BaseOverlay: Sent FindNodeResponse Messages/s", numFindNodeResponseSent / time);
00256     globalStatistics->addStdDev("BaseOverlay: Sent FindNodeResponse Bytes/s", bytesFindNodeResponseSent / time);
00257     globalStatistics->addStdDev("BaseOverlay: Sent FailedNode Messages/s", numFailedNodeSent / time);
00258     globalStatistics->addStdDev("BaseOverlay: Sent FailedNode Bytes/s", bytesFailedNodeSent / time);
00259     globalStatistics->addStdDev("BaseOverlay: Sent FailedNodeResponse Messages/s", numFailedNodeResponseSent / time);
00260     globalStatistics->addStdDev("BaseOverlay: Sent FailedNodeResponse Bytes/s", bytesFailedNodeResponseSent / time);
00261 
00262     globalStatistics->addStdDev("BaseOverlay: Received User Messages/s", numReceived / time);
00263     globalStatistics->addStdDev("BaseOverlay: Received User Bytes/s", bytesReceived / time);
00264     globalStatistics->addStdDev("BaseOverlay: Received Inbound Messages/s", numInbound / time);
00265     globalStatistics->addStdDev("BaseOverlay: Received Inbound Bytes/s", bytesInbound / time);
00266     globalStatistics->addStdDev("BaseOverlay: Received Signaling Messages/s", numSignalingReceived / time);
00267     globalStatistics->addStdDev("BaseOverlay: Received Signaling Bytes/s", bytesSignalingReceived / time);
00268     globalStatistics->addStdDev("BaseOverlay: Received Total Messages/s",
00269                                 (numReceived + numSignalingReceived)/time);
00270     globalStatistics->addStdDev("BaseOverlay: Received Total Bytes/s",
00271                                 (bytesReceived + bytesSignalingReceived)/time);
00272     globalStatistics->addStdDev("BaseOverlay: Forwarded User Messages/s", numForwarded / time);
00273     globalStatistics->addStdDev("BaseOverlay: Forwarded User Bytes/s", bytesForwarded / time);
00274     globalStatistics->addStdDev("BaseOverlay: Forwarded Signaling Messages/s", numSignalingForwarded / time);
00275     globalStatistics->addStdDev("BaseOverlay: Forwarded Signaling Bytes/s", bytesSignalingForwarded / time);
00276     globalStatistics->addStdDev("BaseOverlay: Forwarded Total Messages/s",
00277                                 (numForwarded + numSignalingForwarded)/time);
00278     globalStatistics->addStdDev("BaseOverlay: Forwarded Total Bytes/s",
00279                                 (bytesForwarded + bytesSignalingForwarded)/time);
00280 
00281     globalStatistics->addStdDev("BaseOverlay: Dropped Messages/s", numDropped / time);
00282     globalStatistics->addStdDev("BaseOverlay: Dropped Bytes/s", bytesDropped / time);
00283 
00284     globalStatistics->addStdDev("BaseOverlay: Active Time", simTime() - creationTime);
00285 
00286     globalStatistics->doFinish();
00287 
00288 }

int BaseOverlay::numInitStages (  )  const [protected]

Sets init stage.

See also:
InitStages.h
00059 {
00060     return MAX_STAGE_OVERLAY + 1;
00061 }

void BaseOverlay::initializeOverlay ( int  stage  )  [protected, virtual]

Initializes derived-class-attributes.


Initializes derived-class-attributes, called by BaseOverlay::initialize(). By default this method is called once. If more stages are needed one can overload numInitStages() and add more stages.

Parameters:
stage the init stage

Reimplemented in Broose, Chord, Gia, Kademlia, Koorde, Pastry, and Vast.

00192 {
00193 }

void BaseOverlay::finishOverlay (  )  [protected, virtual]

collects statistical data in derived class

Reimplemented in Broose, Chord, Gia, Kademlia, Koorde, Pastry, and Vast.

00291 {
00292 }

void BaseOverlay::setOwnNodeID (  )  [private, virtual]

Reimplemented in Pastry.

00450 {
00451     thisNode.key = OverlayKey::random();
00452 }

bool BaseOverlay::isMalicious (  ) 

Returns true, if node is malicious.

Returns:
true, if node is malicious.
00298 {
00299     return bootstrapOracle->isMalicious(getThisNode());
00300 }

NodeHandle & BaseOverlay::getThisNode (  ) 

Returns the NodeHandle of this node.

Returns:
the NodeHandle of this node.
00303 {
00304     return thisNode;
00305 }

void BaseOverlay::bindToPort ( int  port  )  [protected]

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

00317 {
00318     cModule *node = parentModule()->parentModule();
00319     IPvXAddress ip = IPAddressResolver().addressOf(node);
00320 
00321     EV << "[BaseOverlay::bindToPort() @ " << ip
00322        << " (" << thisNode.key.toString(16) << ")]\n"
00323        << "    Binding to UDP port " << port
00324        << endl;
00325 
00326     // TODO UDPAppBase should be ported to use UDPSocket sometime, but for now
00327     // we just manage the UDP socket by hand...
00328     cMessage *msg = new cMessage("UDP_C_BIND", UDP_C_BIND);
00329     UDPControlInfo *ctrl = new UDPControlInfo();
00330     ctrl->setSrcPort(port);
00331     ctrl->setSockId(UDPSocket::generateSocketId());
00332     msg->setControlInfo(ctrl);
00333     send(msg, "to_udp");
00334 }

void BaseOverlay::route ( const OverlayKey key,
CompType  destComp,
CompType  srcComp,
cMessage *  msg,
const TransportAddress hint = TransportAddress::UNSPECIFIED_NODE 
) [protected, virtual]

Sends a packet over UDP.

Prints a brief about packets having an attached UDPControlInfo (i.e. those which just arrived from UDP, or about to be send to UDP). Routes message through overlay.

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

Parameters:
key destination key
destComp the destination component
srcComp the source component
msg message to route
hint next hop (usually unused)

Reimplemented in Gia.

01004 {
01005     if (key.isUnspecified() && hint.isUnspecified())
01006         error("route(): Key and hint unspecified!");
01007 
01008     // create base route message
01009     BaseAppDataMessage* baseAppDataMsg =
01010         new BaseAppDataMessage("BaseAppDataMessage");
01011     baseAppDataMsg->setType(APPDATA);
01012     baseAppDataMsg->setDestComp(destComp);
01013     baseAppDataMsg->setSrcComp(srcComp);
01014     baseAppDataMsg->setLength(BASEAPPDATA_L(baseAppDataMsg));
01015 
01016     baseAppDataMsg->setSignaling(false);
01017     baseAppDataMsg->encapsulate(msg);
01018 
01019     // debug output
01020     if (debugOutput) {
01021         EV << "[BaseOverlay::route() @ " << thisNode.ip
01022         << " (" << thisNode.key.toString(16) << ")]\n"
01023         << "    Received message from application"
01024         << endl;
01025     }
01026 
01027     if (key.isUnspecified()) {
01028         sendMessageToUDP(hint, baseAppDataMsg);
01029     } else {
01030         sendToKey( key, baseAppDataMsg, 1, hint );
01031     }
01032 }

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:
msg delivered message
destKey the destination key of the message
00343 {
00344     KBRdeliver* deliverMsg = new KBRdeliver();
00345 
00346     OverlayCtrlInfo* overlayCtrlInfo =
00347         check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00348 
00349     BaseAppDataMessage* appDataMsg = dynamic_cast<BaseAppDataMessage*>(msg);
00350 
00351     // TODO GIA
00352     if (appDataMsg != NULL) {
00353         overlayCtrlInfo->setSrcComp(appDataMsg->getSrcComp());
00354         overlayCtrlInfo->setDestComp(appDataMsg->getDestComp());
00355     }
00356 
00357     deliverMsg->setControlInfo(overlayCtrlInfo);
00358     deliverMsg->setDestKey(destKey);
00359 
00360     deliverMsg->encapsulate(msg->decapsulate());
00361 
00362     deliverMsg->setType(KBR_DELIVER);
00363 
00364     cGate* destGate = getCompRpcGate(static_cast<CompType>(
00365             overlayCtrlInfo->getDestComp()));
00366 
00367     if (destGate == NULL) {
00368         opp_error("BaseOverlay::callDeliver(): Unknown destComp!");
00369     }
00370 
00371     sendDirect(deliverMsg, 0, destGate);
00372 
00373     delete msg;
00374 }

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:
key destination key
msg message to forward
nextHopNode next hop
00378 {
00379     KBRforward* forwardMsg = new KBRforward();
00380 
00381     forwardMsg->setDestKey(msg->getDestKey());
00382     forwardMsg->setNextHopNode(nextHopNode);
00383     forwardMsg->encapsulate(msg->encapsulatedMsg()->decapsulate());
00384 
00385     OverlayCtrlInfo* overlayCtrlInfo =
00386         new OverlayCtrlInfo();
00387     overlayCtrlInfo->setTransportType(ROUTE_TRANSPORT);
00388     overlayCtrlInfo->setHopCount(msg->getHopCount());
00389     overlayCtrlInfo->setSrcNode(msg->getSrcNode());
00390     overlayCtrlInfo->setSrcComp(check_and_cast<BaseAppDataMessage*>
00391         (msg->encapsulatedMsg())->getSrcComp());
00392     overlayCtrlInfo->setDestComp(check_and_cast<BaseAppDataMessage*>
00393         (msg->encapsulatedMsg())->getDestComp());
00394 
00395     if (msg->controlInfo() != NULL) {
00396         OverlayCtrlInfo* ctrlInfo =
00397             check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00398 
00399         overlayCtrlInfo->setLastHopAddr(ctrlInfo->getLastHopAddr());
00400         overlayCtrlInfo->setLastHopPort(ctrlInfo->getLastHopPort());
00401 
00402         delete ctrlInfo;
00403     }
00404 
00405     forwardMsg->setControlInfo(overlayCtrlInfo);
00406 
00407     forwardMsg->setType(KBR_FORWARD);
00408 
00409     send(forwardMsg, "to_app");
00410 
00411     delete msg;
00412 }

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:
node the node that has joined or changed its state
joined has the node joined or changed its state?
00464 {
00465     KBRupdate* updateMsg = new KBRupdate("UPDATE");
00466 
00467     updateMsg->setNode(node);
00468     updateMsg->setJoined(joined);
00469 
00470     updateMsg->setType(KBR_UPDATE);
00471 
00472     send(updateMsg, "to_app");//"to_upperTier");
00473 }

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:
nodeID The new nodeID for this node.
00432 {
00433     Enter_Method("join()");
00434 
00435     // set nodeID and IP
00436     thisNode.ip =
00437         IPAddressResolver().addressOf(parentModule()->parentModule()).get4();
00438     if (nodeID.isUnspecified())  {
00439         setOwnNodeID();//thisNode.key = OverlayKey::random();
00440     } else {
00441         thisNode.key = nodeID;
00442     }
00443 
00444     callUpdate(thisNode, true);
00445 
00446     joinOverlay();
00447 }

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:
key the given node
num number of nodes that are returned
safe The safe parameters is not implemented yet
00416 {
00417     Enter_Method("local_lookup()");
00418 
00419     if (safe == true) {
00420         error("BaseOverlay::local_lookup(): safe flag is not implemented!");
00421     }
00422 
00423     NodeVector* nodeVector = findNode(key, num, num);
00424 
00425     if (((int)nodeVector->size()) > num)
00426         nodeVector->resize(num);
00427 
00428     return nodeVector;
00429 }

NodeVector * BaseOverlay::neighborSet ( int  num  )  [virtual]

00456 {
00457     Enter_Method("neighborSet()");
00458 
00459     return local_lookup(thisNode.key, num, false);
00460 }

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:
node the NodeHandle
key destination key
numSiblings The nodes knows all numSiblings nodes close to this key
err return false if the range could not be determined
Returns:
bool true, if the node is responsible for the key.

Reimplemented in Broose, Chord, Kademlia, and Pastry.

00477 {
00478     Enter_Method("isSiblingFor()");
00479 
00480     opp_error( "isSiblingFor: Not implemented!" );
00481 
00482     return false;
00483 }

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 Broose, Chord, Kademlia, and Pastry.

00486 {
00487     Enter_Method("getMaxNumSiblings()");
00488 
00489     opp_error( "getMaxNumSiblings: Not implemented!" );
00490 
00491     return false;
00492 }

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 Broose, Chord, Kademlia, and Pastry.

00495 {
00496     Enter_Method("getMaxNumRedundantNodes()");
00497 
00498     opp_error( "getMaxNumRedundantNodes: Not implemented!" );
00499 
00500     return false;
00501 }

void BaseOverlay::removeBootstrapNode ( const NodeHandle node  )  [protected]

00508 {
00509     bootstrapOracle->removePeer(node);
00510 }

const NodeHandle & BaseOverlay::getBootstrapNode (  )  [protected]

00513 {
00514     return bootstrapOracle->getBootstrapNode();
00515 }

void BaseOverlay::registerBootstrapNode ( const NodeHandle node  )  [protected]

00518 {
00519     bootstrapOracle->registerPeer(node);
00520 }

void BaseOverlay::handleMessage ( cMessage *  msg  )  [private]

Checks for message type and calls corresponding method.


Checks for message type (from UDP/App or selfmessage) and calls corresponding method like route(), get(), put(), remove(), handleTimerEvent(), handleAppMessage() and handleUDPMessage().

Parameters:
msg The message to be handled
00528 {
00529     // process self-messages
00530     if (msg->isSelfMessage()) {
00531         // process rpc self-messages
00532         BaseRpcMessage* rpcMessage = dynamic_cast<BaseRpcMessage*>(msg);
00533         if (rpcMessage!=NULL) {
00534             internalHandleRpcMessage(rpcMessage);
00535             return;
00536         }
00537         // process all other self-messages
00538         handleTimerEvent(msg);
00539     }
00540 
00541     // process messages from UDP
00542     else if (msg->arrivedOn("from_udp")) {
00543         UDPControlInfo* udpControlInfo =
00544             check_and_cast<UDPControlInfo*>(msg->removeControlInfo());
00545         OverlayCtrlInfo* overlayCtrlInfo = new OverlayCtrlInfo;
00546         //TODO TransportAddress
00547         overlayCtrlInfo->setLastHopAddr(udpControlInfo->srcAddr());
00548         overlayCtrlInfo->setLastHopPort(udpControlInfo->srcPort());
00549         overlayCtrlInfo->setTransportType(UDP_TRANSPORT);
00550 
00551         msg->setControlInfo(overlayCtrlInfo);
00552         delete udpControlInfo;
00553 
00554         BaseOverlayMessage* baseOverlayMsg =
00555             dynamic_cast<BaseOverlayMessage*>(msg);
00556 
00557         if (baseOverlayMsg == NULL) {
00558             RECORD_STATS(numDropped++; bytesDropped += msg->byteLength());
00559             delete msg;
00560             return;
00561         }
00562 
00563         // records stats if message is not a UDP "self message"
00564         if (overlayCtrlInfo->getLastHopAddr() != thisNode.ip ||
00565                 overlayCtrlInfo->getLastHopPort() != thisNode.port) {
00566             // is this from anywhere else?
00567             if (baseOverlayMsg->getSignaling() == false)
00568                 RECORD_STATS(numReceived++; bytesReceived +=
00569                                  baseOverlayMsg->byteLength());
00570             else
00571                 RECORD_STATS(numSignalingReceived++;bytesSignalingReceived
00572                              += baseOverlayMsg->byteLength());
00573         }
00574         if (overlayCtrlInfo->getLastHopAddr() != thisNode.ip) {
00575             // is this from a different node?
00576             RECORD_STATS(numInbound++; bytesInbound +=
00577                              baseOverlayMsg->byteLength());
00578         }
00579 
00580         handleBaseOverlayMessage(baseOverlayMsg);
00581     }
00582 
00583     // process CommonAPIMessages from App
00584     else if (dynamic_cast<CommonAPIMessage*>(msg) != NULL) {
00585         if (dynamic_cast<KBRroute*>(msg) != NULL) {
00586             KBRroute* apiMsg = static_cast<KBRroute*>(msg);
00587 
00588             route(apiMsg->getDestKey(), static_cast<CompType>(apiMsg->getDestComp()),
00589                   static_cast<CompType>(apiMsg->getSrcComp()), apiMsg->decapsulate(),
00590                           apiMsg->getHint());
00591         } else if (dynamic_cast<KBRforward*>(msg) != NULL) {
00592             KBRforward* apiMsg = static_cast<KBRforward*>(msg);
00593             OverlayCtrlInfo* overlayCtrlInfo =
00594                 check_and_cast<OverlayCtrlInfo*>
00595                 (msg->removeControlInfo());
00596 
00597             BaseAppDataMessage* dataMsg =
00598                 new BaseAppDataMessage();
00599             dataMsg->setType(APPDATA);
00600             dataMsg->setLength(BASEAPPDATA_L(dataMsg));
00601             dataMsg->setName(msg->encapsulatedMsg()->name());
00602             dataMsg->encapsulate(msg->decapsulate());
00603             dataMsg->setSrcComp(overlayCtrlInfo->getSrcComp());
00604             dataMsg->setDestComp(overlayCtrlInfo->getDestComp());
00605             dataMsg->setSignaling(false);
00606 
00607             BaseRouteMessage* routeMsg = new BaseRouteMessage(dataMsg->name());
00608             routeMsg->setType(OVERLAYROUTE);
00609             routeMsg->setLength(BASEROUTE_L(routeMsg));
00610             routeMsg->encapsulate(dataMsg);
00611 
00612             routeMsg->setSignaling(false);
00613             routeMsg->setDestKey(apiMsg->getDestKey());
00614             routeMsg->setSrcNode(overlayCtrlInfo->getSrcNode());
00615             routeMsg->setHopCount(overlayCtrlInfo->getHopCount());
00616             routeMsg->setControlInfo(overlayCtrlInfo);
00617 
00618             // message marked with this-pointer as already forwarded to tier1
00619             routeMsg->setContextPointer(this);
00620 
00621             sendToKey(apiMsg->getDestKey(), routeMsg, 1, apiMsg->getNextHopNode());
00622         }
00623 
00624         delete msg;
00625     }
00626 
00627     else if (dynamic_cast<BaseRpcMessage*>(msg) != NULL) {
00628         BaseRpcMessage* rpcMessage =
00629             static_cast<BaseRpcMessage*>(msg);
00630         internalHandleRpcMessage(rpcMessage);
00631     }
00632 
00633     // process other messages from App
00634     else if (msg->arrivedOn("from_app")) {
00635         handleAppMessage(msg);
00636 
00637     } else {
00638         opp_error("BaseOverlay::handleMessage(): Received msg with "
00639                   "unknown type!");
00640         delete msg;
00641     }
00642 }

void BaseOverlay::handleBaseOverlayMessage ( BaseOverlayMessage *  msg,
const OverlayKey destKey = OverlayKey::UNSPECIFIED_KEY 
) [private]

Handles a BaseOverlayMessage
.

Handles BaseOverlayMessages of type OVERLAYSIGNALING, RPC, APPDATA or OVERLAYROUTE.

Parameters:
msg The message to be handled
destKey the destination key of the message
00646 {
00647     switch (msg->getType()) {
00648     case OVERLAYSIGNALING:
00649         handleUDPMessage(msg);
00650         return;
00651 
00652     case RPC: {
00653         // process rpc-messages
00654         BaseRpcMessage* rpcMessage =
00655             check_and_cast<BaseRpcMessage*>(msg);
00656         internalHandleRpcMessage(rpcMessage);
00657         return;
00658     }
00659 
00660     case APPDATA: {
00661         BaseAppDataMessage* baseAppDataMsg =
00662             check_and_cast<BaseAppDataMessage*>(msg);
00663         callDeliver(baseAppDataMsg, destKey);
00664         return;
00665     }
00666 
00667     case OVERLAYROUTE: {
00668         BaseRouteMessage* baseRouteMsg =
00669             check_and_cast<BaseRouteMessage*>(msg);
00670 
00671         if (baseRouteMsg->getDestKey().isUnspecified())
00672             opp_error("BaseOverlay: No destination key in ROUTE msg");
00673 
00674 
00675         // if this node is malicious drop the message
00676         if (isMalicious()) {
00677             EV << "[BaseOverlay::handleBaseOverlayMessage() @ " << thisNode.ip
00678             << " (" << thisNode.key.toString(16) << ")]\n"
00679             << "    BaseRouteMessage gets dropped because this node is malicious"
00680             << endl;
00681             RECORD_STATS(numDropped++;
00682                          bytesDropped += baseRouteMsg->byteLength());
00683             delete msg;
00684             return;
00685         }
00686 
00687         // collect delay-value of completed hop
00688         if (collectPerHopDelay) {
00689             baseRouteMsg->setHopDelayArraySize(baseRouteMsg->
00690                                                getHopDelayArraySize() + 1);
00691             baseRouteMsg->setHopDelay(baseRouteMsg->getHopDelayArraySize() - 1,
00692                                       simTime() - baseRouteMsg->getHopStamp());
00693         }
00694 
00695         bool err;
00696         if (isSiblingFor(thisNode, baseRouteMsg->getDestKey(),
00697                          1, &err) /*&& !err*/) {
00698             OverlayCtrlInfo* overlayCtrlInfo =
00699                 check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00700 
00701             overlayCtrlInfo->setHopCount(baseRouteMsg->getHopCount());
00702             overlayCtrlInfo->setSrcNode(baseRouteMsg->getSrcNode());
00703 
00704             BaseOverlayMessage* tmpMsg
00705             = check_and_cast<BaseOverlayMessage*>
00706               (baseRouteMsg->decapsulate());
00707             tmpMsg->setControlInfo(overlayCtrlInfo);
00708 
00709             if (collectPerHopDelay) {
00710                 RECORD_STATS(
00711                     size_t i;
00712                     for (i = singleHopDelays.size();
00713                              i < baseRouteMsg->getHopDelayArraySize();) {
00714                         singleHopDelays.push_back(new HopDelayRecord[++i]);
00715                     }
00716                     i = baseRouteMsg->getHopDelayArraySize() - 1;
00717                     HopDelayRecord* hdr = singleHopDelays[i];
00718                     for (size_t j = 0; j <= i; ++j) {
00719                         hdr[j].count++;
00720                         hdr[j].val += baseRouteMsg->getHopDelay(j);
00721                     }
00722                 );
00723             }
00724             if (iterativeLookup ||
00725                 forwardMessageRecursive(thisNode, baseRouteMsg)) {
00726                 handleBaseOverlayMessage(tmpMsg, baseRouteMsg->getDestKey());
00727                 delete msg;
00728             }
00729             return;
00730         } else {
00731             // forward msg if this node is not responsible for the key
00732             sendToKey(baseRouteMsg->getDestKey(), baseRouteMsg, 1);
00733             return;
00734         }
00735         break;
00736     }
00737 
00738     default:
00739         EV << "[BaseOverlay::handleBaseOverlayMessage() @ " << thisNode.ip
00740         << " (" << thisNode.key.toString(16) << ")]\n"
00741         << "    Received unknown message from UDP of type " << msg->name()
00742         << endl;
00743         break;
00744     }
00745 }

void BaseOverlay::handleUDPMessage ( BaseOverlayMessage *  msg  )  [protected, virtual]

Processes messages from underlay.

Parameters:
msg Message from UDP

Reimplemented in Broose, Chord, Gia, Kademlia, Koorde, Pastry, and Vast.

00791 {
00792     delete msg;
00793 }

void BaseOverlay::handleTimerEvent ( cMessage *  msg  )  [protected, virtual]

Processes "timer" self-messages.

Parameters:
msg A self-message

Reimplemented in Broose, Chord, Gia, Kademlia, Koorde, Pastry, and Vast.

00780 {
00781     // timer...
00782 }

void BaseOverlay::handleAppMessage ( cMessage *  msg  )  [protected, virtual]

Processes non-commonAPI messages.

Parameters:
msg non-commonAPIMessage

Reimplemented in Gia, and Vast.

00786 {
00787     delete msg;
00788 }

void BaseOverlay::receiveChangeNotification ( int  category,
cPolymorphic *  details 
) [protected, virtual]

callback-method for events at the NotificationBoard

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

Reimplemented in Vast.

00748 {
00749     Enter_Method_Silent();
00750     if (category == NF_OVERLAY_TRANSPORTADDRESS_CHANGED) {
00751         handleTransportAddressChangedNotification();
00752     } else if (category == NF_OVERLAY_NODE_LEAVE) {
00753         handleNodeLeaveNotification();
00754     } else if (category == NF_OVERLAY_NODE_GRACEFUL_LEAVE) {
00755         handleNodeGracefulLeaveNotification();
00756     }
00757 }

void BaseOverlay::handleTransportAddressChangedNotification (  )  [protected, virtual]

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

00760 {
00761     // get new ip address
00762     thisNode.ip = IPAddressResolver().addressOf(
00763                       parentModule()->parentModule()).get4();
00764 
00765     joinOverlay();
00766 }

void BaseOverlay::handleNodeLeaveNotification (  )  [protected, virtual]

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

00769 {
00770     // ...
00771 }

void BaseOverlay::handleNodeGracefulLeaveNotification (  )  [protected, virtual]

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

00774 {
00775     // ...
00776 }

void BaseOverlay::recordOverlaySentStats ( BaseOverlayMessage *  msg  )  [protected, virtual]

Collect overlay specific sent messages statistics.

This method is called from BaseOverlay::sendMessageToUDP() for every overlay message that is sent by a node. Use this to collect statistical data for overlay protocol specific message types.

Parameters:
msg The overlay message to be sent to the UDP layer

Reimplemented in Broose, Chord, and Koorde.

00797 {
00798     // collect statistics ...
00799 }

void BaseOverlay::setOverlayReady ( bool  ready  )  [protected]

Sets the overlay ready icon and register/deregisters the node at the BootstrapOracle.

Parameters:
ready true if the overlay changed to ready state (joined successfully)
00802 {
00803     displayString().setTagArg("i", 1, ready ? "" : "red");
00804     bootstrapOracle->setOverlayReadyIcon(getThisNode(), ready);
00805 
00806     if (ready) {
00807         registerBootstrapNode(thisNode);
00808     } else {
00809         removeBootstrapNode(thisNode);
00810     }
00811 
00812     TierReadyMessage* msg = new TierReadyMessage;
00813     msg->setReady(ready);
00814     send( msg, "to_app");
00815 }

void BaseOverlay::sendRouteMessage ( const TransportAddress dest,
BaseRouteMessage *  msg,
bool  ack 
) [private]

00824 {
00825     if (msg && !iterativeLookup && (dest != thisNode)) {
00826         msg->setHopCount(msg->getHopCount() + 1);
00827     }
00828     if (!ack)
00829         sendMessageToUDP(dest, msg);
00830     else {
00831         NextHopCall* nextHopCall = new NextHopCall(msg->name());
00832         nextHopCall->setLength(NEXTHOPCALL_L(nextHopCall));
00833         nextHopCall->encapsulate(msg);
00834         sendUdpRpcCall(dest, nextHopCall);
00835     }
00836 }

void BaseOverlay::sendMessageToUDP ( const TransportAddress dest,
BaseOverlayMessage *  msg 
)

Sends message to underlay.

Parameters:
dest destination node
msg message to send
00839 {
00840     // if there's still a control info attached to the message, remove it
00841     cPolymorphic* ctrlInfo = msg->removeControlInfo();
00842     if (ctrlInfo != NULL)
00843         delete ctrlInfo;
00844 
00845     // debug message
00846     if (debugOutput) {
00847         EV << "[BaseOverlay::sendMessageToUDP() @ " << thisNode.ip
00848         << " (" << thisNode.key.toString(16) << ")]\n"
00849         << "    Sending" << msg->name() << " to " << dest.ip
00850         << endl;
00851     }
00852 
00853     msg->setKind(UDP_C_DATA);
00854     UDPControlInfo* udpControlInfo = new UDPControlInfo();
00855     udpControlInfo->setSrcAddr(thisNode.ip);
00856     udpControlInfo->setSrcPort(thisNode.port);
00857     udpControlInfo->setDestAddr(dest.ip);
00858     udpControlInfo->setDestPort(dest.port);
00859     msg->setControlInfo(udpControlInfo);
00860 
00861     send(msg, "to_udp");
00862 
00863     if (dest != thisNode) {
00864         // record statistics, if message is not local
00865         if (dest.ip != thisNode.ip) {
00866             RECORD_STATS(numOutbound++; bytesOutbound += msg->byteLength());
00867         }
00868         if (msg->getSignaling() == false) {
00869             RECORD_STATS(numSent++; bytesSent += msg->byteLength());
00870         } else {
00871             RECORD_STATS(numSignalingSent++; bytesSignalingSent +=
00872                              msg->byteLength());
00873         }
00874         recordOverlaySentStats(msg);
00875     }
00876 }

void BaseOverlay::pingKey ( const OverlayKey destKey,
simtime_t  timeout = -1,
int  retries = 0,
const char *  caption = NULL,
RpcListener rpcListener = NULL,
int  rpcId = -1 
)

ping a node by its OverlayKey

Statistics are collected by this method.

Parameters:
destKey key of the node to ping
timeout RPC timeout
retries how often to retry after timeout
caption special name for the ping call (instead of "PING")
rpcListener RPC Listener
rpcId RPC id
00887 {
00888     PingCall* call = createPingCall(caption);
00889     RECORD_STATS(numPingSent++; bytesPingSent += call->byteLength());
00890     sendRouteRpcCall(OVERLAY_COMP, destKey, call,
00891                      timeout, retries, rpcId, rpcListener);
00892 }

void BaseOverlay::initLookups (  )  [private]

creates a LookupSet

00902 {
00903     lookups = LookupSet();
00904 }

void BaseOverlay::finishLookups (  )  [private]

deletes entries in lookups

00907 {
00908     while (lookups.size() > 0) {
00909         (*lookups.begin())->abortLookup();
00910     }
00911     lookups.clear();
00912 }

bool BaseOverlay::forwardMessageRecursive ( const TransportAddress dest,
BaseRouteMessage *  msg 
) [private, virtual]

Hook for forwarded message in recursive lookup mode.

This hook is called just before a message is forwarded to a next hop or if the message is at its destination just before it is sent to the app. Default implementation just returns true. This hook can for example be used to detect failed nodes and call handleFailedNode() before the actual forwarding takes place.

Parameters:
dest destination node
msg message 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 Kademlia, and Pastry.

01036 {
01037     return true;
01038 }

void BaseOverlay::sendToKey ( const OverlayKey key,
BaseOverlayMessage *  message,
int  numSiblings = 1,
const TransportAddress nextHop = TransportAddress::UNSPECIFIED_NODE 
)

Sends a message to an overlay node, with the generic routing algorithm.

Parameters:
key The destination key
message Message to be sent
numSiblings number of siblings to send message to (numSiblings > 1 means multicast)
nextHop If nextHop is given, the message gets sent to this node before it is routed (nextHop is used as a proxy)
01042 {
01043     BaseRouteMessage* routeMsg = NULL;
01044 
01045     if (debugOutput) {
01046         EV << "[BaseOverlay::sendToKey() @ " << thisNode.ip
01047         << " (" << thisNode.key.toString(16) << ")]\n"
01048         << "    Sending " << msg <<  " to " << key
01049         << endl;
01050     }
01051 
01052     if (key.isUnspecified())
01053         error("BaseOverlay::sendToKey(): unspecified destination key!");
01054 
01055     if (msg->getType() != OVERLAYROUTE) {
01056         routeMsg = new BaseRouteMessage("BaseRouteMessage");
01057         routeMsg->setType(OVERLAYROUTE);
01058         routeMsg->setDestKey(key);
01059         routeMsg->setSrcNode(thisNode);
01060         routeMsg->setSignaling(msg->getSignaling());
01061         // copy the name of the inner message
01062         routeMsg->setName(msg->name());
01063         routeMsg->setLength(BASEROUTE_L(routeMsg));
01064         routeMsg->encapsulate(msg);
01065 
01066         OverlayCtrlInfo* routeCtrlInfo = new OverlayCtrlInfo;
01067         routeCtrlInfo->setLastHopAddr(thisNode.ip);
01068         routeCtrlInfo->setLastHopPort(thisNode.port);
01069         routeCtrlInfo->setTransportType(ROUTE_TRANSPORT);
01070         routeMsg->setControlInfo(routeCtrlInfo);
01071 
01072         //message marked as not already forwarded to tier1
01073         routeMsg->setContextPointer(NULL);
01074     } else {
01075         routeMsg = check_and_cast<BaseRouteMessage*>(msg);
01076     }
01077 
01078     /* // only used as workaround - uncomment if assert fails!
01079     if (!routeMsg->controlInfo()) {
01080         // workaround
01081         OverlayCtrlInfo* routeCtrlInfo = new OverlayCtrlInfo;
01082         routeCtrlInfo->setLastHopAddr(thisNode.ip);
01083         routeCtrlInfo->setLastHopPort(thisNode.port);
01084         routeCtrlInfo->setTransportType(ROUTE_TRANSPORT);
01085         routeMsg->setControlInfo(routeCtrlInfo);
01086     }
01087     */
01088 
01089     // set timestamp for next hop
01090     if (collectPerHopDelay) {
01091         routeMsg->setHopStamp(simTime());
01092     }
01093 
01094     if (!nextHop.isUnspecified()) {
01095         // send msg to nextHop if specified (used for join rpcs)
01096         if (iterativeLookup && (nextHop != thisNode)) {
01097             routeMsg->setHopCount(routeMsg->getHopCount() + 1);
01098         }
01099         assert(routeMsg->controlInfo());
01100         sendRouteMessage(nextHop, routeMsg, useNextHopRpc);
01101         return;
01102     }
01103 
01104     if (iterativeLookup) {
01105         // create lookup and sent to key
01106         AbstractLookup* lookup = createLookup(routeMsg);
01107         lookup->lookup( routeMsg->getDestKey(), numSiblings, hopCountMax,
01108                         0, new SendToKeyListener( this, routeMsg ));
01109     } else  {
01110         NodeVector* nextHops = findNode(routeMsg->getDestKey(),
01111                 getMaxNumRedundantNodes(), numSiblings, routeMsg);
01112 
01113         if (nextHops->size() == 0) {
01114             EV << "[BaseOverlay::sendToKey() @ " << thisNode.ip
01115                << " (" << thisNode.key.toString(16) << ")]\n"
01116                << "    FindNode() returned NULL - dropping message"
01117                << endl;
01118             // statistics
01119             RECORD_STATS(numDropped++; bytesDropped += routeMsg->byteLength());
01120             delete routeMsg;
01121         } else {
01122             // delete message if the hop count maximum is exceeded
01123             if (routeMsg->getHopCount() >= hopCountMax) {
01124 
01125                 EV << "[BaseOverlay::sendToKey() @ " << thisNode.ip
01126                    << " (" << thisNode.key.toString(16) << ")]\n"
01127                    << "    Discards " << routeMsg->name() << " from "
01128                    << routeMsg->getSrcNode().ip << "\n"
01129                    << "    The hop count maximum has been exceeded ("
01130                    << routeMsg->getHopCount() << ">="
01131                    << hopCountMax << ")"
01132                    << endl;
01133                 // statistics
01134                 RECORD_STATS(numDropped++;
01135                              bytesDropped += routeMsg->byteLength());
01136                 delete routeMsg;
01137                 delete nextHops;
01138                 return;
01139             }
01140 
01141             // callForward to app
01142             if (useCommonAPIforward &&
01143                 dynamic_cast<BaseAppDataMessage*>(
01144                         routeMsg->encapsulatedMsg()) &&
01145                 routeMsg->contextPointer() == NULL) {
01146                 callForward(routeMsg->getDestKey(), routeMsg, (*nextHops)[0]);
01147                 delete nextHops;
01148                 return;
01149             }
01150 
01151             //message marked as not already forwarded
01152             routeMsg->setContextPointer(NULL);
01153 
01154             NodeHandle* nextHop = &((*nextHops)[0]);
01155             if (*nextHop == thisNode) {
01156                 bool isSibling, err;
01157                 isSibling = isSiblingFor(thisNode,routeMsg->getDestKey(),
01158                         numSiblings, &err);
01159                 if (isSibling && !err) {
01160                     //EV << "[BaseOverlay::sendToKey() @ " << thisNode.ip
01161                     //   << " (" << thisNode.key.toString(16) << ")]\n"
01162                     //   << "    Forwards msg for key " << routeMsg->getDestKey() "\n"
01163                     //   << "    to node " << (*nextHops)[0]
01164                     //   << endl;
01165                     delete nextHops;
01166                     assert(routeMsg->controlInfo());
01167                     handleBaseOverlayMessage(routeMsg, key);
01168                     return;
01169                 } else if (!isSibling && err) {
01170                     if(nextHops->size() > 1) {
01171                         nextHop = &((*nextHops)[1]);
01172                     } else {
01173                         EV << "[BaseOverlay::sendToKey() @ " << thisNode.ip
01174                            << " (" << thisNode.key.toString(16) << ")]\n"
01175                            << "    ERROR forwarding message " << *routeMsg
01176                            << "\n    from " << routeMsg->getSrcNode()
01177                            << " to " << routeMsg->getDestKey()
01178                            << "\n    (nextHops->size() = " << nextHops->size()
01179                            << ")" << endl;
01180                         RECORD_STATS(numDropped++; bytesDropped +=
01181                             routeMsg->byteLength());
01182                         delete routeMsg;
01183                         delete nextHops;
01184                         return;
01185                     }
01186                 } else if (!isSibling && !err) {
01187                     error("nextHop = thisNode but isSiblingsFor() is false!");
01188                 } else {
01189                     error("isSiblingsFor() is true with an error: "
01190                           "Erroneous method isSiblingFor()!");
01191                 }
01192             }
01193             // forward msg if this node is not responsible for the key
01194             OverlayCtrlInfo* overlayCtrlInfo =
01195                     dynamic_cast<OverlayCtrlInfo*>(msg->controlInfo());
01196 
01197             // records statistics, if we forward this message
01198             if ((overlayCtrlInfo != NULL) && (overlayCtrlInfo->getLastHopAddr()
01199                     != thisNode.ip)) {
01200                 if (routeMsg->getSignaling() == false) {
01201                     RECORD_STATS(numForwarded++; bytesForwarded +=
01202                             routeMsg->byteLength());
01203                 } else {
01204                     RECORD_STATS(numSignalingForwarded++;
01205                             bytesSignalingForwarded +=
01206                             routeMsg->byteLength());
01207                 }
01208             }
01209 
01210             if (forwardMessageRecursive(*nextHop, routeMsg)) {
01211                 delete routeMsg->removeControlInfo();
01212                 sendRouteMessage(*nextHop, routeMsg, useNextHopRpc);
01213             }
01214         }
01215         delete nextHops;
01216     }
01217 }

AbstractLookup * BaseOverlay::createLookup ( const BaseOverlayMessage *  msg = NULL,
const cObject *  findNodeExt = NULL 
) [protected, virtual]

Creates an abstract iterative lookup instance.

Parameters:
msg pointer to the message for which the lookup is created. Derived classes can use it to construct an object with additional info for the lookup class.
findNodeExt object that will be sent with the findNodeCalls
Returns:
AbstractLookup* The new lookup instance.
01222 {
01223     //Enter_Method_Silent();
01224 
01225     AbstractLookup* newLookup;
01226     iterativeLookup ?
01227         (newLookup = new BaseLookup(this, baseLookupConfig, findNodeExt)) :
01228         (newLookup = new RecursiveLookup(this));
01229 
01230     lookups.insert( newLookup );
01231     return newLookup;
01232 }

void BaseOverlay::removeLookup ( AbstractLookup lookup  )  [protected, virtual]

Removes the abstract lookup instance.

Parameters:
lookup the Lookup to remove
01235 {
01236     lookups.erase(lookup);
01237 }

OverlayKey BaseOverlay::distance ( const OverlayKey x,
const OverlayKey y 
) const [protected, 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:
x Left-hand-side Key
y Right-hand-side key
Returns:
OverlayKey Distance between x and y

Reimplemented in Kademlia.

01242 {
01243     opp_error("BaseOverlay::distance(): Not implemented!");
01244     return OverlayKey::UNSPECIFIED_KEY;
01245 }

NodeVector * BaseOverlay::findNode ( const OverlayKey key,
int  numRedundantNodes,
int  numSiblings,
BaseOverlayMessage *  msg = NULL 
) [protected, virtual]

Implements the find node call.

This method simply returns the closest nodes known in the corresponding routing topology. If the node is a sibling for this key (isSiblingFor(key) = true), this method returns all numSiblings siblings, with the closest neighbor to the key first.

Parameters:
key The lookup key.
numRedundantNodes Maximum number of next hop nodes to return.
numSiblings number of siblings to return
msg A pointer to the BaseRouteMessage or FindNodeCall message of this lookup.
Returns:
NodeVector with closest nodes.

Reimplemented in Broose, Chord, Kademlia, Koorde, and Pastry.

01252 {
01253     opp_error( "findNode: Not implemented!" );
01254     return NULL;
01255 }

void BaseOverlay::joinOverlay (  )  [protected, virtual]

Join the overlay with a given nodeID in thisNode.key.

Join the overlay with a given nodeID in thisNode.key. This method may be called by an application to join the overlay with a specific nodeID. It is also called if the node's IP address changes.

Reimplemented in Broose, Chord, Gia, Kademlia, and Pastry.

01259 {
01260 //  std::cout << "BaseOverlay::joinOverlay(): Not implemented!" << endl;
01261     return;
01262 }

bool BaseOverlay::handleFailedNode ( const TransportAddress failed  )  [protected, virtual]

Handles a failed node.

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

Parameters:
failed the failed node
Returns:
true if lookup should retry here

Reimplemented in Pastry.

01265 {
01266     return false;
01267 }

void BaseOverlay::lookupRpc ( LookupCall *  call  )  [protected, virtual]

01440 {
01441     // create lookup and sent to key
01442     AbstractLookup* lookup = createLookup(call);
01443     lookup->lookup(call->getKey(), call->getNumSiblings(), hopCountMax,
01444                    1, new SendToKeyListener( this, call ));
01445 
01446 }

void BaseOverlay::nextHopRpc ( NextHopCall *  call  )  [protected, virtual]

01449 {
01450     BaseRouteMessage* routeMsg
01451         = check_and_cast<BaseRouteMessage*>(call->decapsulate());
01452 
01453     OverlayCtrlInfo* overlayCtrlInfo =
01454         check_and_cast<OverlayCtrlInfo*>(call->controlInfo()->dup());
01455     overlayCtrlInfo->setHopCount(routeMsg->getHopCount());
01456     overlayCtrlInfo->setSrcNode(routeMsg->getSrcNode());
01457 
01458     /*
01459     std::cout << overlayCtrlInfo->getHopCount() << "\n"
01460               << overlayCtrlInfo->getLastHopAddr() << "\n"
01461               << overlayCtrlInfo->getLastHopPort() << "\n"
01462               << overlayCtrlInfo->getSrcNode() << "\n"
01463               << overlayCtrlInfo->getSrcComp() << "\n"
01464               << overlayCtrlInfo->getDestComp() << "\n" << std::endl;
01465     */
01466 
01467     routeMsg->setControlInfo(overlayCtrlInfo);
01468     assert(routeMsg->controlInfo());
01469 
01470     std::string temp("ACK: [");
01471     (temp += routeMsg->name()) += "]";
01472 
01473     NextHopResponse* response
01474         = new NextHopResponse(temp.c_str());
01475     response->setLength(NEXTHOPRESPONSE_L(response));
01476     sendRpcResponse(call, response);
01477 
01478     handleBaseOverlayMessage(routeMsg, routeMsg->getDestKey());
01479 }

void BaseOverlay::countFindNodeCall ( const FindNodeCall *  call  )  [protected]

01360 {
01361     RECORD_STATS(numFindNodeSent++;
01362                  bytesFindNodeSent += call->byteLength());
01363 }

void BaseOverlay::countFailedNodeCall ( const FailedNodeCall *  call  )  [protected]

01366 {
01367     RECORD_STATS(numFailedNodeSent++;
01368                  bytesFailedNodeSent += call->byteLength());
01369 }

void BaseOverlay::sendRpcMessageWithTransport ( TransportType  transportType,
CompType  destComp,
const TransportAddress dest,
const OverlayKey destKey,
BaseRpcMessage *  message 
) [protected, virtual]

Implements BaseRpc.

01278 {
01279     switch (transportType) {
01280     case UDP_TRANSPORT:
01281         sendMessageToUDP( dest, message );
01282         break;
01283     case ROUTE_TRANSPORT:
01284         sendToKey( destKey, message, 1, dest );
01285         break;
01286     case INTERNAL_TRANSPORT: {
01287         cGate *destCompGate = getCompRpcGate(destComp);
01288         if (destCompGate == NULL) {
01289             opp_error("BaseOverlay::sendRpcMessageWithTransport():"
01290                       " INTERNAL_RPC to unknown RpcCompType!");
01291         }
01292         OverlayCtrlInfo *overlayCtrlInfo = new OverlayCtrlInfo();
01293         overlayCtrlInfo->setSrcComp(getThisCompType());
01294         overlayCtrlInfo->setDestComp(destComp);
01295         overlayCtrlInfo->setTransportType(INTERNAL_TRANSPORT);
01296         message->setControlInfo(overlayCtrlInfo);
01297         sendDirect( message, 0, destCompGate);
01298         break;
01299     }
01300     default:
01301         opp_error("BaseOverlay::sendRpcMessageWithTransport: "
01302                   "invalid transportType!");
01303         break;
01304     }
01305 }

bool BaseOverlay::internalHandleRpc ( BaseCallMessage *  msg  )  [protected, virtual]

Handles internal rpc requests.


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

Parameters:
msg The call message
Returns:
bool true, if call has been handled.

Reimplemented from BaseRpc.

01309 {
01310     // call rpc stubs
01311     RPC_SWITCH_START( msg );
01312     RPC_DELEGATE( FindNode, findNodeRpc );
01313     RPC_DELEGATE( FailedNode, failedNodeRpc );
01314     RPC_DELEGATE( Lookup, lookupRpc );
01315     RPC_DELEGATE( NextHop, nextHopRpc );
01316     RPC_SWITCH_END( );
01317 
01318     // if RPC was handled return true, else tell the parent class to handle it
01319     return RPC_HANDLED || BaseRpc::internalHandleRpc(msg);
01320 }

bool BaseOverlay::internalHandleRpcResponse ( BaseResponseMessage *  msg,
int  rpcId,
simtime_t  rtt 
) [protected, virtual]

Handles rpc responses internal in base classes
.

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

Parameters:
msg The call message
rpcId The ID of the call
rtt the time between sending the call and receiving the response
Returns:
bool true, if call has been handled.

Reimplemented from BaseRpc.

01324 {
01325     // if RPC was handled return true, else tell the parent class to handle it
01326     return BaseRpc::internalHandleRpcResponse(msg, rpcId, rtt);
01327 }

void BaseOverlay::internalHandleRpcTimeout ( BaseCallMessage *  msg,
const TransportAddress dest,
int  rpcId,
const OverlayKey destKey 
) [protected, virtual]

Handles rpc timeouts internal in base classes
.

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

Parameters:
msg The call message
dest The node that did not response
rpcId The ID of the call
destKey The key of the call if used
Returns:
bool true, if call has been handled.
Todo:
return bool?

Reimplemented from BaseRpc.

01332 {
01333     BaseRpc::internalHandleRpcTimeout(msg, dest, rpcId, destKey);
01334 
01335     RPC_SWITCH_START( msg )
01336         RPC_ON_CALL( NextHop )
01337         {
01338             //TODO neighborFailed(dest);
01339             BaseRouteMessage* tempMsg
01340                 = check_and_cast<BaseRouteMessage*>(msg->decapsulate());
01341 
01342             if (!tempMsg->controlInfo()) {
01343                 OverlayCtrlInfo* overlayCtrlInfo = new OverlayCtrlInfo;
01344                 overlayCtrlInfo->setLastHopAddr(thisNode.ip);
01345                 overlayCtrlInfo->setLastHopPort(thisNode.port);
01346                 overlayCtrlInfo->setHopCount(tempMsg->getHopCount());
01347                 overlayCtrlInfo->setSrcNode(tempMsg->getSrcNode());
01348                 overlayCtrlInfo->setTransportType(UDP_TRANSPORT);
01349                 tempMsg->setControlInfo(overlayCtrlInfo);
01350             }
01351 
01352             handleBaseOverlayMessage(tempMsg, destKey);
01353             break;
01354         }
01355     RPC_SWITCH_END( )
01356 }

CompType BaseOverlay::getThisCompType (  )  [protected, virtual]

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.

00308 {
00309     return OVERLAY_COMP;
00310 }

void BaseOverlay::insertBootstrapNode ( const NodeHandle node  ) 

01481 {
01482     Enter_Method_Silent();
01483 
01484     EV << "New bootstrap node " << node << endl;
01485 }

void BaseOverlay::registerComp ( CompType  compType,
cModule *  module 
)

01489 {
01490     cGate *gate = NULL;
01491 
01492     if (module != NULL)
01493         gate = module->gate("direct_in");
01494 
01495     compModuleList[compType] = make_pair<cModule*, cGate*>(module, gate);
01496 }

cModule * BaseOverlay::getCompModule ( CompType  compType  ) 

01499 {
01500     CompModuleList::iterator it = compModuleList.find(compType);
01501 
01502     if (it != compModuleList.end())
01503         return it->second.first;
01504     else
01505         return NULL;
01506 }

cGate * BaseOverlay::getCompRpcGate ( CompType  compType  ) 

01509 {
01510     CompModuleList::iterator it = compModuleList.find(compType);
01511 
01512     if (it != compModuleList.end())
01513         return it->second.second;
01514     else
01515         return NULL;
01516 }

void BaseOverlay::findNodeRpc ( FindNodeCall *  call  )  [private]

01373 {
01374     // if this node is malicious don't answer a findNodeCall
01375     if (isMalicious()) {
01376         EV << "[BaseOverlay::findNodeRpc() @ " << thisNode.ip
01377         << " (" << thisNode.key.toString(16) << ")]\n"
01378         << "    Node ignores findNodeCall because this node is malicious"
01379         << endl;
01380         delete call;
01381         return;
01382     }
01383 
01384     FindNodeResponse* findNodeResponse =
01385         new FindNodeResponse("FindNodeResponse");
01386 
01387     NodeVector* nextHops = findNode(call->getLookupKey(),
01388                                     call->getNumRedundantNodes(),
01389                                     call->getNumSiblings(), call);
01390 
01391     findNodeResponse->setClosestNodesArraySize(nextHops->size());
01392 
01393     for (uint i=0; i < nextHops->size(); i++) {
01394         findNodeResponse->setClosestNodes(i, (*nextHops)[i]);
01395     }
01396 
01397     bool err;
01398     if (isSiblingFor(thisNode, call->getLookupKey(), call->getNumSiblings(),
01399                      &err)) {
01400         findNodeResponse->setSiblings(true);
01401     }
01402 
01403     findNodeResponse->setLength(FINDNODERESPONSE_L(findNodeResponse));
01404 
01405     if (call->hasObject("findNodeExt")) {
01406         cMessage* findNodeExt = (cMessage*)call->removeObject("findNodeExt");
01407         findNodeResponse->addObject(findNodeExt);
01408         findNodeResponse->addLength(findNodeExt->length());
01409     }
01410 
01411     RECORD_STATS(numFindNodeResponseSent++; bytesFindNodeResponseSent +=
01412                      findNodeResponse->byteLength());
01413 
01414     delete nextHops;
01415 
01416     sendRpcResponse(call, findNodeResponse);
01417 }

void BaseOverlay::failedNodeRpc ( FailedNodeCall *  call  )  [private]

01420 {
01421     FailedNodeResponse* failedNodeResponse =
01422         new FailedNodeResponse("FailedNodeResponse");
01423     failedNodeResponse->setTryAgain(handleFailedNode(call->getFailedNode()));
01424     failedNodeResponse->setLength(FAILEDNODERESPONSE_L(failedNodeResponse));
01425 
01426     if (call->hasObject("findNodeExt")) {
01427         cMessage* findNodeExt = check_and_cast<cMessage*>(
01428                                     call->removeObject("findNodeExt"));
01429         failedNodeResponse->addObject(findNodeExt);
01430         failedNodeResponse->addLength(findNodeExt->length());
01431     }
01432 
01433     RECORD_STATS(numFailedNodeResponseSent++; bytesFailedNodeResponseSent +=
01434                      failedNodeResponse->byteLength());
01435 
01436     sendRpcResponse(call, failedNodeResponse);
01437 }


Friends And Related Function Documentation

friend class BaseLookup [friend]

friend class RecursiveLookup [friend]

friend class BasePathLookup [friend]

friend class BootstrapList [friend]

friend class SendToKeyListener [friend]


Member Data Documentation

int BaseOverlay::numSent [private]

int BaseOverlay::bytesSent [private]

int BaseOverlay::numSignalingSent [private]

int BaseOverlay::bytesSignalingSent [private]

int BaseOverlay::numReceived [private]

int BaseOverlay::bytesReceived [private]

int BaseOverlay::numSignalingReceived [private]

int BaseOverlay::bytesSignalingReceived [private]

int BaseOverlay::numOutbound [private]

int BaseOverlay::bytesOutbound [private]

int BaseOverlay::numInbound [private]

int BaseOverlay::bytesInbound [private]

int BaseOverlay::numForwarded [protected]

int BaseOverlay::bytesForwarded [protected]

int BaseOverlay::numSignalingForwarded [protected]

int BaseOverlay::bytesSignalingForwarded [protected]

int BaseOverlay::numFindNodeSent [protected]

int BaseOverlay::bytesFindNodeSent [protected]

int BaseOverlay::numFindNodeResponseSent [protected]

int BaseOverlay::bytesFindNodeResponseSent [protected]

int BaseOverlay::numFailedNodeSent [protected]

int BaseOverlay::bytesFailedNodeSent [protected]

int BaseOverlay::numFailedNodeResponseSent [protected]

int BaseOverlay::bytesFailedNodeResponseSent [protected]

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

simtime_t BaseOverlay::creationTime [protected]

BootstrapOracle* BaseOverlay::bootstrapOracle [protected]

pointer to BootstrapOracle in this node

Reimplemented from TopologyVis.

NotificationBoard* BaseOverlay::notificationBoard [protected]

pointer to NotificationBoard in this node

UnderlayConfigurator* BaseOverlay::underlayConfigurator [protected]

pointer to UnderlayConfigurator in this node

bool BaseOverlay::debugOutput [protected]

debug output ?

Reimplemented from BaseRpc.

bool BaseOverlay::measureNetwInitPhase [protected]

fetch statistics in init phase ?

bool BaseOverlay::iterativeLookup [protected]

do iterative instead of recursive lookups

bool BaseOverlay::useCommonAPIforward [protected]

forward messages to applications?

bool BaseOverlay::collectPerHopDelay [protected]

collect delay for single hops

bool BaseOverlay::useNextHopRpc [protected]

send ACK when receiving route message

bool BaseOverlay::drawOverlayTopology [protected]

int BaseOverlay::localPort [protected]

used UDP-port

int BaseOverlay::hopCountMax [protected]

maximum hop count

int BaseOverlay::numDropped [protected]

number of dropped packets

int BaseOverlay::bytesDropped [protected]

number of dropped bytes

cOutVector BaseOverlay::delayVector [protected]

statistical output vector for packet-delays

cOutVector BaseOverlay::hopCountVector [protected]

statistical output vector for hop-counts

States BaseOverlay::state [protected]

BaseLookupConfiguration BaseOverlay::baseLookupConfig [protected]

LookupSet BaseOverlay::lookups [protected]

CompModuleList BaseOverlay::compModuleList [private]


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:28 2008 for ITM OverSim by  doxygen 1.5.3