OverSim
BasePastry Class Reference

#include <BasePastry.h>

Inheritance diagram for BasePastry:
BaseOverlay ProxListener BaseRpc BaseTcpSupport TopologyVis RpcListener Bamboo Pastry

Classes

struct  PingContext

Public Member Functions

virtual ~BasePastry ()
int getMaxNumSiblings ()
 Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay protocol.
int getMaxNumRedundantNodes ()
 Query the maximum number of redundant next hop nodes that are returned by findNode().
virtual void handleAppMessage (BaseOverlayMessage *msg)
 processes messages from application
virtual void updateTooltip ()
 updates information shown in tk-environment
virtual NodeVectorfindNode (const OverlayKey &key, int numRedundantNodes, int numSiblings, BaseOverlayMessage *msg)
 Implements the find node call.
virtual void handleStateMessage (PastryStateMessage *msg)=0
 processes state messages, merging with own state tables
virtual void finishOverlay ()
 collects statistical data in derived class
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 AbstractLookupcreateLookup (RoutingType routingType=DEFAULT_ROUTING, const BaseOverlayMessage *msg=NULL, const cPacket *dummy=NULL, bool appLookup=false)
 Creates an abstract iterative lookup instance.
uint8_t getBitsPerDigit ()
void proxCallback (const TransportAddress &node, int rpcId, cPolymorphic *contextPointer, Prox prox)
virtual OverlayKey estimateMeanDistance ()
 returns mean distance between OverlayKeys in the network
uint8_t getRTLastRow () const
std::vector< TransportAddress > * getRTRow (uint8_t index) const
std::vector< TransportAddress > * getLeafSet () const
- Public Member Functions inherited from BaseOverlay
 BaseOverlay ()
virtual ~BaseOverlay ()
 Virtual destructor.
States getState ()
bool isMalicious ()
 Returns true, if node is malicious.
bool isInSimpleMultiOverlayHost ()
 Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.
const simtime_t & getCreationTime ()
void join (const OverlayKey &nodeID=OverlayKey::UNSPECIFIED_KEY)
 Join the overlay with a given nodeID.
virtual NodeVectorlocal_lookup (const OverlayKey &key, int num, bool safe)
 finds nodes closest to the given OverlayKey
virtual NodeVectorneighborSet (int num)
void sendMessageToUDP (const TransportAddress &dest, cPacket *msg, simtime_t delay=SIMTIME_ZERO)
 Sends message to underlay.
void sendToKey (const OverlayKey &key, BaseOverlayMessage *message, int numSiblings=1, const std::vector< TransportAddress > &sourceRoute=TransportAddress::UNSPECIFIED_NODES, RoutingType routingType=DEFAULT_ROUTING)
 Sends a message to an overlay node, with the generic routing algorithm.
void registerComp (CompType compType, cModule *module)
cModule * getCompModule (CompType compType)
cGate * getCompRpcGate (CompType compType)
void sendMessageToAllComp (cMessage *msg, CompType srcComp)
bool providesKbr ()
bool getMeasureAuthBlock ()
BootstrapListgetBootstrapList () const
virtual uint32_t estimateOverlaySize ()
 estimates the current number of nodes online
- Public Member Functions inherited from BaseRpc
 BaseRpc ()
const NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
simtime_t getUdpTimeout ()
- Public Member Functions inherited from RpcListener
virtual ~RpcListener ()
 destructor
- Public Member Functions inherited from BaseTcpSupport
virtual void socketDataArrived (int connId, void *yourPtr, cPacket *msg, bool urgent)
virtual void socketEstablished (int connId, void *yourPtr)
virtual void socketPeerClosed (int connId, void *yourPtr)
virtual void socketFailure (int connId, void *yourPtr, int code)
virtual void socketStatusArrived (int connId, void *yourPtr, TCPStatusInfo *status)
- Public Member Functions inherited from TopologyVis
 TopologyVis ()
void showOverlayNeighborArrow (const NodeHandle &neighbor, bool flush=true, const char *displayString=NULL)
 Draws an arrow from this node to neighbor.
void deleteOverlayNeighborArrow (const NodeHandle &neighbor)
 Removes an arrow from this node to neighbor.

Public Attributes

int joins
int joinTries
int joinPartial
int joinSeen
int joinBytesSeen
int joinReceived
int joinBytesReceived
int joinSent
int joinBytesSent
int stateSent
int stateBytesSent
int stateReceived
int stateBytesReceived
int repairReqSent
int repairReqBytesSent
int repairReqReceived
int repairReqBytesReceived
int stateReqSent
int stateReqBytesSent
int stateReqReceived
int stateReqBytesReceived
int totalLookups
int responsibleLookups
int routingTableLookups
int closerNodeLookups
int closerNodeLookupsFromNeighborhood
int leafsetReqSent
int leafsetReqBytesSent
int leafsetReqReceived
int leafsetReqBytesReceived
int leafsetSent
int leafsetBytesSent
int leafsetReceived
int leafsetBytesReceived
int routingTableRowReqSent
int routingTableRowReqBytesSent
int routingTableRowReqReceived
int routingTableRowReqBytesReceived
int routingTableRowSent
int routingTableRowBytesSent
int routingTableRowReceived
int routingTableRowBytesReceived

Protected Types

enum  StateObject { ROUTINGTABLE, LEAFSET, NEIGHBORHOODSET }
enum  { PING_RECEIVED_STATE = 1, PING_NEXT_HOP = 2, PING_SINGLE_NODE = 3, PING_DISCOVERY = 4 }
- Protected Types inherited from BaseOverlay
typedef UNORDERED_SET
< AbstractLookup
*, lookupHashFcn,
lookupHashFcn
LookupSet

Protected Member Functions

virtual void changeState (int toState)
 changes node state
virtual bool handleRpcCall (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invocation messages.
virtual void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
virtual void handleRpcTimeout (BaseCallMessage *call, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &key)
 This method is called if an RPC timeout has been reached.
void handleRequestLeafSetCall (RequestLeafSetCall *call)
void handleRequestRoutingRowCall (RequestRoutingRowCall *call)
virtual void handleRequestLeafSetResponse (RequestLeafSetResponse *response)
virtual void handleRequestRoutingRowResponse (RequestRoutingRowResponse *response)
PastryStateMessagecreateStateMessage (enum PastryStateMsgType type=PASTRY_STATE_STD, simtime_t timestamp=-1, int16_t row=-1, bool lastHop=false)
virtual void checkProxCache (void)=0
 checks whether proxCache is complete, takes appropriate actions depending on the protocol state
virtual void purgeVectors (void)
 delete all information/messages caching vectors, used for restarting overlay or finish()
void baseInit (void)
 initializes parameters and variables used in both Bamboo and Pastry
void baseChangeState (int)
 changes node state, but leaves specific behavour, scheduling tasks in particular, to the inheriting protocols
OverlayKey distance (const OverlayKey &x, const OverlayKey &y, bool useAlternative=false) const
 This method should implement the distance between two keys.
virtual void iterativeJoinHook (BaseOverlayMessage *msg, bool incrHopCount)
void prePing (const PastryStateMessage *stateMsg)
 ping all nodes in a given state message.
void pingNodes (void)
 ping all nodes in the pastry state message pointed to by private member stateCache
void determineAliveTable (const PastryStateMessage *stateMsg)
 change the aliveTable to match the given stateMsg.
void newLeafs (void)
 Pastry API: send newLeafs() to application if enabled.
- Protected Member Functions inherited from BaseOverlay
int numInitStages () const
 Sets init stage.
virtual void initializeOverlay (int stage)
 Initializes derived-class-attributes.
void bindToPort (int port)
 Tells UDP we want to get all packets arriving on the given port.
virtual void route (const OverlayKey &key, CompType destComp, CompType srcComp, cPacket *msg, const std::vector< TransportAddress > &sourceRoute=TransportAddress::UNSPECIFIED_NODES, RoutingType routingType=DEFAULT_ROUTING)
 Routes message through overlay.
void callDeliver (BaseOverlayMessage *msg, const OverlayKey &destKey)
 Calls deliver function in application.
void callForward (const OverlayKey &key, BaseRouteMessage *msg, const NodeHandle &nextHopNode)
 Calls forward function in application.
void callUpdate (const NodeHandle &node, bool joined)
 Informs application about state changes of nodes or newly joined nodes.
void handleMessage (cMessage *msg)
 Checks for message type and calls corresponding method.
void handleBaseOverlayMessage (BaseOverlayMessage *msg, const OverlayKey &destKey=OverlayKey::UNSPECIFIED_KEY)
 Handles a BaseOverlayMessage

virtual void handleUDPMessage (BaseOverlayMessage *msg)
 Processes messages from underlay.
virtual void handleAppMessage (cMessage *msg)
 Processes "timer" self-messages.
virtual void receiveChangeNotification (int category, const cPolymorphic *details)
 callback-method for events at the NotificationBoard
virtual void handleTransportAddressChangedNotification ()
 This method gets call if the node has a new TransportAddress (IP address) because he changed his access network.
virtual void handleNodeLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed.
virtual void handleNodeGracefulLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.
virtual void recordOverlaySentStats (BaseOverlayMessage *msg)
 Collect overlay specific sent messages statistics.
void setOverlayReady (bool ready)
 Sets the overlay ready icon and register/deregisters the node at the GlobalNodeList.
virtual void removeLookup (AbstractLookup *lookup)
 Removes the abstract lookup instance.
virtual void joinOverlay ()
 Join the overlay with a given nodeID in thisNode.key.
virtual void joinForeignPartition (const NodeHandle &node)
 Join another overlay partition with the given node as bootstrap node.
virtual bool handleFailedNode (const TransportAddress &failed)
 Handles a failed node.
virtual void lookupRpc (LookupCall *call)
virtual void nextHopRpc (NextHopCall *call)
void countFindNodeCall (const FindNodeCall *call)
void countFailedNodeCall (const FailedNodeCall *call)
bool internalHandleRpcCall (BaseCallMessage *msg)
 Handles internal rpc requests.
void internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 Handles rpc responses internal in base classes

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

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

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

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

Protected Attributes

uint32_t bitsPerDigit
uint32_t numberOfLeaves
uint32_t numberOfNeighbors
double readyWaitAmount
double joinTimeoutAmount
double repairTimeout
bool enableNewLeafs
bool useRegularNextHop
bool alwaysSendUpdate
bool optimizeLookup
bool proximityNeighborSelection
simtime_t nearNodeRtt
bool nearNodeImproved
bool periodicMaintenance
TransportAddressleaf2ask
TransportAddress bootstrapNode
TransportAddress nearNode
simtime_t lastStateChange
PastryStateMsgHandle stateCache
 Handle for processing a single state message.
std::queue< PastryStateMsgHandlestateCacheQueue
 Queue of state messages waiting to be processed in READY state.
PastryStateMsgProximity aliveTable
 Early update of leaf set: helper structure for marking known-dead nodes.
uint32_t joinHopCount
cMessage * readyWait
cMessage * joinUpdateWait
PastryRoutingTableroutingTable
PastryLeafSetleafSet
PastryNeighborhoodSetneighborhoodSet
- Protected Attributes inherited from BaseOverlay
int numAppDataForwarded
 number of forwarded app data packets
int bytesAppDataForwarded
 number of forwarded app data bytes at out-gate
int numAppLookupForwarded
 number of forwarded app lookup packets
int bytesAppLookupForwarded
 number of forwarded app lookup bytes at out-gate
int numMaintenanceForwarded
 number of forwarded maintenance packets
int bytesMaintenanceForwarded
 number of forwarded maintenance bytes at out-gate
int numFindNodeSent
int bytesFindNodeSent
int numFindNodeResponseSent
int bytesFindNodeResponseSent
int numFailedNodeSent
int bytesFailedNodeSent
int numFailedNodeResponseSent
int bytesFailedNodeResponseSent
std::vector< HopDelayRecord * > singleHopDelays
simtime_t creationTime
 simtime when the node has been created
GlobalNodeListglobalNodeList
 pointer to GlobalNodeList in this node
NotificationBoard * notificationBoard
 pointer to NotificationBoard in this node
UnderlayConfiguratorunderlayConfigurator
 pointer to UnderlayConfigurator in this node
BootstrapListbootstrapList
 pointer to the BootstrapList module
GlobalParametersglobalParameters
 pointer to the GlobalParameters module
uint32_t overlayId
 identifies the overlay this node belongs to (used for multiple overlays)
bool debugOutput
 debug output ?
RoutingType defaultRoutingType
bool useCommonAPIforward
 forward messages to applications?
bool collectPerHopDelay
 collect delay for single hops
bool routeMsgAcks
 send ACK when receiving route message
uint32_t recNumRedundantNodes
 numRedundantNodes for recursive routing
bool recordRoute
 record visited hops on route
bool drawOverlayTopology
bool rejoinOnFailure
bool sendRpcResponseToLastHop
 needed by KBR protocols for NAT support
bool dropFindNodeAttack
 if node is malicious, it tries a findNode attack
bool isSiblingAttack
 if node is malicious, it tries a isSibling attack
bool invalidNodesAttack
 if node is malicious, it tries a invalidNode attack
bool dropRouteMessageAttack
 if node is malicious, it drops all received BaseRouteMessages
int localPort
 used UDP-port
int hopCountMax
 maximum hop count
bool measureAuthBlock
 if true, measure the overhead of signatures in rpc messages
bool restoreContext
 if true, a node rejoins with its old nodeId and malicious state
int numDropped
 number of dropped packets
int bytesDropped
 number of dropped bytes
cOutVector delayVector
 statistical output vector for packet-delays
cOutVector hopCountVector
 statistical output vector for hop-counts
States state
IterativeLookupConfiguration iterativeLookupConfig
RecursiveLookupConfiguration recursiveLookupConfig
LookupSet lookups
bool kbr
 set this to true, if the overlay provides KBR services
- Protected Attributes inherited from BaseRpc
NodeHandle thisNode
 NodeHandle to this node.
BaseOverlayoverlay
bool debugOutput
 debug output ?
GlobalStatisticsglobalStatistics
 pointer to GlobalStatistics module in this node
CompType thisCompType
NeighborCacheneighborCache
 pointer to the neighbor cache
CryptoModulecryptoModule
 pointer to CryptoModule
int numPingSent
int bytesPingSent
int numPingResponseSent
int bytesPingResponseSent
- Protected Attributes inherited from TopologyVis
cModule * thisTerminal
GlobalNodeListglobalNodeList
 pointer to corresponding node

Friends

class PastryLeafSet

Additional Inherited Members

- Public Types inherited from BaseOverlay
enum  States {
  INIT = 0, BOOTSTRAP = 1, DISCOVERY = 2, PREJOIN = 3,
  JOIN = 4, POSTJOIN = 5, READY = 6, REFRESH = 7,
  SHUTDOWN = 8, FAILED = 9, RSET = JOIN, BSET = POSTJOIN
}

Detailed Description

Definition at line 49 of file BasePastry.h.

Member Enumeration Documentation

anonymous enum
protected
Enumerator:
PING_RECEIVED_STATE 
PING_NEXT_HOP 
PING_SINGLE_NODE 
PING_DISCOVERY 

Definition at line 285 of file BasePastry.h.

enum BasePastry::StateObject
protected
Enumerator:
ROUTINGTABLE 
LEAFSET 
NEIGHBORHOODSET 

Definition at line 267 of file BasePastry.h.

Constructor & Destructor Documentation

BasePastry::~BasePastry ( )
virtual

Definition at line 808 of file BasePastry.cc.

{
}

Member Function Documentation

void BasePastry::baseChangeState ( int  toState)
protected

changes node state, but leaves specific behavour, scheduling tasks in particular, to the inheriting protocols

Definition at line 187 of file BasePastry.cc.

Referenced by Bamboo::changeState(), and Pastry::changeState().

{
switch (toState) {
case INIT:
lastStateChange = simTime();
getParentModule()->getParentModule()->bubble("entering INIT state");
break;
case JOIN:
// bootstrapNode must be obtained before calling this method,
// for example by calling changeState(INIT)
// no existing pastry network -> first node of a new one
return;
}
getParentModule()->getParentModule()->bubble("entering JOIN state");
break;
case READY:
assert(state != READY);
// if we are the first node in the network,
// there's nothing else to do
return;
}
getParentModule()->getParentModule()->bubble("entering READY state");
break;
default: // discovery
break;
}
}
void BasePastry::baseInit ( void  )
protected

initializes parameters and variables used in both Bamboo and Pastry

Definition at line 57 of file BasePastry.cc.

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

{
bitsPerDigit = par("bitsPerDigit");
numberOfLeaves = par("numberOfLeaves");
numberOfNeighbors = par("numberOfNeighbors");
joinTimeoutAmount = par("joinTimeout");
repairTimeout = par("repairTimeout");
enableNewLeafs = par("enableNewLeafs");
optimizeLookup = par("optimizeLookup");
useRegularNextHop = par("useRegularNextHop");
alwaysSendUpdate = par("alwaysSendUpdate");
proximityNeighborSelection = par("proximityNeighborSelection");
throw cRuntimeError("NeighborCache is disabled, which is mandatory "
"for Pastry/Bamboo. Activate it by setting "
"\"**.neighborCache.enableNeighborCache "
"= true\" in your omnetpp.ini!");
}
if (numberOfLeaves % 2) {
EV << "[BasePastry::baseInit() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Warning: numberOfLeaves must be even - adding 1."
<< endl;
}
routingTable = check_and_cast<PastryRoutingTable*>
(getParentModule()->getSubmodule("pastryRoutingTable"));
leafSet = check_and_cast<PastryLeafSet*>
(getParentModule()->getSubmodule("pastryLeafSet"));
(getParentModule()->getSubmodule("pastryNeighborhoodSet"));
stateCache.msg = NULL;
stateCache.prox = NULL;
// initialize statistics
joins = 0;
joinTries = 0;
joinSeen = 0;
joinSent = 0;
stateSent = 0;
WATCH(joins);
WATCH(joinTries);
WATCH(joinSeen);
WATCH(joinBytesSeen);
WATCH(joinReceived);
WATCH(joinSent);
WATCH(joinBytesSent);
WATCH(stateSent);
WATCH(stateReceived);
WATCH(repairReqSent);
WATCH(stateReqSent);
WATCH(leafsetSent);
WATCH_PTR(stateCache.msg);
}
virtual void BasePastry::changeState ( int  toState)
inlineprotectedvirtual

changes node state

Parameters
toStatestate to change to

Reimplemented in Pastry, and Bamboo.

Definition at line 162 of file BasePastry.h.

Referenced by baseChangeState().

{ };
virtual void BasePastry::checkProxCache ( void  )
protectedpure virtual

checks whether proxCache is complete, takes appropriate actions depending on the protocol state

Referenced by pingNodes(), and proxCallback().

AbstractLookup * BasePastry::createLookup ( RoutingType  routingType = DEFAULT_ROUTING,
const BaseOverlayMessage msg = NULL,
const cPacket *  findNodeExt = NULL,
bool  appLookup = false 
)
virtual

Creates an abstract iterative lookup instance.

Parameters
routingTypeThe routing type for this lookup (e.g. recursive/iterative)
msgpointer to the message for which the lookup is created. Derived classes can use it to construct an object with additional info for the lookup class.
findNodeExtobject that will be sent with the findNodeCalls
appLookupSet to true, if lookup is triggered by application (for statistics)
Returns
AbstractLookup* The new lookup instance.

Reimplemented from BaseOverlay.

Definition at line 1020 of file BasePastry.cc.

Referenced by Bamboo::doGlobalTuning().

{
assert(dummy == NULL);
PastryFindNodeExtData* findNodeExt =
new PastryFindNodeExtData("findNodeExt");
if (msg &&
dynamic_cast<const PastryJoinCall*>(msg->getEncapsulatedPacket())) {
const PastryJoinCall* joinCall =
static_cast<const PastryJoinCall*>(msg->getEncapsulatedPacket());
assert(!joinCall->getSrcNode().isUnspecified());
findNodeExt->setSendStateTo(joinCall->getSrcNode());
findNodeExt->setJoinHopCount(1);
}
findNodeExt->setBitLength(PASTRYFINDNODEEXTDATA_L);
AbstractLookup* newLookup = BaseOverlay::createLookup(routingType,
msg, findNodeExt,
appLookup);
delete findNodeExt;
return newLookup;
}
PastryStateMessage * BasePastry::createStateMessage ( enum PastryStateMsgType  type = PASTRY_STATE_STD,
simtime_t  timestamp = -1,
int16_t  row = -1,
bool  lastHop = false 
)
protected

Definition at line 664 of file BasePastry.cc.

Referenced by Bamboo::changeState(), Pastry::doJoinUpdate(), Bamboo::doLeafsetMaintenance(), Pastry::doSecondStage(), Pastry::endProcessingState(), Pastry::handlePastryJoinCall(), handleRequestLeafSetCall(), Pastry::handleRequestRepairCall(), handleRequestRoutingRowCall(), Pastry::handleRequestStateCall(), Pastry::handleTimerEvent(), Pastry::iterativeJoinHook(), and Pastry::recursiveRoutingHook().

{
//checks
((row == -1) || (timestamp != -1))) {
throw cRuntimeError("Creating JOIN State without hopCount"
" or with timestamp!");
} else if ((type & (PASTRY_STATE_ROUTINGROW)) && row == -1) {
throw cRuntimeError("Creating ROUTINGROW State without row!");
} else if ((type & (PASTRY_STATE_UPDATE)) &&
timestamp == -1) {
throw cRuntimeError("Creating UPDATE/REPAIR State without timestamp!");
} else if ((type & (PASTRY_STATE_LEAFSET | PASTRY_STATE_STD |
((row != -1) || (timestamp != -1))) {
throw cRuntimeError("Creating STD/UPDATE State with row/hopCount"
" or timestamp!");
}
std::string typeStr = cEnum::get("PastryStateMsgType")->getStringFor(type);
typeStr.erase(0, 13);
EV << "[BasePastry::sendStateTables() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " creating new state message (" << typeStr << ")" //TODO
<< endl;
// create new state msg and set special fields for some types:
PastryStateMessage* stateMsg =
new PastryStateMessage((std::string("STATE (") + typeStr + ")").c_str());
stateMsg->setTimestamp((timestamp == -1) ? simTime() : timestamp);
if (type == PASTRY_STATE_JOIN || type == PASTRY_STATE_MINJOIN) {
stateMsg->setRow(row);
stateMsg->setLastHop(lastHop);
}
// fill in standard content:
stateMsg->setPastryStateMsgType(type);
stateMsg->setSender(thisNode);
// the following part of the new join works on the assumption,
// that the node routing the join message is close to the joining node
// therefore it should be switched on together with the discovery algorithm
if (type == PASTRY_STATE_MINJOIN) {
//send just the needed row for new join protocol
routingTable->dumpRowToMessage(stateMsg, row);
if (lastHop) {
} else {
stateMsg->setLeafSetArraySize(0);
}
if (row == 1) {
} else {
}
} else if (type == PASTRY_STATE_LEAFSET) {
} else if (type == PASTRY_STATE_ROUTINGROW) {
routingTable->dumpRowToMessage(stateMsg, row);
} else {
}
stateMsg->setBitLength(PASTRYSTATE_L(stateMsg));
return stateMsg;
}
void BasePastry::determineAliveTable ( const PastryStateMessage stateMsg)
protected

change the aliveTable to match the given stateMsg.

each node that's knowm to be dead from our neighborCache gets a value of PASTRY_PROX_INFINITE, all other nodes just get a value of 1

Definition at line 438 of file BasePastry.cc.

Referenced by Pastry::handleStateMessage(), and Bamboo::handleStateMessage().

{
uint32_t rt_size = stateMsg->getRoutingTableArraySize();
aliveTable.pr_rt.clear();
aliveTable.pr_rt.resize(rt_size, 1);
uint32_t ls_size = stateMsg->getLeafSetArraySize();
aliveTable.pr_ls.clear();
aliveTable.pr_ls.resize(ls_size, 1);
uint32_t ns_size = stateMsg->getNeighborhoodSetArraySize();
aliveTable.pr_ns.clear();
aliveTable.pr_ns.resize(ns_size, 1);
for (uint32_t i = 0; i < rt_size + ls_size + ns_size; i++) {
const TransportAddress* node;
std::vector<simtime_t>::iterator tblPos;
if (i < rt_size) {
node = &(stateMsg->getRoutingTable(i));
tblPos = aliveTable.pr_rt.begin() + i;
} else if ( i < (rt_size + ls_size) ) {
node = &(stateMsg->getLeafSet(i - rt_size));
tblPos = aliveTable.pr_ls.begin() + (i - rt_size);
} else {
node = &(stateMsg->getNeighborhoodSet(i - rt_size - ls_size));
tblPos = aliveTable.pr_ns.begin() + (i - rt_size - ls_size);
}
if (node->isUnspecified()) {
*tblPos = PASTRY_PROX_UNDEF;
} else if (neighborCache->getProx(*node,
}
}
}
OverlayKey BasePastry::distance ( const OverlayKey x,
const OverlayKey y,
bool  useAlternative = false 
) const
protectedvirtual

This method should implement the distance between two keys.

It may be overloaded to implement a new metric. The default implementation uses the standard-metric d = abs(x-y).

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

Reimplemented from BaseOverlay.

Definition at line 1110 of file BasePastry.cc.

{
if (!useAlternative) return KeyRingMetric().distance(x, y);
return KeyPrefixMetric().distance(x, y);
}
OverlayKey BasePastry::estimateMeanDistance ( )
virtual

returns mean distance between OverlayKeys in the network

Returns
mean distance

Reimplemented from BaseOverlay.

Definition at line 1103 of file BasePastry.cc.

NodeVector * BasePastry::findNode ( const OverlayKey key,
int  numRedundantNodes,
int  numSiblings,
BaseOverlayMessage msg 
)
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
keyThe lookup key.
numRedundantNodesMaximum number of next hop nodes to return.
numSiblingsnumber of siblings to return
msgA pointer to the BaseRouteMessage or FindNodeCall message of this lookup.
Returns
NodeVector with closest nodes.

Reimplemented from BaseOverlay.

Definition at line 906 of file BasePastry.cc.

{
if ((numRedundantNodes > getMaxNumRedundantNodes()) ||
(numSiblings > getMaxNumSiblings())) {
opp_error("(Pastry::findNode()) numRedundantNodes or numSiblings "
"too big!");
}
NodeVector* nextHops = new NodeVector(numRedundantNodes);
if (state != READY) {
return nextHops;
} else if (key.isUnspecified() || leafSet->isClosestNode(key)) {
nextHops->add(thisNode);
} else {
const NodeHandle* next = &(leafSet->getDestinationNode(key));
if (next->isUnspecified()) {
next = &(routingTable->lookupNextHop(key));
if (!next->isUnspecified()) {
}
} else {
}
if (next->isUnspecified()) {
// call findCloserNode() on all state objects
const NodeHandle* tmp;
next = &(routingTable->findCloserNode(key, true));
tmp = &(neighborhoodSet->findCloserNode(key, true));
if ((! tmp->isUnspecified()) &&
(leafSet->isCloser(*tmp, key, *next))) {
next = tmp;
}
tmp = &(leafSet->findCloserNode(key, true));
if ((! tmp->isUnspecified()) &&
(leafSet->isCloser(*tmp, key, *next))) {
next = tmp;
}
} else {
next = &(routingTable->findCloserNode(key));
if (next->isUnspecified()) {
}
if (next->isUnspecified()) {
next = &(leafSet->findCloserNode(key));
}
}
}
if (!next->isUnspecified()) {
nextHops->add(*next);
}
}
bool err;
// if we're a sibling, return all numSiblings
if ((numSiblings >= 0) && isSiblingFor(thisNode, key, numSiblings, &err)) {
if (err == false) {
delete nextHops;
return leafSet->createSiblingVector(key, numSiblings);
}
}
if (/*(nextHops->size() > 0) &&*/ (numRedundantNodes > 1)) {
//memleak... comp should be a ptr and deleted in NodeVector::~NodeVector()...
//KeyDistanceComparator<KeyRingMetric>* comp =
// new KeyDistanceComparator<KeyRingMetric>( key );
//KeyDistanceComparator<KeyPrefixMetric> comp(key);
NodeVector* additionalHops = new NodeVector( numRedundantNodes, &comp );
routingTable->findCloserNodes(key, additionalHops);
leafSet->findCloserNodes(key, additionalHops);
neighborhoodSet->findCloserNodes(key, additionalHops);
if (useRegularNextHop && (nextHops->size() > 0) &&
(*additionalHops)[0] != (*nextHops)[0]) {
for (uint32_t i = 0; i < additionalHops->size(); i++) {
if ((*additionalHops)[i] != (*nextHops)[0])
nextHops->push_back((*additionalHops)[i]);
}
delete additionalHops;
} else {
delete nextHops;
return additionalHops;
}
}
return nextHops;
}
void BasePastry::finishOverlay ( )
virtual

collects statistical data in derived class

Reimplemented from BaseOverlay.

Definition at line 813 of file BasePastry.cc.

{
// remove this node from the bootstrap list
// collect statistics
if (time < GlobalStatistics::MIN_MEASURED) return;
// join statistics: only evaluate join from nodes
// that have been created in measurement phase
time >= (simTime() - creationTime)) {
// join is on the way...
if (joinTries > 0 && state == JOIN) joinTries--;
if (joinTries > 0) {
globalStatistics->addStdDev("BasePastry: join success ratio", (double)joins / (double)joinTries);
globalStatistics->addStdDev("BasePastry: join tries", joinTries);
}
}
// TODO new methods Pastry::finnishOverlay() / Bamboo::finishOverlay()
globalStatistics->addStdDev("Pastry: joins with missing replies from routing path/s",
joinPartial / time);
globalStatistics->addStdDev("Pastry: JOIN Messages seen/s", joinSeen / time);
globalStatistics->addStdDev("Pastry: bytes of JOIN Messages seen/s", joinBytesSeen / time);
globalStatistics->addStdDev("Pastry: JOIN Messages received/s", joinReceived / time);
globalStatistics->addStdDev("Pastry: bytes of JOIN Messages received/s",
globalStatistics->addStdDev("Pastry: JOIN Messages sent/s", joinSent / time);
globalStatistics->addStdDev("Pastry: bytes of JOIN Messages sent/s", joinBytesSent / time);
globalStatistics->addStdDev("Pastry: REPAIR Requests sent/s", repairReqSent / time);
globalStatistics->addStdDev("Pastry: bytes of REPAIR Requests sent/s",
globalStatistics->addStdDev("Pastry: REPAIR Requests received/s", repairReqReceived / time);
globalStatistics->addStdDev("Pastry: bytes of REPAIR Requests received/s",
globalStatistics->addStdDev("Pastry: STATE Requests sent/s", stateReqSent / time);
globalStatistics->addStdDev("Pastry: bytes of STATE Requests sent/s", stateReqBytesSent / time);
globalStatistics->addStdDev("Pastry: STATE Requests received/s", stateReqReceived / time);
globalStatistics->addStdDev("Pastry: bytes of STATE Requests received/s",
globalStatistics->addStdDev("Pastry: STATE Messages sent/s", stateSent / time);
globalStatistics->addStdDev("Pastry: bytes of STATE Messages sent/s", stateBytesSent / time);
globalStatistics->addStdDev("Pastry: STATE Messages received/s", stateReceived / time);
globalStatistics->addStdDev("Pastry: bytes of STATE Messages received/s",
globalStatistics->addStdDev("BasePastry: LEAFSET Requests sent/s", leafsetReqSent / time);
globalStatistics->addStdDev("BasePastry: bytes of LEAFSET Requests sent/s", leafsetReqBytesSent / time);
globalStatistics->addStdDev("BasePastry: LEAFSET Requests received/s", leafsetReqReceived / time);
globalStatistics->addStdDev("BasePastry: bytes of LEAFSET Requests received/s",
globalStatistics->addStdDev("BasePastry: LEAFSET Messages sent/s", leafsetSent / time);
globalStatistics->addStdDev("BasePastry: bytes of LEAFSET Messages sent/s", leafsetBytesSent / time);
globalStatistics->addStdDev("BasePastry: LEAFSET Messages received/s", leafsetReceived / time);
globalStatistics->addStdDev("BasePastry: bytes of LEAFSET Messages received/s",
globalStatistics->addStdDev("BasePastry: ROUTING TABLE ROW Requests sent/s", routingTableRowReqSent / time);
globalStatistics->addStdDev("BasePastry: bytes of ROUTING TABLE ROW Requests sent/s", routingTableRowReqBytesSent / time);
globalStatistics->addStdDev("BasePastry: ROUTING TABLE ROW Requests received/s", routingTableRowReqReceived / time);
globalStatistics->addStdDev("BasePastry: bytes of ROUTING TABLE ROW Requests received/s",
globalStatistics->addStdDev("BasePastry: ROUTING TABLE ROW Messages sent/s", routingTableRowSent / time);
globalStatistics->addStdDev("BasePastry: bytes of ROUTING TABLE ROW Messages sent/s", routingTableRowBytesSent / time);
globalStatistics->addStdDev("BasePastry: ROUTING TABLE ROW Messages received/s", routingTableRowReceived / time);
globalStatistics->addStdDev("BasePastry: bytes of ROUTING TABLE ROW Messages received/s",
globalStatistics->addStdDev("BasePastry: total number of lookups", totalLookups);
globalStatistics->addStdDev("BasePastry: responsible lookups", responsibleLookups);
globalStatistics->addStdDev("BasePastry: lookups in routing table", routingTableLookups);
globalStatistics->addStdDev("BasePastry: lookups using closerNode()", closerNodeLookups);
globalStatistics->addStdDev("BasePastry: lookups using closerNode() with result from "
"neighborhood set", closerNodeLookupsFromNeighborhood);
}
uint8_t BasePastry::getBitsPerDigit ( )
inlinevirtual

Reimplemented from BaseOverlay.

Definition at line 101 of file BasePastry.h.

{ return bitsPerDigit; };
std::vector< TransportAddress > * BasePastry::getLeafSet ( ) const

Definition at line 1068 of file BasePastry.cc.

Referenced by DiscoveryMode::handleRpcCall().

{
std::vector<TransportAddress>* ret = new std::vector<TransportAddress>;
return ret;
};
int BasePastry::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 from BaseOverlay.

Definition at line 900 of file BasePastry.cc.

Referenced by findNode().

{
return (int)floor(numberOfLeaves);
}
int BasePastry::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 from BaseOverlay.

Definition at line 894 of file BasePastry.cc.

Referenced by findNode().

{
return (int)floor(numberOfLeaves / 2.0);
}
uint8_t BasePastry::getRTLastRow ( ) const

Definition at line 1056 of file BasePastry.cc.

Referenced by DiscoveryMode::handleRpcCall().

{
};
std::vector< TransportAddress > * BasePastry::getRTRow ( uint8_t  index) const

Definition at line 1062 of file BasePastry.cc.

Referenced by DiscoveryMode::handleRpcCall().

{
return routingTable->getRow(index);
};
void BasePastry::handleAppMessage ( BaseOverlayMessage msg)
virtual

processes messages from application

Parameters
msgmessage from application

Definition at line 779 of file BasePastry.cc.

{
delete msg;
}
void BasePastry::handleRequestLeafSetCall ( RequestLeafSetCall call)
protected

Definition at line 543 of file BasePastry.cc.

Referenced by handleRpcCall().

{
EV << "[BasePastry::handleRequestLeafSetCall() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]"
<< endl;
leafsetReqBytesReceived += call->getByteLength());
if (state != READY) {
EV << " local node is NOT in READY state (call deleted)!" << endl;
delete call;
return;
}
new RequestLeafSetResponse("REQUEST LEAFSET Response");
response->setTimestamp(simTime());
response->setBitLength(PASTRYREQUESTLEAFSETRESPONSE_L(response));
response->encapsulate(createStateMessage(PASTRY_STATE_LEAFSET));
//merge leafset and sender's NodeHandle from call (if exists: PULL)
if (call->getEncapsulatedPacket()) {
EV << " ... it's a leafSet PULL message!" << endl;
PastryStateMessage* stateMsg =
check_and_cast<PastryStateMessage*>(call->decapsulate());
stateMsg->setLeafSetArraySize(stateMsg->getLeafSetArraySize() + 1);
stateMsg->setLeafSet(stateMsg->getLeafSetArraySize() - 1,
stateMsg->getSender());
handleStateMessage(stateMsg);
//set sender's NodeHandle in response if it was set in call (PULL/PUSH)
//response->setSender(thisNode);
response->setName("LeafSet PUSH");
}
leafsetBytesSent += response->getByteLength());
sendRpcResponse(call, response);
}
void BasePastry::handleRequestLeafSetResponse ( RequestLeafSetResponse response)
protectedvirtual

Reimplemented in Pastry, and Bamboo.

Definition at line 634 of file BasePastry.cc.

Referenced by handleRpcResponse().

{
EV << "[BasePastry::handleRequestLeafSetResponse() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]"
<< endl;
response->getByteLength());
if (state == READY) {
handleStateMessage(check_and_cast<PastryStateMessage*>(response->decapsulate()));
}
}
void BasePastry::handleRequestRoutingRowCall ( RequestRoutingRowCall call)
protected

Definition at line 591 of file BasePastry.cc.

Referenced by handleRpcCall().

{
EV << "[BasePastry::handleRequestRoutingRowCall() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]"
<< endl;
routingTableRowReqBytesReceived += call->getByteLength());
if (state == READY) {
// fill response with row entries
if (call->getRow() > routingTable->getLastRow()) {
EV << " received request for nonexistent routing"
<< "table row, dropping message!"
<< endl;
delete call;
} else {
new RequestRoutingRowResponse("REQUEST ROUTINGROW Response");
assert(call->getRow() >= -1 &&
call->getRow() <= routingTable->getLastRow());
response->setBitLength(PASTRYREQUESTROUTINGROWRESPONSE_L(response));
-1,
(call->getRow() == -1) ?
call->getRow()));
routingTableRowBytesSent += call->getByteLength());
sendRpcResponse(call, response);
}
} else {
EV << " received routing table request before reaching "
<< "READY state, dropping message!" << endl;
delete call;
}
}
void BasePastry::handleRequestRoutingRowResponse ( RequestRoutingRowResponse response)
protectedvirtual

Reimplemented in Pastry.

Definition at line 649 of file BasePastry.cc.

Referenced by handleRpcResponse().

{
EV << "[BasePastry::handleRequestRoutingRowResponse() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]"
<< endl;
routingTableRowBytesReceived += response->getByteLength());
if (state == READY) {
handleStateMessage(check_and_cast<PastryStateMessage*>(response->decapsulate()));
}
}
bool BasePastry::handleRpcCall ( BaseCallMessage msg)
protectedvirtual

Processes Remote-Procedure-Call invocation messages.


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

Returns
true, if rpc has been handled

Reimplemented from BaseRpc.

Reimplemented in Pastry.

Definition at line 476 of file BasePastry.cc.

Referenced by Pastry::handleRpcCall().

{
if (state != READY) {
EV << "[BasePastry::handleRpcCall() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Received RPC call and state != READY"
<< endl;
return false;
}
// delegate messages
// RPC_DELEGATE( <messageName>[Call|Response], <methodToCall> )
return RPC_HANDLED;
}
void BasePastry::handleRpcResponse ( BaseResponseMessage msg,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
)
protectedvirtual

This method is called if an RPC response has been received.

Parameters
msgThe response message.
contextPointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code
rpcIdThe RPC id.
rttThe Round-Trip-Time of this RPC

Reimplemented from RpcListener.

Reimplemented in Pastry, and Bamboo.

Definition at line 497 of file BasePastry.cc.

{
RPC_ON_RESPONSE( RequestLeafSet ) {
EV << "[BasePastry::handleRpcResponse() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Received a RequestLeafSet RPC Response: id=" << rpcId << "\n"
<< " msg=" << *_RequestLeafSetResponse << " rtt=" << SIMTIME_DBL(rtt)
<< endl;
BasePastry::handleRequestLeafSetResponse(_RequestLeafSetResponse);
break;
}
RPC_ON_RESPONSE( RequestRoutingRow ) {
EV << "[BasePastry::handleRpcResponse() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Received a RequestRoutingRow RPC Response: id=" << rpcId << "\n"
<< " msg=" << *_RequestRoutingRowResponse << " rtt=" << SIMTIME_DBL(rtt)
<< endl;
BasePastry::handleRequestRoutingRowResponse(_RequestRoutingRowResponse);
break;
}
}
void BasePastry::handleRpcTimeout ( BaseCallMessage msg,
const TransportAddress dest,
cPolymorphic *  context,
int  rpcId,
const OverlayKey destKey 
)
protectedvirtual

This method is called if an RPC timeout has been reached.

Parameters
msgThe original RPC message.
destThe destination node
contextPointer to an optional state object. The object has to be handled/deleted by the handleRpcResponse() code
rpcIdThe RPC id.
destKeythe destination OverlayKey

Reimplemented from RpcListener.

Reimplemented in Pastry.

Definition at line 524 of file BasePastry.cc.

{
EV << "[BasePastry::handleRpcTimeout() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Timeout of RPC Call: id=" << rpcId << "\n"
<< " msg=" << *call << " key=" << key
<< endl;
if (state == JOIN) {
join();
} else if (state == READY && !dest.isUnspecified() && key.isUnspecified()) {
}
}
virtual void BasePastry::handleStateMessage ( PastryStateMessage msg)
pure virtual

processes state messages, merging with own state tables

Parameters
msgthe pastry state message

Implemented in Bamboo, and Pastry.

Referenced by handleRequestLeafSetCall(), handleRequestLeafSetResponse(), and handleRequestRoutingRowResponse().

bool BasePastry::isSiblingFor ( const NodeHandle node,
const OverlayKey key,
int  numSiblings,
bool *  err 
)
virtual

Query if a node is among the siblings for a given key.

Query if a node is among the siblings for a given key. This means, that the nodeId of this node is among the closest numSiblings nodes to the key and that by a local findNode() call all other siblings to this key can be retrieved.

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

Reimplemented from BaseOverlay.

Definition at line 742 of file BasePastry.cc.

Referenced by findNode().

{
if (key.isUnspecified())
error("Pastry::isSiblingFor(): key is unspecified!");
if ((numSiblings == 1) && (node == thisNode)) {
if (leafSet->isClosestNode(key)) {
*err = false;
return true;
} else {
*err = false;
return false;
}
}
NodeVector* result = leafSet->createSiblingVector(key, numSiblings);
if (result == NULL) {
*err = true;
return false;
}
if (result->contains(node.getKey())) {
delete result;
*err = false;
return true;
} else {
delete result;
*err = true;
return false;
}
}
virtual void BasePastry::iterativeJoinHook ( BaseOverlayMessage msg,
bool  incrHopCount 
)
inlineprotectedvirtual

Reimplemented in Pastry.

Definition at line 264 of file BasePastry.h.

Referenced by findNode().

{ };
void BasePastry::newLeafs ( void  )
protected

Pastry API: send newLeafs() to application if enabled.

Definition at line 258 of file BasePastry.cc.

Referenced by Pastry::handleFailedNode(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), and Pastry::mergeState().

{
if (! enableNewLeafs) return;
if (msg) {
send(msg, "appOut");
EV << "[BasePastry::newLeafs() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " newLeafs() called."
<< endl;
}
}
void BasePastry::pingNodes ( void  )
protected

ping all nodes in the pastry state message pointed to by private member stateCache

Definition at line 369 of file BasePastry.cc.

Referenced by Bamboo::checkProxCache(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), and Pastry::processState().

{
EV << "[BasePastry::pingNodes() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]" << endl;
if (stateCache.msg == NULL) throw cRuntimeError("no state msg");
assert(stateCache.prox == NULL);
uint32_t rt_size = stateCache.msg->getRoutingTableArraySize();
uint32_t ls_size = stateCache.msg->getLeafSetArraySize();
// set prox state
for (uint32_t i = 0; i < rt_size + ls_size + ns_size; i++) {
const NodeHandle* node;
std::vector<simtime_t>::iterator proxPos;
PingContext* pingContext = NULL;
StateObject stateObject;
uint32_t index;
if (stateCache.msg == NULL) break;
if (i < rt_size) {
proxPos = stateCache.prox->pr_rt.begin() + i;
stateObject = ROUTINGTABLE;
index = i;
} else if ( i < (rt_size + ls_size) ) {
node = &(stateCache.msg->getLeafSet(i - rt_size));
proxPos = stateCache.prox->pr_ls.begin() + (i - rt_size);
stateObject = LEAFSET;
index = i - rt_size;
} else {
node = &(stateCache.msg->getNeighborhoodSet(i - rt_size - ls_size));
proxPos = stateCache.prox->pr_ns.begin() + (i - rt_size - ls_size);
stateObject = NEIGHBORHOODSET;
index = i - rt_size - ls_size;
}
// proximity is undefined for unspecified nodes:
if (!node->isUnspecified()) {
pingContext = new PingContext(stateObject, index,
this, pingContext);
if (prox == Prox::PROX_SELF) {
*proxPos = 0;
} else if ((prox == Prox::PROX_TIMEOUT) ||
(prox == Prox::PROX_UNKNOWN)) {
} else if (prox == Prox::PROX_WAITING) {
*proxPos = PASTRY_PROX_PENDING;
} else {
*proxPos = prox.proximity;
}
} else {
throw cRuntimeError("Undefined node in STATE message!");
}
}
}
void BasePastry::prePing ( const PastryStateMessage stateMsg)
protected

ping all nodes in a given state message.

this is called when a state message arrives while another one is still being processed.

Definition at line 342 of file BasePastry.cc.

Referenced by Pastry::doSecondStage(), Pastry::handleStateMessage(), and Bamboo::handleStateMessage().

{
uint32_t rt_size = stateMsg->getRoutingTableArraySize();
uint32_t ls_size = stateMsg->getLeafSetArraySize();
uint32_t ns_size = stateMsg->getNeighborhoodSetArraySize();
for (uint32_t i = 0; i < rt_size + ls_size + ns_size; i++) {
const NodeHandle* node;
if (i < rt_size) {
node = &(stateMsg->getRoutingTable(i));
}
else if (i < (rt_size + ls_size) ) {
node = &(stateMsg->getLeafSet(i - rt_size));
}
else {
node = &(stateMsg->getNeighborhoodSet(i - rt_size - ls_size));
}
if ((node->isUnspecified()) || (*node == thisNode)) {
continue;
}
PING_RECEIVED_STATE, this, NULL);
}
}
void BasePastry::proxCallback ( const TransportAddress node,
int  rpcId,
cPolymorphic *  contextPointer,
Prox  prox 
)
virtual

Implements ProxListener.

Definition at line 273 of file BasePastry.cc.

{
Enter_Method("proxCallback()");
EV << "[BasePastry::proxCallback() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Pong (or timeout) received (from "
<< node.getIp() << ")"
<< endl;
double rtt = ((prox == Prox::PROX_TIMEOUT) ? PASTRY_PROX_INFINITE
: prox.proximity);
// merge single pinged nodes (bamboo global tuning)
if (rpcId == PING_SINGLE_NODE) {
rtt : SimTime::getMaxTime());
delete contextPointer;
return;
}
if (contextPointer != NULL && stateCache.msg && stateCache.prox) {
PingContext* pingContext = check_and_cast<PingContext*>(contextPointer);
if (pingContext->nonce != stateCache.nonce) {
delete contextPointer;
return;
}
// handle failed node
if (rtt == PASTRY_PROX_INFINITE && state == READY) {
handleFailedNode(node); // TODO
// this could initiate a re-join, exit the handler in that
// case because all local data was erased:
if (state != READY) {
delete contextPointer;
return;
}
}
switch (pingContext->stateObject) {
assert(stateCache.prox->pr_rt.size() > pingContext->index);
*(stateCache.prox->pr_rt.begin() + pingContext->index) = rtt;
break;
case LEAFSET:
assert(stateCache.prox->pr_ls.size() > pingContext->index);
*(stateCache.prox->pr_ls.begin() + pingContext->index) = rtt;
break;
assert(stateCache.prox->pr_ns.size() > pingContext->index);
*(stateCache.prox->pr_ns.begin() + pingContext->index) = rtt;
break;
default:
throw cRuntimeError("wrong state object type!");
}
}
assert(stateCacheQueue.size() < 50);
delete contextPointer;
}
void BasePastry::purgeVectors ( void  )
protectedvirtual

delete all information/messages caching vectors, used for restarting overlay or finish()

Reimplemented in Pastry.

Definition at line 41 of file BasePastry.cc.

Referenced by baseChangeState(), and ~BasePastry().

{
// purge Queue for processing multiple STATE messages:
while (! stateCacheQueue.empty()) {
delete stateCacheQueue.front().msg;
delete stateCacheQueue.front().prox;
}
// delete cached state message:
delete stateCache.msg;
stateCache.msg = NULL;
delete stateCache.prox;
stateCache.prox = NULL;
}
void BasePastry::updateTooltip ( )
virtual

updates information shown in tk-environment

Definition at line 785 of file BasePastry.cc.

Referenced by baseChangeState(), Bamboo::checkProxCache(), Pastry::checkProxCache(), Pastry::doJoinUpdate(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), and proxCallback().

{
if (ev.isGUI()) {
std::stringstream ttString;
// show our predecessor and successor in tooltip
ttString << leafSet->getPredecessor() << endl << thisNode << endl
getParentModule()->getParentModule()->getDisplayString().
setTagArg("tt", 0, ttString.str().c_str());
getParentModule()->getDisplayString().
setTagArg("tt", 0, ttString.str().c_str());
getDisplayString().setTagArg("tt", 0, ttString.str().c_str());
// draw arrows:
"m=m,50,0,50,0;ls=red,1");
"m=m,50,100,50,100;ls=green,1");
}
}

Friends And Related Function Documentation

friend class PastryLeafSet
friend

Definition at line 325 of file BasePastry.h.

Member Data Documentation

PastryStateMsgProximity BasePastry::aliveTable
protected

Early update of leaf set: helper structure for marking known-dead nodes.

Definition at line 227 of file BasePastry.h.

Referenced by determineAliveTable(), Pastry::handleStateMessage(), and Bamboo::handleStateMessage().

bool BasePastry::alwaysSendUpdate
protected

Definition at line 197 of file BasePastry.h.

Referenced by baseInit(), and Pastry::endProcessingState().

uint32_t BasePastry::bitsPerDigit
protected

Definition at line 189 of file BasePastry.h.

Referenced by baseChangeState(), baseInit(), and Bamboo::doGlobalTuning().

TransportAddress BasePastry::bootstrapNode
protected
int BasePastry::closerNodeLookups

Definition at line 128 of file BasePastry.h.

Referenced by baseInit(), findNode(), and finishOverlay().

int BasePastry::closerNodeLookupsFromNeighborhood

Definition at line 129 of file BasePastry.h.

Referenced by baseInit(), findNode(), and finishOverlay().

bool BasePastry::enableNewLeafs
protected

Definition at line 195 of file BasePastry.h.

Referenced by baseInit(), and newLeafs().

int BasePastry::joinBytesReceived

Definition at line 110 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handlePastryJoinCall().

int BasePastry::joinBytesSeen

Definition at line 108 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::recursiveRoutingHook().

int BasePastry::joinBytesSent

Definition at line 112 of file BasePastry.h.

Referenced by baseInit(), Pastry::changeState(), and finishOverlay().

uint32_t BasePastry::joinHopCount
protected
int BasePastry::joinPartial

Definition at line 106 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handleTimerEvent().

int BasePastry::joinReceived

Definition at line 109 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handlePastryJoinCall().

int BasePastry::joins

Definition at line 101 of file BasePastry.h.

Referenced by baseChangeState(), baseInit(), and finishOverlay().

int BasePastry::joinSeen
int BasePastry::joinSent

Definition at line 111 of file BasePastry.h.

Referenced by baseInit(), Pastry::changeState(), and finishOverlay().

double BasePastry::joinTimeoutAmount
protected

Definition at line 193 of file BasePastry.h.

Referenced by baseInit().

int BasePastry::joinTries

Definition at line 105 of file BasePastry.h.

Referenced by baseChangeState(), baseInit(), and finishOverlay().

cMessage* BasePastry::joinUpdateWait
protected
TransportAddress* BasePastry::leaf2ask
protected

Definition at line 207 of file BasePastry.h.

int BasePastry::leafsetBytesReceived

Definition at line 138 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestLeafSetResponse().

int BasePastry::leafsetBytesSent

Definition at line 136 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestLeafSetCall().

int BasePastry::leafsetReceived

Definition at line 137 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestLeafSetResponse().

int BasePastry::leafsetReqBytesReceived

Definition at line 134 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestLeafSetCall().

int BasePastry::leafsetReqBytesSent
int BasePastry::leafsetReqReceived

Definition at line 133 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestLeafSetCall().

int BasePastry::leafsetReqSent
int BasePastry::leafsetSent

Definition at line 135 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestLeafSetCall().

TransportAddress BasePastry::nearNode
protected
bool BasePastry::nearNodeImproved
protected
simtime_t BasePastry::nearNodeRtt
protected

Definition at line 201 of file BasePastry.h.

Referenced by Pastry::changeState(), and Pastry::pingResponse().

uint32_t BasePastry::numberOfLeaves
protected
uint32_t BasePastry::numberOfNeighbors
protected

Definition at line 191 of file BasePastry.h.

Referenced by baseChangeState(), and baseInit().

bool BasePastry::optimizeLookup
protected

Definition at line 198 of file BasePastry.h.

Referenced by baseInit(), and findNode().

bool BasePastry::periodicMaintenance
protected

Definition at line 205 of file BasePastry.h.

cMessage* BasePastry::readyWait
protected
double BasePastry::readyWaitAmount
protected

Definition at line 192 of file BasePastry.h.

Referenced by Pastry::handleStateMessage(), and Pastry::initializeOverlay().

int BasePastry::repairReqBytesReceived

Definition at line 120 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handleRequestRepairCall().

int BasePastry::repairReqBytesSent
int BasePastry::repairReqReceived

Definition at line 119 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handleRequestRepairCall().

int BasePastry::repairReqSent
double BasePastry::repairTimeout
protected

Definition at line 194 of file BasePastry.h.

Referenced by baseChangeState(), and baseInit().

int BasePastry::responsibleLookups

Definition at line 126 of file BasePastry.h.

Referenced by baseInit(), findNode(), and finishOverlay().

int BasePastry::routingTableLookups

Definition at line 127 of file BasePastry.h.

Referenced by baseInit(), findNode(), and finishOverlay().

int BasePastry::routingTableRowBytesReceived

Definition at line 147 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestRoutingRowResponse().

int BasePastry::routingTableRowBytesSent

Definition at line 145 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestRoutingRowCall().

int BasePastry::routingTableRowReceived

Definition at line 146 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestRoutingRowResponse().

int BasePastry::routingTableRowReqBytesReceived

Definition at line 143 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestRoutingRowCall().

int BasePastry::routingTableRowReqBytesSent
int BasePastry::routingTableRowReqReceived

Definition at line 142 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestRoutingRowCall().

int BasePastry::routingTableRowReqSent
int BasePastry::routingTableRowSent

Definition at line 144 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and handleRequestRoutingRowCall().

std::queue<PastryStateMsgHandle> BasePastry::stateCacheQueue
protected

Queue of state messages waiting to be processed in READY state.

Definition at line 222 of file BasePastry.h.

Referenced by Bamboo::checkProxCache(), Pastry::doSecondStage(), Pastry::endProcessingState(), Pastry::handleStateMessage(), Bamboo::handleStateMessage(), proxCallback(), and purgeVectors().

int BasePastry::stateReqBytesReceived

Definition at line 124 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handleRequestStateCall().

int BasePastry::stateReqBytesSent

Definition at line 122 of file BasePastry.h.

Referenced by baseInit(), Pastry::doSecondStage(), and finishOverlay().

int BasePastry::stateReqReceived

Definition at line 123 of file BasePastry.h.

Referenced by baseInit(), finishOverlay(), and Pastry::handleRequestStateCall().

int BasePastry::stateReqSent

Definition at line 121 of file BasePastry.h.

Referenced by baseInit(), Pastry::doSecondStage(), and finishOverlay().

int BasePastry::totalLookups

Definition at line 125 of file BasePastry.h.

Referenced by baseInit(), findNode(), and finishOverlay().

bool BasePastry::useRegularNextHop
protected

Definition at line 196 of file BasePastry.h.

Referenced by baseInit(), and findNode().


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