OverSim
NicePeerInfo.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2009 Institut fuer Telematik, Universitaet Karlsruhe (TH)
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 //
18 
24 #ifndef __NICEPEERINFO_H_
25 #define __NICEPEERINFO_H_
26 
27 #include <BaseOverlay.h>
28 #include <omnetpp.h>
29 #include <iostream>
30 
31 namespace oversim
32 {
33 
34 class Nice;
35 
36 }
37 
38 namespace oversim
39 {
40 
41 typedef std::pair<unsigned int, double> HeartbeatEvaluator;
42 
44 {
45  friend std::ostream& operator<<(std::ostream& os, NicePeerInfo& pi);
46 
47 public:
48 
49  NicePeerInfo(Nice* _parent);
50  ~NicePeerInfo();
51 
52  void set_distance_estimation_start(double value);
53  double getDES();
54  void set_distance(double value);
55  double get_distance();
56 
57  void startHeartbeatTimeout();
58  cMessage* getHbTimer();
59 
60  void updateDistance(TransportAddress member, double distance);
61  double getDistanceTo(TransportAddress member);
62 
63  unsigned int get_last_sent_HB();
64  void set_last_sent_HB(unsigned int seqNo);
65 
66  unsigned int get_last_recv_HB();
67  void set_last_recv_HB(unsigned int seqNo);
68 
69  double get_last_HB_arrival();
70  void set_last_HB_arrival(double arrival);
71 
72  bool get_backHBPointer();
73  void set_backHBPointer(bool _backHBPointer);
74 
75  void set_backHB(bool backHBPointer, unsigned int seqNo, double time);
76  double get_backHB(unsigned int seqNo);
77  unsigned int get_backHB_seqNo(bool index);
78 
79  void touch();
80  double getActivity();
81 
82  void setSubClusterMembers( unsigned int members );
83  unsigned int getSubClusterMembers();
84 
85 protected:
86 
87  //virtual void handleMessage(cMessage* msg);
88 
89 private:
90 
93  double distance;
94  cMessage* hbTimer;
95  std::map<TransportAddress, double> distanceTable;
96 
97  double activity;
98 
99  unsigned int subclustermembers;
100 
103 
104  unsigned int last_sent_HB;
105  unsigned int last_recv_HB;
107 
108 
109 }; // NicePeerInfo
110 
111 }; //namespace
112 
113 #endif /* _NICEPEERINFO_H_ */