IBR-DTNSuite  0.10
ProphetRoutingExtension.h
Go to the documentation of this file.
1 /*
2  * ProphetRoutingExtension.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef PROPHETROUTINGEXTENSION_H_
23 #define PROPHETROUTINGEXTENSION_H_
24 
28 
30 #include <ibrcommon/thread/Mutex.h>
31 #include <ibrcommon/thread/Queue.h>
33 
34 #include <map>
35 #include <list>
36 
37 namespace dtn
38 {
39  namespace routing
40  {
52  {
53  friend class ForwardingStrategy;
54  static const std::string TAG;
55 
56  public:
57  ProphetRoutingExtension(ForwardingStrategy *strategy, float p_encounter_max, float p_encounter_first,
58  float p_first_threshold, float beta, float gamma, float delta,
59  size_t time_unit, size_t i_typ,
60  dtn::data::Timestamp next_exchange_timeout);
61  virtual ~ProphetRoutingExtension();
62 
63  /* virtual methods from BaseRouter::Extension */
64  virtual void requestHandshake(const dtn::data::EID&, NodeHandshake&) const;
65  virtual void responseHandshake(const dtn::data::EID&, const NodeHandshake&, NodeHandshake&);
66  virtual void processHandshake(const dtn::data::EID&, NodeHandshake&);
67  virtual void notify(const dtn::core::Event *evt) throw ();
68  virtual void componentUp() throw ();
69  virtual void componentDown() throw ();
70 
76  ibrcommon::ThreadsafeReference<DeliveryPredictabilityMap> getDeliveryPredictabilityMap();
82  ibrcommon::ThreadsafeReference<const DeliveryPredictabilityMap> getDeliveryPredictabilityMap() const;
83 
88  ibrcommon::ThreadsafeReference<const AcknowledgementSet> getAcknowledgementSet() const;
89  protected:
90  virtual void run() throw ();
91  void __cancellation() throw ();
92  private:
97  void updateNeighbor(const dtn::data::EID& neighbor);
98 
103  void age();
104 
105  DeliveryPredictabilityMap _deliveryPredictabilityMap;
106  ForwardingStrategy *_forwardingStrategy;
107  AcknowledgementSet _acknowledgementSet;
108 
109  ibrcommon::Mutex _next_exchange_mutex;
110  dtn::data::Timestamp _next_exchange_timeout;
111  dtn::data::Timestamp _next_exchange_timestamp;
112 
116  float p_encounter(const dtn::data::EID &neighbor) const;
117 
118  float _p_encounter_max;
119  float _p_encounter_first;
120  float _p_first_threshold;
121  float _delta;
122  size_t _i_typ;
123 
124  typedef std::map<dtn::data::EID, dtn::data::Timestamp> age_map;
125  age_map _ageMap;
126 
127  class Task
128  {
129  public:
130  virtual ~Task() {};
131  virtual std::string toString() const = 0;
132  };
133 
134  class SearchNextBundleTask : public Task
135  {
136  public:
137  SearchNextBundleTask(const dtn::data::EID &eid);
138  virtual ~SearchNextBundleTask();
139 
140  virtual std::string toString() const;
141 
142  const dtn::data::EID eid;
143  };
144 
145  class NextExchangeTask : public Task
146  {
147  public:
148  NextExchangeTask();
149  virtual ~NextExchangeTask();
150 
151  virtual std::string toString() const;
152  };
153 
154  ibrcommon::Queue<Task* > _taskqueue;
155 
156  public:
163  {
164  public:
165  explicit GRTR_Strategy();
166  virtual ~GRTR_Strategy();
167  virtual bool shallForward(const DeliveryPredictabilityMap& neighbor_dpm, const dtn::data::MetaBundle& bundle) const;
168  };
169 
177  {
178  public:
179  explicit GTMX_Strategy(unsigned int NF_max);
180  virtual ~GTMX_Strategy();
181  virtual bool shallForward(const DeliveryPredictabilityMap& neighbor_dpm, const dtn::data::MetaBundle& bundle) const;
182 
183  void addForward(const dtn::data::BundleID &id);
184 
185  private:
186  unsigned int _NF_max;
187 
188  typedef std::map<dtn::data::BundleID, unsigned int> nf_map;
189  nf_map _NF_map;
190  };
191  };
192  } // namespace routing
193 } // namespace dtn
194 
195 #endif // PROPHETROUTINGEXTENSION_H_