41 NDN_THROW(std::invalid_argument(
"BestRouteStrategy does not support version " +
42 std::to_string(*parsed.
version)));
50 NDN_LOG_DEBUG(*m_retxSuppression);
56 static const auto strategyName = Name(
"/localhost/nfd/strategy/best-route").appendVersion(5);
62 const shared_ptr<pit::Entry>& pitEntry)
64 auto suppression = m_retxSuppression->decidePerPitEntry(*pitEntry);
72 auto it = nexthops.end();
76 it = std::find_if(nexthops.begin(), nexthops.end(), [&] (
const auto& nexthop) {
77 return isNextHopEligible(ingress.face, interest, nexthop, pitEntry);
80 if (it == nexthops.end()) {
82 lp::NackHeader nackHeader;
83 nackHeader.setReason(lp::NackReason::NO_ROUTE);
89 Face& outFace = it->getFace();
96 it = std::find_if(nexthops.begin(), nexthops.end(),
97 [&, now = time::steady_clock::now()] (
const auto& nexthop) {
98 return isNextHopEligible(ingress.face, interest, nexthop, pitEntry, true, now);
101 if (it != nexthops.end()) {
102 Face& outFace = it->getFace();
110 if (it == nexthops.end()) {
114 Face& outFace = it->getFace();
122 const shared_ptr<pit::Entry>& pitEntry)
This file contains common algorithms used by forwarding strategies.
Represents a face-endpoint pair in the forwarder.
Main class of NFD's forwarding engine.
Generalization of a network interface.
FaceId getId() const noexcept
Returns the face ID.
Represents an entry in the FIB.
const NextHopList & getNextHops() const noexcept
"Best route" forwarding strategy.
BestRouteStrategy(Forwarder &forwarder, const Name &name=getStrategyName())
void afterReceiveNack(const lp::Nack &nack, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) override
Trigger after a Nack is received.
void afterReceiveInterest(const Interest &interest, const FaceEndpoint &ingress, const shared_ptr< pit::Entry > &pitEntry) override
Trigger after an Interest is received.
static const Name & getStrategyName()
void processNack(const lp::Nack &nack, const Face &inFace, const shared_ptr< pit::Entry > &pitEntry)
static std::unique_ptr< RetxSuppressionExponential > construct(const StrategyParameters ¶ms)
Base class of all forwarding strategies.
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.
bool sendNack(const lp::NackHeader &header, Face &egress, const shared_ptr< pit::Entry > &pitEntry)
Send a Nack packet.
pit::OutRecord * sendInterest(const Interest &interest, Face &egress, const shared_ptr< pit::Entry > &pitEntry)
Send an Interest packet.
static ParsedInstanceName parseInstanceName(const Name &input)
Parse a strategy instance name.
void setInstanceName(const Name &name) noexcept
Set strategy instance name.
static StrategyParameters parseParameters(const PartialName ¶ms)
Parse strategy parameters encoded in a strategy instance name.
static Name makeInstanceName(const Name &input, const Name &strategyName)
Construct a strategy instance name.
#define NFD_LOG_INIT(name)
std::vector< NextHop > NextHopList
A collection of nexthops in a FIB entry.
@ SUPPRESS
Interest is a retransmission and should be suppressed.
@ NEW
Interest is new (not a retransmission).
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.
NFD_REGISTER_STRATEGY(SelfLearningStrategy)
#define NFD_LOG_INTEREST_FROM(interest, ingress, msg)
Logs the reception of interest on ingress, followed by msg, at DEBUG level.
std::optional< uint64_t > version
The strategy version number, if present.
PartialName parameters
Parameter components, may be empty.