OverSim
Quon.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 
25 #ifndef __QUON_H_
26 #define __QUON_H_
27 
28 #include <BaseOverlay.h>
29 #include <GlobalNodeList.h>
30 #include <GlobalStatistics.h>
31 #include <float.h>
32 
33 #include <Quon_m.h>
34 #include <QuonHelper.h>
35 #include "LoginCache.h"
36 
42 class Quon : public BaseOverlay
43 {
44  public:
45  // OMNeT++
46  ~Quon();
47  void initializeOverlay(int stage);
48  void finishOverlay();
50  void handleTimerEvent(cMessage* msg);
51  void handleAppMessage(cMessage* msg);
53 
54  QState getState();
55  double getAOI();
57  double getAreaDimension();
59  long getSoftNeighborCount();
60 
62 
63  private:
64  // parameters
65  simtime_t joinTimeout;
66  simtime_t deleteTimeout;
67  simtime_t aliveTimeout;
68  double AOIWidth;
69  double minAOI;
70  double maxAOI;
71  unsigned int connectionLimit;
72  double areaDimension;
73  simtime_t backupIntervall;
76 
81 
82  // timers
83  cMessage* join_timer;
84  cMessage* sec_timer;
85  cMessage* alive_timer;
86  cMessage* backup_timer;
87 
88  void sendToApp(cMessage* msg);
89  void sendMessage(QuonMessage* quonMsg, NodeHandle destination);
90  void setBootstrapedIcon();
92 
93  // timer processing
94  void processJoinTimer();
95  void processSecTimer();
96  void processDeleteTimer(cMessage* msg);
97  void processAliveTimer();
98  void processBackupTimer();
99 
100  // app handlers
101  void handleJoin(GameAPIPositionMessage* gameMsg);
102  void handleMove(GameAPIPositionMessage* gameMsg);
103  void handleEvent(GameAPIMessage* msg);
104 
105  // overlay handlers
106  void handleJoinRequest(QuonMessage* quonMsg);
107  void handleJoinAcknowledge(QuonListMessage* quonListMsg);
108  void handleNodeMove(QuonMoveMessage* quonMoveMsg);
109  void handleNewNeighbors(QuonListMessage* quonListMsg);
110  void handleNodeLeave(QuonListMessage* quonListMsg);
111  void handleInvalidNode(QuonListMessage* quonListMsg);
112 
113  // app<->overlay synchronisation
114  void synchronizeAppNeighbors(QPurgeType purgeSoftSites = QKEEPSOFT);
115  void deleteAppNeighbor(NodeHandle node);
116 
117  // statistics
130  unsigned int secTimerCount;
132  unsigned long avgAOI;
133  simtime_t joinTime;
134 
135  // quon functions
136  bool addSite(Vector2D p, NodeHandle node, double AOI, bool isSoft = false, QUpdateType update = QFOREIGN);
137  void updateThisSite(Vector2D p);
138  void classifySites();
139  bool deleteSite(NodeHandle node);
140  int purgeSites(QPurgeType purgeSoftSites = QKEEPSOFT);
141  void adaptAoI();
142 
143  // node references
148 
149  // node state
152 
153  // login cache
157 };
158 
159 #endif