NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
34  : Strategy(forwarder, name)
35 {
36 }
37 
39 {
40 }
41 
42 static inline bool
43 predicate_PitEntry_canForwardTo_NextHop(shared_ptr<pit::Entry> pitEntry,
44  const fib::NextHop& nexthop)
45 {
46  return pitEntry->canForwardTo(*nexthop.getFace());
47 }
48 
49 void
51  const Interest& interest,
52  shared_ptr<fib::Entry> fibEntry,
53  shared_ptr<pit::Entry> pitEntry)
54 {
55  if (pitEntry->hasUnexpiredOutRecords()) {
56  // not a new Interest, don't forward
57  return;
58  }
59 
60  const fib::NextHopList& nexthops = fibEntry->getNextHops();
61  fib::NextHopList::const_iterator it = std::find_if(nexthops.begin(), nexthops.end(),
62  bind(&predicate_PitEntry_canForwardTo_NextHop, pitEntry, _1));
63 
64  if (it == nexthops.end()) {
65  this->rejectPendingInterest(pitEntry);
66  return;
67  }
68 
69  shared_ptr<Face> outFace = it->getFace();
70  this->sendInterest(pitEntry, outFace);
71 }
72 
73 } // namespace fw
74 } // namespace nfd
static bool predicate_PitEntry_canForwardTo_NextHop(shared_ptr< pit::Entry > pitEntry, const fib::NextHop &nexthop)
main class of NFD
Definition: forwarder.hpp:54
represents a face
Definition: face.hpp:59
BestRouteStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
std::vector< fib::NextHop > NextHopList
Definition: fib-entry.hpp:48
void rejectPendingInterest(shared_ptr< pit::Entry > pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:168
represents a forwarding strategy
Definition: strategy.hpp:37
const shared_ptr< Face > & getFace() const
Definition: fib-nexthop.cpp:38
void sendInterest(shared_ptr< pit::Entry > pitEntry, shared_ptr< Face > outFace, bool wantNewNonce=false)
send Interest to outFace
Definition: strategy.hpp:160
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
represents a nexthop record in FIB entry
Definition: fib-nexthop.hpp:38