38 const time::milliseconds BestRouteStrategy2::RETX_SUPPRESSION_INITIAL(10);
39 const time::milliseconds BestRouteStrategy2::RETX_SUPPRESSION_MAX(250);
43 , m_retxSuppression(RETX_SUPPRESSION_INITIAL,
59 bool wantUnused =
false,
60 time::steady_clock::TimePoint now = time::steady_clock::TimePoint::min())
62 Face& upstream = nexthop.
getFace();
65 if (upstream.getId() == currentDownstream)
75 if (outRecord != pitEntry->out_end() && outRecord->getExpiry() > now) {
86 static inline fib::NextHopList::const_iterator
91 fib::NextHopList::const_iterator found = nexthops.end();
92 time::steady_clock::TimePoint earliestRenewed = time::steady_clock::TimePoint::max();
93 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
97 BOOST_ASSERT(outRecord != pitEntry->out_end());
98 if (outRecord->getLastRenewed() < earliestRenewed) {
100 earliestRenewed = outRecord->getLastRenewed();
108 const shared_ptr<pit::Entry>& pitEntry)
119 fib::NextHopList::const_iterator it = nexthops.end();
123 it = std::find_if(nexthops.begin(), nexthops.end(),
125 false, time::steady_clock::TimePoint::min()));
127 if (it == nexthops.end()) {
128 NFD_LOG_DEBUG(interest <<
" from=" << inFace.getId() <<
" noNextHop");
130 lp::NackHeader nackHeader;
131 nackHeader.setReason(lp::NackReason::NO_ROUTE);
132 this->
sendNack(pitEntry, inFace, nackHeader);
138 Face& outFace = it->getFace();
141 <<
" newPitEntry-to=" << outFace.getId());
146 it = std::find_if(nexthops.begin(), nexthops.end(),
148 true, time::steady_clock::now()));
149 if (it != nexthops.end()) {
150 Face& outFace = it->getFace();
153 <<
" retransmit-unused-to=" << outFace.getId());
159 if (it == nexthops.end()) {
160 NFD_LOG_DEBUG(interest <<
" from=" << inFace.getId() <<
" retransmitNoNextHop");
163 Face& outFace = it->getFace();
166 <<
" retransmit-retry-to=" << outFace.getId());
174 inline lp::NackReason
177 if (x == lp::NackReason::NONE) {
180 if (y == lp::NackReason::NONE) {
183 return static_cast<lp::NackReason
>(std::min(static_cast<int>(x), static_cast<int>(y)));
188 const shared_ptr<pit::Entry>& pitEntry)
190 int nOutRecordsNotNacked = 0;
191 Face* lastFaceNotNacked =
nullptr;
192 lp::NackReason leastSevereReason = lp::NackReason::NONE;
194 const lp::NackHeader* inNack = outR.getIncomingNack();
195 if (inNack ==
nullptr) {
196 ++nOutRecordsNotNacked;
197 lastFaceNotNacked = &outR.getFace();
204 lp::NackHeader outNack;
205 outNack.setReason(leastSevereReason);
207 if (nOutRecordsNotNacked == 1) {
208 BOOST_ASSERT(lastFaceNotNacked !=
nullptr);
210 if (inR != pitEntry->in_end()) {
212 NFD_LOG_DEBUG(nack.getInterest() <<
" nack-from=" << inFace.getId() <<
213 " nack=" << nack.getReason() <<
214 " nack-to(bidirectional)=" << lastFaceNotNacked->getId() <<
215 " out-nack=" << outNack.getReason());
216 this->
sendNack(pitEntry, *lastFaceNotNacked, outNack);
221 if (nOutRecordsNotNacked > 0) {
222 NFD_LOG_DEBUG(nack.getInterest() <<
" nack-from=" << inFace.getId() <<
223 " nack=" << nack.getReason() <<
224 " waiting=" << nOutRecordsNotNacked);
230 NFD_LOG_DEBUG(nack.getInterest() <<
" nack-from=" << inFace.getId() <<
231 " nack=" << nack.getReason() <<
232 " nack-to=all out-nack=" << outNack.getReason());
#define NFD_REGISTER_STRATEGY(StrategyType)
registers a built-in strategy
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...
#define NFD_LOG_DEBUG(expression)
void sendNacks(const shared_ptr< pit::Entry > &pitEntry, const lp::NackHeader &header, std::initializer_list< const Face * > exceptFaces=std::initializer_list< const Face * >())
send Nack to every face that has an in-record, except those in exceptFaces
contains information about an Interest toward an outgoing face
Interest is retransmission and should be suppressed.
void sendNack(const shared_ptr< pit::Entry > &pitEntry, const Face &outFace, const lp::NackHeader &header)
send Nack to outFace
Table::const_iterator iterator
bool violatesScope(const pit::Entry &pitEntry, const Face &outFace)
determine whether forwarding the Interest in pitEntry to outFace would violate scope ...
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
virtual Result decide(const Face &inFace, const Interest &interest, pit::Entry &pitEntry) const override
determines whether Interest is a retransmission, and if so, whether it shall be forwarded or suppress...
lp::NackReason compareLessSevere(lp::NackReason x, lp::NackReason y)
a retransmission suppression decision algorithm that suppresses retransmissions using exponential bac...
std::vector< fib::NextHop > NextHopList
BestRouteStrategy2(Forwarder &forwarder, const Name &name=STRATEGY_NAME)
virtual void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Nack is received
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry) override
trigger after Interest is received
static bool predicate_NextHop_eligible(const shared_ptr< pit::Entry > &pitEntry, const fib::NextHop &nexthop, FaceId currentDownstream, bool wantUnused=false, time::steady_clock::TimePoint now=time::steady_clock::TimePoint::min())
determines whether a NextHop is eligible
represents a forwarding strategy
Interest is new (not a retransmission)
#define NFD_LOG_INIT(name)
static const Name STRATEGY_NAME
uint64_t FaceId
identifies a face
void sendInterest(const shared_ptr< pit::Entry > &pitEntry, Face &outFace, bool wantNewNonce=false)
send Interest to outFace
represents a nexthop record in FIB entry
const NextHopList & getNextHops() const
static fib::NextHopList::const_iterator findEligibleNextHopWithEarliestOutRecord(const shared_ptr< pit::Entry > &pitEntry, const fib::NextHopList &nexthops, FaceId currentDownstream)
pick an eligible NextHop with earliest out-record
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