36 const time::milliseconds BestRouteStrategy2::RETX_SUPPRESSION_INITIAL(10);
37 const time::milliseconds BestRouteStrategy2::RETX_SUPPRESSION_MAX(250);
42 , m_retxSuppression(RETX_SUPPRESSION_INITIAL,
48 BOOST_THROW_EXCEPTION(std::invalid_argument(
"BestRouteStrategy2 does not accept parameters"));
51 BOOST_THROW_EXCEPTION(std::invalid_argument(
52 "BestRouteStrategy2 does not support version " + std::to_string(*parsed.
version)));
60 static Name strategyName(
"/localhost/nfd/strategy/best-route/%FD%05");
75 const shared_ptr<pit::Entry>& pitEntry,
76 bool wantUnused =
false,
77 time::steady_clock::TimePoint now = time::steady_clock::TimePoint::min())
79 const Face& outFace = nexthop.
getFace();
82 if (outFace.getId() == inFace.getId() && outFace.getLinkType() != ndn::nfd::LINK_TYPE_AD_HOC)
92 if (outRecord != pitEntry->out_end() && outRecord->getExpiry() > now) {
103 static inline fib::NextHopList::const_iterator
106 const shared_ptr<pit::Entry>& pitEntry)
108 fib::NextHopList::const_iterator found = nexthops.end();
109 time::steady_clock::TimePoint earliestRenewed = time::steady_clock::TimePoint::max();
110 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
114 BOOST_ASSERT(outRecord != pitEntry->out_end());
115 if (outRecord->getLastRenewed() < earliestRenewed) {
117 earliestRenewed = outRecord->getLastRenewed();
125 const shared_ptr<pit::Entry>& pitEntry)
136 fib::NextHopList::const_iterator it = nexthops.end();
140 it = std::find_if(nexthops.begin(), nexthops.end(),
142 false, time::steady_clock::TimePoint::min()));
144 if (it == nexthops.end()) {
145 NFD_LOG_DEBUG(interest <<
" from=" << inFace.getId() <<
" noNextHop");
147 lp::NackHeader nackHeader;
148 nackHeader.setReason(lp::NackReason::NO_ROUTE);
149 this->
sendNack(pitEntry, inFace, nackHeader);
155 Face& outFace = it->getFace();
158 <<
" newPitEntry-to=" << outFace.getId());
163 it = std::find_if(nexthops.begin(), nexthops.end(),
165 true, time::steady_clock::now()));
166 if (it != nexthops.end()) {
167 Face& outFace = it->getFace();
170 <<
" retransmit-unused-to=" << outFace.getId());
176 if (it == nexthops.end()) {
177 NFD_LOG_DEBUG(interest <<
" from=" << inFace.getId() <<
" retransmitNoNextHop");
180 Face& outFace = it->getFace();
183 <<
" retransmit-retry-to=" << outFace.getId());
189 const shared_ptr<pit::Entry>& pitEntry)
void setInstanceName(const Name &name)
set strategy instance name
#define NFD_LOG_DEBUG(expression)
static const Name & getStrategyName()
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
void sendNack(const shared_ptr< pit::Entry > &pitEntry, const Face &outFace, const lp::NackHeader &header)
send Nack to outFace
static bool isNextHopEligible(const Face &inFace, const Interest &interest, const fib::NextHop &nexthop, const shared_ptr< pit::Entry > &pitEntry, bool wantUnused=false, time::steady_clock::TimePoint now=time::steady_clock::TimePoint::min())
determines whether a NextHop is eligible
BestRouteStrategy2(Forwarder &forwarder, const Name &name=getStrategyName())
Interest is retransmission and should be suppressed.
static Name makeInstanceName(const Name &input, const Name &strategyName)
construct a strategy instance name
#define NFD_REGISTER_STRATEGY(S)
registers a strategy
Table::const_iterator iterator
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Interest is new (not a retransmission)
a retransmission suppression decision algorithm that suppresses retransmissions using exponential bac...
std::vector< fib::NextHop > NextHopList
void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Nack is received
PartialName parameters
parameter components
void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
ndn::optional< uint64_t > version
whether strategyName contains a version component
RetxSuppressionResult decidePerPitEntry(pit::Entry &pitEntry)
determines whether Interest is a retransmission per pit entry and if so, whether it shall be forwarde...
represents a forwarding strategy
This file contains common algorithms used by forwarding strategies.
#define NFD_LOG_INIT(name)
static fib::NextHopList::const_iterator findEligibleNextHopWithEarliestOutRecord(const Face &inFace, const Interest &interest, const fib::NextHopList &nexthops, const shared_ptr< pit::Entry > &pitEntry)
pick an eligible NextHop with earliest out-record
static ParsedInstanceName parseInstanceName(const Name &input)
parse a strategy instance name
void processNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry)
represents a nexthop record in FIB entry
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
const NextHopList & getNextHops() const
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
decide that a pending Interest cannot be forwarded
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present