IBR-DTNSuite  0.10
ForwardingStrategy.cpp
Go to the documentation of this file.
1 /*
2  * ForwardingStrategy.cpp
3  *
4  * Created on: 11.01.2013
5  * Author: morgenro
6  */
7 
11 
12 namespace dtn
13 {
14  namespace routing
15  {
17  : _prophet_router(NULL)
18  {}
19 
21  {}
22 
23  bool ForwardingStrategy::neighborDPIsGreater(const DeliveryPredictabilityMap& neighbor_dpm, const dtn::data::EID& destination) const
24  {
25  const dtn::data::EID destnode = destination.getNode();
26 
27  try {
28  float local_pv = 0.0f;
29 
30  // get the local value
31  {
32  ibrcommon::MutexLock dpm_lock(_prophet_router->_deliveryPredictabilityMap);
33  const DeliveryPredictabilityMap& dp_map = _prophet_router->_deliveryPredictabilityMap;
34  local_pv = dp_map.get(destnode);
35  }
36 
37  try {
38  // retrieve the value from the DeliveryPredictabilityMap of the neighbor
39  float foreign_pv = neighbor_dpm.get(destnode);
40 
41  return (foreign_pv > local_pv);
43  // if the foreign router has no entry for the destination
44  // then compare the local value with a fictitious initial value
45  return (_prophet_router->_p_first_threshold > local_pv);
46  }
48  // always forward if the destination is not in our own predictability map
49  }
50 
51  return false;
52  }
53 
55  {
56  _prophet_router = router;
57  }
58  } /* namespace routing */
59 } /* namespace dtn */