OverSim
Vast.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __VAST_H_
25 #define __VAST_H_
26 
27 #include <omnetpp.h>
28 #include <BaseOverlay.h>
29 #include <float.h>
30 #include <VastDefs.h>
31 #include <Vast_m.h>
32 //#include <IPvXAddress.h>
33 //#include <NodeHandle.h>
34 //#include <NeighborsList.h>
35 
37 
41 class Vast : public BaseOverlay
42 {
43  public:
44  // OMNeT++
45  ~Vast();
46  void initializeOverlay(int stage);
47  void finishOverlay();
49  void handleTimerEvent(cMessage* msg);
50  void handleAppMessage(cMessage* msg);
53 
54  double getAOI();
57  double getAreaDimension();
58 
61 
62  protected:
63  // node references
64  double AOI_size;
65  double areaDimension;
68 
69  // statistics
80 
82  unsigned int secTimerCount;
83 
84  // parameters
88  unsigned long stockListSize;
89 
90  // Voronoi parameters
94 
95  void addNode(Vector2D p, NodeHandle node, int NeighborCount = 0);
96  void addNodeToStock(NodeHandle node);
97  void removeNode(NodeHandle node);
98  void buildVoronoi();
99  void buildVoronoi(Vector2D old_pos, Vector2D new_pos, NodeHandle enclosingCheck = NodeHandle::UNSPECIFIED_NODE);
100  void removeNeighbors();
101 
102  // timers
103  cMessage* join_timer;
104  cMessage* ping_timer;
105  cMessage* discovery_timer;
107  cMessage* sec_timer;
108 
109  void sendToApp(cMessage* msg);
110  void sendMessage(VastMessage* vastMsg, NodeHandle destAddr);
111  void setBootstrapedIcon();
112  void changeState(int state);
113 
114  // timer processing
115  void processJoinTimer();
116  void processPingTimer();
117  void processSecTimer();
119  void processDiscoveryTimer();
120 
121  // app handlers
122  void handleJoin(GameAPIPositionMessage* sgcMsg);
123  void handleMove(GameAPIPositionMessage* sgcMsg);
124  void handleEvent(GameAPIMessage* msg);
125 
126  // overlay handlers
127  void handleJoinRequest(VastMessage *vastMsg);
128  void handleJoinAcknowledge(VastListMessage *vastListMsg);
129  void handleNodeMove(VastMoveMessage *vastMoveMsg);
130  void handleNewNeighbors(VastListMessage *vastListMsg);
131  void handleNodeLeave(VastListMessage *vastListMsg);
133  void handleBackupNeighbors(VastListMessage *vastListMsg);
134  void handlePing(VastMessage *vastMsg);
135  void handlePong(VastMessage *vastMsg);
136  void handleDiscardNode(VastDiscardMessage *vastMsg);
137  void sendDiscardNode(VastMessage *vastMsg);
138  void synchronizeApp(VastMoveMessage *vastMoveMsg = NULL);
139 };
140 
141 #endif