blob: 24aa9d7538957e75a7b000180e2e9d32f24e1862 [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{
Junxiao Shi18739c42016-12-22 08:03:00 +000039 ParsedInstanceName parsed = parseInstanceName(name);
Junxiao Shi91f6ee02016-12-29 21:44:44 +000040 if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
Davide Pesavento2c9d2ca2024-01-27 16:36:51 -050041 NDN_THROW(std::invalid_argument("AsfStrategy does not support version " +
42 std::to_string(*parsed.version)));
Junxiao Shi91f6ee02016-12-29 21:44:44 +000043 }
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -040044
45 StrategyParameters params = parseParameters(parsed.parameters);
46 m_retxSuppression = RetxSuppressionExponential::construct(params);
47 auto probingInterval = params.getOrDefault<time::milliseconds::rep>("probing-interval",
48 m_probing.getProbingInterval().count());
49 m_probing.setProbingInterval(time::milliseconds(probingInterval));
50 m_nMaxTimeouts = params.getOrDefault<size_t>("max-timeouts", m_nMaxTimeouts);
51
Junxiao Shi18739c42016-12-22 08:03:00 +000052 this->setInstanceName(makeInstanceName(name, getStrategyName()));
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050053
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -040054 NDN_LOG_DEBUG(*m_retxSuppression);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -040055 NFD_LOG_DEBUG("probing-interval=" << m_probing.getProbingInterval()
Saurab Dulalaf3ff5a2021-09-19 19:45:07 -040056 << " max-timeouts=" << m_nMaxTimeouts);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000057}
58
Junxiao Shi037f4ab2016-12-13 04:27:06 +000059const Name&
60AsfStrategy::getStrategyName()
61{
Eric Newberry358414d2021-03-21 20:56:42 -070062 static const auto strategyName = Name("/localhost/nfd/strategy/asf").appendVersion(4);
Junxiao Shi037f4ab2016-12-13 04:27:06 +000063 return strategyName;
64}
65
Saurab Dulala6dec222019-04-01 00:15:10 -050066void
Davide Pesavento0498ce82021-06-14 02:02:21 -040067AsfStrategy::afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress,
Junxiao Shi15e98b02016-08-12 11:21:44 +000068 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +000069{
Saurab Dulal432be572021-01-26 12:09:29 -060070 const auto& fibEntry = this->lookupFib(*pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000071
Saurab Dulal432be572021-01-26 12:09:29 -060072 // Check if the interest is new and, if so, skip the retx suppression check
73 if (!hasPendingOutRecords(*pitEntry)) {
awlane5fdcbec2023-12-15 14:56:05 -060074 auto faceToUse = getBestFaceForForwarding(interest, ingress.face, fibEntry, pitEntry);
Saurab Dulal432be572021-01-26 12:09:29 -060075 if (faceToUse == nullptr) {
Alex Lane653eb072023-07-27 22:11:46 -040076 NFD_LOG_INTEREST_FROM(interest, ingress, "new no-nexthop");
Teng Liangebc20f62020-06-23 16:55:20 -070077 sendNoRouteNack(ingress.face, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -050078 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -040079 else {
Alex Lane653eb072023-07-27 22:11:46 -040080 NFD_LOG_INTEREST_FROM(interest, ingress, "new forward-to=" << faceToUse->getId());
Saurab Dulal432be572021-01-26 12:09:29 -060081 forwardInterest(interest, *faceToUse, fibEntry, pitEntry);
82 sendProbe(interest, ingress, *faceToUse, fibEntry, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -050083 }
84 return;
85 }
86
awlane5fdcbec2023-12-15 14:56:05 -060087 auto faceToUse = getBestFaceForForwarding(interest, ingress.face, fibEntry, pitEntry, false);
Saurab Dulala6dec222019-04-01 00:15:10 -050088 if (faceToUse != nullptr) {
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -040089 auto suppressResult = m_retxSuppression->decidePerUpstream(*pitEntry, *faceToUse);
Saurab Dulal432be572021-01-26 12:09:29 -060090 if (suppressResult == RetxSuppressionResult::SUPPRESS) {
91 // Cannot be sent on this face, interest was received within the suppression window
Alex Lane653eb072023-07-27 22:11:46 -040092 NFD_LOG_INTEREST_FROM(interest, ingress, "retx forward-to=" << faceToUse->getId() << " suppressed");
Saurab Dulal432be572021-01-26 12:09:29 -060093 }
94 else {
95 // The retx arrived after the suppression period: forward it but don't probe, because
96 // probing was done earlier for this interest when it was newly received
Alex Lane653eb072023-07-27 22:11:46 -040097 NFD_LOG_INTEREST_FROM(interest, ingress, "retx forward-to=" << faceToUse->getId());
Saurab Dulal432be572021-01-26 12:09:29 -060098 auto* outRecord = forwardInterest(interest, *faceToUse, fibEntry, pitEntry);
99 if (outRecord && suppressResult == RetxSuppressionResult::FORWARD) {
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -0400100 m_retxSuppression->incrementIntervalForOutRecord(*outRecord);
Saurab Dulal432be572021-01-26 12:09:29 -0600101 }
102 }
Saurab Dulala6dec222019-04-01 00:15:10 -0500103 return;
104 }
105
Saurab Dulal432be572021-01-26 12:09:29 -0600106 // If all eligible faces have been used (i.e., they all have a pending out-record),
107 // choose the nexthop with the earliest out-record
108 const auto& nexthops = fibEntry.getNextHops();
109 auto it = findEligibleNextHopWithEarliestOutRecord(ingress.face, interest, nexthops, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500110 if (it == nexthops.end()) {
Alex Lane653eb072023-07-27 22:11:46 -0400111 NFD_LOG_INTEREST_FROM(interest, ingress, "retx no-nexthop");
Saurab Dulal432be572021-01-26 12:09:29 -0600112 return;
113 }
114 auto& outFace = it->getFace();
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -0400115 auto suppressResult = m_retxSuppression->decidePerUpstream(*pitEntry, outFace);
Saurab Dulal432be572021-01-26 12:09:29 -0600116 if (suppressResult == RetxSuppressionResult::SUPPRESS) {
Alex Lane653eb072023-07-27 22:11:46 -0400117 NFD_LOG_INTEREST_FROM(interest, ingress, "retx retry-to=" << outFace.getId() << " suppressed");
Saurab Dulala6dec222019-04-01 00:15:10 -0500118 }
119 else {
Alex Lane653eb072023-07-27 22:11:46 -0400120 NFD_LOG_INTEREST_FROM(interest, ingress, "retx retry-to=" << outFace.getId());
Saurab Dulal432be572021-01-26 12:09:29 -0600121 // sendInterest() is used here instead of forwardInterest() because the measurements info
122 // were already attached to this face in the previous forwarding
Davide Pesavento0498ce82021-06-14 02:02:21 -0400123 auto* outRecord = sendInterest(interest, outFace, pitEntry);
Saurab Dulal432be572021-01-26 12:09:29 -0600124 if (outRecord && suppressResult == RetxSuppressionResult::FORWARD) {
Ashlesh Gawande1ef93d02022-04-08 00:25:06 -0400125 m_retxSuppression->incrementIntervalForOutRecord(*outRecord);
Saurab Dulal432be572021-01-26 12:09:29 -0600126 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000127 }
128}
129
130void
Davide Pesavento0498ce82021-06-14 02:02:21 -0400131AsfStrategy::beforeSatisfyInterest(const Data& data, const FaceEndpoint& ingress,
132 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000133{
Junxiao Shifc021862016-08-25 21:51:18 +0000134 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(pitEntry->getName());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000135 if (namespaceInfo == nullptr) {
Alex Lane653eb072023-07-27 22:11:46 -0400136 NFD_LOG_DATA_FROM(data, ingress, "no-measurements");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000137 return;
138 }
139
140 // Record the RTT between the Interest out to Data in
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400141 FaceInfo* faceInfo = namespaceInfo->getFaceInfo(ingress.face.getId());
Ashlesh Gawandecad76b62017-04-04 15:28:30 -0500142 if (faceInfo == nullptr) {
Alex Lane653eb072023-07-27 22:11:46 -0400143 NFD_LOG_DATA_FROM(data, ingress, "no-face-info");
Ashlesh Gawandecad76b62017-04-04 15:28:30 -0500144 return;
145 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400146
Md Ashiqur Rahmanc88d2d42019-08-28 20:19:47 +0000147 auto outRecord = pitEntry->getOutRecord(ingress.face);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400148 if (outRecord == pitEntry->out_end()) {
Alex Lane653eb072023-07-27 22:11:46 -0400149 NFD_LOG_DATA_FROM(data, ingress, "no-out-record");
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400150 }
151 else {
152 faceInfo->recordRtt(time::steady_clock::now() - outRecord->getLastRenewed());
Alex Lane653eb072023-07-27 22:11:46 -0400153 NFD_LOG_DATA_FROM(data, ingress, "rtt=" << faceInfo->getLastRtt() << " srtt=" << faceInfo->getSrtt());
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400154 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000155
156 // Extend lifetime for measurements associated with Face
ashiqopuc7079482019-02-20 05:34:37 +0000157 namespaceInfo->extendFaceInfoLifetime(*faceInfo, ingress.face.getId());
Alex Lane9cec6992020-03-05 19:10:09 -0600158 // Extend PIT entry timer to allow slower probes to arrive
159 this->setExpiryTimer(pitEntry, 50_ms);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400160 faceInfo->cancelTimeout(data.getName());
awlane5fdcbec2023-12-15 14:56:05 -0600161 faceInfo->setNTimeouts(0);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000162}
163
164void
Davide Pesavento0498ce82021-06-14 02:02:21 -0400165AsfStrategy::afterReceiveNack(const lp::Nack& nack, const FaceEndpoint& ingress,
Junxiao Shi15e98b02016-08-12 11:21:44 +0000166 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000167{
Alex Lane653eb072023-07-27 22:11:46 -0400168 NFD_LOG_NACK_FROM(nack, ingress, "");
Alex Lane9cec6992020-03-05 19:10:09 -0600169 onTimeoutOrNack(pitEntry->getName(), ingress.face.getId(), true);
awlane9acba9c2024-01-26 18:10:39 -0600170 this->processNack(nack, ingress.face, pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000171}
172
Saurab Dulal432be572021-01-26 12:09:29 -0600173pit::OutRecord*
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400174AsfStrategy::forwardInterest(const Interest& interest, Face& outFace, const fib::Entry& fibEntry,
Saurab Dulal432be572021-01-26 12:09:29 -0600175 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000176{
Saurab Dulal432be572021-01-26 12:09:29 -0600177 const auto& interestName = interest.getName();
Teng Liangebc20f62020-06-23 16:55:20 -0700178 auto faceId = outFace.getId();
179
Davide Pesavento0498ce82021-06-14 02:02:21 -0400180 auto* outRecord = sendInterest(interest, outFace, pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000181
Saurab Dulal432be572021-01-26 12:09:29 -0600182 FaceInfo& faceInfo = m_measurements.getOrCreateFaceInfo(fibEntry, interestName, faceId);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000183
184 // Refresh measurements since Face is being used for forwarding
Saurab Dulal432be572021-01-26 12:09:29 -0600185 NamespaceInfo& namespaceInfo = m_measurements.getOrCreateNamespaceInfo(fibEntry, interestName);
Teng Liangebc20f62020-06-23 16:55:20 -0700186 namespaceInfo.extendFaceInfoLifetime(faceInfo, faceId);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000187
188 if (!faceInfo.isTimeoutScheduled()) {
Saurab Dulal432be572021-01-26 12:09:29 -0600189 auto timeout = faceInfo.scheduleTimeout(interestName,
190 [this, name = interestName, faceId] {
191 onTimeoutOrNack(name, faceId, false);
192 });
Teng Liangebc20f62020-06-23 16:55:20 -0700193 NFD_LOG_TRACE("Scheduled timeout for " << fibEntry.getPrefix() << " to=" << faceId
Saurab Dulal432be572021-01-26 12:09:29 -0600194 << " in " << time::duration_cast<time::milliseconds>(timeout));
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000195 }
Saurab Dulal432be572021-01-26 12:09:29 -0600196
197 return outRecord;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000198}
199
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400200void
201AsfStrategy::sendProbe(const Interest& interest, const FaceEndpoint& ingress, const Face& faceToUse,
202 const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry)
203{
Saurab Dulal432be572021-01-26 12:09:29 -0600204 if (!m_probing.isProbingNeeded(fibEntry, interest.getName()))
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400205 return;
206
207 Face* faceToProbe = m_probing.getFaceToProbe(ingress.face, interest, fibEntry, faceToUse);
208 if (faceToProbe == nullptr)
209 return;
210
Saurab Dulal432be572021-01-26 12:09:29 -0600211 Interest probeInterest(interest);
212 probeInterest.refreshNonce();
Alex Lane653eb072023-07-27 22:11:46 -0400213 NFD_LOG_DEBUG("Sending probe " << probeInterest.getName() << " nonce=" << probeInterest.getNonce()
214 << " to=" << faceToProbe->getId() << " trigger-nonce=" << interest.getNonce());
Saurab Dulal432be572021-01-26 12:09:29 -0600215 forwardInterest(probeInterest, *faceToProbe, fibEntry, pitEntry);
216
217 m_probing.afterForwardingProbe(fibEntry, interest.getName());
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400218}
219
awlane5fdcbec2023-12-15 14:56:05 -0600220static auto
221getFaceRankForForwarding(const FaceStats& fs) noexcept
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000222{
awlane5fdcbec2023-12-15 14:56:05 -0600223 // The RTT is used to store the status of the face:
224 // - A positive value indicates data was received and is assumed to indicate a working face (group 1),
225 // - RTT_NO_MEASUREMENT indicates a face is unmeasured (group 2),
226 // - RTT_TIMEOUT indicates a face is timed out (group 3).
227 // These groups are defined in the technical report.
228 //
229 // When forwarding, we assume an order where working faces (group 1) are ranked
230 // higher than unmeasured faces (group 2), and unmeasured faces are ranked higher
231 // than timed out faces (group 3). We assign each group a priority value from 1-3
232 // to ensure lowest-to-highest ordering consistent with this logic.
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000233
awlane5fdcbec2023-12-15 14:56:05 -0600234 // Working faces are ranked first in priority; if RTT is not
235 // a special value, we assume the face to be in this group.
236 int priority = 1;
237 if (fs.rtt == FaceInfo::RTT_NO_MEASUREMENT) {
238 priority = 2;
239 }
240 else if (fs.rtt == FaceInfo::RTT_TIMEOUT) {
241 priority = 3;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000242 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400243
awlane5fdcbec2023-12-15 14:56:05 -0600244 // We set SRTT by default to the max value; if a face is working, we instead set it to the actual value.
245 // Unmeasured and timed out faces are not sorted by SRTT.
246 auto srtt = priority == 1 ? fs.srtt : time::nanoseconds::max();
247
248 // For ranking, group takes the priority over SRTT (if present) or cost, SRTT (if present)
249 // takes priority over cost, and cost takes priority over FaceId.
250 // FaceId is included to ensure all unique entries are included in the ranking (see #5310)
251 return std::tuple(priority, srtt, fs.cost, fs.face->getId());
252}
253
254bool
255AsfStrategy::FaceStatsForwardingCompare::operator()(const FaceStats& lhs, const FaceStats& rhs) const noexcept
256{
257 return getFaceRankForForwarding(lhs) < getFaceRankForForwarding(rhs);
258}
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000259
Junxiao Shia6de4292016-07-12 02:08:10 +0000260Face*
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400261AsfStrategy::getBestFaceForForwarding(const Interest& interest, const Face& inFace,
262 const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry,
Saurab Dulala6dec222019-04-01 00:15:10 -0500263 bool isInterestNew)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000264{
awlane5fdcbec2023-12-15 14:56:05 -0600265 FaceStatsForwardingSet rankedFaces;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000266
Saurab Dulala6dec222019-04-01 00:15:10 -0500267 auto now = time::steady_clock::now();
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400268 for (const auto& nh : fibEntry.getNextHops()) {
269 if (!isNextHopEligible(inFace, interest, nh, pitEntry, !isInterestNew, now)) {
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000270 continue;
271 }
272
Saurab Dulal432be572021-01-26 12:09:29 -0600273 const FaceInfo* info = m_measurements.getFaceInfo(fibEntry, interest.getName(), nh.getFace().getId());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000274 if (info == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400275 rankedFaces.insert({&nh.getFace(), FaceInfo::RTT_NO_MEASUREMENT,
276 FaceInfo::RTT_NO_MEASUREMENT, nh.getCost()});
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000277 }
278 else {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400279 rankedFaces.insert({&nh.getFace(), info->getLastRtt(), info->getSrtt(), nh.getCost()});
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000280 }
281 }
282
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400283 auto it = rankedFaces.begin();
284 return it != rankedFaces.end() ? it->face : nullptr;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000285}
286
287void
Alex Lane9cec6992020-03-05 19:10:09 -0600288AsfStrategy::onTimeoutOrNack(const Name& interestName, FaceId faceId, bool isNack)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000289{
Junxiao Shifc021862016-08-25 21:51:18 +0000290 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(interestName);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000291 if (namespaceInfo == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400292 NFD_LOG_TRACE(interestName << " FibEntry has been removed since timeout scheduling");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000293 return;
294 }
295
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400296 FaceInfo* fiPtr = namespaceInfo->getFaceInfo(faceId);
297 if (fiPtr == nullptr) {
298 NFD_LOG_TRACE(interestName << " FaceInfo id=" << faceId << " has been removed since timeout scheduling");
299 return;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000300 }
301
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400302 auto& faceInfo = *fiPtr;
Saurab Dulalaf3ff5a2021-09-19 19:45:07 -0400303 size_t nTimeouts = faceInfo.getNTimeouts() + 1;
304 faceInfo.setNTimeouts(nTimeouts);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500305
Saurab Dulalaf3ff5a2021-09-19 19:45:07 -0400306 if (nTimeouts < m_nMaxTimeouts && !isNack) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400307 NFD_LOG_TRACE(interestName << " face=" << faceId << " timeout-count=" << nTimeouts << " ignoring");
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500308 // Extend lifetime for measurements associated with Face
309 namespaceInfo->extendFaceInfoLifetime(faceInfo, faceId);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400310 faceInfo.cancelTimeout(interestName);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500311 }
312 else {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400313 NFD_LOG_TRACE(interestName << " face=" << faceId << " timeout-count=" << nTimeouts);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500314 faceInfo.recordTimeout(interestName);
awlane5fdcbec2023-12-15 14:56:05 -0600315 faceInfo.setNTimeouts(0);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500316 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000317}
318
319void
Teng Liangebc20f62020-06-23 16:55:20 -0700320AsfStrategy::sendNoRouteNack(Face& face, const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000321{
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000322 lp::NackHeader nackHeader;
323 nackHeader.setReason(lp::NackReason::NO_ROUTE);
Davide Pesavento0498ce82021-06-14 02:02:21 -0400324 this->sendNack(nackHeader, face, pitEntry);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400325 this->rejectPendingInterest(pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000326}
327
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400328} // namespace nfd::fw::asf