29 #include <ndn-cxx/util/random.hpp> 43 NDN_THROW(std::invalid_argument(
"RandomStrategy does not accept parameters"));
46 NDN_THROW(std::invalid_argument(
47 "RandomStrategy does not support version " + to_string(*parsed.
version)));
55 static Name strategyName(
"/localhost/nfd/strategy/random/%FD%01");
61 const shared_ptr<pit::Entry>& pitEntry)
70 NFD_LOG_DEBUG(interest <<
" from=" << ingress <<
" no nexthop");
72 lp::NackHeader nackHeader;
73 nackHeader.setReason(lp::NackReason::NO_ROUTE);
79 std::shuffle(nhs.begin(), nhs.end(), ndn::random::getRandomNumberEngine());
80 this->
sendInterest(pitEntry, nhs.front().getFace(), interest);
85 const shared_ptr<pit::Entry>& pitEntry)
Main class of NFD's forwarding engine.
void setInstanceName(const Name &name)
Set strategy instance name.
bool sendNack(const shared_ptr< pit::Entry > &pitEntry, Face &egress, const lp::NackHeader &header)
Send a Nack packet.
static Name makeInstanceName(const Name &input, const Name &strategyName)
Construct a strategy instance name.
const fib::Entry & lookupFib(const pit::Entry &pitEntry) const
Performs a FIB lookup, considering Link object if present.
void afterReceiveInterest(const FaceEndpoint &ingress, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
Trigger after Interest is received.
Represents a face-endpoint pair in the forwarder.
void afterReceiveNack(const FaceEndpoint &ingress, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) override
Trigger after Nack is received.
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
bool isNextHopEligible(const Face &inFace, const Interest &interest, const fib::NextHop &nexthop, const shared_ptr< pit::Entry > &pitEntry, bool wantUnused, time::steady_clock::TimePoint now)
determines whether a NextHop is eligible i.e.
Represents a collection of nexthops.
PartialName parameters
parameter components
RandomStrategy(Forwarder &forwarder, const Name &name=getStrategyName())
Represents a forwarding strategy.
This file contains common algorithms used by forwarding strategies.
const NextHopList & getNextHops() const
#define NFD_LOG_INIT(name)
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)
static const Name & getStrategyName()
void rejectPendingInterest(const shared_ptr< pit::Entry > &pitEntry)
Schedule the PIT entry for immediate deletion.
pit::OutRecord * sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &egress, const Interest &interest)
Send an Interest packet.
optional< uint64_t > version
whether strategyName contains a version component