BaseOverlay Class Reference

#include <BaseOverlay.h>

Inheritance diagram for BaseOverlay:

RpcListener Chord Gia Kademlia Vast 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. A minimal overlay has to implement numInitStages(), route(), handleUDPMessage() and receiveChangeNotification(). Derived classes must use BaseOverlayMessage as base class for own message types.

Author:
Bernhard Heep (initial)

Sebastian Mies (rpc, lookup)


Public Member Functions

virtual ~BaseOverlay ()
 Virtual destructor.
virtual void setMalicious (bool malicious)
 Sets node to a malicious state.
bool isMalicious ()
 Returns true, if node is malicious.
NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
void sendMessageToUDP (const NodeHandle &dest, BaseOverlayMessage *msg)
 Sends message to underlay.
uint32_t sendRpcMessage (const NodeHandle &dest, BaseCallMessage *msg, RpcListener *rpcListener=NULL, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY, int rpcId=-1, simtime_t timeout=-1, int retries=0)
 Sends a Remote-Procedure-Call message to the underlay.
void cancelRpcMessage (uint32_t nonce)
 Cancels a Remote-Procedure-Call.
void sendToKey (const OverlayKey &key, BaseOverlayMessage *message, uint numNeighbors=0, const NodeHandle &nextHop=NodeHandle::UNSPECIFIED_NODE)
 Sends a message to a overlay node, with the generic routing algorithm.

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
virtual void route (const OverlayKey &key, cMessage *msg, const NodeHandle &hint=NodeHandle::UNSPECIFIED_NODE)
 Routes message through overlay.
virtual bool isResponsible (const OverlayKey &key)
 Query if the node knowns the k-neighborhood for a key.
void callDeliver (BaseOverlayMessage *msg)
 Calls deliver function in application.
void callForward (OverlayKey &key, BaseRouteMessage *msg, NodeHandle *hint=NULL)
 Calls forward function in application.
virtual void handleUDPMessage (BaseOverlayMessage *msg)=0
 Processes messages from underlay.
virtual void handleTimerEvent (cMessage *msg)
 Processes "timer" self-messages.
virtual void handleAppMessage (cMessage *msg)
 Processes non-commonAPI messages.
virtual void recordOverlaySentStats (BaseOverlayMessage *msg)
 Collect overlay specific sent messages statistics.
void setReadyIcon (bool ready)
 Colors module-icon blue (ready) or red (not ready).
void showOverlayNeighborArrow (const NodeHandle &neighbor, bool flush=true, char *displayString=NULL)
 Draws an arrow from this node to neighbor.
void deleteOverlayNeighborArrow (const NodeHandle &neighbor)
 Removes an arrow from this node to neighbor.
void sendRpcResponse (BaseCallMessage *call, BaseResponseMessage *response)
 Send Remote-Procedure response message and deletes call message.
virtual void handleRpc (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invokation messages.
virtual AbstractLookupcreateLookup ()
 Creates a 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, BaseOverlayMessage *msg=NULL)
 Implements the find node call.
virtual PingResponse * ping (PingCall *call)
 Implements a ping call.

Protected Attributes

int numForwarded
 number of forwarded packets
int bytesForwarded
 number of forwarded bytes at out-gate
int numSignalingForwarded
 number of forwarded signaling packets
int bytesSignalingForwarded
 number of forwarded signaling bytes at out-gate
int numFindNodeSent
int bytesFindNodeSent
cModule * thisTerminal
 pointer to corresponding node
NodeHandle thisNode
 NodeHandle to this node.
BootstrapOraclebootstrapOracle
 pointer to BootstrapOracle in this node
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module 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 onlyCommonAPIMessages
 drop non-commonAPIMessages ?
bool useBaseLookup
 use the base lookup class
bool iterativeLookup
 do iterative instead of recursive lookups
int localPort
 used UDP-port
int hopCountMax
 maximum hop count
int numDropped
 number of dropped packets
int bytesDropped
 number of dropped bytes
bool malicious
 true, if node is malicious
cOutVector delayVector
 statistical output vector for packet-delays
cOutVector hopCountVector
 statistical output vector for hop-counts
BaseLookupConfiguration baseLookupConfig
LookupSet lookups

Private Types

typedef hash_map< int, RpcStateRpcStates
 IN
 OUT
enum  Direction { IN, OUT }

Private Member Functions

void initialize (int stage)
 initializes base-class-attributes
void finish ()
 collects statistical data
void handleMessage (cMessage *msg)
 Checks for message type and calls corresponding method.
void handleBaseOverlayMessage (BaseOverlayMessage *msg)
 Handles a BaseOverlayMessage
.
void compactGateArray (cModule *terminal, enum Direction dir)
 compacts arrow gate-array
void internalHandleRpcMessage (BaseRpcMessage *msg)
 Handles incoming rpc messages and delegates them to the corresponsing listeners or handlers.
bool internalHandleRpc (BaseCallMessage *msg)
 Handles internal rpc requests.
void initRpcs ()
 Initializes Remote-Procedure state.
void finishRpcs ()
 Deinitializes Remote-Procedure state.
void initLookups ()
void finishLookups ()
void internalRoute (const OverlayKey &key, cMessage *msg, const NodeHandle &hint=NodeHandle::UNSPECIFIED_NODE)
void findNodeRpc (FindNodeCall *call)
void pingRpc (PingCall *call)

Private Attributes

int numSent
 number of sent packets (incl. forwarded packets)
int bytesSent
 number of sent bytes (incl. forwarded bytes)
int numSignalingSent
 number of sent signaling packets (incl. forwarded packets)
int bytesSignalingSent
 number of sent signaling bytes (incl. forwarded bytes)
int numReceived
 number of received packets (incl. packets to be forwarded )
int bytesReceived
 number of received bytes (incl. bytes to be forwarded)
int numSignalingReceived
 number of received signaling packets (incl. packets to be forwarded)
int bytesSignalingReceived
 number of received signaling bytes (incl. bytes to be forwarded)
cGate * thisOutGateArray
 out-gate array for vis. overlay topology
cGate * thisInGateArray
 in-gate array for vis. overlay topology
bool drawOverlayTopology
 draw overlay topology?
int rpcsPending
RpcListenerdefaultRpcListener
RpcStates rpcStates

Friends

class BaseLookup

Classes

class  lookupHashFcn
class  RpcState


Member Typedef Documentation

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

typedef hash_map<int,RpcState> BaseOverlay::RpcStates [private]


Member Enumeration Documentation

enum BaseOverlay::Direction [private]

Enumerator:
IN 
OUT 
00368 { IN, OUT };


Constructor & Destructor Documentation

BaseOverlay::~BaseOverlay (  )  [virtual]

Virtual destructor.

00043 {
00044     finishLookups();
00045     finishRpcs();
00046 }


Member Function Documentation

void BaseOverlay::callDeliver ( BaseOverlayMessage *  msg  )  [protected]

Calls deliver function in application.

Encapsulates messages in KBRdeliver messages and sends them to application.

Parameters:
msg delivered message
00229 {
00230     KBRdeliver* deliverMsg = new KBRdeliver();
00231 
00232     OverlayCtrlInfo* overlayCtrlInfo =
00233         check_and_cast<OverlayCtrlInfo*>
00234         (msg->removeControlInfo());
00235 
00236     deliverMsg->setControlInfo(overlayCtrlInfo);
00237 
00238     deliverMsg->encapsulate(msg->decapsulate());
00239 
00240     send(deliverMsg, "to_app");
00241 
00242     delete msg;
00243 }

void BaseOverlay::callForward ( OverlayKey key,
BaseRouteMessage *  msg,
NodeHandle hint = NULL 
) [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
hint next hop (usually unused)
00247 {
00248     KBRforward* forwardMsg = new KBRforward();
00249     forwardMsg->encapsulate(msg->decapsulate());
00250 
00251     OverlayCtrlInfo* overlayCtrlInfo =
00252         new OverlayCtrlInfo();
00253     overlayCtrlInfo->setThisNode(thisNode);
00254     overlayCtrlInfo->setHopCount(msg->getHopCount());
00255     overlayCtrlInfo->setDestKey(msg->getDestKey());
00256     overlayCtrlInfo->setSrcNode(msg->getSrcNode());
00257 
00258     forwardMsg->setControlInfo(overlayCtrlInfo);
00259 
00260     send(forwardMsg, "to_app");
00261 
00262     delete msg;
00263 }

void BaseOverlay::cancelRpcMessage ( uint32_t  nonce  ) 

Cancels a Remote-Procedure-Call.

Parameters:
nonce The nonce of the RPC
00747 {
00748     if (rpcStates.count(nonce)==0)
00749         return;
00750     RpcState state = rpcStates[nonce];
00751     rpcStates.erase(nonce);
00752     cancelAndDelete(state.callMsg);
00753     cancelAndDelete(state.timeoutMsg);
00754 }

void BaseOverlay::compactGateArray ( cModule *  terminal,
enum Direction  dir 
) [private]

compacts arrow gate-array

Parameters:
terminal node
dir in- or out-array?
00573 {
00574     cGate* gateArray = (dir == OUT ? terminal->gate("overlayNeighborArrowOut")
00575                         : terminal->gate("overlayNeighborArrowIn"));
00576     const char* gateName = (dir == OUT ? "overlayNeighborArrowOut"
00577                             : "overlayNeighborArrowIn");
00578 
00579     for (int j = 0; j < gateArray->size() - 1; j++) {
00580         if (terminal->gate(gateName, j)->isConnectedOutside())
00581             continue;
00582 
00583         cGate* tempGate = NULL;
00584         int k = 1;
00585         while ((tempGate == NULL) && ((j + k) != gateArray->size())) {
00586             tempGate = (dir == OUT ? terminal->gate(gateName, j + k)->toGate()
00587                         : terminal->gate(gateName, j + k)->fromGate());
00588             k++;
00589         }
00590 
00591         if (tempGate == NULL)
00592             break;
00593 
00594         if (dir == OUT) {
00595             terminal->gate(gateName, j + k - 1)->disconnect();
00596             terminal->gate(gateName, j)->connectTo(tempGate);
00597         } else {
00598             tempGate->disconnect();
00599             tempGate->connectTo(terminal->gate(gateName, j));
00600         }
00601     }
00602 
00603     int nullGates = 0;
00604     for (int j = 0; j < gateArray->size(); j++)
00605         if (!terminal->gate(gateName, j)->isConnectedOutside())
00606             nullGates++;
00607 
00608     terminal->setGateSize(gateName, gateArray->size() - nullGates);
00609 }

AbstractLookup * BaseOverlay::createLookup (  )  [protected, virtual]

Creates a abstract iterative lookup instance.

Returns:
AbstractLookup* The new lookup instance.
01068 {
01069     AbstractLookup* newLookup = new BaseLookup( this, baseLookupConfig );
01070     lookups.insert( newLookup );
01071     return newLookup;
01072 }

void BaseOverlay::deleteOverlayNeighborArrow ( const NodeHandle neighbor  )  [protected]

Removes an arrow from this node to neighbor.

Parameters:
neighbor neighbor to remove arrow to
Todo:
add neighbor's kind to distinguish arrows pointing to the same neighbor
00536 {
00537     if (!ev.isGUI() || !drawOverlayTopology)
00538         return;
00539 
00540     //does neighbor module exist anymore?
00541     if (simulation.module(neighbor.moduleId) == NULL)
00542         return;
00543 
00544     cModule* neighborTerminal
00545     = simulation.module(neighbor.moduleId)->parentModule();
00546 
00547     //find gate
00548     bool compactOut = false;
00549     bool compactIn = false;
00550     for (int i = 0; i < thisOutGateArray->size(); i++) {
00551         // NULL-Gate?
00552         if (thisTerminal->gate("overlayNeighborArrowOut", i)->toGate() == NULL) {
00553             compactOut = true;
00554             continue;
00555         }
00556 
00557         if (thisTerminal->gate("overlayNeighborArrowOut", i)->toGate()->ownerModule()->id() == neighborTerminal->id()) {
00558             thisTerminal->gate("overlayNeighborArrowOut", i)->disconnect();
00559             compactOut = true;
00560             compactIn = true;
00561         }
00562     }
00563 
00564     //compact OUT-array
00565     if (compactOut)
00566         compactGateArray(thisTerminal, OUT);
00567     //compact IN-array
00568     if (compactIn)
00569         compactGateArray(neighborTerminal, IN);
00570 }

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
01082 {
01083     return x > y ? x-y : y-x;
01084 }

NodeVector * BaseOverlay::findNode ( const OverlayKey key,
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 in the k-neighborhood to key (isResponsible(key) = true), this method returns all k neighbors, with the closest neighbor to the key first.

Parameters:
key The lookup key.
msg A pointer to the BaseRouteMessage or FindNodeCall message of this lookup.
Returns:
NodeVector with closest nodes.

Reimplemented in Chord, and Kademlia.

01089 {
01090     opp_error( "findNode: Not implemented!" );
01091     return NULL;
01092 }

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

01102 {
01103     FindNodeResponse* findNodeResponse =
01104         new FindNodeResponse("FindNodeResponse");
01105 
01106     NodeVector* nextHops = findNode(call->getLookupKey(), call);
01107 
01108     findNodeResponse->setClosestNodesArraySize(nextHops->size());
01109 
01110     for (uint i=0; i < nextHops->size(); i++) {
01111         findNodeResponse->setClosestNodes(i, (*nextHops)[i]);
01112     }
01113 
01114     if (isResponsible(call->getLookupKey()))
01115         findNodeResponse->setNeighbors(true);
01116 
01117     findNodeResponse->setLength(FINDNODERESPONSE_L(findNodeResponse));
01118  
01119     if (call->hasObject("findNodeExt")) {
01120         cMessage* findNodeExt = (cMessage*)call->removeObject("findNodeExt");
01121         findNodeResponse->addObject(findNodeExt);
01122         findNodeResponse->addLength(findNodeExt->length());
01123     }
01124 
01125     RECORD_STATS(numFindNodeSent++; bytesFindNodeSent +=
01126                  findNodeResponse->byteLength());
01127 
01128     delete nextHops;
01129 
01130     sendRpcResponse( call, findNodeResponse );
01131 }

void BaseOverlay::finish (  )  [private]

collects statistical data

00152 {
00153     finishOverlay();
00154     finishLookups();
00155     finishRpcs();
00156 
00157     recordScalar("BaseOverlay: Sent User Messages", numSent);
00158     recordScalar("BaseOverlay: Sent User Bytes", bytesSent);
00159     recordScalar("BaseOverlay: Sent Signaling Messages", numSignalingSent);
00160     recordScalar("BaseOverlay: Sent Signaling Bytes", bytesSignalingSent);
00161     recordScalar("BaseOverlay: Sent Total Messages", numSent + numSignalingSent);
00162     recordScalar("BaseOverlay: Sent Total Bytes", bytesSent + bytesSignalingSent);
00163     recordScalar("BaseOverlay: Sent FindNode Messages", numFindNodeSent);
00164     recordScalar("BaseOverlay: Sent FindNode Bytes", bytesFindNodeSent);
00165 
00166     recordScalar("BaseOverlay: Received User Messages", numReceived);
00167     recordScalar("BaseOverlay: Received User Bytes", bytesReceived);
00168     recordScalar("BaseOverlay: Received Signaling Messages", numSignalingReceived);
00169     recordScalar("BaseOverlay: Received Signaling Bytes", bytesSignalingReceived);
00170     recordScalar("BaseOverlay: Received Total Messages", numReceived
00171                  + numSignalingReceived);
00172     recordScalar("BaseOverlay: Received Total Bytes", bytesReceived
00173                  + bytesSignalingReceived);
00174     recordScalar("BaseOverlay: Forwarded User Messages", numForwarded);
00175     recordScalar("BaseOverlay: Forwarded User Bytes", bytesForwarded);
00176     recordScalar("BaseOverlay: Forwarded Signaling Messages", numSignalingForwarded);
00177     recordScalar("BaseOverlay: Forwarded Signaling Bytes", bytesSignalingForwarded);
00178     recordScalar("BaseOverlay: Forwarded Total Messages", numForwarded
00179                  + numSignalingForwarded);
00180     recordScalar("BaseOverlay: Forwarded Total Bytes", bytesForwarded
00181                  + bytesSignalingForwarded);
00182 
00183     recordScalar("BaseOverlay: Dropped Messages", numDropped);
00184     recordScalar("BaseOverlay: Dropped Bytes", bytesDropped);
00185 
00186 }

void BaseOverlay::finishLookups (  )  [private]

00889 {
00890     while (lookups.size()!=0)
00891         delete *lookups.begin();
00892     lookups.clear();
00893 }

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

collects statistical data in derived class

Reimplemented in Chord, Gia, Kademlia, and Vast.

00189 {
00190     // ...
00191 }

void BaseOverlay::finishRpcs (  )  [private]

Deinitializes Remote-Procedure state.

00669 {
00670     // stop all rpcs
00671     for (RpcStates::iterator i = rpcStates.begin();
00672             i != rpcStates.end(); i++) {
00673         cancelAndDelete(i->second.callMsg);
00674         cancelAndDelete(i->second.timeoutMsg);
00675     }
00676     rpcStates.clear();
00677 
00678     // delete default rpc listener
00679     if (defaultRpcListener!=NULL) {
00680         delete defaultRpcListener;
00681         defaultRpcListener = NULL;
00682     }
00683 }

NodeHandle & BaseOverlay::getThisNode (  ) 

Returns the NodeHandle of this node.

Returns:
the NodeHandle of this node.
00208 {
00209     return thisNode;
00210 }

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

Processes non-commonAPI messages.


Processes non-commonAPI messages if parameter "onlyCommonAPIMessages" is false.

Parameters:
msg non-commonAPIMessage

Reimplemented in Gia, and Vast.

00422 {
00423     delete msg;
00424 }

void BaseOverlay::handleBaseOverlayMessage ( BaseOverlayMessage *  msg  )  [private]

Handles a BaseOverlayMessage
.

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

Parameters:
msg The message to be handled
00341 {
00342     switch(msg->getType()) {
00343     case OVERLAYSIGNALING:
00344         handleUDPMessage(msg);
00345         return;
00346 
00347     case RPC: {
00348             // process rpc-messages
00349             BaseRpcMessage* rpcMessage =
00350                 check_and_cast<BaseRpcMessage*>(msg);
00351             internalHandleRpcMessage(rpcMessage);
00352             return;
00353         }
00354 
00355     case APPDATA: {
00356             BaseAppDataMessage* baseAppDataMsg =
00357                 check_and_cast<BaseAppDataMessage*>(msg);
00358             callDeliver(baseAppDataMsg);
00359             return;
00360         }
00361 
00362     case OVERLAYROUTE: {
00363             BaseRouteMessage* baseRouteMsg =
00364                 check_and_cast<BaseRouteMessage*>(msg);
00365 
00366             if (baseRouteMsg->getDestKey().isUnspecified())
00367                 opp_error("BaseOverlay: No destination key in ROUTE msg");
00368 
00369             if (baseRouteMsg->getFinalHop()) {
00370 
00371                 // check if this node is really resposible for this key
00372                 if (!isResponsible(baseRouteMsg->getDestKey())) {
00373                     EV << "BaseOverlay: Received BaseRouteMessage with "
00374                        << "finalHopFlag set, but this node "
00375                        << "is not responsible - dropping message!" << endl;
00376                     RECORD_STATS(numDropped++;
00377                                  bytesDropped += baseRouteMsg->byteLength());
00378                     delete msg;
00379                     return;
00380                 }
00381 
00382                 OverlayCtrlInfo* overlayCtrlInfo =
00383                     check_and_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
00384 
00385                 overlayCtrlInfo->setThisNode(thisNode);
00386                 overlayCtrlInfo->setHopCount(baseRouteMsg->getHopCount());
00387                 overlayCtrlInfo->setDestKey(baseRouteMsg->getDestKey());
00388                 overlayCtrlInfo->setSrcNode(baseRouteMsg->getSrcNode());
00389 
00390                 BaseOverlayMessage* tmpMsg
00391                 = check_and_cast<BaseOverlayMessage*>
00392                   (baseRouteMsg->decapsulate());
00393                 tmpMsg->setControlInfo(overlayCtrlInfo);
00394 
00395                 handleBaseOverlayMessage(tmpMsg);
00396                 delete msg;
00397                 return;
00398             } else {
00399                 // forward msg if this node is not responsible for the key
00400                 sendToKey(baseRouteMsg->getDestKey(), baseRouteMsg, 1);
00401                 return;
00402             }
00403             break;
00404         }
00405 
00406     default:
00407         EV << "BaseOverlay::handleMessage(): received unknown message "
00408         << "from UDP of type " << msg->name() << endl;
00409         break;
00410     }
00411 }

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
00272 {
00273     // process self-messages
00274     if (msg->isSelfMessage()) {
00275         // process rpc self-messages
00276         BaseRpcMessage* rpcMessage = dynamic_cast<BaseRpcMessage*>(msg);
00277         if (rpcMessage!=NULL) {
00278             internalHandleRpcMessage(rpcMessage);
00279             return;
00280         }
00281         // process all other self-messages
00282         handleTimerEvent(msg);
00283     }
00284 
00285     // process messages from UDP
00286     else if (msg->arrivedOn("from_udp")) {
00287         UDPControlInfo* udpControlInfo =
00288             check_and_cast<UDPControlInfo*>(msg->removeControlInfo());
00289         OverlayCtrlInfo* overlayCtrlInfo = new OverlayCtrlInfo;
00290         overlayCtrlInfo->setLastHopAddr(udpControlInfo->srcAddr());
00291         overlayCtrlInfo->setLastHopPort(udpControlInfo->srcPort());
00292         msg->setControlInfo(overlayCtrlInfo);
00293         delete udpControlInfo;
00294 
00295         BaseOverlayMessage* baseOverlayMsg =
00296             dynamic_cast<BaseOverlayMessage*>(msg);
00297 
00298         if (baseOverlayMsg == NULL) {
00299             delete msg;
00300             return;
00301         }
00302 
00303         // records stats if message is not a UDP "self message"
00304         if (overlayCtrlInfo->getLastHopAddr() != thisNode.ip) {
00305             if (baseOverlayMsg->getSignaling() == false)
00306                 RECORD_STATS(numReceived++; bytesReceived +=
00307                                  baseOverlayMsg->byteLength());
00308             else
00309                 RECORD_STATS(numSignalingReceived++;bytesSignalingReceived
00310                              += baseOverlayMsg->byteLength());
00311         }
00312 
00313         handleBaseOverlayMessage(baseOverlayMsg);
00314     }
00315 
00316     // process CommonAPIMessages from App
00317     else if (dynamic_cast<CommonAPIMessage*>(msg) != NULL) {
00318         OverlayCtrlInfo* overlayCtrlInfo =
00319             check_and_cast<OverlayCtrlInfo*>
00320             (msg->removeControlInfo());
00321 
00322         if (dynamic_cast<KBRroute*>(msg) != NULL)
00323             internalRoute(overlayCtrlInfo->getDestKey(), msg->decapsulate(),
00324                           overlayCtrlInfo->getHint());
00325 
00326         delete msg;
00327         delete overlayCtrlInfo;
00328     }
00329 
00330     // process other messages from App
00331     else if (msg->arrivedOn("from_app") && onlyCommonAPIMessages == false)
00332         handleAppMessage(msg);
00333 
00334     else {
00335         RECORD_STATS(numDropped++; bytesDropped += msg->byteLength());
00336         delete msg;
00337     }
00338 }

void BaseOverlay::handleRpc ( BaseCallMessage *  msg  )  [protected, virtual]

Processes Remote-Procedure-Call invokation messages.


This method should be overloaded when the overlay provides RPC functionality. One can use

Reimplemented in Chord, and Kademlia.

00855 {
00856     opp_error( "handleRpc: Not implemented!" );
00857     delete msg;
00858 }

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

Processes "timer" self-messages.

Parameters:
msg A self-message

Reimplemented in Chord, Gia, Kademlia, and Vast.

00416 {
00417     // timer...
00418 }

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

Processes messages from underlay.

Parameters:
msg Message from UDP

Implemented in Chord, Gia, Kademlia, and Vast.

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

initializes base-class-attributes

Parameters:
stage the init stage
00054 {
00055     if(stage == MIN_STAGE_OVERLAY) {
00056         OverlayKey::setKeyLength(par("keyLength"));
00057 
00058         // fetch some parameters
00059         debugOutput                     = par("debugOutput");
00060         measureNetwInitPhase            = par("measureNetwInitPhase");
00061         localPort                       = par("localPort");
00062         hopCountMax                     = par("hopCountMax");
00063         drawOverlayTopology             = par("drawOverlayTopology");
00064         useBaseLookup                   = par("useBaseLookup");
00065         iterativeLookup                 = par("iterativeLookup");
00066         onlyCommonAPIMessages           = true;
00067 
00068         // set base lookup parameters
00069         baseLookupConfig.numNextHops    = par("lookupNumberNextHops");
00070         baseLookupConfig.parallelPaths  = par("lookupParallelPaths");
00071         baseLookupConfig.parallelRpcs   = par("lookupParallelRpcs");
00072         baseLookupConfig.secure         = par("lookupSecure");
00073         baseLookupConfig.merge          = par("lookupMerge");
00074 
00075         // statistics
00076         numSent = 0;
00077         bytesSent = 0;
00078         numSignalingSent = 0;
00079         bytesSignalingSent = 0;
00080         numReceived = 0;
00081         bytesReceived = 0;
00082         numSignalingReceived = 0;
00083         bytesSignalingReceived = 0;
00084         numForwarded = 0;
00085         bytesForwarded = 0;
00086         numSignalingForwarded = 0;
00087         bytesSignalingForwarded = 0;
00088         numDropped = 0;
00089         bytesDropped = 0;
00090         numFindNodeSent = 0;
00091         bytesFindNodeSent = 0;
00092 
00093         WATCH(numSent);
00094         WATCH(bytesSent);
00095         WATCH(numSignalingSent);
00096         WATCH(bytesSignalingSent);
00097         WATCH(numReceived);
00098         WATCH(bytesReceived);
00099         WATCH(numSignalingReceived);
00100         WATCH(bytesSignalingReceived);
00101         WATCH(numForwarded);
00102         WATCH(bytesForwarded);
00103         WATCH(numSignalingForwarded);
00104         WATCH(bytesSignalingForwarded);
00105         WATCH(numDropped);
00106         WATCH(bytesDropped);
00107         WATCH(numFindNodeSent);
00108         WATCH(bytesFindNodeSent);
00109 
00110         // set up UDP
00111         bindToPort(localPort);
00112 
00113         // find friend modules
00114         bootstrapOracle = BootstrapOracleAccess().get();
00115         underlayConfigurator = UnderlayConfiguratorAccess().get();
00116         globalStatistics = GlobalStatisticsAccess().get();
00117         notificationBoard = NotificationBoardAccess().get();
00118 
00119         thisTerminal = parentModule()->parentModule();
00120 
00121         // set up local nodehandle
00122         thisNode.moduleId = parentModule()->id();
00123         thisNode.ip = IPAddressResolver().
00124                       addressOf(parentModule()->parentModule()).get4();
00125         thisNode.port = localPort;
00126         thisNode.key = OverlayKey::UNSPECIFIED_KEY;
00127 
00128         // set up arrow-gates
00129         thisOutGateArray = thisTerminal->gate("overlayNeighborArrowOut");
00130         thisInGateArray = thisTerminal->gate("overlayNeighborArrowIn");
00131         thisTerminal->setGateSize("overlayNeighborArrowOut" ,1);
00132         thisTerminal->setGateSize("overlayNeighborArrowIn" ,1);
00133 
00134         // subscribe to the notification board
00135         notificationBoard->subscribe( this,NF_HOSTPOSITION_UPDATED);
00136 
00137         // init rpcs
00138         initRpcs();
00139         initLookups();
00140     }
00141 
00142     if(stage >= MIN_STAGE_OVERLAY && stage <= MAX_STAGE_OVERLAY)
00143         initializeOverlay(stage);
00144 }

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 Chord, Gia, Kademlia, and Vast.

00147 {
00148     // ...
00149 }

void BaseOverlay::initLookups (  )  [private]

00884 {
00885     lookups = LookupSet();
00886 }

void BaseOverlay::initRpcs (  )  [private]

Initializes Remote-Procedure state.

00660 {
00661     rpcsPending = 0;
00662     rpcStates.clear();
00663 
00664     defaultRpcListener = new RpcListener();
00665 }

bool BaseOverlay::internalHandleRpc ( BaseCallMessage *  msg  )  [private]

Handles internal rpc requests.


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

Parameters:
msg The call message
Returns:
bool true, if call has been handled.
00841 {
00842     // call rpc stubs
00843     RPC_SWITCH_START( msg );
00844     RPC_DELEGATE( FindNode, findNodeRpc );
00845     RPC_SWITCH_END( );
00846 
00847     // check if rpc has been handled
00848     IF_RPC_HANDLED return true;
00849     else
00850         return false;
00851 }

void BaseOverlay::internalHandleRpcMessage ( BaseRpcMessage *  msg  )  [private]

Handles incoming rpc messages and delegates them to the corresponsing listeners or handlers.

Parameters:
msg The message to handle.
00758 {
00759     // check if this is a rpc call message
00760     BaseCallMessage* rpCall = dynamic_cast<BaseCallMessage*>(msg);
00761     if (rpCall != NULL) {
00762         if (!internalHandleRpc(rpCall))
00763             handleRpc(rpCall);
00764         return;
00765     }
00766 
00767     // get nonce
00768     int nonce = msg->getNonce();
00769 
00770     // nonce known? no -> delete message and return
00771     if (rpcStates.count(nonce)==0) {
00772         EV << "RPC: Nonce Unknown!" << endl;
00773         delete msg;
00774         return;
00775     }
00776 
00777     // get state and remove from map
00778     RpcState state = rpcStates[nonce];
00779     rpcStates.erase(nonce);
00780 
00781     // is timeout message?
00782     if ( msg->isSelfMessage() ) { // yes-> inform listener
00783 
00784         // retry?
00785         state.retries--;
00786         simtime_t timeout = simulation.simTime() - state.timeSent;
00787         if (state.retries>=0) {
00788             if (state.destKey.isUnspecified()) {
00789                 sendMessageToUDP( state.dest,
00790                                   dynamic_cast<BaseCallMessage*>
00791                                   (state.callMsg->dup()));
00792             } else {
00793                 // send message to key
00794                 sendToKey( state.destKey,
00795                            dynamic_cast<BaseCallMessage*>
00796                            (state.callMsg->dup()), 1, state.dest );
00797             }
00798             if (timeout!=0)
00799                 scheduleAt( simulation.simTime() + timeout, msg );
00800             rpcStates[nonce] = state;
00801             return;
00802         }
00803 
00804         // inform listener
00805         if ( state.listener != NULL )
00806             state.listener->handleRpcTimeout( state.callMsg, state.dest,
00807                                               state.id );
00808 
00809         // inform overlay
00810         handleRpcTimeout( state.callMsg, state.dest, state.id );
00811 
00812     } else { // no-> handle rpc response
00813 
00814         // get parameters
00815         simtime_t rtt = simulation.simTime() - state.timeSent;
00816         BaseResponseMessage* response
00817         = dynamic_cast<BaseResponseMessage*>(msg);
00818 
00819         // inform listener
00820         if ( state.listener != NULL )
00821             state.listener->handleRpcResponse( response, state.id, rtt );
00822 
00823         // inform overlay
00824         handleRpcResponse( response, state.id, rtt );
00825 
00826         // delete response
00827         delete response;
00828     }
00829 
00830     // delete messages
00831     cancelAndDelete(state.callMsg);
00832     cancelAndDelete(state.timeoutMsg);
00833 
00834     // clean up pointers
00835     state.callMsg = NULL;
00836     state.timeoutMsg = NULL;
00837 }

void BaseOverlay::internalRoute ( const OverlayKey key,
cMessage *  msg,
const NodeHandle hint = NodeHandle::UNSPECIFIED_NODE 
) [private]

00938 {
00939     // check if base lookup should be used
00940     if (!useBaseLookup) {
00941         route(key,msg,hint);
00942         return;
00943     }
00944 
00945     if(key.isUnspecified())
00946         error("route(): key unspecified!");
00947 
00948     // create base route message
00949     BaseAppDataMessage* baseAppDataMsg =
00950         new BaseAppDataMessage("BaseAppDataMessage");
00951     baseAppDataMsg->setType(APPDATA);
00952     baseAppDataMsg->setLength(BASEAPPDATA_L(baseAppDataMsg));
00953     baseAppDataMsg->setSignaling(false);
00954     baseAppDataMsg->setKind(1);
00955     baseAppDataMsg->encapsulate(msg);
00956 
00957     // debug output
00958     if (debugOutput) {
00959         EV << "BaseOverlay: Node " << thisNode.ip << " received message from "
00960         "application." << endl;
00961     }
00962 
00963     sendToKey( key, baseAppDataMsg, 1, hint );
00964 }

bool BaseOverlay::isMalicious (  ) 

Returns true, if node is malicious.

Returns:
true, if node is malicious.
00203 {
00204     return malicious;
00205 }

bool BaseOverlay::isResponsible ( const OverlayKey key  )  [protected, virtual]

Query if the node knowns the k-neighborhood for a key.

Query if the node knowns the complete k-neighborhood for the given key. Usually these are all nodes, that are responsible for the key. If there is no k-neighborhood in a specific overlay protocol, this method simply returns true, if the node is responsible for the key.

Parameters:
key destination key
Returns:
bool true, if the node knows the k-neighborhood for key.

Reimplemented in Chord, and Kademlia.

00222 {
00223     opp_error( "isResponsible: Not implemented!" );
00224     return false;
00225 }

int BaseOverlay::numInitStages (  )  const [protected]

Sets init stage.

See also:
InitStages.h
00049 {
00050     return MAX_STAGE_OVERLAY + 1;
00051 }

PingResponse * BaseOverlay::ping ( PingCall *  call  )  [protected, virtual]

Implements a ping call.


This method implementts a simple ping call.

Parameters:
call The ping message
Returns:
The ping response or NULL if no response should be sent.
01096 {
01097     return new PingResponse();
01098 }

void BaseOverlay::pingRpc ( PingCall *  call  )  [private]

01135 {
01136     sendRpcResponse( call, ping(call) );
01137 }

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

00428 {
00429     // collect statistics ...
00430 }

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

Removes the abstract lookup instance.

Parameters:
lookup 
01075 {
01076     lookups.erase(lookup);
01077 }

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

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
msg message to route
hint next hop (usually unused)

Reimplemented in Gia.

00219 {}

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

Sends message to underlay.

Parameters:
dest destination node
msg message to send
00617 {
00618     // if there's still a control info attached to the message, remove it
00619     cPolymorphic* ctrlInfo = msg->removeControlInfo();
00620     if (ctrlInfo != NULL)
00621         delete ctrlInfo;
00622 
00623     // debug message
00624     if (debugOutput) {
00625         EV << "BaseOverlay: Node " << thisNode.ip << ": sends "
00626         << msg->name() << " to " << dest.ip << "." << endl;
00627     }
00628 
00629     msg->setKind(UDP_C_DATA);
00630     UDPControlInfo* udpControlInfo = new UDPControlInfo();
00631     udpControlInfo->setSrcAddr(thisNode.ip);
00632     udpControlInfo->setSrcPort(thisNode.port);
00633     udpControlInfo->setDestAddr(dest.ip);
00634     udpControlInfo->setDestPort(dest.port);
00635     msg->setControlInfo(udpControlInfo);
00636 
00637     send(msg, "to_udp");
00638 
00639     if (dest != thisNode) {
00640         // record statistics, if message is not local
00641         if (msg->getSignaling() == false) {
00642             RECORD_STATS(numSent++; bytesSent += msg->byteLength());
00643         } else {
00644             RECORD_STATS(numSignalingSent++; bytesSignalingSent +=
00645                              msg->byteLength());
00646         }
00647         recordOverlaySentStats(msg);
00648         globalStatistics->sentTotalBytes+=msg->byteLength();
00649 
00650     }
00651 }

uint32_t BaseOverlay::sendRpcMessage ( const NodeHandle dest,
BaseCallMessage *  msg,
RpcListener rpcListener = NULL,
const OverlayKey destKey = OverlayKey::UNSPECIFIED_KEY,
int  rpcId = -1,
simtime_t  timeout = -1,
int  retries = 0 
)

Sends a Remote-Procedure-Call message to the underlay.


If no timeout is provided, a default value of 1.0 for underlay and 5.0 for a overlay rpc is used. After a timeout the message gets retransmitted for at maximum retries times.

The destKey attribute is kept untouched.

Parameters:
dest Destination node handle
msg RPC Call Message
rpcListener RPC Listener
destKey first route the RPC to the node that is responsible for kestkey
rpcId RPC id
timeout RPC timeout
retries How often we try to resent rpc call, if it gets lost
Returns:
The nonce of the RPC
00692 {
00693 
00694     // create nonce, timeout and set default parameters
00695     uint nonce;
00696     do {
00697         nonce = intuniform( 0, 2147483647);
00698     } while (rpcStates.count(nonce) > 0);
00699 
00700 
00701     if (timeout == -1)
00702         timeout = destKey.isUnspecified() ? 1.0 : 5.0;
00703     if (rpcListener == NULL)
00704         rpcListener = defaultRpcListener;
00705 
00706     // create state
00707     RpcState state;
00708     state.id = rpcId;
00709     state.timeSent = simulation.simTime();
00710     state.dest = dest;
00711     state.destKey = destKey;
00712     state.listener = rpcListener;
00713     state.timeoutMsg = new RpcTimeoutMessage();
00714     state.timeoutMsg->setNonce(nonce);
00715     state.retries = retries;
00716 
00717     if (rpcStates.count(nonce) > 0)
00718         error("RPC nonce collision");
00719 
00720     // set message parameters
00721     msg->setNonce( nonce );
00722     msg->setSrcNode( thisNode );
00723     msg->setType(RPC);
00724 
00725     // save copy of call message in RpcState
00726     state.callMsg = dynamic_cast<BaseCallMessage*>(msg->dup());
00727 
00728     // register state
00729     rpcStates[nonce] = state;
00730 
00731     // schedule timeout message
00732     if (timeout!=0)
00733         scheduleAt( simulation.simTime() + timeout, state.timeoutMsg);
00734 
00735     if (destKey.isUnspecified()) {
00736         sendMessageToUDP( dest, msg );
00737     } else {
00738         // send message to key
00739         sendToKey( destKey, msg, 1, dest );
00740     }
00741 
00742     return nonce;
00743 }

void BaseOverlay::sendRpcResponse ( BaseCallMessage *  call,
BaseResponseMessage *  response 
) [protected]

Send Remote-Procedure response message and deletes call message.


The destKey attribute is kept untouched. If call or reponse is NULL no reponse will be sent.

Parameters:
call The corresponding call message to the reponse
response The call return value
00863 {
00864     if (call==NULL || response==NULL) {
00865         if ( call!=NULL )
00866             delete call;
00867         return;
00868     }
00869     response->setSrcNode( thisNode );
00870     response->setType( RPC );
00871     response->setNonce( call->getNonce() );
00872     sendMessageToUDP( call->getSrcNode(), response );
00873     delete call;
00874 }

void BaseOverlay::sendToKey ( const OverlayKey key,
BaseOverlayMessage *  message,
uint  numNeighbors = 0,
const NodeHandle nextHop = NodeHandle::UNSPECIFIED_NODE 
)

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

Parameters:
key The destination key
message Message to be sent
numNeighbors number of neighbors to send message to (multicast)
nextHop If nextHop is given, the message gets sent to this node before it is routed (nextHop is used as a proxy)
00968 {
00969     BaseRouteMessage* routeMsg = NULL;
00970 
00971 
00972     if (key.isUnspecified())
00973         error("BaseOverlay::sendToKey(): unspecified destination key!");
00974 
00975     if (msg->getType() != OVERLAYROUTE) {
00976         routeMsg = new BaseRouteMessage("BaseRouteMessage");
00977         routeMsg->setType(OVERLAYROUTE);
00978         routeMsg->setDestKey(key);
00979         routeMsg->setSrcNode(thisNode);
00980         routeMsg->setSignaling(msg->getSignaling());
00981         routeMsg->setKind(routeMsg->getSignaling() ? 0 : 1);
00982         // copy the name of the inner message
00983         routeMsg->setName(msg->name());
00984         routeMsg->setLength(BASEROUTE_L(routeMsg));
00985         routeMsg->encapsulate(msg);
00986     } else {
00987         routeMsg = check_and_cast<BaseRouteMessage*>(msg);
00988     }
00989 
00990     if (!nextHop.isUnspecified()) {
00991         // send msg to nextHop if specified (used for join rpcs)
00992         sendMessageToUDP(nextHop, routeMsg);
00993         return;
00994     }
00995 
00996     if (iterativeLookup) {
00997         // create lookup and sent to key
00998         AbstractLookup* lookup = createLookup();
00999         lookup->lookup( routeMsg->getDestKey(), numNeighbors, hopCountMax,
01000                         new SendToKeyListener( this, routeMsg ) );
01001     } else  {
01002         // if this node knows the destination node, set the finalHop flag
01003         if(isResponsible(routeMsg->getDestKey())) {
01004             routeMsg->setFinalHop(true);
01005         }
01006 
01007         NodeVector* nextHops = findNode(routeMsg->getDestKey(), routeMsg);
01008 
01009         if (nextHops->size() == 0) {
01010 
01011             EV <<   "BaseOverlay::sendToKey(): findNode() returned NULL "
01012             "- dropping message" << endl;
01013             // statistics
01014             RECORD_STATS(numDropped++; bytesDropped += routeMsg->byteLength());
01015             delete routeMsg;
01016         } else {
01017             // delete message if the hop count maximum is exceeded
01018             if (routeMsg->getHopCount() >= hopCountMax) {
01019                 if (debugOutput) {
01020                     EV << "BaseOverlay: Node " << thisNode.ip << " discards "
01021                     << routeMsg->name() << " from "
01022                     << routeMsg->getSrcNode().ip
01023                     << ". The hop count maximum has been exceeded. ("
01024                     << routeMsg->getHopCount() << ">="
01025                     << hopCountMax << ")" << endl;
01026                     //cout << "HopCount exceeded!" << endl;
01027                 }
01028 
01029                 // statistics
01030                 RECORD_STATS(numDropped++;
01031                              bytesDropped += routeMsg->byteLength());
01032                 delete routeMsg;
01033                 return;
01034             }
01035 
01036             // forward msg if this node is not responsible for the key
01037 
01038             if ((*nextHops)[0] != thisNode) {
01039                 // increase hop count for non-local messages
01040                 routeMsg->setHopCount(routeMsg->getHopCount() + 1);
01041 
01042                 OverlayCtrlInfo* overlayCtrlInfo =
01043                     dynamic_cast<OverlayCtrlInfo*>(msg->removeControlInfo());
01044 
01045                 // records statistics, if we forward this message
01046                 if ((overlayCtrlInfo != NULL) &&
01047                         (overlayCtrlInfo->getLastHopAddr() != thisNode.ip)) {
01048                     if (routeMsg->getSignaling() == false) {
01049                         RECORD_STATS(numForwarded++; bytesForwarded +=
01050                                          routeMsg->byteLength());
01051                     } else {
01052                         RECORD_STATS(numSignalingForwarded++;
01053                                      bytesSignalingForwarded +=
01054                                          routeMsg->byteLength());
01055                     }
01056                 }
01057                 if (overlayCtrlInfo != NULL)
01058                     delete overlayCtrlInfo;
01059             }
01060             sendMessageToUDP((*nextHops)[0], routeMsg);
01061         }
01062         delete nextHops;
01063     }
01064 }

void BaseOverlay::setMalicious ( bool  malicious  )  [virtual]

Sets node to a malicious state.

This method can be overloaded to manage the state change.

Parameters:
malicious true, if node behaves maliciously
00198 {
00199     this->malicious = malicious;
00200 }

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

Colors module-icon blue (ready) or red (not ready).

Parameters:
ready state to visualize
00438 {
00439     if (ev.isGUI()) {
00440         if (ready) {
00441             thisTerminal->displayString().setTagArg("i2", 1, "");
00442             displayString().setTagArg("i", 1, "");
00443         } else {
00444             thisTerminal->displayString().setTagArg("i2", 1, "red");
00445             displayString().setTagArg("i", 1, "red");
00446         }
00447     }
00448 }

void BaseOverlay::showOverlayNeighborArrow ( const NodeHandle neighbor,
bool  flush = true,
char *  displayString = NULL 
) [protected]

Draws an arrow from this node to neighbor.

Parameters:
neighbor neighbor to point to
flush delete all previous drawn arrows starting at this node?
displayString display string to define the arrow drawing style
Todo:
add neighbor's kind to distinguish arrows pointing to the same neighbor
00452 {
00453     if (!ev.isGUI() || !drawOverlayTopology)
00454         return;
00455 
00456     char red[] = "o=red,1";
00457     if (displayString == NULL)
00458         displayString = red;
00459 
00460     cModule* neighborTerminal;
00461     cGate* neighborInGateArray;
00462 
00463     // flush
00464     if (flush) {
00465         for (int l = 0; l < thisOutGateArray->size(); l++) {
00466             cGate* tempGate
00467             = thisTerminal->gate("overlayNeighborArrowOut", l)->toGate();
00468             thisTerminal->gate("overlayNeighborArrowOut", l)->disconnect();
00469             if (tempGate != NULL)
00470                 compactGateArray(tempGate->ownerModule(), IN);
00471         }
00472         thisTerminal->setGateSize("overlayNeighborArrowOut" ,0);
00473     }
00474 
00475     if (simulation.module(neighbor.moduleId) != NULL) {
00476         neighborTerminal
00477         = simulation.module(neighbor.moduleId)->parentModule();
00478         neighborInGateArray = simulation.module(neighbor.moduleId)->
00479                               parentModule()->gate("overlayNeighborArrowIn");
00480     } else
00481         return;
00482 
00483     if (thisTerminal == neighborTerminal)
00484         return;
00485 
00486     //do not draw double
00487     for (int i = 0; i < thisOutGateArray->size(); i++)
00488         if (thisTerminal->gate("overlayNeighborArrowOut", i)->toGate() != NULL
00489                 && neighborTerminal
00490                 == thisTerminal->gate("overlayNeighborArrowOut", i)->
00491                 toGate()->ownerModule())
00492             return;
00493 
00494     // IN
00495     int i = 0;
00496     if (neighborInGateArray->size() == 0)
00497         neighborTerminal->setGateSize("overlayNeighborArrowIn", 1);
00498     else {
00499         for (i = 0; i < neighborInGateArray->size() - 1; i++) {
00500             if (!(neighborTerminal->gate("overlayNeighborArrowIn", i)
00501                     ->isConnectedOutside()))
00502                 break;
00503         }
00504         if (neighborTerminal->gate("overlayNeighborArrowIn", i)
00505                 ->isConnectedOutside()) {
00506             neighborTerminal->setGateSize("overlayNeighborArrowIn", i + 2);
00507             i++;
00508         }
00509     }
00510 
00511     // OUT
00512     int j = 0;
00513     if (thisOutGateArray->size() == 0)
00514         thisTerminal->setGateSize("overlayNeighborArrowOut", 1);
00515     else {
00516         for (j = 0; j < (thisOutGateArray->size() - 1); j++) {
00517             if (!(thisTerminal->gate("overlayNeighborArrowOut", j)
00518                     ->isConnectedOutside()))
00519                 break;
00520         }
00521         if (thisTerminal->gate("overlayNeighborArrowOut", j)
00522                 ->isConnectedOutside()) {
00523             thisTerminal->setGateSize("overlayNeighborArrowOut", j + 2);
00524             j++;
00525         }
00526     }
00527 
00528     thisTerminal->gate("overlayNeighborArrowOut", j)->
00529     connectTo(neighborTerminal->gate("overlayNeighborArrowIn", i));
00530 
00531     thisTerminal->gate("overlayNeighborArrowOut", j)->
00532     setDisplayString(displayString);
00533 }


Friends And Related Function Documentation

friend class BaseLookup [friend]


Member Data Documentation

BaseLookupConfiguration BaseOverlay::baseLookupConfig [protected]

BootstrapOracle* BaseOverlay::bootstrapOracle [protected]

pointer to BootstrapOracle in this node

int BaseOverlay::bytesDropped [protected]

number of dropped bytes

int BaseOverlay::bytesFindNodeSent [protected]

int BaseOverlay::bytesForwarded [protected]

number of forwarded bytes at out-gate

int BaseOverlay::bytesReceived [private]

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

int BaseOverlay::bytesSent [private]

number of sent bytes (incl. forwarded bytes)

int BaseOverlay::bytesSignalingForwarded [protected]

number of forwarded signaling bytes at out-gate

int BaseOverlay::bytesSignalingReceived [private]

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

int BaseOverlay::bytesSignalingSent [private]

number of sent signaling bytes (incl. forwarded bytes)

bool BaseOverlay::debugOutput [protected]

debug output ?

RpcListener* BaseOverlay::defaultRpcListener [private]

cOutVector BaseOverlay::delayVector [protected]

statistical output vector for packet-delays

bool BaseOverlay::drawOverlayTopology [private]

draw overlay topology?

GlobalStatistics* BaseOverlay::globalStatistics [protected]

pointer to GlobalStatistics module in this node

int BaseOverlay::hopCountMax [protected]

maximum hop count

cOutVector BaseOverlay::hopCountVector [protected]

statistical output vector for hop-counts

bool BaseOverlay::iterativeLookup [protected]

do iterative instead of recursive lookups

int BaseOverlay::localPort [protected]

used UDP-port

LookupSet BaseOverlay::lookups [protected]

bool BaseOverlay::malicious [protected]

true, if node is malicious

bool BaseOverlay::measureNetwInitPhase [protected]

fetch statistics in init phase ?

NotificationBoard* BaseOverlay::notificationBoard [protected]

pointer to NotificationBoard in this node

int BaseOverlay::numDropped [protected]

number of dropped packets

int BaseOverlay::numFindNodeSent [protected]

int BaseOverlay::numForwarded [protected]

number of forwarded packets

int BaseOverlay::numReceived [private]

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

int BaseOverlay::numSent [private]

number of sent packets (incl. forwarded packets)

int BaseOverlay::numSignalingForwarded [protected]

number of forwarded signaling packets

int BaseOverlay::numSignalingReceived [private]

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

int BaseOverlay::numSignalingSent [private]

number of sent signaling packets (incl. forwarded packets)

bool BaseOverlay::onlyCommonAPIMessages [protected]

drop non-commonAPIMessages ?

int BaseOverlay::rpcsPending [private]

RpcStates BaseOverlay::rpcStates [private]

cGate* BaseOverlay::thisInGateArray [private]

in-gate array for vis. overlay topology

NodeHandle BaseOverlay::thisNode [protected]

NodeHandle to this node.

Reimplemented in Gia.

cGate* BaseOverlay::thisOutGateArray [private]

out-gate array for vis. overlay topology

cModule* BaseOverlay::thisTerminal [protected]

pointer to corresponding node

UnderlayConfigurator* BaseOverlay::underlayConfigurator [protected]

pointer to UnderlayConfigurator in this node

bool BaseOverlay::useBaseLookup [protected]

use the base lookup class


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:37:06 2007 for ITM OverSim by  doxygen 1.4.7