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 00025 #ifndef __QUON_H_ 00026 #define __QUON_H_ 00027 00028 #include <BaseOverlay.h> 00029 #include <GlobalNodeList.h> 00030 #include <GlobalStatistics.h> 00031 #include <float.h> 00032 00033 #include <Quon_m.h> 00034 #include <QuonHelper.h> 00035 00041 class Quon : public BaseOverlay 00042 { 00043 public: 00044 // OMNeT++ 00045 ~Quon(); 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 handleNodeGracefulLeaveNotification(); 00052 00053 QState getState(); 00054 double getAOI(); 00055 Vector2D getPosition(); 00056 double getAreaDimension(); 00057 OverlayKey getKey(); 00058 long getSoftNeighborCount(); 00059 00060 QuonSiteMap Sites; 00061 00062 private: 00063 // parameters 00064 simtime_t joinTimeout; 00065 simtime_t deleteTimeout; 00066 simtime_t aliveTimeout; 00067 simtime_t AOIAdaptionIntervall; 00068 double AOIWidth; 00069 double minAOI; 00070 double maxAOI; 00071 unsigned int connectionLimit; 00072 double areaDimension; 00073 simtime_t backupIntervall; 00074 bool useDynamicAOI; 00075 bool useSquareMetric; 00076 00077 bool linearAdaption; 00078 double adaptionSensitivity; 00079 double gossipSensitivity; 00080 00081 // timers 00082 cMessage* join_timer; 00083 cMessage* sec_timer; 00084 cMessage* alive_timer; 00085 cMessage* backup_timer; 00086 cMessage* adaption_timer; 00087 00088 void sendToApp(cMessage* msg); 00089 void sendMessage(QuonMessage* quonMsg, NodeHandle destination); 00090 void setBootstrapedIcon(); 00091 void changeState(QState qstate); 00092 00093 // timer processing 00094 void processJoinTimer(); 00095 void processSecTimer(); 00096 void processDeleteTimer(cMessage* msg); 00097 void processAliveTimer(); 00098 void processBackupTimer(); 00099 00100 // app handlers 00101 void handleJoin(GameAPIPositionMessage* gameMsg); 00102 void handleMove(GameAPIPositionMessage* gameMsg); 00103 void handleEvent(GameAPIMessage* msg); 00104 00105 // overlay handlers 00106 void handleJoinRequest(QuonMessage* quonMsg); 00107 void handleJoinAcknowledge(QuonListMessage* quonListMsg); 00108 void handleNodeMove(QuonMoveMessage* quonMoveMsg); 00109 void handleNewNeighbors(QuonListMessage* quonListMsg); 00110 void handleNodeLeave(QuonListMessage* quonListMsg); 00111 void handleInvalidNode(QuonListMessage* quonListMsg); 00112 00113 // app<->overlay synchronisation 00114 void synchronizeAppNeighbors(QPurgeType purgeSoftSites = QKEEPSOFT); 00115 void deleteAppNeighbor(NodeHandle node); 00116 00117 // statistics 00118 double joinRequestBytesSend; 00119 double joinAcknowledgeBytesSend; 00120 double nodeMoveBytesSend; 00121 double newNeighborsBytesSend; 00122 double nodeLeaveBytesSend; 00123 double maxBytesPerSecondSend; 00124 double averageBytesPerSecondSend; 00125 double bytesPerSecond; 00126 long softConnections; 00127 long softNeighborCount; 00128 long bindingNeighborCount; 00129 long directNeighborCount; 00130 unsigned int secTimerCount; 00131 long rejoinCount; 00132 unsigned long avgAOI; 00133 00134 // p-quadtree functions 00135 bool addSite(Vector2D p, NodeHandle node, double AOI, bool isSoft = false, QUpdateType update = QFOREIGN); 00136 void updateThisSite(Vector2D p); 00137 void classifySites(); 00138 bool deleteSite(NodeHandle node); 00139 int purgeSites(QPurgeType purgeSoftSites = QKEEPSOFT); 00140 00141 // node references 00142 QuonSite* thisSite; 00143 QDeleteMap deletedSites; 00144 NodeHandle (*bindingBackup)[4]; 00145 int numBackups; 00146 00147 // node state 00148 QState qstate; 00149 }; 00150 00151 #endif