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 " + 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)
91 auto outRecord = pitEntry->getOutRecord(outFace);
92 if (outRecord != pitEntry->out_end() && outRecord->getExpiry() > now) {
103 static fib::NextHopList::const_iterator
106 const shared_ptr<pit::Entry>& pitEntry)
108 auto found = nexthops.end();
109 auto earliestRenewed = time::steady_clock::TimePoint::max();
111 for (
auto it = nexthops.begin(); it != nexthops.end(); ++it) {
115 auto outRecord = pitEntry->getOutRecord(it->getFace());
116 BOOST_ASSERT(outRecord != pitEntry->out_end());
117 if (outRecord->getLastRenewed() < earliestRenewed) {
119 earliestRenewed = outRecord->getLastRenewed();
128 const shared_ptr<pit::Entry>& pitEntry)
139 auto it = nexthops.end();
143 it = std::find_if(nexthops.begin(), nexthops.end(), [&] (
const auto& nexthop) {
147 if (it == nexthops.end()) {
148 NFD_LOG_DEBUG(interest <<
" from=" << inFace.getId() <<
" noNextHop");
150 lp::NackHeader nackHeader;
151 nackHeader.setReason(lp::NackReason::NO_ROUTE);
152 this->
sendNack(pitEntry, inFace, nackHeader);
158 Face& outFace = it->getFace();
161 <<
" newPitEntry-to=" << outFace.getId());
166 it = std::find_if(nexthops.begin(), nexthops.end(), [&] (
const auto& nexthop) {
167 return isNextHopEligible(inFace, interest, nexthop, pitEntry,
true, time::steady_clock::now());
170 if (it != nexthops.end()) {
171 Face& outFace = it->getFace();
174 <<
" retransmit-unused-to=" << outFace.getId());
180 if (it == nexthops.end()) {
181 NFD_LOG_DEBUG(interest <<
" from=" << inFace.getId() <<
" retransmitNoNextHop");
184 Face& outFace = it->getFace();
187 <<
" retransmit-retry-to=" << outFace.getId());
193 const shared_ptr<pit::Entry>& pitEntry)
void setInstanceName(const Name &name)
set strategy instance name
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
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...
void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Nack is received
Represents a collection of nexthops.
PartialName parameters
parameter components
void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
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)
NFD_REGISTER_STRATEGY(SelfLearningStrategy)
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)
schedule the PIT entry for immediate deletion
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
optional< uint64_t > version
whether strategyName contains a version component