OverSim
Quon Class Reference

QuON: An overlay network based on quadtrees. More...

#include <Quon.h>

Inheritance diagram for Quon:
BaseOverlay BaseRpc BaseTcpSupport TopologyVis RpcListener

Public Member Functions

 ~Quon ()
void initializeOverlay (int stage)
 Initializes derived-class-attributes.
void finishOverlay ()
 collects statistical data in derived class
void handleUDPMessage (BaseOverlayMessage *msg)
 Processes messages from underlay.
void handleTimerEvent (cMessage *msg)
void handleAppMessage (cMessage *msg)
 Processes "timer" self-messages.
void handleNodeGracefulLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.
QState getState ()
double getAOI ()
Vector2D getPosition ()
double getAreaDimension ()
OverlayKey getKey ()
long getSoftNeighborCount ()
- Public Member Functions inherited from BaseOverlay
 BaseOverlay ()
virtual ~BaseOverlay ()
 Virtual destructor.
bool isMalicious ()
 Returns true, if node is malicious.
bool isInSimpleMultiOverlayHost ()
 Returns true if overlay is one in an array, inside a SimpleMultiOverlayHost.
const simtime_t & getCreationTime ()
void join (const OverlayKey &nodeID=OverlayKey::UNSPECIFIED_KEY)
 Join the overlay with a given nodeID.
virtual NodeVectorlocal_lookup (const OverlayKey &key, int num, bool safe)
 finds nodes closest to the given OverlayKey
virtual NodeVectorneighborSet (int num)
virtual bool isSiblingFor (const NodeHandle &node, const OverlayKey &key, int numSiblings, bool *err)
 Query if a node is among the siblings for a given key.
virtual int getMaxNumSiblings ()
 Query the maximum number of siblings (nodes close to a key) that are maintained by this overlay protocol.
virtual int getMaxNumRedundantNodes ()
 Query the maximum number of redundant next hop nodes that are returned by findNode().
void sendMessageToUDP (const TransportAddress &dest, cPacket *msg, simtime_t delay=SIMTIME_ZERO)
 Sends message to underlay.
void sendToKey (const OverlayKey &key, BaseOverlayMessage *message, int numSiblings=1, const std::vector< TransportAddress > &sourceRoute=TransportAddress::UNSPECIFIED_NODES, RoutingType routingType=DEFAULT_ROUTING)
 Sends a message to an overlay node, with the generic routing algorithm.
virtual OverlayKey distance (const OverlayKey &x, const OverlayKey &y, bool useAlternative=false) const
 This method should implement the distance between two keys.
void registerComp (CompType compType, cModule *module)
cModule * getCompModule (CompType compType)
cGate * getCompRpcGate (CompType compType)
void sendMessageToAllComp (cMessage *msg, CompType srcComp)
bool providesKbr ()
virtual uint8_t getBitsPerDigit ()
bool getMeasureAuthBlock ()
BootstrapListgetBootstrapList () const
virtual OverlayKey estimateMeanDistance ()
 returns mean distance between OverlayKeys in the network
virtual uint32_t estimateOverlaySize ()
 estimates the current number of nodes online
- Public Member Functions inherited from BaseRpc
 BaseRpc ()
const NodeHandlegetThisNode ()
 Returns the NodeHandle of this node.
simtime_t getUdpTimeout ()
- Public Member Functions inherited from RpcListener
virtual ~RpcListener ()
 destructor
- Public Member Functions inherited from BaseTcpSupport
virtual void socketDataArrived (int connId, void *yourPtr, cPacket *msg, bool urgent)
virtual void socketEstablished (int connId, void *yourPtr)
virtual void socketPeerClosed (int connId, void *yourPtr)
virtual void socketFailure (int connId, void *yourPtr, int code)
virtual void socketStatusArrived (int connId, void *yourPtr, TCPStatusInfo *status)
- Public Member Functions inherited from TopologyVis
 TopologyVis ()
void showOverlayNeighborArrow (const NodeHandle &neighbor, bool flush=true, const char *displayString=NULL)
 Draws an arrow from this node to neighbor.
void deleteOverlayNeighborArrow (const NodeHandle &neighbor)
 Removes an arrow from this node to neighbor.

Public Attributes

QuonSiteMap Sites

Private Member Functions

void sendToApp (cMessage *msg)
void sendMessage (QuonMessage *quonMsg, NodeHandle destination)
void setBootstrapedIcon ()
void changeState (QState qstate)
void processJoinTimer ()
void processSecTimer ()
void processDeleteTimer (cMessage *msg)
void processAliveTimer ()
void processBackupTimer ()
void handleJoin (GameAPIPositionMessage *gameMsg)
void handleMove (GameAPIPositionMessage *gameMsg)
void handleEvent (GameAPIMessage *msg)
void handleJoinRequest (QuonMessage *quonMsg)
void handleJoinAcknowledge (QuonListMessage *quonListMsg)
void handleNodeMove (QuonMoveMessage *quonMoveMsg)
void handleNewNeighbors (QuonListMessage *quonListMsg)
void handleNodeLeave (QuonListMessage *quonListMsg)
void handleInvalidNode (QuonListMessage *quonListMsg)
void synchronizeAppNeighbors (QPurgeType purgeSoftSites=QKEEPSOFT)
void deleteAppNeighbor (NodeHandle node)
bool addSite (Vector2D p, NodeHandle node, double AOI, bool isSoft=false, QUpdateType update=QFOREIGN)
void updateThisSite (Vector2D p)
void classifySites ()
bool deleteSite (NodeHandle node)
int purgeSites (QPurgeType purgeSoftSites=QKEEPSOFT)
void adaptAoI ()

Private Attributes

simtime_t joinTimeout
simtime_t deleteTimeout
simtime_t aliveTimeout
double AOIWidth
double minAOI
double maxAOI
unsigned int connectionLimit
double areaDimension
simtime_t backupIntervall
bool useDynamicAOI
bool useSquareMetric
bool linearAdaption
double adaptionSensitivity
double gossipSensitivity
bool nnOnlyBinding
cMessage * join_timer
cMessage * sec_timer
cMessage * alive_timer
cMessage * backup_timer
double joinRequestBytesSend
double joinAcknowledgeBytesSend
double nodeMoveBytesSend
double newNeighborsBytesSend
double nodeLeaveBytesSend
double maxBytesPerSecondSend
double averageBytesPerSecondSend
double bytesPerSecond
long softConnections
long softNeighborCount
long bindingNeighborCount
long directNeighborCount
unsigned int secTimerCount
long rejoinCount
unsigned long avgAOI
simtime_t joinTime
QuonSitethisSite
QDeleteMap deletedSites
NodeHandle(* bindingBackup )[4]
int numBackups
QState qstate
bool aloneInOverlay
LoginCacheloginCache
int cacheInterval
int timeSinceCache

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
}
- Protected Types inherited from BaseOverlay
typedef UNORDERED_SET
< AbstractLookup
*, lookupHashFcn,
lookupHashFcn
LookupSet
- 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 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 recordOverlaySentStats (BaseOverlayMessage *msg)
 Collect overlay specific sent messages statistics.
void setOverlayReady (bool ready)
 Sets the overlay ready icon and register/deregisters the node at the GlobalNodeList.
virtual AbstractLookupcreateLookup (RoutingType routingType=DEFAULT_ROUTING, const BaseOverlayMessage *msg=NULL, const cPacket *findNodeExt=NULL, bool appLookup=false)
 Creates an abstract iterative lookup instance.
virtual void removeLookup (AbstractLookup *lookup)
 Removes the abstract lookup instance.
virtual NodeVectorfindNode (const OverlayKey &key, int numRedundantNodes, int numSiblings, BaseOverlayMessage *msg=NULL)
 Implements the find node call.
virtual void joinOverlay ()
 Join the overlay with a given nodeID in thisNode.key.
virtual void joinForeignPartition (const NodeHandle &node)
 Join another overlay partition with the given node as bootstrap node.
virtual bool handleFailedNode (const TransportAddress &failed)
 Handles a failed node.
virtual void lookupRpc (LookupCall *call)
virtual void nextHopRpc (NextHopCall *call)
void countFindNodeCall (const FindNodeCall *call)
void countFailedNodeCall (const FailedNodeCall *call)
bool internalHandleRpcCall (BaseCallMessage *msg)
 Handles internal rpc requests.
void internalHandleRpcResponse (BaseResponseMessage *msg, cPolymorphic *context, int rpcId, simtime_t rtt)
 Handles rpc responses internal in base classes

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

void internalSendRouteRpc (BaseRpcMessage *message, const OverlayKey &destKey, const std::vector< TransportAddress > &sourceRoute, RoutingType routingType)
CompType getThisCompType ()
 Return the component type of this module.
- Protected 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

Detailed Description

QuON: An overlay network based on quadtrees.

Author
Helge Backhaus, Stephan Krause

Definition at line 42 of file Quon.h.

Constructor & Destructor Documentation

Quon::~Quon ( )

Definition at line 1173 of file Quon.cc.

{
// destroy self timer messages
cancelAndDelete(join_timer);
cancelAndDelete(sec_timer);
cancelAndDelete(alive_timer);
cancelAndDelete(backup_timer);
delete thisSite;
QuonSiteMap::iterator itSites = Sites.begin();
while(itSites != Sites.end()) {
delete itSites->second;
++itSites;
}
}

Member Function Documentation

void Quon::adaptAoI ( )
private

Definition at line 498 of file Quon.cc.

Referenced by handleMove().

{
// adjust AOIWidth
double oldAOI = AOIWidth;
AOIWidth -= (maxAOI - minAOI) * ((double) Sites.size() - (double) connectionLimit) * adaptionSensitivity / (double) connectionLimit;
} else if( Sites.size() > 0 ){
AOIWidth *= (1-adaptionSensitivity) + (double) connectionLimit * adaptionSensitivity / (double) Sites.size();
}
if( gossipSensitivity > 0 && Sites.size() > 0 ) {
double avgNeighborAOI = 0;
for( QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites ){
avgNeighborAOI += itSites->second->AOIwidth;
}
avgNeighborAOI /= Sites.size();
}
if(AOIWidth > maxAOI) {
}
else if(AOIWidth < minAOI) {
}
if( oldAOI != AOIWidth ){
GameAPIResizeAOIMessage* gameMsg = new GameAPIResizeAOIMessage("RESIZE_AOI");
gameMsg->setAOIsize(AOIWidth);
sendToApp(gameMsg);
}
}
bool Quon::addSite ( Vector2D  p,
NodeHandle  node,
double  AOI,
bool  isSoft = false,
QUpdateType  update = QFOREIGN 
)
private

Definition at line 315 of file Quon.cc.

Referenced by handleJoinAcknowledge(), handleNewNeighbors(), handleNodeLeave(), and handleNodeMove().

{
aloneInOverlay = false;
QuonSiteMap::iterator itSites = Sites.find(node.getKey());
QDeleteMap::iterator delIt = deletedSites.find(node.getKey());
// add node if he is not in the delete list OR has changed position since
// put in the delete list. don't add node if he has signled his leave himself
// (i.e. his position in the delete list is 0,0)
if(node.getKey() != thisSite->address.getKey() &&
(delIt == deletedSites.end() || (delIt->second != Vector2D(0,0) && delIt->second != p) )){
if(itSites == Sites.end()) {
EV << "[Quon::addSite() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Site " << node.getIp() << " at " << p << " has been added to the list."
<< endl;
}
QuonSite* temp = new QuonSite();
temp->position = p;
temp->address = node;
if(update == QDIRECT) {
temp->dirty = true;
}
temp->alive = true;
temp->type = QUNDEFINED;
temp->softNeighbor = isSoft;
temp->AOIwidth = AOI;
Sites.insert(std::make_pair(temp->address.getKey(), temp));
}
else if(update == QDIRECT || !itSites->second->alive) {
EV << "[Quon::addSite() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Site " << node.getIp() << " at " << p << " has been updated in the list."
<< endl;
}
itSites->second->position = p;
itSites->second->dirty = true;
itSites->second->alive = true;
itSites->second->softNeighbor = isSoft;
itSites->second->type = QUNDEFINED;
itSites->second->AOIwidth = AOI;
}
return true;
}
return false;
}
void Quon::changeState ( QState  qstate)
private

Definition at line 121 of file Quon.cc.

Referenced by classifySites(), finishOverlay(), handleJoin(), handleJoinAcknowledge(), handleNodeGracefulLeaveNotification(), and initializeOverlay().

{
this->qstate = qstate;
switch(qstate) {
cancelEvent(join_timer);
cancelEvent(sec_timer);
cancelEvent(alive_timer);
cancelEvent(backup_timer);
break;
case QJOINING:
if( joinTime == 0 ) joinTime = simTime();
scheduleAt(simTime(), join_timer);
scheduleAt(simTime() + 1.0, sec_timer);
break;
case QREADY:
cancelEvent(join_timer);
"QuON: JoinTime",
SIMTIME_DBL(simTime()) - SIMTIME_DBL(joinTime) + par("addJoinDelay").doubleValue()
);
);
joinTime = 0;
// tell the application we are ready unless we are rejoining the overlay
//if(rejoinCount == 0) {
CompReadyMessage* readyMsg = new CompReadyMessage("OVERLAY_READY");
readyMsg->setReady(true);
readyMsg->setComp(getThisCompType());
// TODO/FIXME: use overlay->sendMessageToAllComp(msg, getThisCompType())?
sendToApp(readyMsg);
//}
// set initial AOI size
GameAPIResizeAOIMessage* gameMsg = new GameAPIResizeAOIMessage("RESIZE_AOI");
gameMsg->setAOIsize(AOIWidth);
sendToApp(gameMsg);
if(aliveTimeout > 0.0) {
scheduleAt(simTime() + aliveTimeout, alive_timer);
}
if(backupIntervall > 0.0) {
scheduleAt(simTime() + backupIntervall, backup_timer);
}
break;
}
// debug output
EV << "[Quon::changeState() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Node " << thisSite->address.getIp() << " entered ";
switch(qstate) {
EV << "UNINITIALIZED";
break;
case QJOINING:
EV << "JOINING";
break;
case QREADY:
EV << "READY";
break;
}
EV << " state." << endl;
}
}
void Quon::classifySites ( )
private

Definition at line 375 of file Quon.cc.

Referenced by handleJoinAcknowledge(), handleMove(), handleNewNeighbors(), handleNodeLeave(), handleNodeMove(), and processAliveTimer().

{
if(Sites.size() > 0) {
QuonSite* (*bindingCandidates)[4] = new QuonSite*[numBackups+1][4];
for( int i = 0; i <= numBackups; ++i ){
for( int ii = 0; ii < 4; ++ii ){
bindingCandidates[i][ii] = 0;
}
}
double (*bindingDistance)[4] = new double[numBackups+1][4];
for( int i = 0; i <= numBackups; ++i ){
for( int ii = 0; ii < 4; ++ii ){
bindingDistance[i][ii] = std::numeric_limits<double>::infinity();
}
}
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
QuonAOI NeighborAOI(itSites->second->position, itSites->second->AOIwidth, useSquareMetric);
if(AOI.collide(itSites->second->position) || NeighborAOI.collide(thisSite->position)) {
if(itSites->second->type != QNEIGHBOR) {
itSites->second->type = QNEIGHBOR;
itSites->second->dirty = true;
}
}
else if(itSites->second->type != QUNDEFINED) {
itSites->second->type = QUNDEFINED;
itSites->second->dirty = true;
}
int quad = thisSite->position.getQuadrant( itSites->second->position );
double dist;
dist = thisSite->position.xyMaxDistance(itSites->second->position);
} else {
dist = thisSite->position.distanceSqr(itSites->second->position);
}
// if dist is smaller than the most far binding candidate
if( dist < bindingDistance[numBackups][quad] ){
// Go through list of binding candidates until distance to current candidate
// is greater than distance to new candidate (i.e. look where in the binding
// candidate list the node belongs)
int backupPos = numBackups-1;
while( backupPos >= 0 && dist < bindingDistance[backupPos][quad] ){
// move old candidate one position back in the queue to make
// room for new candidate
bindingCandidates[backupPos+1][quad] = bindingCandidates[backupPos][quad];
bindingDistance[backupPos+1][quad] = bindingDistance[backupPos][quad];
--backupPos;
}
// place new candidate at appropriate position in candidate list
bindingCandidates[backupPos+1][quad] = itSites->second;
bindingDistance[backupPos+1][quad] = dist;
}
}
for( int i = 0; i < 4; ++i ){
if( bindingCandidates[0][i] ){
bindingCandidates[0][i]->type = QBINDING;
bindingCandidates[0][i]->dirty = true;
for( int ii = 1; ii <= numBackups; ++ii ){
if( bindingCandidates[ii][i] ){
bindingBackup[ii-1][i] = bindingCandidates[ii][i]->address;
}
}
}
}
delete[] bindingCandidates;
delete[] bindingDistance;
}
else {
}
}
}
void Quon::deleteAppNeighbor ( NodeHandle  node)
private

Definition at line 1024 of file Quon.cc.

Referenced by handleNodeLeave(), and processAliveTimer().

{
GameAPIListMessage* gameMsg = new GameAPIListMessage("NEIGHBOR_UPDATE");
gameMsg->setRemoveNeighbor(0, node);
sendToApp(gameMsg);
}
bool Quon::deleteSite ( NodeHandle  node)
private

Definition at line 456 of file Quon.cc.

Referenced by handleNodeLeave(), and processAliveTimer().

{
QuonSiteMap::iterator itSites = Sites.find(node.getKey());
if(itSites != Sites.end()) {
EV << "[Quon::deleteSite() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Site " << node.getIp() << " at " << itSites->second->position << " has been removed from the list."
<< endl;
}
delete itSites->second;
Sites.erase(itSites);
return true;
}
return false;
}
void Quon::finishOverlay ( )
virtual

collects statistical data in derived class

Reimplemented from BaseOverlay.

Definition at line 1103 of file Quon.cc.

{
double overallBytesSend = joinRequestBytesSend
if(overallBytesSend != 0.0) {
// collect statistics in percent
globalStatistics->addStdDev("Quon: fraction of JOIN_REQUEST bytes sent ", joinRequestBytesSend / overallBytesSend);
globalStatistics->addStdDev("Quon: fraction of JOIN_ACKNOWLEDGE bytes sent", joinAcknowledgeBytesSend / overallBytesSend);
globalStatistics->addStdDev("Quon: fraction of NODE_MOVE bytes sent", nodeMoveBytesSend / overallBytesSend);
globalStatistics->addStdDev("Quon: fraction of NEW_NEIGHBORS bytes sent", newNeighborsBytesSend / overallBytesSend);
globalStatistics->addStdDev("Quon: fraction of NODE_LEAVE bytes sent", nodeLeaveBytesSend / overallBytesSend);
}
globalStatistics->addStdDev("Quon: max bytes/second sent", maxBytesPerSecondSend);
// We use our own time count to avoid rounding errors
// simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime);
// if(time != 0.0) {
if(secTimerCount != 0) {
globalStatistics->addStdDev("Quon: average bytes/second sent", averageBytesPerSecondSend / (double) secTimerCount);
globalStatistics->addStdDev("Quon: average direct-neighbor count", directNeighborCount / (double) secTimerCount);
globalStatistics->addStdDev("Quon: average binding-neighbor count", bindingNeighborCount / (double) secTimerCount);
globalStatistics->addStdDev("Quon: average soft-neighbor count", softNeighborCount / (double) secTimerCount);
//globalStatistics->addStdDev("Quon: average rejoin count", rejoinCount);
globalStatistics->addStdDev("Quon: average AOI width", avgAOI / (double) secTimerCount);
}
}
double Quon::getAOI ( )

Definition at line 1141 of file Quon.cc.

{
Enter_Method_Silent();
return AOIWidth - (double)par("AOIBuffer");
}
double Quon::getAreaDimension ( )

Definition at line 1153 of file Quon.cc.

{
Enter_Method_Silent();
return areaDimension;
}
OverlayKey Quon::getKey ( )

Definition at line 1159 of file Quon.cc.

Referenced by ConnectivityProbeQuon::extractTopology().

{
Enter_Method_Silent();
return thisSite->address.getKey();
}
Vector2D Quon::getPosition ( )

Definition at line 1147 of file Quon.cc.

{
Enter_Method_Silent();
return thisSite->position;
}
long Quon::getSoftNeighborCount ( )

Definition at line 1165 of file Quon.cc.

{
Enter_Method_Silent();
long temp = softConnections;
return temp;
}
QState Quon::getState ( )

Reimplemented from BaseOverlay.

Definition at line 1135 of file Quon.cc.

Referenced by ConnectivityProbeQuon::extractTopology().

{
Enter_Method_Silent();
return qstate;
}
void Quon::handleAppMessage ( cMessage *  msg)
virtual

Processes "timer" self-messages.

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

Reimplemented from BaseOverlay.

Definition at line 229 of file Quon.cc.

{
GameAPIMessage* gameAPIMsg = dynamic_cast<GameAPIMessage*>(msg);
if(gameAPIMsg != NULL) {
// debug output
EV << "[Quon::handleAppMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Node " << thisSite->address.getIp() << " received " << gameAPIMsg->getName() << " from application."
<< endl;
}
switch(gameAPIMsg->getCommand()) {
GameAPIPositionMessage* gameAPIPositionMsg = dynamic_cast<GameAPIPositionMessage*>(msg);
if(qstate == QJOINING) {
handleJoin(gameAPIPositionMsg);
}
else if(qstate == QREADY) {
handleMove(gameAPIPositionMsg);
}
} break;
handleEvent(gameAPIMsg);
} break;
}
}
delete msg;
}
void Quon::handleEvent ( GameAPIMessage msg)
private

Definition at line 763 of file Quon.cc.

Referenced by handleAppMessage().

{
// send event to neighbors
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
QuonEventMessage *quonMsg = new QuonEventMessage("EVENT");
quonMsg->encapsulate((cPacket*)msg->dup());
// FIXME: Message length!
sendMessage(quonMsg, itSites->second->address);
}
}
void Quon::handleInvalidNode ( QuonListMessage quonListMsg)
private

Definition at line 961 of file Quon.cc.

Referenced by handleNewNeighbors(), handleNodeLeave(), and handleNodeMove().

{
return;
for(unsigned int i=0; i<quonListMsg->getNeighborHandleArraySize(); i++) {
if(deletedSites.find(quonListMsg->getNeighborHandle(i).getKey()) != deletedSites.end()) {
QuonListMessage* quonLeaveMsg = new QuonListMessage("NODE_LEAVE");
quonLeaveMsg->setCommand(NODE_LEAVE);
quonLeaveMsg->setSender(quonListMsg->getNeighborHandle(i));
quonLeaveMsg->setPosition(quonListMsg->getNeighborPosition(i));
quonLeaveMsg->setAOIsize(AOIWidth);
quonLeaveMsg->setNeighborHandleArraySize(Sites.size());
quonLeaveMsg->setNeighborPositionArraySize(Sites.size());
int i = 0;
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type == QBINDING) {
quonLeaveMsg->setNeighborHandle(i, itSites->second->address);
quonLeaveMsg->setNeighborPosition(i, itSites->second->position);
++i;
}
}
quonLeaveMsg->setNeighborHandleArraySize(i);
quonLeaveMsg->setNeighborPositionArraySize(i);
quonLeaveMsg->setBitLength(QUONLIST_L(quonLeaveMsg));
sendMessage(quonLeaveMsg, quonListMsg->getSender());
}
}
}
void Quon::handleJoin ( GameAPIPositionMessage gameMsg)
private

Definition at line 673 of file Quon.cc.

Referenced by handleAppMessage().

{
TransportAddress joinNode;
if( loginCache ) {
joinNode = loginCache->getLoginNode( gameMsg->getPosition() );
} else {
}
thisSite->position = gameMsg->getPosition();
// check if this is the only node in the overlay
if(joinNode.isUnspecified()) {
}
else {
QuonMessage* quonMsg = new QuonMessage("JOIN_REQUEST");
quonMsg->setAOIsize(AOIWidth);
quonMsg->setBitLength(QUON_L(quonMsg));
sendMessage(quonMsg, joinNode);
}
}
void Quon::handleJoinAcknowledge ( QuonListMessage quonListMsg)
private

Definition at line 820 of file Quon.cc.

Referenced by handleUDPMessage().

{
// add acceptor node
addSite(quonListMsg->getPosition(), quonListMsg->getSender(), quonListMsg->getAOIsize(), false, QDIRECT);
// add new neighbors
for(unsigned int i=0; i<quonListMsg->getNeighborHandleArraySize(); i++) {
addSite(quonListMsg->getNeighborPosition(i), quonListMsg->getNeighborHandle(i), quonListMsg->getAOIsize());
}
// update simple client
// contact new neighbors
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
QuonMoveMessage* quonMoveMsg = new QuonMoveMessage("NODE_MOVE");
quonMoveMsg->setCommand(NODE_MOVE);
quonMoveMsg->setSender(thisSite->address);
quonMoveMsg->setPosition(quonListMsg->getPosition());
quonMoveMsg->setAOIsize(AOIWidth);
if(itSites->second->type == QBINDING) {
quonMoveMsg->setIsBinding(true);
}
quonMoveMsg->setBitLength(QUONMOVE_L(quonMoveMsg));
sendMessage(quonMoveMsg, itSites->second->address);
}
}
void Quon::handleJoinRequest ( QuonMessage quonMsg)
private

Definition at line 775 of file Quon.cc.

Referenced by handleUDPMessage().

{
Vector2D joinPosition = quonMsg->getPosition();
// start with this node
double min_dist = thisSite->position.distanceSqr(joinPosition);
QuonSite* forwardSite = thisSite;
// iterate through all neighbors
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->position.distanceSqr(joinPosition) < min_dist) { //FIXME: use xy metric if desired?
min_dist = itSites->second->position.distanceSqr(joinPosition);
forwardSite = itSites->second;
}
}
// do nothing and let node retry with new position if current position is illegal
if(min_dist == 0.0) {
delete quonMsg;
}
else if(forwardSite->type == QTHIS) {
QuonListMessage* quonListMsg = new QuonListMessage("JOIN_ACKNOWLEDGE");
quonListMsg->setSender(thisSite->address);
quonListMsg->setPosition(thisSite->position);
quonListMsg->setAOIsize(AOIWidth);
// fill neighbors list
quonListMsg->setNeighborHandleArraySize(Sites.size());
quonListMsg->setNeighborPositionArraySize(Sites.size());
int i = 0;
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
quonListMsg->setNeighborHandle(i, itSites->second->address);
quonListMsg->setNeighborPosition(i, itSites->second->position);
++i;
}
quonListMsg->setNeighborHandleArraySize(i);
quonListMsg->setBitLength(QUONLIST_L(quonListMsg));
sendMessage(quonListMsg, quonMsg->getSender());
delete quonMsg;
}
else {
sendMessage(quonMsg, forwardSite->address);
}
}
void Quon::handleMove ( GameAPIPositionMessage gameMsg)
private

Definition at line 698 of file Quon.cc.

Referenced by handleAppMessage().

{
// adapt aoi
}
Vector2D position = gameMsg->getPosition();
// send position update to neighbors
QuonMoveMessage* quonMoveMsg = new QuonMoveMessage("NODE_MOVE");
quonMoveMsg->setCommand(NODE_MOVE);
quonMoveMsg->setSender(thisSite->address);
quonMoveMsg->setPosition(thisSite->position);
quonMoveMsg->setAOIsize(AOIWidth);
quonMoveMsg->setNewPosition(position);
quonMoveMsg->setBitLength(QUONMOVE_L(quonMoveMsg));
QuonMoveMessage* quonMoveBindingMsg = new QuonMoveMessage(*quonMoveMsg);
quonMoveBindingMsg->setNeighborHandleArraySize(Sites.size());
quonMoveBindingMsg->setNeighborPositionArraySize(Sites.size());
int i = 0;
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type == QBINDING || itSites->second->softNeighbor ) {
quonMoveBindingMsg->setNeighborHandle(i, itSites->second->address);
quonMoveBindingMsg->setNeighborPosition(i, itSites->second->position);
++i;
}
}
quonMoveBindingMsg->setNeighborHandleArraySize(i);
quonMoveBindingMsg->setNeighborPositionArraySize(i);
if(i > 0) {
// speedhack:
// instead of building individual MoveMessages for every binding and softstate neighbor,
// we just send all binding/soft to every other binding/soft neighbor and pretend we did not send neighbors their own neighborslistentry
quonMoveBindingMsg->setBitLength(QUONMOVE_L(quonMoveBindingMsg) - QUONENTRY_L);
}
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
QuonMoveMessage* copyMsg;
if(itSites->second->type == QBINDING || itSites->second->softNeighbor ) {
copyMsg = new QuonMoveMessage(*quonMoveBindingMsg);
if(itSites->second->type == QBINDING) {
copyMsg->setIsBinding(true);
}
else {
}
}
else {
copyMsg = new QuonMoveMessage(*quonMoveMsg);
}
sendMessage(copyMsg, itSites->second->address);
}
delete quonMoveMsg;
delete quonMoveBindingMsg;
// update position
updateThisSite(position);
// update simple client
}
void Quon::handleNewNeighbors ( QuonListMessage quonListMsg)
private

Definition at line 922 of file Quon.cc.

Referenced by handleUDPMessage().

{
addSite(quonListMsg->getPosition(), quonListMsg->getSender(), quonListMsg->getAOIsize(), false, QDIRECT);
// add new neighbors
handleInvalidNode(quonListMsg);
for(unsigned int i=0; i<quonListMsg->getNeighborHandleArraySize(); i++) {
addSite(quonListMsg->getNeighborPosition(i), quonListMsg->getNeighborHandle(i), quonListMsg->getAOIsize());
}
// update simple client
}
void Quon::handleNodeGracefulLeaveNotification ( )
virtual

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

Reimplemented from BaseOverlay.

Definition at line 530 of file Quon.cc.

{
if(qstate == QREADY) {
CompReadyMessage* readyMsg = new CompReadyMessage("OVERLAY_FINISHED");
readyMsg->setReady(false);
readyMsg->setComp(getThisCompType());
// TODO/FIXME: use overlay->sendMessageToAllComp(msg, getThisCompType())?
sendToApp(readyMsg);
if(Sites.size() > 0) {
// generate node leave messages
QuonListMessage* quonListMsg = new QuonListMessage("NODE_LEAVE");
quonListMsg->setCommand(NODE_LEAVE);
quonListMsg->setSender(thisSite->address);
quonListMsg->setPosition(thisSite->position);
quonListMsg->setAOIsize(AOIWidth);
// fill neighbors list
quonListMsg->setNeighborHandleArraySize(Sites.size());
quonListMsg->setNeighborPositionArraySize(Sites.size());
int i = 0;
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
quonListMsg->setNeighborHandle(i, itSites->second->address);
quonListMsg->setNeighborPosition(i, itSites->second->position);
++i;
}
quonListMsg->setBitLength(QUONLIST_L(quonListMsg));
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
QuonListMessage* quonCopyMsg = new QuonListMessage(*quonListMsg);
sendMessage(quonCopyMsg, itSites->second->address);
}
delete quonListMsg;
}
}
}
void Quon::handleNodeLeave ( QuonListMessage quonListMsg)
private

Definition at line 937 of file Quon.cc.

Referenced by handleUDPMessage().

{
deleteSite(quonListMsg->getSender());
// update simple client
deleteAppNeighbor(quonListMsg->getSender());
// insert into delete list
QuonSelfMessage* msg = new QuonSelfMessage("delete_timer");
msg->setKey(quonListMsg->getSender().getKey());
scheduleAt(simTime() + deleteTimeout, msg);
deletedSites.insert(std::make_pair(quonListMsg->getSender().getKey(), Vector2D(0,0)));
// add possible new neighbors
handleInvalidNode(quonListMsg);
for(unsigned int i=0; i<quonListMsg->getNeighborHandleArraySize(); i++) {
addSite(quonListMsg->getNeighborPosition(i), quonListMsg->getNeighborHandle(i), quonListMsg->getAOIsize(), true);
}
// update simple client
}
void Quon::handleNodeMove ( QuonMoveMessage quonMoveMsg)
private

Definition at line 850 of file Quon.cc.

Referenced by handleUDPMessage().

{
"QuON: MoveDelay",
SIMTIME_DBL(simTime()) - SIMTIME_DBL(quonMoveMsg->getCreationTime())
);
);
// IF node was marked for deletetion, remove it from the delete list
QDeleteMap::iterator delIt = deletedSites.find(quonMoveMsg->getSender().getKey());
if( delIt != deletedSites.end() ){
deletedSites.erase( delIt );
}
// Compute old and new AOI of moving node
QuonAOI oldAOI(quonMoveMsg->getPosition(), quonMoveMsg->getAOIsize(), useSquareMetric);
QuonAOI newAOI(quonMoveMsg->getNewPosition(), quonMoveMsg->getAOIsize(), useSquareMetric);
QuonSiteMap::iterator itSites = Sites.find(quonMoveMsg->getSender().getKey());
if(itSites != Sites.end() && itSites->second->AOIwidth < quonMoveMsg->getAOIsize()) {
oldAOI.resize(itSites->second->AOIwidth);
}
}
addSite(quonMoveMsg->getNewPosition(), quonMoveMsg->getSender(), quonMoveMsg->getAOIsize(), quonMoveMsg->getIsBinding(), QDIRECT);
// add new neighbors
handleInvalidNode(quonMoveMsg);
for(unsigned int i=0; i<quonMoveMsg->getNeighborHandleArraySize(); i++) {
addSite(quonMoveMsg->getNeighborPosition(i), quonMoveMsg->getNeighborHandle(i), quonMoveMsg->getAOIsize());
}
// update simple client
// send new neighbors
if( nnOnlyBinding && !quonMoveMsg->getIsBinding() ) return; //{
//QuonSiteMap::iterator itSites = Sites.find(quonMoveMsg->getSender().getKey());
//if (itSites->second->type != QBINDING && ! itSites->second->softNeighbor ) return;
//}
QuonListMessage* quonListMsg = new QuonListMessage("NEW_NEIGHBORS");
quonListMsg->setCommand(NEW_NEIGHBORS);
quonListMsg->setSender(thisSite->address);
quonListMsg->setPosition(thisSite->position);
quonListMsg->setAOIsize(AOIWidth);
quonListMsg->setNeighborHandleArraySize(Sites.size());
quonListMsg->setNeighborPositionArraySize(Sites.size());
int i = 0;
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(quonMoveMsg->getSender() != itSites->second->address &&
!oldAOI.collide(itSites->second->position) &&
newAOI.collide(itSites->second->position)) {
quonListMsg->setNeighborHandle(i, itSites->second->address);
quonListMsg->setNeighborPosition(i, itSites->second->position);
++i;
}
}
if(i > 0) {
quonListMsg->setNeighborHandleArraySize(i);
quonListMsg->setBitLength(QUONLIST_L(quonListMsg));
sendMessage(quonListMsg, quonMoveMsg->getSender());
}
else {
delete quonListMsg;
}
}
void Quon::handleTimerEvent ( cMessage *  msg)
virtual

Reimplemented from BaseRpc.

Definition at line 191 of file Quon.cc.

{
if(msg->isName("join_timer")) {
//reset timer
cancelEvent(join_timer);
if(qstate != QREADY) {
scheduleAt(simTime() + joinTimeout, msg);
// handle event
}
}
else if(msg->isName("sec_timer")) {
//reset timer
cancelEvent(sec_timer);
scheduleAt(simTime() + 1, msg);
// handle event
}
else if(msg->isName("delete_timer")) {
// handle event
}
else if(msg->isName("alive_timer")) {
//reset timer
cancelEvent(alive_timer);
scheduleAt(simTime() + aliveTimeout, msg);
// handle event
}
else if(msg->isName("backup_timer")) {
//reset timer
cancelEvent(backup_timer);
scheduleAt(simTime() + backupIntervall, msg);
// handle event
}
}
void Quon::handleUDPMessage ( BaseOverlayMessage msg)
virtual

Processes messages from underlay.

Parameters
msgMessage from UDP

Reimplemented from BaseOverlay.

Definition at line 260 of file Quon.cc.

{
delete msg;
return;
}
QuonMessage* quonMsg = dynamic_cast<QuonMessage*>(msg);
if(quonMsg != NULL) {
// debug output
EV << "[Quon::handleUDPMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Node " << thisSite->address.getIp() << " received " << quonMsg->getName() << " from " << quonMsg->getSender().getIp() << "."
<< endl;
}
if(qstate == QREADY) {
switch(quonMsg->getCommand()) {
case JOIN_REQUEST: {
} break;
case NODE_MOVE: {
QuonMoveMessage* quonMoveMsg = dynamic_cast<QuonMoveMessage*>(msg);
handleNodeMove(quonMoveMsg);
delete msg;
} break;
case NEW_NEIGHBORS: {
QuonListMessage* quonListMsg = dynamic_cast<QuonListMessage*>(msg);
handleNewNeighbors(quonListMsg);
delete msg;
} break;
case NODE_LEAVE: {
QuonListMessage* quonListMsg = dynamic_cast<QuonListMessage*>(msg);
handleNodeLeave(quonListMsg);
delete msg;
} break;
case QUON_EVENT: {
sendToApp(quonMsg->decapsulate());
delete quonMsg;
} break;
}
}
else if(qstate == QJOINING && quonMsg->getCommand() == JOIN_ACKNOWLEDGE) {
QuonListMessage* quonListMsg = dynamic_cast<QuonListMessage*>(msg);
handleJoinAcknowledge(quonListMsg);
delete msg;
}
else {
delete msg;
}
}
else {
delete msg;
}
}
void Quon::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 31 of file Quon.cc.

{
// because of IPAddressResolver, we need to wait until interfaces are registered,
// address auto-assignment takes place etc.
if(stage != MIN_STAGE_OVERLAY) {
return;
}
// fetch parameters
minAOI = (double)par("minAOIWidth") + (double)par("AOIBuffer"); // FIXME: use buffer only where required
maxAOI = (double)par("AOIWidth") + (double)par("AOIBuffer"); // FIXME: use buffer only where required
connectionLimit = par("connectionLimit");
areaDimension = par("areaDimension");
joinTimeout = par("joinTimeout");
deleteTimeout = par("deleteTimeout");
aliveTimeout = (double)par("aliveTimeout") / 2.0;
backupIntervall = par("contactBackupIntervall");
numBackups = par("numBackups");
linearAdaption = par("AOIAdaptLinear");
adaptionSensitivity = par("AOIAdaptionSensitivity");
gossipSensitivity = par("AOIGossipSensitivity");
useSquareMetric = par("useSquareMetric");
nnOnlyBinding = par("newNeighborsOnlyBinding");
loginCache = dynamic_cast<LoginCache*>(simulation.getModuleByPath("globalObserver.globalFunctions[0].function.loginCache"));
cacheInterval = par("cacheInterval");
// determine wether we want dynamic AOI or not
// set node key and thisSite pointer
thisSite = new QuonSite();
// initialize self-messages
join_timer = new cMessage("join_timer");
sec_timer = new cMessage("sec_timer");
alive_timer = new cMessage("alive_timer");
backup_timer = new cMessage("backup_timer");
// statistics
//rejoinCount = 0;
avgAOI= 0 ;
joinTime = 0;
// watch some variables
WATCH(thisSite->address);
WATCH(thisSite->position);
WATCH(AOIWidth);
//WATCH_POINTER_MAP(Sites);
//WATCH_POINTER_MAP(deletedSites);
//WATCH_SET(Positions);
//WATCH(rejoinCount);
// set initial state
aloneInOverlay = false;
}
void Quon::processAliveTimer ( )
private

Definition at line 620 of file Quon.cc.

Referenced by handleTimerEvent().

{
bool rebuild = false;
QuonSiteMap::iterator itSites = Sites.begin();
while(itSites != Sites.end()) {
if(itSites->second->alive) {
itSites->second->alive = false;
++itSites;
}
else {
NodeHandle node = itSites->second->address;
QuonSelfMessage* msg = new QuonSelfMessage("delete_timer");
msg->setKey(node.getKey());
scheduleAt(simTime() + deleteTimeout, msg);
deletedSites.insert(std::make_pair(node.getKey(), itSites->second->position));
++itSites;
deleteSite(node);
// update simple client
if(!rebuild) {
rebuild = true;
}
}
}
if(rebuild) {
// update simple client
}
}
void Quon::processBackupTimer ( )
private

Definition at line 652 of file Quon.cc.

Referenced by handleTimerEvent().

{
QuonMoveMessage* quonMoveMsg = new QuonMoveMessage("NODE_MOVE");
quonMoveMsg->setCommand(NODE_MOVE);
quonMoveMsg->setSender(thisSite->address);
quonMoveMsg->setPosition(thisSite->position);
quonMoveMsg->setAOIsize(AOIWidth);
quonMoveMsg->setIsBinding(true);
for(unsigned int i=0; i<4; i++) {
for( int ii = 0; ii < numBackups; ++ii ){
if(!bindingBackup[ii][i].isUnspecified()) {
QuonMoveMessage* copyMsg = new QuonMoveMessage(*quonMoveMsg);
copyMsg->setBitLength(QUONMOVE_L(copyMsg));
sendMessage(copyMsg, bindingBackup[ii][i]);
}
}
}
delete quonMoveMsg;
}
void Quon::processDeleteTimer ( cMessage *  msg)
private

Definition at line 610 of file Quon.cc.

Referenced by handleTimerEvent().

{
QuonSelfMessage* quonMsg = dynamic_cast<QuonSelfMessage*>(msg);
QDeleteMap::iterator itSite = deletedSites.find(quonMsg->getKey());
if(itSite != deletedSites.end()) {
deletedSites.erase(itSite);
}
cancelAndDelete(quonMsg);
}
void Quon::processJoinTimer ( )
private

Definition at line 566 of file Quon.cc.

Referenced by handleTimerEvent().

{
GameAPIMessage* gameMsg = new GameAPIMessage("MOVEMENT_REQUEST");
sendToApp(gameMsg);
}
void Quon::processSecTimer ( )
private

Definition at line 573 of file Quon.cc.

Referenced by handleTimerEvent().

{
}
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
switch(itSites->second->type) {
case QNEIGHBOR:
break;
case QBINDING:
break;
case QUNDEFINED:
if( itSites->second->softNeighbor ){
}
break;
case QTHIS:
break;
}
}
);
if( loginCache ) {
}
}
}
int Quon::purgeSites ( QPurgeType  purgeSoftSites = QKEEPSOFT)
private

Definition at line 473 of file Quon.cc.

Referenced by handleJoinAcknowledge(), handleMove(), handleNewNeighbors(), handleNodeLeave(), handleNodeMove(), and processAliveTimer().

{
int purged = 0;
QuonSiteMap::iterator itSites = Sites.begin();
while(itSites != Sites.end()) {
// Purge softNeighbors only if QPURGESOFT is set
if(itSites->second->type == QUNDEFINED && ( purgeSoftSites == QPURGESOFT || !itSites->second->softNeighbor) ) {
EV << "[Quon::purgeSites() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Site " << itSites->second->address.getIp() << " at " << itSites->second->position << " has been removed from the list.\n"
<< " Status: " << ((itSites->second->type == QUNDEFINED) ? "QUNDEFINED" : "QSOFT")
<< endl;
}
delete itSites->second;
Sites.erase(itSites++);
++purged;
}
else {
++itSites;
}
}
return purged;
}
void Quon::sendMessage ( QuonMessage quonMsg,
NodeHandle  destination 
)
private

Definition at line 1047 of file Quon.cc.

Referenced by handleEvent(), handleInvalidNode(), handleJoin(), handleJoinAcknowledge(), handleJoinRequest(), handleMove(), handleNodeGracefulLeaveNotification(), handleNodeMove(), and processBackupTimer().

{
// collect statistics
switch(quonMsg->getCommand()) {
joinRequestBytesSend += quonMsg->getByteLength();
break;
joinAcknowledgeBytesSend += quonMsg->getByteLength();
break;
case NODE_MOVE:
nodeMoveBytesSend += quonMsg->getByteLength();
break;
newNeighborsBytesSend += quonMsg->getByteLength();
break;
case NODE_LEAVE:
nodeLeaveBytesSend += quonMsg->getByteLength();
break;
}
if(qstate == QREADY) {
bytesPerSecond += quonMsg->getByteLength();
}
);
// debug output
EV << "[Quon::sendMessage() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Node " << thisSite->address.getIp() << " sending " << quonMsg->getName() << " to " << destination.getIp() << "."
<< endl;
}
sendMessageToUDP(destination, quonMsg);
}
void Quon::sendToApp ( cMessage *  msg)
private

Definition at line 1035 of file Quon.cc.

Referenced by adaptAoI(), changeState(), deleteAppNeighbor(), handleNodeGracefulLeaveNotification(), handleUDPMessage(), processJoinTimer(), and synchronizeAppNeighbors().

{
// debug output
EV << "[Quon::sendToApp() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " Node " << thisSite->address.getIp() << " sending " << msg->getName() << " to application."
<< endl;
}
send(msg, "appOut");
}
void Quon::setBootstrapedIcon ( )
private

Definition at line 1083 of file Quon.cc.

Referenced by changeState().

{
if(ev.isGUI()) {
switch(qstate) {
getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "red");
getDisplayString().setTagArg("i", 1, "red");
break;
case QJOINING:
getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "yellow");
getDisplayString().setTagArg("i", 1, "yellow");
break;
case QREADY:
getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "green");
getDisplayString().setTagArg("i", 1, "green");
break;
}
}
}
void Quon::synchronizeAppNeighbors ( QPurgeType  purgeSoftSites = QKEEPSOFT)
private

Definition at line 989 of file Quon.cc.

Referenced by handleJoinAcknowledge(), handleMove(), handleNewNeighbors(), handleNodeLeave(), handleNodeMove(), and processAliveTimer().

{
GameAPIListMessage* gameMsg = new GameAPIListMessage("NEIGHBOR_UPDATE");
gameMsg->setAddNeighborArraySize(Sites.size());
int remSize, addSize;
remSize = addSize = 0;
for(QuonSiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type == QUNDEFINED && (purgeSoftSites == QPURGESOFT || !itSites->second->softNeighbor) && itSites->second->dirty) {
gameMsg->setRemoveNeighbor(remSize, itSites->second->address);
++remSize;
}
else if(itSites->second->dirty) {
gameMsg->setAddNeighbor(addSize, itSites->second->address);
gameMsg->setNeighborPosition(addSize, itSites->second->position);
itSites->second->dirty = false;
++addSize;
}
}
if(remSize > 0 || addSize > 0) {
gameMsg->setRemoveNeighborArraySize(remSize);
gameMsg->setAddNeighborArraySize(addSize);
gameMsg->setNeighborPositionArraySize(addSize);
sendToApp(gameMsg);
}
else {
delete gameMsg;
}
}
void Quon::updateThisSite ( Vector2D  p)
private

Definition at line 364 of file Quon.cc.

Referenced by handleMove().

{
EV << "[Quon::updateThisSite() @ " << thisNode.getIp()
<< " (" << thisNode.getKey().toString(16) << ")]\n"
<< " This Site position has been updated to " << p << "."
<< endl;
}
}

Member Data Documentation

double Quon::adaptionSensitivity
private

Definition at line 78 of file Quon.h.

Referenced by adaptAoI(), and initializeOverlay().

cMessage* Quon::alive_timer
private

Definition at line 85 of file Quon.h.

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

simtime_t Quon::aliveTimeout
private

Definition at line 67 of file Quon.h.

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

bool Quon::aloneInOverlay
private

Definition at line 151 of file Quon.h.

Referenced by addSite(), classifySites(), handleJoin(), and initializeOverlay().

double Quon::areaDimension
private

Definition at line 72 of file Quon.h.

Referenced by getAreaDimension(), and initializeOverlay().

double Quon::averageBytesPerSecondSend
private

Definition at line 124 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

unsigned long Quon::avgAOI
private

Definition at line 132 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

cMessage* Quon::backup_timer
private

Definition at line 86 of file Quon.h.

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

simtime_t Quon::backupIntervall
private

Definition at line 73 of file Quon.h.

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

NodeHandle(* Quon::bindingBackup)[4]
private

Definition at line 146 of file Quon.h.

Referenced by classifySites(), initializeOverlay(), and processBackupTimer().

long Quon::bindingNeighborCount
private

Definition at line 128 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

double Quon::bytesPerSecond
private

Definition at line 125 of file Quon.h.

Referenced by handleJoinAcknowledge(), initializeOverlay(), processSecTimer(), and sendMessage().

int Quon::cacheInterval
private

Definition at line 155 of file Quon.h.

Referenced by initializeOverlay(), and processSecTimer().

unsigned int Quon::connectionLimit
private

Definition at line 71 of file Quon.h.

Referenced by adaptAoI(), and initializeOverlay().

QDeleteMap Quon::deletedSites
private
simtime_t Quon::deleteTimeout
private

Definition at line 66 of file Quon.h.

Referenced by handleNodeLeave(), initializeOverlay(), and processAliveTimer().

long Quon::directNeighborCount
private

Definition at line 129 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

double Quon::gossipSensitivity
private

Definition at line 79 of file Quon.h.

Referenced by adaptAoI(), and initializeOverlay().

cMessage* Quon::join_timer
private

Definition at line 83 of file Quon.h.

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

double Quon::joinAcknowledgeBytesSend
private

Definition at line 119 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and sendMessage().

double Quon::joinRequestBytesSend
private

Definition at line 118 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and sendMessage().

simtime_t Quon::joinTime
private

Definition at line 133 of file Quon.h.

Referenced by changeState(), and initializeOverlay().

simtime_t Quon::joinTimeout
private

Definition at line 65 of file Quon.h.

Referenced by handleTimerEvent(), and initializeOverlay().

bool Quon::linearAdaption
private

Definition at line 77 of file Quon.h.

Referenced by adaptAoI(), and initializeOverlay().

LoginCache* Quon::loginCache
private

Definition at line 154 of file Quon.h.

Referenced by changeState(), handleJoin(), initializeOverlay(), and processSecTimer().

double Quon::maxAOI
private

Definition at line 70 of file Quon.h.

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

double Quon::maxBytesPerSecondSend
private

Definition at line 123 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

double Quon::minAOI
private

Definition at line 69 of file Quon.h.

Referenced by adaptAoI(), and initializeOverlay().

double Quon::newNeighborsBytesSend
private

Definition at line 121 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and sendMessage().

bool Quon::nnOnlyBinding
private

Definition at line 80 of file Quon.h.

Referenced by handleNodeMove(), and initializeOverlay().

double Quon::nodeLeaveBytesSend
private

Definition at line 122 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and sendMessage().

double Quon::nodeMoveBytesSend
private

Definition at line 120 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and sendMessage().

int Quon::numBackups
private

Definition at line 147 of file Quon.h.

Referenced by classifySites(), initializeOverlay(), and processBackupTimer().

long Quon::rejoinCount
private

Definition at line 131 of file Quon.h.

Referenced by classifySites().

cMessage* Quon::sec_timer
private

Definition at line 84 of file Quon.h.

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

unsigned int Quon::secTimerCount
private

Definition at line 130 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

long Quon::softConnections
private

Definition at line 126 of file Quon.h.

Referenced by getSoftNeighborCount(), handleMove(), and initializeOverlay().

long Quon::softNeighborCount
private

Definition at line 127 of file Quon.h.

Referenced by finishOverlay(), initializeOverlay(), and processSecTimer().

int Quon::timeSinceCache
private

Definition at line 156 of file Quon.h.

Referenced by initializeOverlay(), and processSecTimer().

bool Quon::useDynamicAOI
private

Definition at line 74 of file Quon.h.

Referenced by handleMove(), handleNodeMove(), and initializeOverlay().

bool Quon::useSquareMetric
private

Definition at line 75 of file Quon.h.

Referenced by classifySites(), handleNodeMove(), and initializeOverlay().


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