blob: 2373c69e750a5c62db05230c8cb3eed82c9b8433 [file] [log] [blame]
Vince Lehman8a4c29e2016-07-11 08:49:35 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawande90015992017-07-11 17:25:48 -05002/*
Davide Pesavento2c9d2ca2024-01-27 16:36:51 -05003 * Copyright (c) 2014-2024, Regents of the University of California,
Vince Lehman8a4c29e2016-07-11 08:49:35 +00004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#include "asf-strategy.hpp"
Ashlesh Gawande2a73f352016-12-01 15:37:03 +000027#include "algorithm.hpp"
Davide Pesavento2cae8ca2019-04-18 20:48:05 -040028#include "common/logger.hpp"
Vince Lehman8a4c29e2016-07-11 08:49:35 +000029
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040030namespace nfd::fw::asf {
Vince Lehman8a4c29e2016-07-11 08:49:35 +000031
Davide Pesaventoa3148082018-04-12 18:21:54 -040032NFD_LOG_INIT(AsfStrategy);
Junxiao Shi037f4ab2016-12-13 04:27:06 +000033NFD_REGISTER_STRATEGY(AsfStrategy);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000034
Vince Lehman8a4c29e2016-07-11 08:49:35 +000035AsfStrategy::AsfStrategy(Forwarder& forwarder, const Name& name)
Junxiao Shi18739c42016-12-22 08:03:00 +000036 : Strategy(forwarder)
awlane9acba9c2024-01-26 18:10:39 -060037 , ProcessNackTraits(this)
Vince Lehman8a4c29e2016-07-11 08:49:35 +000038 , m_measurements(getMeasurements())
39 , m_probing(m_measurements)
Vince Lehman8a4c29e2016-07-11 08:49:35 +000040{
Junxiao Shi18739c42016-12-22 08:03:00 +000041 ParsedInstanceName parsed = parseInstanceName(name);
Junxiao Shi91f6ee02016-12-29 21:44:44 +000042 if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
Davide Pesavento2c9d2ca2024-01-27 16:36:51 -050043 NDN_THROW(std::invalid_argument("AsfStrategy does not support version " +
44 std::to_string(*parsed.version)));
Junxiao Shi91f6ee02016-12-29 21:44:44 +000045 }
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -040046
47 StrategyParameters params = parseParameters(parsed.parameters);
48 m_retxSuppression = RetxSuppressionExponential::construct(params);
49 auto probingInterval = params.getOrDefault<time::milliseconds::rep>("probing-interval",
50 m_probing.getProbingInterval().count());
51 m_probing.setProbingInterval(time::milliseconds(probingInterval));
52 m_nMaxTimeouts = params.getOrDefault<size_t>("max-timeouts", m_nMaxTimeouts);
53
Junxiao Shi18739c42016-12-22 08:03:00 +000054 this->setInstanceName(makeInstanceName(name, getStrategyName()));
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050055
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -040056 NDN_LOG_DEBUG(*m_retxSuppression);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -040057 NFD_LOG_DEBUG("probing-interval=" << m_probing.getProbingInterval()
Saurab Dulalaf3ff5a2021-09-19 19:45:07 -040058 << " max-timeouts=" << m_nMaxTimeouts);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000059}
60
Junxiao Shi037f4ab2016-12-13 04:27:06 +000061const Name&
62AsfStrategy::getStrategyName()
63{
Eric Newberry358414d2021-03-21 20:56:42 -070064 static const auto strategyName = Name("/localhost/nfd/strategy/asf").appendVersion(4);
Junxiao Shi037f4ab2016-12-13 04:27:06 +000065 return strategyName;
66}
67
Saurab Dulala6dec222019-04-01 00:15:10 -050068void
Davide Pesavento0498ce82021-06-14 02:02:21 -040069AsfStrategy::afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress,
Junxiao Shi15e98b02016-08-12 11:21:44 +000070 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +000071{
Saurab Dulal432be572021-01-26 12:09:29 -060072 const auto& fibEntry = this->lookupFib(*pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000073
Saurab Dulal432be572021-01-26 12:09:29 -060074 // Check if the interest is new and, if so, skip the retx suppression check
75 if (!hasPendingOutRecords(*pitEntry)) {
76 auto* faceToUse = getBestFaceForForwarding(interest, ingress.face, fibEntry, pitEntry);
77 if (faceToUse == nullptr) {
Alex Lane653eb072023-07-27 22:11:46 -040078 NFD_LOG_INTEREST_FROM(interest, ingress, "new no-nexthop");
Teng Liangebc20f62020-06-23 16:55:20 -070079 sendNoRouteNack(ingress.face, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -050080 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -040081 else {
Alex Lane653eb072023-07-27 22:11:46 -040082 NFD_LOG_INTEREST_FROM(interest, ingress, "new forward-to=" << faceToUse->getId());
Saurab Dulal432be572021-01-26 12:09:29 -060083 forwardInterest(interest, *faceToUse, fibEntry, pitEntry);
84 sendProbe(interest, ingress, *faceToUse, fibEntry, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -050085 }
86 return;
87 }
88
Saurab Dulal432be572021-01-26 12:09:29 -060089 auto* faceToUse = getBestFaceForForwarding(interest, ingress.face, fibEntry, pitEntry, false);
Saurab Dulala6dec222019-04-01 00:15:10 -050090 if (faceToUse != nullptr) {
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -040091 auto suppressResult = m_retxSuppression->decidePerUpstream(*pitEntry, *faceToUse);
Saurab Dulal432be572021-01-26 12:09:29 -060092 if (suppressResult == RetxSuppressionResult::SUPPRESS) {
93 // Cannot be sent on this face, interest was received within the suppression window
Alex Lane653eb072023-07-27 22:11:46 -040094 NFD_LOG_INTEREST_FROM(interest, ingress, "retx forward-to=" << faceToUse->getId() << " suppressed");
Saurab Dulal432be572021-01-26 12:09:29 -060095 }
96 else {
97 // The retx arrived after the suppression period: forward it but don't probe, because
98 // probing was done earlier for this interest when it was newly received
Alex Lane653eb072023-07-27 22:11:46 -040099 NFD_LOG_INTEREST_FROM(interest, ingress, "retx forward-to=" << faceToUse->getId());
Saurab Dulal432be572021-01-26 12:09:29 -0600100 auto* outRecord = forwardInterest(interest, *faceToUse, fibEntry, pitEntry);
101 if (outRecord && suppressResult == RetxSuppressionResult::FORWARD) {
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -0400102 m_retxSuppression->incrementIntervalForOutRecord(*outRecord);
Saurab Dulal432be572021-01-26 12:09:29 -0600103 }
104 }
Saurab Dulala6dec222019-04-01 00:15:10 -0500105 return;
106 }
107
Saurab Dulal432be572021-01-26 12:09:29 -0600108 // If all eligible faces have been used (i.e., they all have a pending out-record),
109 // choose the nexthop with the earliest out-record
110 const auto& nexthops = fibEntry.getNextHops();
111 auto it = findEligibleNextHopWithEarliestOutRecord(ingress.face, interest, nexthops, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500112 if (it == nexthops.end()) {
Alex Lane653eb072023-07-27 22:11:46 -0400113 NFD_LOG_INTEREST_FROM(interest, ingress, "retx no-nexthop");
Saurab Dulal432be572021-01-26 12:09:29 -0600114 return;
115 }
116 auto& outFace = it->getFace();
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -0400117 auto suppressResult = m_retxSuppression->decidePerUpstream(*pitEntry, outFace);
Saurab Dulal432be572021-01-26 12:09:29 -0600118 if (suppressResult == RetxSuppressionResult::SUPPRESS) {
Alex Lane653eb072023-07-27 22:11:46 -0400119 NFD_LOG_INTEREST_FROM(interest, ingress, "retx retry-to=" << outFace.getId() << " suppressed");
Saurab Dulala6dec222019-04-01 00:15:10 -0500120 }
121 else {
Alex Lane653eb072023-07-27 22:11:46 -0400122 NFD_LOG_INTEREST_FROM(interest, ingress, "retx retry-to=" << outFace.getId());
Saurab Dulal432be572021-01-26 12:09:29 -0600123 // sendInterest() is used here instead of forwardInterest() because the measurements info
124 // were already attached to this face in the previous forwarding
Davide Pesavento0498ce82021-06-14 02:02:21 -0400125 auto* outRecord = sendInterest(interest, outFace, pitEntry);
Saurab Dulal432be572021-01-26 12:09:29 -0600126 if (outRecord && suppressResult == RetxSuppressionResult::FORWARD) {
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -0400127 m_retxSuppression->incrementIntervalForOutRecord(*outRecord);
Saurab Dulal432be572021-01-26 12:09:29 -0600128 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000129 }
130}
131
132void
Davide Pesavento0498ce82021-06-14 02:02:21 -0400133AsfStrategy::beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress,
134 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000135{
Junxiao Shifc021862016-08-25 21:51:18 +0000136 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(pitEntry->getName());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000137 if (namespaceInfo == nullptr) {
Alex Lane653eb072023-07-27 22:11:46 -0400138 NFD_LOG_DATA_FROM(data, ingress, "no-measurements");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000139 return;
140 }
141
142 // Record the RTT between the Interest out to Data in
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400143 FaceInfo* faceInfo = namespaceInfo->getFaceInfo(ingress.face.getId());
Ashlesh Gawandecad76b62017-04-04 15:28:30 -0500144 if (faceInfo == nullptr) {
Alex Lane653eb072023-07-27 22:11:46 -0400145 NFD_LOG_DATA_FROM(data, ingress, "no-face-info");
Ashlesh Gawandecad76b62017-04-04 15:28:30 -0500146 return;
147 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400148
Md Ashiqur Rahmanc88d2d42019-08-28 20:19:47 +0000149 auto outRecord = pitEntry->getOutRecord(ingress.face);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400150 if (outRecord == pitEntry->out_end()) {
Alex Lane653eb072023-07-27 22:11:46 -0400151 NFD_LOG_DATA_FROM(data, ingress, "no-out-record");
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400152 }
153 else {
154 faceInfo->recordRtt(time::steady_clock::now() - outRecord->getLastRenewed());
Alex Lane653eb072023-07-27 22:11:46 -0400155 NFD_LOG_DATA_FROM(data, ingress, "rtt=" << faceInfo->getLastRtt() << " srtt=" << faceInfo->getSrtt());
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400156 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000157
158 // Extend lifetime for measurements associated with Face
ashiqopuc7079482019-02-20 05:34:37 +0000159 namespaceInfo->extendFaceInfoLifetime(*faceInfo, ingress.face.getId());
Alex Lane9cec6992020-03-05 19:10:09 -0600160 // Extend PIT entry timer to allow slower probes to arrive
161 this->setExpiryTimer(pitEntry, 50_ms);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400162 faceInfo->cancelTimeout(data.getName());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000163}
164
165void
Davide Pesavento0498ce82021-06-14 02:02:21 -0400166AsfStrategy::afterReceiveNack(const lp::Nack& nack, const FaceEndpoint& ingress,
Junxiao Shi15e98b02016-08-12 11:21:44 +0000167 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000168{
Alex Lane653eb072023-07-27 22:11:46 -0400169 NFD_LOG_NACK_FROM(nack, ingress, "");
Alex Lane9cec6992020-03-05 19:10:09 -0600170 onTimeoutOrNack(pitEntry->getName(), ingress.face.getId(), true);
awlane9acba9c2024-01-26 18:10:39 -0600171 this->processNack(nack, ingress.face, pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000172}
173
Saurab Dulal432be572021-01-26 12:09:29 -0600174pit::OutRecord*
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400175AsfStrategy::forwardInterest(const Interest& interest, Face& outFace, const fib::Entry& fibEntry,
Saurab Dulal432be572021-01-26 12:09:29 -0600176 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000177{
Saurab Dulal432be572021-01-26 12:09:29 -0600178 const auto& interestName = interest.getName();
Teng Liangebc20f62020-06-23 16:55:20 -0700179 auto faceId = outFace.getId();
180
Davide Pesavento0498ce82021-06-14 02:02:21 -0400181 auto* outRecord = sendInterest(interest, outFace, pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000182
Saurab Dulal432be572021-01-26 12:09:29 -0600183 FaceInfo& faceInfo = m_measurements.getOrCreateFaceInfo(fibEntry, interestName, faceId);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000184
185 // Refresh measurements since Face is being used for forwarding
Saurab Dulal432be572021-01-26 12:09:29 -0600186 NamespaceInfo& namespaceInfo = m_measurements.getOrCreateNamespaceInfo(fibEntry, interestName);
Teng Liangebc20f62020-06-23 16:55:20 -0700187 namespaceInfo.extendFaceInfoLifetime(faceInfo, faceId);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000188
189 if (!faceInfo.isTimeoutScheduled()) {
Saurab Dulal432be572021-01-26 12:09:29 -0600190 auto timeout = faceInfo.scheduleTimeout(interestName,
191 [this, name = interestName, faceId] {
192 onTimeoutOrNack(name, faceId, false);
193 });
Teng Liangebc20f62020-06-23 16:55:20 -0700194 NFD_LOG_TRACE("Scheduled timeout for " << fibEntry.getPrefix() << " to=" << faceId
Saurab Dulal432be572021-01-26 12:09:29 -0600195 << " in " << time::duration_cast<time::milliseconds>(timeout));
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000196 }
Saurab Dulal432be572021-01-26 12:09:29 -0600197
198 return outRecord;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000199}
200
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400201void
202AsfStrategy::sendProbe(const Interest& interest, const FaceEndpoint& ingress, const Face& faceToUse,
203 const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry)
204{
Saurab Dulal432be572021-01-26 12:09:29 -0600205 if (!m_probing.isProbingNeeded(fibEntry, interest.getName()))
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400206 return;
207
208 Face* faceToProbe = m_probing.getFaceToProbe(ingress.face, interest, fibEntry, faceToUse);
209 if (faceToProbe == nullptr)
210 return;
211
Saurab Dulal432be572021-01-26 12:09:29 -0600212 Interest probeInterest(interest);
213 probeInterest.refreshNonce();
Alex Lane653eb072023-07-27 22:11:46 -0400214 NFD_LOG_DEBUG("Sending probe " << probeInterest.getName() << " nonce=" << probeInterest.getNonce()
215 << " to=" << faceToProbe->getId() << " trigger-nonce=" << interest.getNonce());
Saurab Dulal432be572021-01-26 12:09:29 -0600216 forwardInterest(probeInterest, *faceToProbe, fibEntry, pitEntry);
217
218 m_probing.afterForwardingProbe(fibEntry, interest.getName());
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400219}
220
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000221struct FaceStats
222{
Junxiao Shia6de4292016-07-12 02:08:10 +0000223 Face* face;
Ernest McCracken1402fa12019-06-09 00:36:28 -0700224 time::nanoseconds rtt;
225 time::nanoseconds srtt;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000226 uint64_t cost;
227};
228
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400229struct FaceStatsCompare
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000230{
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400231 bool
232 operator()(const FaceStats& lhs, const FaceStats& rhs) const
233 {
234 time::nanoseconds lhsValue = getValueForSorting(lhs);
235 time::nanoseconds rhsValue = getValueForSorting(rhs);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000236
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400237 // Sort by RTT and then by cost
238 return std::tie(lhsValue, lhs.cost) < std::tie(rhsValue, rhs.cost);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000239 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400240
241private:
242 static time::nanoseconds
243 getValueForSorting(const FaceStats& stats)
244 {
245 // These values allow faces with no measurements to be ranked better than timeouts
246 // srtt < RTT_NO_MEASUREMENT < RTT_TIMEOUT
247 if (stats.rtt == FaceInfo::RTT_TIMEOUT) {
248 return time::nanoseconds::max();
249 }
250 else if (stats.rtt == FaceInfo::RTT_NO_MEASUREMENT) {
251 return time::nanoseconds::max() / 2;
252 }
253 else {
254 return stats.srtt;
255 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000256 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400257};
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000258
Junxiao Shia6de4292016-07-12 02:08:10 +0000259Face*
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400260AsfStrategy::getBestFaceForForwarding(const Interest& interest, const Face& inFace,
261 const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry,
Saurab Dulala6dec222019-04-01 00:15:10 -0500262 bool isInterestNew)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000263{
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400264 std::set<FaceStats, FaceStatsCompare> rankedFaces;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000265
Saurab Dulala6dec222019-04-01 00:15:10 -0500266 auto now = time::steady_clock::now();
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400267 for (const auto& nh : fibEntry.getNextHops()) {
268 if (!isNextHopEligible(inFace, interest, nh, pitEntry, !isInterestNew, now)) {
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000269 continue;
270 }
271
Saurab Dulal432be572021-01-26 12:09:29 -0600272 const FaceInfo* info = m_measurements.getFaceInfo(fibEntry, interest.getName(), nh.getFace().getId());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000273 if (info == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400274 rankedFaces.insert({&nh.getFace(), FaceInfo::RTT_NO_MEASUREMENT,
275 FaceInfo::RTT_NO_MEASUREMENT, nh.getCost()});
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000276 }
277 else {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400278 rankedFaces.insert({&nh.getFace(), info->getLastRtt(), info->getSrtt(), nh.getCost()});
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000279 }
280 }
281
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400282 auto it = rankedFaces.begin();
283 return it != rankedFaces.end() ? it->face : nullptr;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000284}
285
286void
Alex Lane9cec6992020-03-05 19:10:09 -0600287AsfStrategy::onTimeoutOrNack(const Name& interestName, FaceId faceId, bool isNack)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000288{
Junxiao Shifc021862016-08-25 21:51:18 +0000289 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(interestName);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000290 if (namespaceInfo == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400291 NFD_LOG_TRACE(interestName << " FibEntry has been removed since timeout scheduling");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000292 return;
293 }
294
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400295 FaceInfo* fiPtr = namespaceInfo->getFaceInfo(faceId);
296 if (fiPtr == nullptr) {
297 NFD_LOG_TRACE(interestName << " FaceInfo id=" << faceId << " has been removed since timeout scheduling");
298 return;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000299 }
300
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400301 auto& faceInfo = *fiPtr;
Saurab Dulalaf3ff5a2021-09-19 19:45:07 -0400302 size_t nTimeouts = faceInfo.getNTimeouts() + 1;
303 faceInfo.setNTimeouts(nTimeouts);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500304
Saurab Dulalaf3ff5a2021-09-19 19:45:07 -0400305 if (nTimeouts < m_nMaxTimeouts && !isNack) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400306 NFD_LOG_TRACE(interestName << " face=" << faceId << " timeout-count=" << nTimeouts << " ignoring");
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500307 // Extend lifetime for measurements associated with Face
308 namespaceInfo->extendFaceInfoLifetime(faceInfo, faceId);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400309 faceInfo.cancelTimeout(interestName);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500310 }
311 else {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400312 NFD_LOG_TRACE(interestName << " face=" << faceId << " timeout-count=" << nTimeouts);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500313 faceInfo.recordTimeout(interestName);
314 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000315}
316
317void
Teng Liangebc20f62020-06-23 16:55:20 -0700318AsfStrategy::sendNoRouteNack(Face& face, const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000319{
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000320 lp::NackHeader nackHeader;
321 nackHeader.setReason(lp::NackReason::NO_ROUTE);
Davide Pesavento0498ce82021-06-14 02:02:21 -0400322 this->sendNack(nackHeader, face, pitEntry);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400323 this->rejectPendingInterest(pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000324}
325
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400326} // namespace nfd::fw::asf