Quon.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 
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         double AOIWidth;
00068         double minAOI;
00069         double maxAOI;
00070         unsigned int connectionLimit;
00071         double areaDimension;
00072         simtime_t backupIntervall;
00073         bool useDynamicAOI;
00074         bool useSquareMetric;
00075 
00076         bool linearAdaption;
00077         double adaptionSensitivity;
00078         double gossipSensitivity;
00079 
00080         // timers
00081         cMessage* join_timer;
00082         cMessage* sec_timer;
00083         cMessage* alive_timer;
00084         cMessage* backup_timer;
00085 
00086         void sendToApp(cMessage* msg);
00087         void sendMessage(QuonMessage* quonMsg, NodeHandle destination);
00088         void setBootstrapedIcon();
00089         void changeState(QState qstate);
00090 
00091         // timer processing
00092         void processJoinTimer();
00093         void processSecTimer();
00094         void processDeleteTimer(cMessage* msg);
00095         void processAliveTimer();
00096         void processBackupTimer();
00097 
00098         // app handlers
00099         void handleJoin(GameAPIPositionMessage* gameMsg);
00100         void handleMove(GameAPIPositionMessage* gameMsg);
00101         void handleEvent(GameAPIMessage* msg);
00102 
00103         // overlay handlers
00104         void handleJoinRequest(QuonMessage* quonMsg);
00105         void handleJoinAcknowledge(QuonListMessage* quonListMsg);
00106         void handleNodeMove(QuonMoveMessage* quonMoveMsg);
00107         void handleNewNeighbors(QuonListMessage* quonListMsg);
00108         void handleNodeLeave(QuonListMessage* quonListMsg);
00109         void handleInvalidNode(QuonListMessage* quonListMsg);
00110 
00111         // app<->overlay synchronisation
00112         void synchronizeAppNeighbors(QPurgeType purgeSoftSites = QKEEPSOFT);
00113         void deleteAppNeighbor(NodeHandle node);
00114 
00115         // statistics
00116         double joinRequestBytesSend;
00117         double joinAcknowledgeBytesSend;
00118         double nodeMoveBytesSend;
00119         double newNeighborsBytesSend;
00120         double nodeLeaveBytesSend;
00121         double maxBytesPerSecondSend;
00122         double averageBytesPerSecondSend;
00123         double bytesPerSecond;
00124         long softConnections;
00125         long softNeighborCount;
00126         long bindingNeighborCount;
00127         long directNeighborCount;
00128         unsigned int secTimerCount;
00129         long rejoinCount;
00130         unsigned long avgAOI;
00131 
00132         // quon functions
00133         bool addSite(Vector2D p, NodeHandle node, double AOI, bool isSoft = false, QUpdateType update = QFOREIGN);
00134         void updateThisSite(Vector2D p);
00135         void classifySites();
00136         bool deleteSite(NodeHandle node);
00137         int purgeSites(QPurgeType purgeSoftSites = QKEEPSOFT);
00138         void adaptAoI();
00139 
00140         // node references
00141         QuonSite* thisSite;
00142         QDeleteMap deletedSites;
00143         NodeHandle (*bindingBackup)[4];
00144         int numBackups;
00145 
00146         // node state
00147         QState qstate;
00148         bool aloneInOverlay;
00149 };
00150 
00151 #endif