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 __QUONPR_H_ 00025 #define __QUONPR_H_ 00026 00027 #include <BaseOverlay.h> 00028 #include <GlobalNodeList.h> 00029 #include <GlobalStatistics.h> 00030 #include <float.h> 00031 00032 #include <QuonPR_m.h> 00033 #include <QuonPRDefs.h> 00034 00036 00040 class QuonPR : public BaseOverlay 00041 { 00042 public: 00043 // OMNeT++ 00044 ~QuonPR(); 00045 void initializeOverlay(int stage); 00046 void finishOverlay(); 00047 void handleUDPMessage(BaseOverlayMessage* msg); 00048 void handleTimerEvent(cMessage* msg); 00049 void handleAppMessage(cMessage* msg); 00050 void handleNodeLeaveNotification(); 00051 void handleNodeGracefulLeaveNotification(); 00052 00053 QState getState(); 00054 double getAOI(); 00055 Vector2D getPosition(); 00056 double getAreaDimension(); 00057 OverlayKey getKey(); 00058 long getSoftNeighborCount(); 00059 00060 PRSiteMap 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 00076 // timers 00077 cMessage* join_timer; 00078 cMessage* sec_timer; 00079 cMessage* alive_timer; 00080 cMessage* backup_timer; 00081 cMessage* adaption_timer; 00082 00083 void sendToApp(cMessage* msg); 00084 void sendMessage(QuonPRMessage* quonMsg, NodeHandle destination); 00085 void setBootstrapedIcon(); 00086 void changeState(QState qstate); 00087 00088 // timer processing 00089 void processJoinTimer(); 00090 void processSecTimer(); 00091 void processDeleteTimer(cMessage* msg); 00092 void processAliveTimer(); 00093 void processBackupTimer(); 00094 00095 // app handlers 00096 void handleJoin(GameAPIPositionMessage* gameMsg); 00097 void handleMove(GameAPIPositionMessage* gameMsg); 00098 void handleEvent(GameAPIMessage* msg); 00099 00100 // overlay handlers 00101 void handleJoinRequest(QuonPRMessage* quonMsg); 00102 void handleJoinAcknowledge(QuonPRListMessage* quonListMsg); 00103 void handleNodeMove(QuonPRMoveMessage* quonMoveMsg); 00104 void handleNewNeighbors(QuonPRListMessage* quonListMsg); 00105 void handleNodeLeave(QuonPRListMessage* quonListMsg); 00106 void handleInvalidNode(QuonPRListMessage* quonListMsg); 00107 void handleInvalidNode(QuonPRMoveMessage* quonMoveMsg); 00108 00109 // app<->overlay synchronisation 00110 void synchronizeAppNeighbors(QPurgeType purgeSoftSites = QKEEPSOFT); 00111 void deleteAppNeighbor(NodeHandle node); 00112 00113 // statistics 00114 double joinRequestBytesSend; 00115 double joinAcknowledgeBytesSend; 00116 double nodeMoveBytesSend; 00117 double newNeighborsBytesSend; 00118 double nodeLeaveBytesSend; 00119 double maxBytesPerSecondSend; 00120 double averageBytesPerSecondSend; 00121 double bytesPerSecond; 00122 long softConnections; 00123 long softNeighborCount; 00124 long bindingNeighborCount; 00125 long directNeighborCount; 00126 long rejoinCount; 00127 00128 // pr-quadtree root 00129 PRTreeNode* PRTree; 00130 00131 // pr-quadtree functions 00132 bool addSite(Vector2D p, NodeHandle node, double AOI, QNeighborType type = QUNDEFINED, QUpdateType update = QFOREIGN); 00133 void updateThisSite(Vector2D p); 00134 void classifySites(); 00135 bool deleteSite(NodeHandle node); 00136 int purgeSites(QPurgeType purgeSoftSites = QKEEPSOFT); 00137 00138 // node references 00139 QPRSite* thisSite; 00140 QPositionSet Positions; 00141 QDeleteMap deletedSites; 00142 NodeHandle bindingBackup[8]; 00143 00144 // node state 00145 QState qstate; 00146 }; 00147 00148 #endif
1.5.5