Vast.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __VAST_H_
00025 #define __VAST_H_
00026 
00027 #include <omnetpp.h>
00028 #include <BaseOverlay.h>
00029 #include <float.h>
00030 #include <VastDefs.h>
00031 #include <Vast_m.h>
00032 //#include <IPvXAddress.h>
00033 //#include <NodeHandle.h>
00034 //#include <NeighborsList.h>
00035 
00037 
00041 class Vast : public BaseOverlay
00042 {
00043     public:
00044         // OMNeT++
00045         ~Vast();
00046         void initializeOverlay(int stage);
00047         void finishOverlay();
00048         void handleUDPMessage(BaseOverlayMessage* msg);
00049         void handleTimerEvent(cMessage* msg);
00050         void handleAppMessage(cMessage* msg);
00051         void handleNodeLeaveNotification();
00052         void handleNodeGracefulLeaveNotification();
00053 
00054         double getAOI();
00055         Vector2D getPosition();
00056         NodeHandle getHandle();
00057         double getAreaDimension();
00058 
00059         SiteMap Sites;
00060         Site thisSite;
00061 
00062     protected:
00063         // node references
00064         double AOI_size;
00065         double areaDimension;
00066         PositionSet Positions;
00067         StockList Stock;
00068 
00069         // statistics
00070         long joinRequestBytesSent;
00071         long joinAcknowledgeBytesSent;
00072         long nodeMoveBytesSent;
00073         long newNeighborsBytesSent;
00074         long nodeLeaveBytesSent;
00075         long enclosingNeighborsRequestBytesSent;
00076         long pingBytesSent;
00077         long pongBytesSent;
00078         long discardNodeBytesSent;
00079 
00080         long maxBytesPerSecondSent, averageBytesPerSecondSent, bytesPerSecond;
00081         unsigned int secTimerCount;
00082 
00083         // parameters
00084         bool debugVoronoiOutput;
00085         simtime_t joinTimeout, pingTimeout, discoveryIntervall, checkCriticalIntervall;
00086         double criticalThreshold;
00087         unsigned long stockListSize;
00088 
00089         // Voronoi parameters
00090         Geometry geom;
00091         EdgeList edgelist;
00092         HeapPQ heap;
00093 
00094         void addNode(Vector2D p, NodeHandle node, int NeighborCount = 0);
00095         void addNodeToStock(NodeHandle node);
00096         void removeNode(NodeHandle node);
00097         void buildVoronoi();
00098         void buildVoronoi(Vector2D old_pos, Vector2D new_pos, NodeHandle enclosingCheck = NodeHandle::UNSPECIFIED_NODE);
00099         void removeNeighbors();
00100 
00101         // timers
00102         cMessage* join_timer;
00103         cMessage* ping_timer;
00104         cMessage* discovery_timer;
00105         cMessage* checkcritical_timer;
00106         cMessage* sec_timer;
00107 
00108         void sendToApp(cMessage* msg);
00109         void sendMessage(VastMessage* vastMsg, NodeHandle destAddr);
00110         void setBootstrapedIcon();
00111         void changeState(int state);
00112 
00113         // timer processing
00114         void processJoinTimer();
00115         void processPingTimer();
00116         void processSecTimer();
00117         void processCheckCriticalTimer();
00118         void processDiscoveryTimer();
00119 
00120         // app handlers
00121         void handleJoin(GameAPIPositionMessage* sgcMsg);
00122         void handleMove(GameAPIPositionMessage* sgcMsg);
00123         void handleEvent(GameAPIMessage* msg);
00124 
00125         // overlay handlers
00126         void handleJoinRequest(VastMessage *vastMsg);
00127         void handleJoinAcknowledge(VastListMessage *vastListMsg);
00128         void handleNodeMove(VastMoveMessage *vastMoveMsg);
00129         void handleNewNeighbors(VastListMessage *vastListMsg);
00130         void handleNodeLeave(VastListMessage *vastListMsg);
00131         void handleEnclosingNeighborsRequest(VastMessage *vastMsg);
00132         void handleBackupNeighbors(VastListMessage *vastListMsg);
00133         void handlePing(VastMessage *vastMsg);
00134         void handlePong(VastMessage *vastMsg);
00135         void handleDiscardNode(VastDiscardMessage *vastMsg);
00136         void sendDiscardNode(VastMessage *vastMsg);
00137         void synchronizeApp(VastMoveMessage *vastMoveMsg = NULL);
00138 };
00139 
00140 #endif
Generated on Wed May 26 16:21:15 2010 for OverSim by  doxygen 1.6.3