OverSim
Vast Class Reference

Voronoi class. More...

#include <Vast.h>

Inheritance diagram for Vast:
BaseOverlay BaseRpc BaseTcpSupport TopologyVis RpcListener

Public Member Functions

 ~Vast ()
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 handleNodeLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed.
void handleNodeGracefulLeaveNotification ()
 This method gets call **.gracefulLeaveDelay seconds before it is killed if this node is among the gracefulLeaveProbability nodes.
double getAOI ()
Vector2D getPosition ()
NodeHandle getHandle ()
double getAreaDimension ()
- 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)
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

SiteMap Sites
Site thisSite

Protected Member Functions

void addNode (Vector2D p, NodeHandle node, int NeighborCount=0)
void addNodeToStock (NodeHandle node)
void removeNode (NodeHandle node)
void buildVoronoi ()
void buildVoronoi (Vector2D old_pos, Vector2D new_pos, NodeHandle enclosingCheck=NodeHandle::UNSPECIFIED_NODE)
void removeNeighbors ()
void sendToApp (cMessage *msg)
void sendMessage (VastMessage *vastMsg, NodeHandle destAddr)
void setBootstrapedIcon ()
void changeState (int state)
void processJoinTimer ()
void processPingTimer ()
void processSecTimer ()
void processCheckCriticalTimer ()
void processDiscoveryTimer ()
void handleJoin (GameAPIPositionMessage *sgcMsg)
void handleMove (GameAPIPositionMessage *sgcMsg)
void handleEvent (GameAPIMessage *msg)
void handleJoinRequest (VastMessage *vastMsg)
void handleJoinAcknowledge (VastListMessage *vastListMsg)
void handleNodeMove (VastMoveMessage *vastMoveMsg)
void handleNewNeighbors (VastListMessage *vastListMsg)
void handleNodeLeave (VastListMessage *vastListMsg)
void handleEnclosingNeighborsRequest (VastMessage *vastMsg)
void handleBackupNeighbors (VastListMessage *vastListMsg)
void handlePing (VastMessage *vastMsg)
void handlePong (VastMessage *vastMsg)
void handleDiscardNode (VastDiscardMessage *vastMsg)
void sendDiscardNode (VastMessage *vastMsg)
void synchronizeApp (VastMoveMessage *vastMoveMsg=NULL)
- 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 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 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 bool handleRpcCall (BaseCallMessage *msg)
 Processes Remote-Procedure-Call invocation messages.
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, cPolymorphic *context, int rpcId, simtime_t rtt)
 This method is called if an RPC response has been received.
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 (BaseCallMessage *msg, const TransportAddress &dest, cPolymorphic *context, int rpcId, const OverlayKey &destKey)
 This method is called if an RPC timeout has been reached.
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

double AOI_size
double areaDimension
PositionSet Positions
StockList Stock
long joinRequestBytesSent
long joinAcknowledgeBytesSent
long nodeMoveBytesSent
long newNeighborsBytesSent
long nodeLeaveBytesSent
long enclosingNeighborsRequestBytesSent
long pingBytesSent
long pongBytesSent
long discardNodeBytesSent
long backupBytesSent
long maxBytesPerSecondSent
long averageBytesPerSecondSent
long bytesPerSecond
unsigned int secTimerCount
bool debugVoronoiOutput
simtime_t joinTimeout
simtime_t pingTimeout
simtime_t discoveryIntervall
simtime_t checkCriticalIntervall
double criticalThreshold
unsigned long stockListSize
Geometry geom
EdgeList edgelist
HeapPQ heap
cMessage * join_timer
cMessage * ping_timer
cMessage * discovery_timer
cMessage * checkcritical_timer
cMessage * sec_timer
- 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

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

Detailed Description

Voronoi class.

An overlay network based on voronoi diagrams.

Definition at line 41 of file Vast.h.

Constructor & Destructor Documentation

Vast::~Vast ( )

Definition at line 1205 of file Vast.cc.

{
if(Sites.size()) {
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
delete itSites->second;
}
Sites.clear();
Positions.clear();
}
// destroy self timer messages
cancelAndDelete(join_timer);
cancelAndDelete(ping_timer);
cancelAndDelete(sec_timer);
cancelAndDelete(discovery_timer);
cancelAndDelete(checkcritical_timer);
}

Member Function Documentation

void Vast::addNode ( Vector2D  p,
NodeHandle  node,
int  NeighborCount = 0 
)
protected

Definition at line 314 of file Vast.cc.

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

{
if(node != thisSite.addr) {
if(Sites.find(node) == Sites.end()) {
Site* temp_site = new Site();
temp_site->coord = p;
temp_site->addr = node;
temp_site->neighborCount = NeighborCount;
Sites.insert(std::make_pair(temp_site->addr, temp_site));
Positions.insert(temp_site->coord);
}
else {
SiteMap::iterator itSites = Sites.find(node);
Positions.erase(itSites->second->coord);
itSites->second->coord = p;
Positions.insert(itSites->second->coord);
if(NeighborCount != 0) {
itSites->second->neighborCount = NeighborCount;
}
}
}
}
void Vast::addNodeToStock ( NodeHandle  node)
protected

Definition at line 338 of file Vast.cc.

Referenced by handleBackupNeighbors().

{
if(node != thisSite.addr) {
for(StockList::iterator itTemp = Stock.begin(); itTemp != Stock.end(); ++itTemp) {
if(*itTemp == node) {
return;
}
}
Stock.push_front(node);
if(Stock.size() > stockListSize) {
Stock.pop_back();
}
}
}
void Vast::buildVoronoi ( )
protected
void Vast::buildVoronoi ( Vector2D  old_pos,
Vector2D  new_pos,
NodeHandle  enclosingCheck = NodeHandle::UNSPECIFIED_NODE 
)
protected

Definition at line 363 of file Vast.cc.

{
int sqrt_nsites = 1;
double xmin, xmax, ymin, ymax;
double deltax, deltay;
// check wether there are any neighbors
if(Sites.size() == 0) return;
xmin = xmax = thisSite.coord.x;
ymin = ymax = thisSite.coord.y;
std::map<Vector2D, Site*> sortedSites;
sortedSites.insert(std::make_pair(thisSite.coord, &thisSite));
for(SiteMap::iterator itTemp = Sites.begin(); itTemp != Sites.end(); ++itTemp) {
// determine min/max site coordinates
if(itTemp->second->coord.x < xmin) xmin = itTemp->second->coord.x;
if(itTemp->second->coord.x > xmax) xmax = itTemp->second->coord.x;
if(itTemp->second->coord.y < ymin) ymin = itTemp->second->coord.y;
if(itTemp->second->coord.y > ymax) ymax = itTemp->second->coord.y;
// reset all sites to UNDEF
itTemp->second->type = UNDEF;
// reset enclosing neighbors set
itTemp->second->enclosingSet.clear();
// fill sorted List
sortedSites.insert(std::make_pair(itTemp->second->coord, itTemp->second));
sqrt_nsites++;
}
// needed to determine appropriate hashtable size
deltax = xmax - xmin;
deltay = ymax - ymin;
sqrt_nsites = (int)sqrt((double)(sqrt_nsites+4));
// start to calculate the voronoi
Site *newsite, *bot, *top, *temp, *p, *v, *bottomsite;
Vector2D newintstar;
int pm;
Halfedge *lbnd, *rbnd, *llbnd, *rrbnd, *bisector;
Edge *e;
newintstar.x = newintstar.y = 0.0;
std::map<Vector2D, Site*>::iterator itSortedSites = sortedSites.begin();
geom.initialize(deltax, deltay, thisSite.coord, old_pos, new_pos, AOI_size);
heap.PQinitialize(sqrt_nsites, ymin, deltay);
bottomsite = itSortedSites->second;
++itSortedSites;
edgelist.initialize(sqrt_nsites, xmin, deltax, bottomsite);
newsite = itSortedSites->second;
++itSortedSites;
while(true) {
if(!heap.PQempty()) newintstar = heap.PQ_min();
if(newsite != NULL && (heap.PQempty() ||
newsite->coord.y < newintstar.y ||
(newsite->coord.y == newintstar.y && newsite->coord.x < newintstar.x))) {
lbnd = edgelist.ELleftbnd(&(newsite->coord));
rbnd = edgelist.ELright(lbnd);
bot = edgelist.rightreg(lbnd);
e = geom.bisect(bot, newsite);
bisector = edgelist.HEcreate(e, le);
edgelist.ELinsert(lbnd, bisector);
if ((p = geom.intersect(lbnd, bisector)) != NULL) {
heap.PQdelete(lbnd);
heap.PQinsert(lbnd, p, geom.dist(p, newsite));
}
lbnd = bisector;
bisector = edgelist.HEcreate(e, re);
edgelist.ELinsert(lbnd, bisector);
if ((p = geom.intersect(bisector, rbnd)) != NULL) heap.PQinsert(bisector, p, geom.dist(p, newsite));
if(itSortedSites != sortedSites.end()) {
newsite = itSortedSites->second;
++itSortedSites;
}
else newsite = NULL;
}
else if (!heap.PQempty()) {
lbnd = heap.PQextractmin();
llbnd = edgelist.ELleft(lbnd);
rbnd = edgelist.ELright(lbnd);
rrbnd = edgelist.ELright(rbnd);
bot = edgelist.leftreg(lbnd);
top = edgelist.rightreg(rbnd);
v = lbnd->vertex;
geom.endpoint(lbnd->ELedge, lbnd->ELpm, v);
geom.endpoint(rbnd->ELedge, rbnd->ELpm, v);
heap.PQdelete(rbnd);
pm = le;
if (bot->coord.y > top->coord.y) {
temp = bot;
bot = top;
top = temp;
pm = re;
}
e = geom.bisect(bot, top);
bisector = edgelist.HEcreate(e, pm);
edgelist.ELinsert(llbnd, bisector);
geom.endpoint(e, re-pm, v);
if((p = geom.intersect(llbnd, bisector)) != NULL) {
heap.PQdelete(llbnd);
heap.PQinsert(llbnd, p, geom.dist(p, bot));
}
if ((p = geom.intersect(bisector, rrbnd)) != NULL) heap.PQinsert(bisector, p, geom.dist(p, bot));
}
else break;
}
// process the generated edgelist
for(lbnd = edgelist.ELright(edgelist.ELleftend); lbnd != edgelist.ELrightend; lbnd = edgelist.ELright(lbnd)) {
e = lbnd -> ELedge;
}
// process sites in order to determine our neighbors
for(SiteMap::iterator itTemp = Sites.begin(); itTemp != Sites.end(); ++itTemp) {
if(itTemp->second->innerEdge[0]) {
if(itTemp->second->outerEdge) {
itTemp->second->type |= BOUNDARY;
// Debug output
EV << "[NeighborsList::buildVoronoi()]\n"
<< " Site at [" << itTemp->second->coord.x << ", "
<< itTemp->second->coord.y << "] is a boundary neighbor."
<< endl;
}
else {
itTemp->second->type |= NEIGHBOR;
// Debug output
EV << "[NeighborsList::buildVoronoi()]\n"
<< " Site at [" << itTemp->second->coord.x << ", "
<< itTemp->second->coord.y << "] is a neighbor."
<< endl;
}
}
// Treat enclosing neighbors whose voronoi region is outside our AOI as boundary neighbors
if((!itTemp->second->type & NEIGHBOR) && (itTemp->second->type & ENCLOSING)) {
itTemp->second->type |= BOUNDARY;
// Debug output
EV << "[NeighborsList::buildVoronoi()]\n"
<< " Site at [" << itTemp->second->coord.x << ", "
<< itTemp->second->coord.y << "] is a boundary neighbor."
<< endl;
}
if(!itTemp->second->innerEdge[1] && itTemp->second->innerEdge[2]) {
itTemp->second->type |= NEW;
// Debug output
EV << "[NeighborsList::buildVoronoi()]\n"
<< " Site at [" << itTemp->second->coord.x << ", "
<< itTemp->second->coord.y << "] is a new neighbor for site at " << new_pos.x << ":" << new_pos.y << "."
<< endl;
}
// enhanced enclosing check
if(!enclosingCheck.isUnspecified() && (Sites.find(enclosingCheck) != Sites.end())) {
Site* tempSite = Sites.find(enclosingCheck)->second;
for(EnclosingSet::iterator itSet = tempSite->enclosingSet.begin(); itSet != tempSite->enclosingSet.end(); ++itSet) {
if(tempSite->oldEnclosingSet.find(*itSet) == tempSite->oldEnclosingSet.end()
&& Sites.find(*itSet) != Sites.end()) {
Sites.find(*itSet)->second->type |= NEW;
}
}
tempSite->enclosingSet.swap(tempSite->oldEnclosingSet);
}
// reset inner- and outeredge indicator
itTemp->second->innerEdge[0] = false;
itTemp->second->innerEdge[1] = false;
itTemp->second->innerEdge[2] = false;
itTemp->second->outerEdge = false;
}
// clean up
}
void Vast::changeState ( int  state)
protected

Definition at line 106 of file Vast.cc.

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

{
switch(state) {
case INIT: {
this->state = INIT;
cancelEvent(join_timer);
cancelEvent(ping_timer);
cancelEvent(sec_timer);
cancelEvent(discovery_timer);
cancelEvent(checkcritical_timer);
} break;
case JOIN: {
this->state = JOIN;
scheduleAt(simTime(), join_timer);
scheduleAt(simTime() + 1.0, sec_timer);
} break;
case READY: {
this->state = READY;
cancelEvent(join_timer);
scheduleAt(simTime() + pingTimeout, ping_timer);
scheduleAt(simTime() + checkCriticalIntervall, checkcritical_timer);
scheduleAt(simTime() + discoveryIntervall, discovery_timer);
}
// tell the application we are ready
CompReadyMessage* readyMsg = new CompReadyMessage("OVERLAY_READY");
readyMsg->setReady(true);
readyMsg->setComp(getThisCompType());
sendToApp(readyMsg);
GameAPIResizeAOIMessage* gameMsg = new GameAPIResizeAOIMessage("RESIZE_AOI");
gameMsg->setAOIsize(AOI_size);
sendToApp(gameMsg);
} break;
}
// debug output
EV << "[Vast::changeState() @ " << thisSite.addr.getIp()
<< " (" << thisSite.addr.getKey().toString(16) << ")]\n"
<< "VAST: Node " << thisSite.addr.getIp() << " entered ";
switch(state) {
case INIT: ev << "INIT"; break;
case JOIN: ev << "JOIN"; break;
case READY: ev << "READY"; break;
}
ev << " state." << endl;
}
}
void Vast::finishOverlay ( )
virtual

collects statistical data in derived class

Reimplemented from BaseOverlay.

Definition at line 1157 of file Vast.cc.

{
// We use our own time count to avoid rounding errors
// simtime_t time = globalStatistics->calcMeasuredLifetime(creationTime);
// if(time == 0) return;
if(secTimerCount == 0) return;
// collect statistics
globalStatistics->addStdDev("Vast: JOIN_REQUEST bytes sent/s", joinRequestBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: JOIN_ACKNOWLEDGE bytes sent/s", joinAcknowledgeBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: NODE_MOVE bytes sent/s", nodeMoveBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: NEW_NEIGHBORS bytes sent/s", newNeighborsBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: NODE_LEAVE bytes sent/s", nodeLeaveBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: ENCLOSING_NEIGHBORS_REQUEST bytes sent/s", enclosingNeighborsRequestBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: PING bytes sent/s", pingBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: PONG bytes sent/s", pongBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: DISCARD_NODE bytes sent/s", discardNodeBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: BACKUP bytes sent/s", backupBytesSent/(double) secTimerCount);
globalStatistics->addStdDev("Vast: max bytes/second sent", maxBytesPerSecondSent);
globalStatistics->addStdDev("Vast: average bytes/second sent", averageBytesPerSecondSent / (double) secTimerCount);
}
double Vast::getAOI ( )

Definition at line 1181 of file Vast.cc.

{
Enter_Method_Silent();
return AOI_size;
}
double Vast::getAreaDimension ( )

Definition at line 1199 of file Vast.cc.

{
Enter_Method_Silent();
return areaDimension;
}
NodeHandle Vast::getHandle ( )

Definition at line 1193 of file Vast.cc.

Referenced by ConnectivityProbe::extractTopology().

{
Enter_Method_Silent();
return thisSite.addr;
}
Vector2D Vast::getPosition ( )

Definition at line 1187 of file Vast.cc.

{
Enter_Method_Silent();
return thisSite.coord;
}
void Vast::handleAppMessage ( cMessage *  msg)
virtual

Processes "timer" self-messages.

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

Reimplemented from BaseOverlay.

Definition at line 197 of file Vast.cc.

{
if(dynamic_cast<GameAPIMessage*>(msg)) {
GameAPIMessage* gameAPIMsg = check_and_cast<GameAPIMessage*>(msg);
// debug output
if(debugOutput) EV << "[Vast::handleAppMessage() @ " << thisSite.addr.getIp()
<< " (" << thisSite.addr.getKey().toString(16) << ")]\n"
<< " Node " << thisSite.addr.getIp() << " received " << gameAPIMsg->getName() << " from application."
<< endl;
switch(gameAPIMsg->getCommand()) {
GameAPIPositionMessage* gameAPIPosMsg = check_and_cast<GameAPIPositionMessage*>(msg);
if(state == JOIN) {
handleJoin(gameAPIPosMsg);
delete msg;
}
else if(state == READY) {
handleMove(gameAPIPosMsg);
delete msg;
}
} break;
handleEvent( gameAPIMsg );
delete msg;
break;
default: {
delete msg;
}
}
}
else delete msg;
}
void Vast::handleBackupNeighbors ( VastListMessage vastListMsg)
protected

Definition at line 975 of file Vast.cc.

Referenced by handleUDPMessage().

{
// add new neighbors to stock list
for(unsigned int i=0; i<vastListMsg->getNeighborNodeArraySize(); i++) {
if(Sites.find(vastListMsg->getNeighborNode(i)) == Sites.end()) {
addNodeToStock(vastListMsg->getNeighborNode(i));
}
}
}
void Vast::handleDiscardNode ( VastDiscardMessage vastMsg)
protected

Definition at line 1003 of file Vast.cc.

Referenced by handleUDPMessage().

{
// discard outdated entry
// update voronoi
//buildVoronoi();
//synchronizeApp();
// removeNeighbors();
}
void Vast::handleEnclosingNeighborsRequest ( VastMessage vastMsg)
protected

Definition at line 946 of file Vast.cc.

Referenced by handleUDPMessage().

{
// send new neighbors
VastListMessage *vastListMsg = new VastListMessage("NEW_NEIGHBORS");
vastListMsg->setCommand(NEW_NEIGHBORS);
vastListMsg->setNeighborNodeArraySize(Sites.size());
vastListMsg->setNeighborPosArraySize(Sites.size());
int i = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if((itSites->second->type & ENCLOSING) && itSites->second->addr != vastMsg->getSourceNode()) {
vastListMsg->setNeighborNode(i, itSites->second->addr);
vastListMsg->setNeighborPos(i, itSites->second->coord);
++i;
}
}
vastListMsg->setNeighborNodeArraySize(i);
vastListMsg->setNeighborPosArraySize(i);
vastListMsg->setBitLength(VASTLIST_L(vastListMsg));
if(vastListMsg->getNeighborNodeArraySize() > 0) {
sendMessage(vastListMsg, vastMsg->getSourceNode());
}
else {
delete vastListMsg;
}
}
void Vast::handleEvent ( GameAPIMessage msg)
protected

Definition at line 771 of file Vast.cc.

Referenced by handleAppMessage().

{
// send event to neighbors
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
VastEventMessage *vastMsg = new VastEventMessage("EVENT");
vastMsg->encapsulate((cPacket*)msg->dup());
// FIXME: Message length!
sendMessage(vastMsg, itSites->second->addr);
}
}
void Vast::handleJoin ( GameAPIPositionMessage sgcMsg)
protected

Definition at line 728 of file Vast.cc.

Referenced by handleAppMessage().

{
thisSite.coord = sgcMsg->getPosition();
// check if this is the only node in the overlay
if(joinNode.isUnspecified()) {
}
else {
VastMessage *vastMsg = new VastMessage("JOIN_REQUEST");
vastMsg->setBitLength(VAST_L(vastMsg));
sendMessage(vastMsg, joinNode);
}
}
void Vast::handleJoinAcknowledge ( VastListMessage vastListMsg)
protected

Definition at line 834 of file Vast.cc.

Referenced by handleUDPMessage().

{
// add acceptor node
addNode(vastListMsg->getPos(), vastListMsg->getSourceNode(), vastListMsg->getNeighborCount());
// add new neighbors
for(unsigned int i=0; i<vastListMsg->getNeighborNodeArraySize(); i++) {
addNode(vastListMsg->getNeighborPos(i), vastListMsg->getNeighborNode(i));
}
// update voronoi with new neighbors
// removeNeighbors();
// contact new neighbors
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
VastMoveMessage *vastMoveMsg = new VastMoveMessage("NODE_MOVE");
vastMoveMsg->setCommand(NODE_MOVE);
vastMoveMsg->setNewPos(thisSite.coord);
vastMoveMsg->setIs_boundary(itSites->second->type & BOUNDARY);
vastMoveMsg->setRequest_list(true);
vastMoveMsg->setBitLength(VASTMOVE_L(vastMoveMsg));
sendMessage(vastMoveMsg, itSites->second->addr);
}
}
void Vast::handleJoinRequest ( VastMessage vastMsg)
protected

Definition at line 783 of file Vast.cc.

Referenced by handleUDPMessage().

{
Site *forwardSite = NULL;
// start with this node
double min_dist = thisSite.coord.distanceSqr(vastMsg->getPos());
forwardSite = &thisSite;
// iterate through all neighbors
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
// dont forward to nodes which are still joining
if(itSites->second->coord.distanceSqr(vastMsg->getPos()) < min_dist && itSites->second->neighborCount >= 0) {
min_dist = itSites->second->coord.distanceSqr(vastMsg->getPos());
forwardSite = itSites->second;
}
}
// do nothing and let node retry with new position if current position is illegal
if(min_dist == 0.0) {
delete vastMsg;
}
else {
// send an acknowledge or forward request if any of our neighbors is closer to joining node
if(forwardSite->type & THIS) {
VastListMessage *vastListMsg = new VastListMessage("JOIN_ACKNOWLEDGE");
// fill neighbors list
vastListMsg->setNeighborNodeArraySize(Sites.size());
vastListMsg->setNeighborPosArraySize(Sites.size());
int i = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
vastListMsg->setNeighborNode(i, itSites->second->addr);
vastListMsg->setNeighborPos(i, itSites->second->coord);
++i;
}
vastListMsg->setBitLength(VASTLIST_L(vastListMsg));
sendMessage(vastListMsg, vastMsg->getSourceNode());
// add node to list to propagte its position early
// nieghborCount is set to -1 to indicate node is still joining
addNode(vastMsg->getPos(), vastMsg->getSourceNode(), -1);
// update voronoi with new neighbors
// removeNeighbors();
delete vastMsg;
}
else {
sendMessage(vastMsg, forwardSite->addr);
}
}
}
void Vast::handleMove ( GameAPIPositionMessage sgcMsg)
protected

Definition at line 744 of file Vast.cc.

Referenced by handleAppMessage().

{
Vector2D pos = sgcMsg->getPosition();
// test if new position is legal
if(Positions.find(pos) != Positions.end()) {
GameAPIMessage *gameMsg = new GameAPIMessage("MOVEMENT_REQUEST");
sendToApp(gameMsg);
return;
}
// set new position
thisSite.coord = pos;
// update voronoi
// send position update to neighbors
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
VastMoveMessage *vastMoveMsg = new VastMoveMessage("NODE_MOVE");
vastMoveMsg->setCommand(NODE_MOVE);
vastMoveMsg->setNewPos(pos);
vastMoveMsg->setIs_boundary(itSites->second->type & BOUNDARY);
vastMoveMsg->setBitLength(VASTMOVE_L(vastMoveMsg));
sendMessage(vastMoveMsg, itSites->second->addr);
}
}
void Vast::handleNewNeighbors ( VastListMessage vastListMsg)
protected

Definition at line 914 of file Vast.cc.

Referenced by handleUDPMessage().

{
// add new neighbors
for(unsigned int i=0; i<vastListMsg->getNeighborNodeArraySize(); i++) {
addNode(vastListMsg->getNeighborPos(i), vastListMsg->getNeighborNode(i));
if(vastListMsg->getRequestEnclosingNeighbors()) {
VastMessage *vastMsg = new VastMessage("ENCLOSING_NEIGHBORS_REQUEST");
vastMsg->setBitLength(VAST_L(vastMsg));
sendMessage(vastMsg, vastListMsg->getNeighborNode(i));
}
}
// update voronoi with new neighbors
// buildVoronoi();
// synchronizeApp();
// removeNeighbors();
}
void Vast::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 586 of file Vast.cc.

{
if(state == READY) {
// generate node leave messages
VastListMessage *vastListMsg = new VastListMessage("NODE_LEAVE");
vastListMsg->setCommand(NODE_LEAVE);
// fill neighbors list
vastListMsg->setNeighborNodeArraySize(Sites.size());
vastListMsg->setNeighborPosArraySize(Sites.size());
int i = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type & ENCLOSING) {
vastListMsg->setNeighborNode(i, itSites->second->addr);
vastListMsg->setNeighborPos(i, itSites->second->coord);
++i;
}
}
vastListMsg->setNeighborNodeArraySize(i);
vastListMsg->setNeighborPosArraySize(i);
vastListMsg->setBitLength(VASTLIST_L(vastListMsg));
if(vastListMsg->getNeighborNodeArraySize() > 0) {
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
VastListMessage *vastCopyMsg = new VastListMessage(*vastListMsg);
sendMessage(vastCopyMsg, itSites->second->addr);
}
}
delete vastListMsg;
}
}
void Vast::handleNodeLeave ( VastListMessage vastListMsg)
protected

Definition at line 933 of file Vast.cc.

Referenced by handleUDPMessage().

{
removeNode(vastListMsg->getSourceNode());
// add possible new neighbors
for(unsigned int i=0; i<vastListMsg->getNeighborNodeArraySize(); i++) {
addNode(vastListMsg->getNeighborPos(i), vastListMsg->getNeighborNode(i));
}
// update voronoi with new neighbors
// buildVoronoi();
// synchronizeApp();
// removeNeighbors();
}
void Vast::handleNodeLeaveNotification ( )
virtual

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

Reimplemented from BaseOverlay.

Definition at line 568 of file Vast.cc.

{
if(state == READY) {
// debug output
EV << "[Vast::receiveChangeNotification() @ " << thisSite.addr.getIp()
<< " (" << thisSite.addr.getKey().toString(16) << ")]\n"
<< " Node " << thisSite.addr.getIp() << " is leaving the overlay."
<< endl;
}
CompReadyMessage* readyMsg = new CompReadyMessage("OVERLAY_FINISHED");
readyMsg->setReady(false);
readyMsg->setComp(getThisCompType());
sendToApp(readyMsg);
}
}
void Vast::handleNodeMove ( VastMoveMessage vastMoveMsg)
protected

Definition at line 859 of file Vast.cc.

Referenced by handleUDPMessage().

{
"Vast: MoveDelay",
SIMTIME_DBL(simTime()) - SIMTIME_DBL(vastMoveMsg->getCreationTime())
);
);
Vector2D old_p, new_p;
old_p = vastMoveMsg->getPos();
new_p = vastMoveMsg->getNewPos();
addNode(new_p, vastMoveMsg->getSourceNode(), vastMoveMsg->getNeighborCount());
// update voronoi with new neighbor detection or without
if(vastMoveMsg->getIs_boundary() || vastMoveMsg->getRequest_list()) {
buildVoronoi(old_p, new_p, vastMoveMsg->getSourceNode()); // enhanced enclosing check
synchronizeApp(vastMoveMsg);
// removeNeighbors();
// send new neighbors
VastListMessage *vastListMsg = new VastListMessage("NEW_NEIGHBORS");
vastListMsg->setCommand(NEW_NEIGHBORS);
vastListMsg->setNeighborNodeArraySize(Sites.size());
vastListMsg->setNeighborPosArraySize(Sites.size());
int i = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type & NEW || vastMoveMsg->getRequest_list()) {
vastListMsg->setNeighborNode(i, itSites->second->addr);
vastListMsg->setNeighborPos(i, itSites->second->coord);
++i;
}
}
vastListMsg->setNeighborNodeArraySize(i);
vastListMsg->setNeighborPosArraySize(i);
vastListMsg->setRequestEnclosingNeighbors(true);
vastListMsg->setBitLength(VASTLIST_L(vastListMsg));
if(vastListMsg->getNeighborNodeArraySize() > 0) {
if( vastMoveMsg->getRequest_list() ) backupBytesSent += vastListMsg->getByteLength();
);
sendMessage(vastListMsg, vastMoveMsg->getSourceNode());
}
else {
delete vastListMsg;
}
}
else {
// buildVoronoi();
synchronizeApp(vastMoveMsg);
// removeNeighbors();
}
}
void Vast::handlePing ( VastMessage vastMsg)
protected

Definition at line 985 of file Vast.cc.

Referenced by handleUDPMessage().

{
VastMessage *vastPongMsg = new VastMessage("PONG");
vastPongMsg->setCommand(PONG);
vastPongMsg->setBitLength(VAST_L(vastPongMsg));
sendMessage(vastPongMsg, vastMsg->getSourceNode());
}
void Vast::handlePong ( VastMessage vastMsg)
protected

Definition at line 993 of file Vast.cc.

Referenced by handleUDPMessage().

{
// replace entry cause it was probably outdated
addNode(vastMsg->getPos(), vastMsg->getSourceNode(), vastMsg->getNeighborCount());
// update voronoi
//buildVoronoi();
//synchronizeApp();
// removeNeighbors();
}
void Vast::handleTimerEvent ( cMessage *  msg)
virtual

Reimplemented from BaseRpc.

Definition at line 158 of file Vast.cc.

{
if(msg->isName("join_timer")) {
//reset timer
cancelEvent(join_timer);
scheduleAt(simTime() + joinTimeout, msg);
// handle event
}
else if(msg->isName("ping_timer")) {
//reset timer
cancelEvent(ping_timer);
scheduleAt(simTime() + pingTimeout, msg);
// handle event
}
else if(msg->isName("sec_timer")) {
//reset timer
cancelEvent(sec_timer);
scheduleAt(simTime() + 1, msg);
// handle event
}
else if(msg->isName("checkcritical_timer")) {
//reset timer
cancelEvent(checkcritical_timer);
scheduleAt(simTime() + checkCriticalIntervall, msg);
// handle event
}
else if(msg->isName("discovery_timer")) {
//reset timer
cancelEvent(discovery_timer);
scheduleAt(simTime() + discoveryIntervall, msg);
// handle event
}
}
void Vast::handleUDPMessage ( BaseOverlayMessage msg)
virtual

Processes messages from underlay.

Parameters
msgMessage from UDP

Reimplemented from BaseOverlay.

Definition at line 232 of file Vast.cc.

{
if(state == INIT) {
delete msg;
return;
}
if(dynamic_cast<VastMessage*>(msg)) {
VastMessage* vastMsg = check_and_cast<VastMessage*>(msg);
if(vastMsg->getDestKey().isUnspecified() ||
vastMsg->getDestKey() == thisSite.addr.getKey()) {
// debug output
if(debugOutput) EV << "[Vast::handleUDPMessage() @ " << thisSite.addr.getIp()
<< " (" << thisSite.addr.getKey().toString(16) << ")]\n"
<< " Node " << thisSite.addr.getIp() << " received " << vastMsg->getName() << " from " << vastMsg->getSourceNode().getIp()
<< endl;
bool doUpdate = true;
if(state == READY) {
switch(vastMsg->getCommand()) {
case JOIN_REQUEST: {
doUpdate = false;
} break;
case NODE_MOVE: {
VastMoveMessage* vastMoveMsg = check_and_cast<VastMoveMessage*>(msg);
handleNodeMove(vastMoveMsg);
} break;
case NEW_NEIGHBORS: {
VastListMessage* vastListMsg = check_and_cast<VastListMessage*>(msg);
handleNewNeighbors(vastListMsg);
} break;
case NODE_LEAVE: {
VastListMessage* vastListMsg = check_and_cast<VastListMessage*>(msg);
handleNodeLeave(vastListMsg);
} break;
} break;
VastListMessage* vastListMsg = check_and_cast<VastListMessage*>(msg);
handleBackupNeighbors(vastListMsg);
} break;
case PING: {
handlePing(vastMsg);
} break;
case PONG: {
handlePong(vastMsg);
} break;
case DISCARD_NODE: {
VastDiscardMessage* vastDiscardMsg = check_and_cast<VastDiscardMessage*>(msg);
handleDiscardNode(vastDiscardMsg);
} break;
case VAST_EVENT: {
sendToApp(vastMsg->decapsulate());
doUpdate = false;
delete vastMsg;
} break;
}
// update timestamp
if(doUpdate) {
SiteMap::iterator itSites = Sites.find(vastMsg->getSourceNode());
if(itSites != Sites.end()) {
itSites->second->tstamp = simTime();
}
delete msg;
}
}
else if(state == JOIN && vastMsg->getCommand() == JOIN_ACKNOWLEDGE) {
VastListMessage* vastListMsg = check_and_cast<VastListMessage*>(msg);
handleJoinAcknowledge(vastListMsg);
delete msg;
}
else delete msg;
}
else {
sendDiscardNode(vastMsg);
delete msg;
}
}
else delete msg;
}
void Vast::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 34 of file Vast.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
debugVoronoiOutput = par("debugVastOutput");
areaDimension = par("areaDimension");
AOI_size = par("AOIWidth");
joinTimeout = par("joinTimeout");
pingTimeout = par("pingTimeout");
discoveryIntervall = par("discoveryIntervall");
checkCriticalIntervall = par("criticalCheckIntervall");
criticalThreshold = par("criticalThreshold");
stockListSize = par("stockListSize");
// set node key
// self-messages
join_timer = new cMessage("join_timer");
ping_timer = new cMessage("ping_timer");
sec_timer = new cMessage("sec_timer");
discovery_timer = new cMessage("discovery_timer");
checkcritical_timer = new cMessage("checkcritical_timer");
// statistics
// watch some variables
WATCH(AOI_size);
WATCH(thisSite);
WATCH_MAP(Sites);
WATCH_SET(Positions);
WATCH(pingBytesSent);
WATCH(pongBytesSent);
// set initial state
}
void Vast::processCheckCriticalTimer ( )
protected

Definition at line 678 of file Vast.cc.

Referenced by handleTimerEvent().

{
double NeighborLevel;
int NeighborSum = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->neighborCount > 0) {
NeighborSum += itSites->second->neighborCount;
}
}
NeighborLevel = (double)(Sites.size() * Sites.size()) / (double)NeighborSum;
if(NeighborLevel < criticalThreshold) {
VastListMessage *vastListMsg = new VastListMessage("BACKUP_NEIGHBORS");
// fill neighbors list
vastListMsg->setNeighborNodeArraySize(Sites.size());
vastListMsg->setNeighborPosArraySize(Sites.size());
int i = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
vastListMsg->setNeighborNode(i, itSites->second->addr);
vastListMsg->setNeighborPos(i, itSites->second->coord);
++i;
}
vastListMsg->setBitLength(VASTLIST_L(vastListMsg));
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
VastListMessage *vastCopyMsg = new VastListMessage(*vastListMsg);
backupBytesSent += vastCopyMsg->getByteLength();
);
sendMessage(vastCopyMsg, itSites->second->addr);
}
delete vastListMsg;
}
}
void Vast::processDiscoveryTimer ( )
protected

Definition at line 713 of file Vast.cc.

Referenced by handleTimerEvent().

{
for(StockList::iterator itStock = Stock.begin(); itStock != Stock.end(); ++itStock) {
VastMoveMessage *vastMoveMsg = new VastMoveMessage("NODE_MOVE");
vastMoveMsg->setCommand(NODE_MOVE);
vastMoveMsg->setNewPos(thisSite.coord);
vastMoveMsg->setRequest_list(true);
vastMoveMsg->setBitLength(VASTMOVE_L(vastMoveMsg));
backupBytesSent += vastMoveMsg->getByteLength();
);
sendMessage(vastMoveMsg, *itStock);
}
}
void Vast::processJoinTimer ( )
protected

Definition at line 618 of file Vast.cc.

Referenced by handleTimerEvent().

{
GameAPIMessage *sgcMsg = new GameAPIMessage("MOVEMENT_REQUEST");
sendToApp(sgcMsg);
}
void Vast::processPingTimer ( )
protected

Definition at line 625 of file Vast.cc.

Referenced by handleTimerEvent().

{
bool abnormalLeave = false;
bool boundaryLeave = false;
std::set<NodeHandle> removeSet;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->tstamp < 0.0) { // node is dropped cause no pong has been received see below
abnormalLeave = true;
if(!(itSites->second->type & NEIGHBOR)) boundaryLeave = true;
itSites->second->type = UNDEF;
removeSet.insert( itSites->first );
}
else if(itSites->second->tstamp < simTime() - pingTimeout) { // node showed no activity for some time request pong and mark it to be dropped next time
VastMessage *vastMsg = new VastMessage("PING");
vastMsg->setCommand(PING);
vastMsg->setBitLength(VAST_L(vastMsg));
sendMessage(vastMsg, itSites->second->addr);
itSites->second->tstamp = -1.0;
}
}
if(abnormalLeave) {
for( std::set<NodeHandle>::iterator it = removeSet.begin(); it != removeSet.end(); ++it) {
removeNode( *it );
}
// removeNeighbors();
if(boundaryLeave) {
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type & BOUNDARY) {
VastMessage *vastMsg = new VastMessage("ENCLOSING_NEIGHBORS_REQUEST");
vastMsg->setBitLength(VAST_L(vastMsg));
sendMessage(vastMsg, itSites->second->addr);
}
}
}
//buildVoronoi();
//removeNeighbors(); should be superfluous
}
}
void Vast::processSecTimer ( )
protected
void Vast::removeNeighbors ( )
protected

Definition at line 550 of file Vast.cc.

Referenced by handleMove().

{
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end();) {
// if current site is no neighbor remove it else go on to next site
if(itSites->second->type == UNDEF) {
// Debug output
if(debugOutput) EV << "[NeighborsList::removeNeighbors()]\n"
<< " Site at [" << itSites->second->coord.x << ", " << itSites->second->coord.y
<< "] has been removed from list."
<< endl;
Positions.erase(itSites->second->coord);
delete itSites->second;
Sites.erase(itSites++);
}
else ++itSites;
}
}
void Vast::removeNode ( NodeHandle  node)
protected

Definition at line 353 of file Vast.cc.

Referenced by handleDiscardNode(), handleNodeLeave(), and processPingTimer().

{
SiteMap::iterator itSites = Sites.find(node);
if(itSites != Sites.end()) {
Positions.erase(itSites->second->coord);
delete itSites->second;
Sites.erase(itSites);
}
}
void Vast::sendDiscardNode ( VastMessage vastMsg)
protected

Definition at line 1013 of file Vast.cc.

Referenced by handleUDPMessage().

{
NodeHandle discardNode;
discardNode.setIp(thisSite.addr.getIp());
discardNode.setKey(vastMsg->getDestKey());
// send message
VastDiscardMessage *vastDiscardMsg = new VastDiscardMessage("DISCARD_NODE");
vastDiscardMsg->setCommand(DISCARD_NODE);
vastDiscardMsg->setDiscardNode(discardNode);
// debug output
if(debugOutput) EV << "[Vast::sendDiscardNode() @ " << thisSite.addr.getIp()
<< " (" << thisSite.addr.getKey().toString(16) << ")]\n"
<< " Node " << thisSite.addr.getIp() << " is leaving the overlay."
<< endl;
vastDiscardMsg->setBitLength(VASTDISCARD_L(vastDiscardMsg));
sendMessage(vastDiscardMsg, vastMsg->getSourceNode());
}
void Vast::sendMessage ( VastMessage vastMsg,
NodeHandle  destAddr 
)
protected

Definition at line 1085 of file Vast.cc.

Referenced by handleEnclosingNeighborsRequest(), handleEvent(), handleJoin(), handleJoinAcknowledge(), handleJoinRequest(), handleMove(), handleNewNeighbors(), handleNodeGracefulLeaveNotification(), handleNodeMove(), handlePing(), processCheckCriticalTimer(), processDiscoveryTimer(), processPingTimer(), and sendDiscardNode().

{
// collect statistics
switch(vastMsg->getCommand()) {
case JOIN_REQUEST: {
joinRequestBytesSent += vastMsg->getByteLength();
} break;
joinAcknowledgeBytesSent += vastMsg->getByteLength();
} break;
case NODE_MOVE: {
nodeMoveBytesSent += vastMsg->getByteLength();
} break;
case NEW_NEIGHBORS: {
newNeighborsBytesSent += vastMsg->getByteLength();
} break;
case NODE_LEAVE: {
nodeLeaveBytesSent += vastMsg->getByteLength();
} break;
enclosingNeighborsRequestBytesSent += vastMsg->getByteLength();
} break;
case PING: {
pingBytesSent += vastMsg->getByteLength();
} break;
case PONG: {
pongBytesSent += vastMsg->getByteLength();
} break;
case DISCARD_NODE: {
discardNodeBytesSent += vastMsg->getByteLength();
} break;
}
bytesPerSecond += vastMsg->getByteLength();
);
// debug output
if(debugOutput) EV << "[Vast::sendMessage() @ " << thisSite.addr.getIp()
<< " (" << thisSite.addr.getKey().toString(16) << ")]\n"
<< " Node " << thisSite.addr.getIp() << " sending " << vastMsg->getName() << " to " << destAddr.getIp() << "."
<< endl;
// set vastbase message stuff
vastMsg->setDestKey(destAddr.getKey());
// fill in sender information only if we are not forwarding a message from another node
// e.g. a joining node
if(vastMsg->getSourceNode().isUnspecified()) {
vastMsg->setPos(thisSite.coord);
vastMsg->setNeighborCount(Sites.size());
}
sendMessageToUDP(destAddr, vastMsg);
}
void Vast::sendToApp ( cMessage *  msg)
protected

Definition at line 1075 of file Vast.cc.

Referenced by changeState(), handleMove(), handleNodeLeaveNotification(), handleUDPMessage(), processJoinTimer(), and synchronizeApp().

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

Definition at line 1139 of file Vast.cc.

Referenced by changeState().

{
if(ev.isGUI()) {
if(state == READY) {
getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "green");
getDisplayString().setTagArg("i", 1, "green");
}
else if(state == JOIN) {
getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "yellow");
getDisplayString().setTagArg("i", 1, "yellow");
}
else {
getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 1, "red");
getDisplayString().setTagArg("i", 1, "red");
}
}
}
void Vast::synchronizeApp ( VastMoveMessage vastMoveMsg = NULL)
protected

Definition at line 1031 of file Vast.cc.

Referenced by handleJoinAcknowledge(), handleJoinRequest(), handleMove(), handleNodeMove(), and processPingTimer().

{
GameAPIListMessage *sgcMsg = new GameAPIListMessage("NEIGHBOR_UPDATE");
sgcMsg->setAddNeighborArraySize(Sites.size() + 1);
sgcMsg->setNeighborPositionArraySize(Sites.size() + 1);
int remSize, addSize;
remSize = addSize = 0;
for(SiteMap::iterator itSites = Sites.begin(); itSites != Sites.end(); ++itSites) {
if(itSites->second->type == UNDEF) {
sgcMsg->setRemoveNeighbor(remSize, itSites->second->addr);
++remSize;
}
else if(!itSites->second->isAdded) {
sgcMsg->setAddNeighbor(addSize, itSites->second->addr);
sgcMsg->setNeighborPosition(addSize, itSites->second->coord);
itSites->second->isAdded = true;
++addSize;
}
}
if(vastMoveMsg &&
Sites.find(vastMoveMsg->getSourceNode()) != Sites.end() &&
Sites.find(vastMoveMsg->getSourceNode())->second->isAdded) {
sgcMsg->setAddNeighbor(addSize, vastMoveMsg->getSourceNode());
sgcMsg->setNeighborPosition(addSize, vastMoveMsg->getNewPos());
++addSize;
}
sgcMsg->setRemoveNeighborArraySize(remSize);
sgcMsg->setAddNeighborArraySize(addSize);
sgcMsg->setNeighborPositionArraySize(addSize);
sendToApp(sgcMsg);
}
else {
delete sgcMsg;
}
}

Member Data Documentation

double Vast::AOI_size
protected

Definition at line 64 of file Vast.h.

Referenced by buildVoronoi(), changeState(), getAOI(), and initializeOverlay().

double Vast::areaDimension
protected

Definition at line 65 of file Vast.h.

Referenced by getAreaDimension(), and initializeOverlay().

long Vast::averageBytesPerSecondSent
protected

Definition at line 81 of file Vast.h.

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

long Vast::backupBytesSent
protected
long Vast::bytesPerSecond
protected

Definition at line 81 of file Vast.h.

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

cMessage* Vast::checkcritical_timer
protected

Definition at line 106 of file Vast.h.

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

simtime_t Vast::checkCriticalIntervall
protected

Definition at line 86 of file Vast.h.

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

double Vast::criticalThreshold
protected

Definition at line 87 of file Vast.h.

Referenced by initializeOverlay(), and processCheckCriticalTimer().

bool Vast::debugVoronoiOutput
protected

Definition at line 85 of file Vast.h.

Referenced by initializeOverlay().

long Vast::discardNodeBytesSent
protected

Definition at line 78 of file Vast.h.

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

cMessage* Vast::discovery_timer
protected

Definition at line 105 of file Vast.h.

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

simtime_t Vast::discoveryIntervall
protected

Definition at line 86 of file Vast.h.

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

EdgeList Vast::edgelist
protected

Definition at line 92 of file Vast.h.

Referenced by buildVoronoi().

long Vast::enclosingNeighborsRequestBytesSent
protected

Definition at line 75 of file Vast.h.

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

Geometry Vast::geom
protected

Definition at line 91 of file Vast.h.

Referenced by buildVoronoi(), and initializeOverlay().

HeapPQ Vast::heap
protected

Definition at line 93 of file Vast.h.

Referenced by buildVoronoi().

cMessage* Vast::join_timer
protected

Definition at line 103 of file Vast.h.

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

long Vast::joinAcknowledgeBytesSent
protected

Definition at line 71 of file Vast.h.

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

long Vast::joinRequestBytesSent
protected

Definition at line 70 of file Vast.h.

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

simtime_t Vast::joinTimeout
protected

Definition at line 86 of file Vast.h.

Referenced by handleTimerEvent(), and initializeOverlay().

long Vast::maxBytesPerSecondSent
protected

Definition at line 81 of file Vast.h.

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

long Vast::newNeighborsBytesSent
protected

Definition at line 73 of file Vast.h.

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

long Vast::nodeLeaveBytesSent
protected

Definition at line 74 of file Vast.h.

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

long Vast::nodeMoveBytesSent
protected

Definition at line 72 of file Vast.h.

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

cMessage* Vast::ping_timer
protected

Definition at line 104 of file Vast.h.

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

long Vast::pingBytesSent
protected

Definition at line 76 of file Vast.h.

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

simtime_t Vast::pingTimeout
protected

Definition at line 86 of file Vast.h.

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

long Vast::pongBytesSent
protected

Definition at line 77 of file Vast.h.

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

PositionSet Vast::Positions
protected

Definition at line 66 of file Vast.h.

Referenced by addNode(), handleMove(), initializeOverlay(), removeNeighbors(), removeNode(), and ~Vast().

cMessage* Vast::sec_timer
protected

Definition at line 107 of file Vast.h.

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

unsigned int Vast::secTimerCount
protected

Definition at line 82 of file Vast.h.

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

StockList Vast::Stock
protected

Definition at line 67 of file Vast.h.

Referenced by addNodeToStock(), and processDiscoveryTimer().

unsigned long Vast::stockListSize
protected

Definition at line 88 of file Vast.h.

Referenced by addNodeToStock(), and initializeOverlay().


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