Vivaldi.h

Go to the documentation of this file.
00001 // Copyright (C) 2008 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00002 //
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 2
00006 // of the License, or (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 // GNU General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00016 //
00017 
00024 #ifndef _VIVALDI_
00025 #define _VIVALDI_
00026 
00027 
00028 #include <vector>
00029 
00030 #include <omnetpp.h>
00031 
00032 #include <GlobalStatisticsAccess.h>
00033 #include <NeighborCache.h>
00034 #include <CoordinateSystem.h>
00035 
00036 class TransportAddress;
00037 
00038 
00039 class Vivaldi : public AbstractNcs
00040 {
00041   private:
00042     //variables for storing the parameter from ned file
00043     bool enableHeightVector;
00044     uint32_t dimension;
00045   protected:
00046     // variable for storing the node coordinates / estimated error
00047     VivaldiCoordsInfo* ownCoords;
00048 
00049     double errorC;
00050     double coordC;
00051 
00052     bool showPosition;
00053 
00054     virtual void finishVivaldi();
00055 
00056     virtual void updateDisplay();
00057 
00058     virtual double calcError(const simtime_t& rtt, double dist, double weight);
00059     virtual double calcDelta(const simtime_t& rtt, double dist, double weight);
00060 
00061     //pointer to GlobalStatistics
00062     GlobalStatistics* globalStatistics;
00063     NeighborCache* neighborCache;
00064 
00065   public:
00066     virtual ~Vivaldi() { delete ownCoords; };
00067 
00068     virtual void init(NeighborCache* neighborCache);
00069     void processCoordinates(const simtime_t& rtt,
00070                             const AbstractNcsNodeInfo& nodeInfo);
00071 
00072     Prox getCoordinateBasedProx(const AbstractNcsNodeInfo& info) const;
00073 
00074     virtual AbstractNcsNodeInfo* getUnvalidNcsInfo() const { return new VivaldiCoordsInfo(enableHeightVector); };
00075     virtual AbstractNcsNodeInfo* createNcsInfo(const std::vector<double>& coords) const;
00076 
00077     const VivaldiCoordsInfo& getOwnNcsInfo() const { return *ownCoords; };
00078     const std::vector<double>& getOwnCoordinates() const { return ownCoords->getCoords(); };
00079     inline double getOwnError() const { return ownCoords->getError(); };
00080     inline double getOwnHeightVector() const { return ownCoords->getHeightVector(); };
00081 };
00082 
00083 #endif
00084