NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
best-route-strategy.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
best-route-strategy.hpp
"
27
28
namespace
nfd
{
29
namespace
fw {
30
31
const
Name
BestRouteStrategy::STRATEGY_NAME
(
"ndn:/localhost/nfd/strategy/best-route/%FD%01"
);
32
NFD_REGISTER_STRATEGY
(BestRouteStrategy);
33
34
BestRouteStrategy::BestRouteStrategy
(
Forwarder
& forwarder,
const
Name
&
name
)
35
:
Strategy
(forwarder, name)
36
{
37
}
38
39
BestRouteStrategy::~BestRouteStrategy
()
40
{
41
}
42
43
static
inline
bool
44
predicate_PitEntry_canForwardTo_NextHop
(shared_ptr<pit::Entry> pitEntry,
45
const
fib::NextHop
& nexthop)
46
{
47
return
pitEntry->canForwardTo(*nexthop.
getFace
());
48
}
49
50
void
51
BestRouteStrategy::afterReceiveInterest
(
const
Face
& inFace,
52
const
Interest
& interest,
53
shared_ptr<fib::Entry> fibEntry,
54
shared_ptr<pit::Entry> pitEntry)
55
{
56
if
(pitEntry->hasUnexpiredOutRecords()) {
57
// not a new Interest, don't forward
58
return
;
59
}
60
61
const
fib::NextHopList
& nexthops = fibEntry->getNextHops();
62
fib::NextHopList::const_iterator it = std::find_if(nexthops.begin(), nexthops.end(),
63
bind(&
predicate_PitEntry_canForwardTo_NextHop
, pitEntry, _1));
64
65
if
(it == nexthops.end()) {
66
this->
rejectPendingInterest
(pitEntry);
67
return
;
68
}
69
70
shared_ptr<Face> outFace = it->getFace();
71
this->
sendInterest
(pitEntry, outFace);
72
}
73
74
}
// namespace fw
75
}
// namespace nfd
nfd::fw::predicate_PitEntry_canForwardTo_NextHop
static bool predicate_PitEntry_canForwardTo_NextHop(shared_ptr< pit::Entry > pitEntry, const fib::NextHop &nexthop)
Definition:
best-route-strategy.cpp:44
nfd::Forwarder
main class of NFD
Definition:
forwarder.hpp:54
ndn::Interest
represents an Interest packet
Definition:
interest.hpp:45
nfd::Face
represents a face
Definition:
face.hpp:57
nfd::fw::BestRouteStrategy::BestRouteStrategy
BestRouteStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
Definition:
best-route-strategy.cpp:34
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:38
ns3::ndn::Name
Name
Definition:
ndn-common.cpp:25
nfd::fw::NFD_REGISTER_STRATEGY
NFD_REGISTER_STRATEGY(AccessStrategy)
nfd::fib::NextHopList
std::vector< fib::NextHop > NextHopList
Definition:
fib-entry.hpp:48
ndn::Name
Name abstraction to represent an absolute name.
Definition:
name.hpp:46
nfd::fw::Strategy::rejectPendingInterest
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded
Definition:
strategy.hpp:169
best-route-strategy.hpp
nfd::fw::Strategy
represents a forwarding strategy
Definition:
strategy.hpp:38
nfd::fib::NextHop::getFace
const shared_ptr< Face > & getFace() const
Definition:
fib-nexthop.cpp:38
nfd::fw::Strategy::sendInterest
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
Definition:
strategy.hpp:161
nfd::fw::BestRouteStrategy::~BestRouteStrategy
virtual ~BestRouteStrategy()
Definition:
best-route-strategy.cpp:39
ndn::name
Definition:
name-component.cpp:37
nfd::fw::BestRouteStrategy::afterReceiveInterest
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, shared_ptr< fib::Entry > fibEntry, shared_ptr< pit::Entry > pitEntry) 1
trigger after Interest is received
Definition:
best-route-strategy.cpp:51
nfd::fib::NextHop
represents a nexthop record in FIB entry
Definition:
fib-nexthop.hpp:38
nfd::fw::BestRouteStrategy::STRATEGY_NAME
static const Name STRATEGY_NAME
Definition:
best-route-strategy.hpp:60
ndnSIM
NFD
daemon
fw
best-route-strategy.cpp
Generated on Tue Feb 23 2016 22:18:44 for ndnSIM by
1.8.11