NicePeerInfo.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2009 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 __NICEPEERINFO_H_
00025 #define __NICEPEERINFO_H_
00026 
00027 #include <BaseOverlay.h>
00028 #include <omnetpp.h>
00029 #include <iostream>
00030 
00031 namespace oversim
00032 {
00033 
00034 class Nice;
00035 
00036 }
00037 
00038 namespace oversim
00039 {
00040 
00041 typedef std::pair<unsigned int, double> HeartbeatEvaluator;
00042 
00043 class NicePeerInfo
00044 {
00045     friend std::ostream& operator<<(std::ostream& os, NicePeerInfo& pi);
00046 
00047 public:
00048 
00049     NicePeerInfo(Nice* _parent);
00050     ~NicePeerInfo();
00051 
00052     void set_distance_estimation_start(double value);
00053     double getDES();
00054     void set_distance(double value);
00055     double get_distance();
00056 
00057     void startHeartbeatTimeout();
00058     cMessage* getHbTimer();
00059 
00060     void updateDistance(TransportAddress member, double distance);
00061     double getDistanceTo(TransportAddress member);
00062 
00063     unsigned int get_last_sent_HB();
00064     void set_last_sent_HB(unsigned int seqNo);
00065 
00066     unsigned int get_last_recv_HB();
00067     void set_last_recv_HB(unsigned int seqNo);
00068 
00069     double get_last_HB_arrival();
00070     void set_last_HB_arrival(double arrival);
00071 
00072     bool get_backHBPointer();
00073     void set_backHBPointer(bool _backHBPointer);
00074 
00075     void set_backHB(bool backHBPointer, unsigned int seqNo, double time);
00076     double get_backHB(unsigned int seqNo);
00077     unsigned int get_backHB_seqNo(bool index);
00078 
00079     void touch();
00080     double getActivity();
00081 
00082     void setSubClusterMembers( unsigned int members );
00083     unsigned int getSubClusterMembers();
00084 
00085 protected:
00086 
00087     //virtual void handleMessage(cMessage* msg);
00088 
00089 private:
00090 
00091     Nice* parent;
00092     double distance_estimation_start;
00093     double distance;
00094     cMessage* hbTimer;
00095     std::map<TransportAddress, double> distanceTable;
00096 
00097     double activity;
00098 
00099     unsigned int subclustermembers;
00100 
00101     HeartbeatEvaluator backHB[2];
00102     bool backHBPointer;
00103 
00104     unsigned int last_sent_HB;
00105     unsigned int last_recv_HB;
00106     double last_HB_arrival;
00107 
00108 
00109 }; // NicePeerInfo
00110 
00111 }; //namespace
00112 
00113 #endif /* _NICEPEERINFO_H_ */
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3