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,
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()) {
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) {
170 if (it != nexthops.end()) {
171 Face& outFace = it->getFace();
174 <<
" retransmit-unused-to=" << outFace.
getId());
180 if (it == nexthops.end()) {
184 Face& outFace = it->getFace();
187 <<
" retransmit-retry-to=" << outFace.
getId());
193 const shared_ptr<pit::Entry>& pitEntry)
static ParsedInstanceName parseInstanceName(const Name &input)
parse a strategy instance name
generalization of a network interface
PartialName parameters
parameter components
void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Nack is received
static time_point now() noexcept
void sendNack(const shared_ptr< pit::Entry > &pitEntry, const Face &outFace, const lp::NackHeader &header)
send Nack to outFace
Best Route strategy version 4.
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
Interest is retransmission and should be suppressed.
void setInstanceName(const Name &name)
set strategy instance name
Represents an Interest packet.
void processNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry)
BestRouteStrategy2(Forwarder &forwarder, const Name &name=getStrategyName())
Represents a collection of nexthops.
represents a Network Nack
ndn::nfd::LinkType getLinkType() const
Copyright (c) 2011-2015 Regents of the University of California.
Interest is new (not a retransmission)
NFD_REGISTER_STRATEGY(AccessStrategy)
void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
schedule the PIT entry for immediate deletion
Represents an absolute name.
represents a forwarding strategy
optional< uint64_t > version
whether strategyName contains a version component
static const Name & getStrategyName()
This file contains common algorithms used by forwarding strategies.
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
performs a FIB lookup, considering Link object if present
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 Name makeInstanceName(const Name &input, const Name &strategyName)
construct a strategy instance name
std::string to_string(const V &v)
const NextHopList & getNextHops() const
#define NFD_LOG_INIT(name)
a retransmission suppression decision algorithm that suppresses retransmissions using exponential bac...
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, const Interest &interest)
send Interest to outFace
bool wouldViolateScope(const Face &inFace, const Interest &interest, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope
RetxSuppressionResult decidePerPitEntry(pit::Entry &pitEntry)
determines whether Interest is a retransmission per pit entry and if so, whether it shall be forwarde...
represents a nexthop record in FIB entry