OverSim
Bamboo Class Reference

Bamboo overlay module. More...

#include <Bamboo.h>

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

Public Member Functions

virtual ~Bamboo ()
virtual void initializeOverlay (int stage)
 Initializes derived-class-attributes.
virtual void handleTimerEvent (cMessage *msg)
void handleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
void handleRequestLeafSetResponse (RequestLeafSetResponse *response)
void handleStateMessage (PastryStateMessage *msg)
 processes state messages, merging with own state tables
- Public Member Functions inherited from BasePastry
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 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 Member Functions inherited from LookupListener
virtual ~LookupListener ()
 virtual destructor

Protected Member Functions

void lookupFinished (AbstractLookup *lookup)
virtual void changeState (int toState)
 changes node state
- Protected Member Functions inherited from BasePastry
virtual bool handleRpcCall (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invocation messages.
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 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.
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)

Private Member Functions

void doLeafsetMaintenance (void)
 periodically repairs the leafset by pushing it to and pulling it from from a random live leafset node
int getNextRowToMaintain ()
void doLocalTuning ()
void doGlobalTuning (void)
 periodically repairs the routing table by performing random lookups
bool handleFailedNode (const TransportAddress &failed)
 notifies leafset and routingtable of a failed node and sends out a repair request if possible
void checkProxCache (void)
 checks whether proxCache is complete, takes appropriate actions depending on the protocol state
virtual void joinOverlay ()

Private Attributes

uint16_t rowToAsk
simtime_t leafsetMaintenanceInterval
simtime_t localTuningInterval
simtime_t globalTuningInterval
cMessage * leafsetMaintenanceTimer
cMessage * globalTuningTimer
cMessage * localTuningTimer

Friends

class BambooLookupListener

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
}
- Public Attributes inherited from BasePastry
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 inherited from BasePastry
enum  StateObject { ROUTINGTABLE, LEAFSET, NEIGHBORHOODSET }
enum  { PING_RECEIVED_STATE = 1, PING_NEXT_HOP = 2, PING_SINGLE_NODE = 3, PING_DISCOVERY = 4 }
- Protected Attributes inherited from BasePastry
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

Detailed Description

Bamboo overlay module.

Author
Gerhard Petruschat
See Also
BaseOverlay

Definition at line 53 of file Bamboo.h.

Constructor & Destructor Documentation

Bamboo::~Bamboo ( )
virtual

Definition at line 41 of file Bamboo.cc.

{
// destroy self timer messages
cancelAndDelete(localTuningTimer);
cancelAndDelete(leafsetMaintenanceTimer);
cancelAndDelete(globalTuningTimer);
}

Member Function Documentation

void Bamboo::changeState ( int  toState)
protectedvirtual

changes node state

Parameters
toStatestate to change to

Reimplemented from BasePastry.

Definition at line 86 of file Bamboo.cc.

Referenced by checkProxCache(), and joinOverlay().

{
baseChangeState(toState);
switch (toState) {
case INIT:
break;
case DISCOVERY:
break;
case JOIN: {
EV << "[Bamboo::changeState()]\n"
<< " sending join message via " << bootstrapNode
<< " to " << thisNode.getKey()
<< endl;
RequestLeafSetCall* call = new RequestLeafSetCall("JOIN Call");
call->setTimestamp(simTime());
call->setBitLength(PASTRYREQUESTLEAFSETCALL_L(call));
leafsetReqBytesSent += call->getByteLength());
}
break;
case READY:
scheduleAt(simTime(), leafsetMaintenanceTimer);
// schedule routing table maintenance task
cancelEvent(localTuningTimer);
scheduleAt(simTime() + localTuningInterval, localTuningTimer);
cancelEvent(globalTuningTimer);
scheduleAt(simTime() + globalTuningInterval, globalTuningTimer);
break;
}
}
void Bamboo::checkProxCache ( void  )
private

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

Definition at line 323 of file Bamboo.cc.

Referenced by handleStateMessage(), and lookupFinished().

{
// no cached STATE message?
if (stateCache.msg) {
simtime_t now = simTime();
// some entries not yet determined?
if ((find(stateCache.prox->pr_rt.begin(), stateCache.prox->pr_rt.end(),
(find(stateCache.prox->pr_ls.begin(), stateCache.prox->pr_ls.end(),
(find(stateCache.prox->pr_ns.begin(), stateCache.prox->pr_ns.end(),
return;
}
}
// merge info in own state tables
// except leafset (was already handled in handleStateMessage)
}
EV << "[Bamboo::checkProxCache()]\n"
<< " Merged nodes into routing table."
<< endl;
}
}
delete stateCache.msg;
stateCache.msg = NULL;
delete stateCache.prox;
stateCache.prox = NULL;
if (state == JOIN) {
}
// process next queued message:
if (! stateCacheQueue.empty()) {
} else {
}
}
}
void Bamboo::doGlobalTuning ( void  )
private

periodically repairs the routing table by performing random lookups

Definition at line 275 of file Bamboo.cc.

Referenced by handleTimerEvent().

{
int digit = getNextRowToMaintain();
// would be a better alternative
//OverlayKey OverlayKey::randomSuffix(uint pos) const;
uint32_t maxDigitIndex = OverlayKey::getLength() - bitsPerDigit;
uint32_t maxKeyIndex = OverlayKey::getLength() - 1;
while (newKey.getBitRange(maxDigitIndex - digit * bitsPerDigit, bitsPerDigit) ==
thisNode.getKey().getBitRange(maxDigitIndex - digit * bitsPerDigit, bitsPerDigit)) {
newKey = OverlayKey::random();
}
assert(digit * bitsPerDigit < OverlayKey::getLength());
for (uint16_t i = 0; i < digit * bitsPerDigit; ++i) {
newKey[maxKeyIndex - i] = thisNode.getKey().getBit(maxKeyIndex - i);
}
createLookup()->lookup(newKey, 1, 0, 0, new BambooLookupListener(this));
}
void Bamboo::doLeafsetMaintenance ( void  )
private

periodically repairs the leafset by pushing it to and pulling it from from a random live leafset node

Definition at line 202 of file Bamboo.cc.

Referenced by handleTimerEvent().

{
if (!ask.isUnspecified()) {
EV << "[Bamboo::doLeafsetMaintenance()]\n"
<< " leafset maintenance: pulling leafset from "
<< ask << endl;
RequestLeafSetCall* call = new RequestLeafSetCall("LeafSet PULL");
call->setTimestamp(simTime());
call->setBitLength(PASTRYREQUESTLEAFSETCALL_L(call));
leafsetReqBytesSent += call->getByteLength());
sendUdpRpcCall(ask, call);
}
}
void Bamboo::doLocalTuning ( )
private

Definition at line 250 of file Bamboo.cc.

Referenced by handleTimerEvent().

{
if ((!ask4row.isUnspecified()) && (ask4row != thisNode)) {
EV << "[Bamboo::doLocalTuning() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Sending Message to Node in Row" << rowToAsk
<< endl;
new RequestRoutingRowCall("REQUEST ROUTINGROW Call (Local Tuning)");
call->setRow(rowToAsk + 1);
call->setBitLength(PASTRYREQUESTROUTINGROWCALL_L(call));
routingTableRowReqBytesSent += call->getByteLength());
sendUdpRpcCall(ask4row, call);
}
}
int Bamboo::getNextRowToMaintain ( )
private

Definition at line 224 of file Bamboo.cc.

Referenced by doGlobalTuning(), and doLocalTuning().

{
int digit = 0;
int lastRow = routingTable->getLastRow();
int* choices = new int[lastRow + 1];
int sum = 0;
for (int i = 0; i < lastRow; ++i) {
sum += (choices[i] = lastRow - i);
}
int rval = intuniform(0, sum);
while (true) {
rval -= choices [digit];
if (rval <= 0)
break;
++digit;
}
delete[] choices;
return digit;
}
bool Bamboo::handleFailedNode ( const TransportAddress failed)
private

notifies leafset and routingtable of a failed node and sends out a repair request if possible

Parameters
failedthe failed node
Returns
true as long as local state is READY (signals lookup to try again)

Definition at line 299 of file Bamboo.cc.

{
if (state != READY) return false;
if (failed.isUnspecified()) {
throw cRuntimeError("Bamboo::handleFailedNode(): failed is unspecified!");
}
const TransportAddress& lsAsk = leafSet->failedNode(failed);
if (lsAsk.isUnspecified() && (! leafSet->isValid())) {
EV << "[Bamboo::handleFailedNode()]\n"
<< " lost connection to the network, trying to re-join."
<< endl;
join();
return false;
}
return true;
}
void Bamboo::handleRequestLeafSetResponse ( RequestLeafSetResponse response)
virtual

Reimplemented from BasePastry.

Definition at line 183 of file Bamboo.cc.

Referenced by handleRpcResponse().

{
EV << "[Bamboo::handleRequestLeafSetResponse() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]"
<< endl;
if (state == JOIN) {
PastryStateMessage* stateMsg =
check_and_cast<PastryStateMessage*>(response->decapsulate());
stateMsg->setLeafSetArraySize(stateMsg->getLeafSetArraySize() + 1);
stateMsg->setLeafSet(stateMsg->getLeafSetArraySize() - 1,
stateMsg->getSender());
handleStateMessage(stateMsg);
}
}
void Bamboo::handleRpcResponse ( BaseResponseMessage msg,
cPolymorphic *  context,
int  rpcId,
simtime_t  rtt 
)
virtual

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

Definition at line 162 of file Bamboo.cc.

{
BasePastry::handleRpcResponse(msg, context, rpcId, rtt);
RPC_ON_RESPONSE( RequestLeafSet ) {
EV << "[Bamboo::handleRpcResponse() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Received a RequestLeafSet RPC Response (PUSH): id="
<< rpcId << "\n"
<< " msg=" << *_RequestLeafSetResponse << " rtt=" << rtt
<< endl;
handleRequestLeafSetResponse(_RequestLeafSetResponse);
break;
}
}
void Bamboo::handleStateMessage ( PastryStateMessage msg)
virtual

processes state messages, merging with own state tables

Parameters
msgthe pastry state message

Implements BasePastry.

Definition at line 377 of file Bamboo.cc.

Referenced by handleRequestLeafSetResponse().

{
if (debugOutput) {
EV << "[Bamboo::handleStateMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " new STATE message to process "
<< static_cast<void*>(msg) << " in state "
<< ((state == READY)?"READY":((state == JOIN)?"JOIN":"INIT"))
<< endl;
}
if (state == INIT) {
EV << "[Bamboo::handleStateMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " can't handle state messages until at least reaching JOIN state."
<< endl;
delete msg;
return;
}
PastryStateMsgHandle handle(msg);
if (state == JOIN) {
// merged state into leafset right now
lastStateChange = simTime();
// no state message is processed right now, start immediately:
stateCache = handle;
} else {
}
return;
}
// determine aliveTable to prevent leafSet from merging nodes that are
// known to be dead:
if (leafSet->mergeState(msg, &aliveTable)) {
// merged state into leafset right now
lastStateChange = simTime();
}
// in READY state, only ping nodes to get proximity metric:
if (!stateCache.msg) {
// no state message is processed right now, start immediately:
stateCache = handle;
} else {
}
} else {
// enqueue message for later processing:
stateCacheQueue.push(handle);
if (stateCacheQueue.size() > 15) {
delete stateCacheQueue.front().msg;
EV << "[Bamboo::handleStateMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " stateCacheQueue full -> pop()" << endl;
}
prePing(msg);
} else {
}
}
}
void Bamboo::handleTimerEvent ( cMessage *  msg)
virtual

Reimplemented from BaseRpc.

Definition at line 133 of file Bamboo.cc.

{
if (msg == localTuningTimer) {
EV << "[Bamboo::handleTimerEvent() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " starting local tuning "
<< "(aka neighbor's neighbors / routing table maintenance)"
<< endl;
scheduleAt(simTime() + localTuningInterval, localTuningTimer);
} else if (msg == leafsetMaintenanceTimer) {
EV << "[Bamboo::handleTimerEvent() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " starting leafset maintenance"
<< endl;
scheduleAt(simTime() + leafsetMaintenanceInterval,
} else if (msg == globalTuningTimer) {
EV << "[Bamboo::handleTimerEvent() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " starting global tuning"
<< endl;
scheduleAt(simTime() + globalTuningInterval, globalTuningTimer);
}
}
void Bamboo::initializeOverlay ( int  stage)
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
stagethe init stage

Reimplemented from BaseOverlay.

Definition at line 50 of file Bamboo.cc.

{
if ( stage != MIN_STAGE_OVERLAY )
return;
// Bamboo provides KBR services
kbr = true;
rowToAsk = 0;
localTuningInterval = par("localTuningInterval");
leafsetMaintenanceInterval = par("leafsetMaintenanceInterval");
globalTuningInterval = par("globalTuningInterval");
localTuningTimer = new cMessage("repairTaskTimer");
leafsetMaintenanceTimer = new cMessage("leafsetMaintenanceTimer");
globalTuningTimer = new cMessage("globalTuningTimer");
}
void Bamboo::joinOverlay ( )
privatevirtual

Definition at line 72 of file Bamboo.cc.

{
// no existing pastry network -> first node of a new one
} else {
// join existing pastry network
}
}
void Bamboo::lookupFinished ( AbstractLookup lookup)
protectedvirtual

Implements LookupListener.

Definition at line 455 of file Bamboo.cc.

Referenced by BambooLookupListener::lookupFinished().

{
EV << "[Bamboo::lookupFinished() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< endl;
if (lookup->isValid()) {
EV << " Lookup successful" << endl;
const NodeVector& result = lookup->getResult();
if (result[0] != thisNode) {
// Global Tuning PING
Prox prox = neighborCache->getProx(result[0],
this, NULL);
if (prox != Prox::PROX_UNKNOWN && prox != Prox::PROX_WAITING) {
routingTable->mergeNode(result[0], prox.proximity);
}
} else {
routingTable->mergeNode(result[0], -1.0);
}
}
} else {
EV << " Lookup failed" << endl;
}
}

Friends And Related Function Documentation

friend class BambooLookupListener
friend

Definition at line 55 of file Bamboo.h.

Referenced by doGlobalTuning().

Member Data Documentation

simtime_t Bamboo::globalTuningInterval
private

Definition at line 95 of file Bamboo.h.

Referenced by changeState(), handleTimerEvent(), and initializeOverlay().

cMessage* Bamboo::globalTuningTimer
private

Definition at line 98 of file Bamboo.h.

Referenced by changeState(), handleTimerEvent(), initializeOverlay(), and ~Bamboo().

simtime_t Bamboo::leafsetMaintenanceInterval
private

Definition at line 93 of file Bamboo.h.

Referenced by handleTimerEvent(), and initializeOverlay().

cMessage* Bamboo::leafsetMaintenanceTimer
private

Definition at line 97 of file Bamboo.h.

Referenced by changeState(), handleTimerEvent(), initializeOverlay(), and ~Bamboo().

simtime_t Bamboo::localTuningInterval
private

Definition at line 94 of file Bamboo.h.

Referenced by changeState(), handleTimerEvent(), and initializeOverlay().

cMessage* Bamboo::localTuningTimer
private

Definition at line 99 of file Bamboo.h.

Referenced by changeState(), handleTimerEvent(), initializeOverlay(), and ~Bamboo().

uint16_t Bamboo::rowToAsk
private

Definition at line 90 of file Bamboo.h.

Referenced by doLocalTuning(), and initializeOverlay().


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