IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
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
8
#include "
routing/prophet/ForwardingStrategy.h
"
9
#include "
routing/prophet/ProphetRoutingExtension.h
"
10
#include "
routing/prophet/DeliveryPredictabilityMap.h
"
11
12
namespace
dtn
13
{
14
namespace
routing
15
{
16
ForwardingStrategy::ForwardingStrategy
()
17
: _prophet_router(NULL)
18
{}
19
20
ForwardingStrategy::~ForwardingStrategy
()
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);
42
}
catch
(
const
DeliveryPredictabilityMap::ValueNotFoundException
&) {
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
}
47
}
catch
(
const
DeliveryPredictabilityMap::ValueNotFoundException
&) {
48
// always forward if the destination is not in our own predictability map
49
}
50
51
return
false
;
52
}
53
54
void
ForwardingStrategy::setProphetRouter
(
ProphetRoutingExtension
*router)
55
{
56
_prophet_router
= router;
57
}
58
}
/* namespace routing */
59
}
/* namespace dtn */
daemon
src
routing
prophet
ForwardingStrategy.cpp
Generated on Thu Mar 27 2014 09:26:20 for IBR-DTNSuite by
1.8.4