NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
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 #include "algorithm.hpp"
28 
29 namespace nfd {
30 namespace fw {
31 
32 const Name BestRouteStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/best-route/%FD%01");
33 NFD_REGISTER_STRATEGY(BestRouteStrategy);
34 
36  : Strategy(forwarder, name)
37 {
38 }
39 
40 void
41 BestRouteStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
42  const shared_ptr<pit::Entry>& pitEntry)
43 {
44  if (hasPendingOutRecords(*pitEntry)) {
45  // not a new Interest, don't forward
46  return;
47  }
48 
49  const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
50  const fib::NextHopList& nexthops = fibEntry.getNextHops();
51 
52  for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
53  Face& outFace = it->getFace();
54  if (!wouldViolateScope(inFace, interest, outFace) &&
55  canForwardToLegacy(*pitEntry, outFace)) {
56  this->sendInterest(pitEntry, outFace, interest);
57  return;
58  }
59  }
60 
61  this->rejectPendingInterest(pitEntry);
62 }
63 
64 } // namespace fw
65 } // namespace nfd
bool canForwardToLegacy(const pit::Entry &pitEntry, const Face &face)
decide whether Interest can be forwarded to face
Definition: algorithm.cpp:82
generalization of a network interface
Definition: face.hpp:67
represents a FIB entry
Definition: fib-entry.hpp:51
main class of NFD
Definition: forwarder.hpp:54
represents an Interest packet
Definition: interest.hpp:42
BestRouteStrategy(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
NFD_REGISTER_STRATEGY(AccessStrategy)
std::vector< fib::NextHop > NextHopList
Definition: fib-entry.hpp:47
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
Definition: strategy.hpp:162
Name abstraction to represent an absolute name.
Definition: name.hpp:46
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
Definition: algorithm.cpp:136
represents a forwarding strategy
Definition: strategy.hpp:38
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
Definition: strategy.cpp:129
const NextHopList & getNextHops() const
Definition: fib-entry.hpp:64
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
Definition: strategy.hpp:137
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
Definition: algorithm.cpp:37
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received