blob: f967c86b6789a08675a900ed583e8796d28312d2 [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/*
Alex Lane9cec6992020-03-05 19:10:09 -06003 * Copyright (c) 2014-2020, 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/global.hpp"
29#include "common/logger.hpp"
Vince Lehman8a4c29e2016-07-11 08:49:35 +000030
31namespace nfd {
32namespace fw {
33namespace asf {
34
Davide Pesaventoa3148082018-04-12 18:21:54 -040035NFD_LOG_INIT(AsfStrategy);
Junxiao Shi037f4ab2016-12-13 04:27:06 +000036NFD_REGISTER_STRATEGY(AsfStrategy);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000037
Vince Lehman8a4c29e2016-07-11 08:49:35 +000038const time::milliseconds AsfStrategy::RETX_SUPPRESSION_INITIAL(10);
39const time::milliseconds AsfStrategy::RETX_SUPPRESSION_MAX(250);
40
Vince Lehman8a4c29e2016-07-11 08:49:35 +000041AsfStrategy::AsfStrategy(Forwarder& forwarder, const Name& name)
Junxiao Shi18739c42016-12-22 08:03:00 +000042 : Strategy(forwarder)
Vince Lehman8a4c29e2016-07-11 08:49:35 +000043 , m_measurements(getMeasurements())
44 , m_probing(m_measurements)
45 , m_retxSuppression(RETX_SUPPRESSION_INITIAL,
46 RetxSuppressionExponential::DEFAULT_MULTIPLIER,
47 RETX_SUPPRESSION_MAX)
48{
Junxiao Shi18739c42016-12-22 08:03:00 +000049 ParsedInstanceName parsed = parseInstanceName(name);
50 if (!parsed.parameters.empty()) {
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050051 processParams(parsed.parameters);
Junxiao Shi18739c42016-12-22 08:03:00 +000052 }
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050053
Junxiao Shi91f6ee02016-12-29 21:44:44 +000054 if (parsed.version && *parsed.version != getStrategyName()[-1].toVersion()) {
Davide Pesavento19779d82019-02-14 13:40:04 -050055 NDN_THROW(std::invalid_argument(
Alexander Afanasyev0c63c632017-12-05 11:17:09 -050056 "AsfStrategy does not support version " + to_string(*parsed.version)));
Junxiao Shi91f6ee02016-12-29 21:44:44 +000057 }
Junxiao Shi18739c42016-12-22 08:03:00 +000058 this->setInstanceName(makeInstanceName(name, getStrategyName()));
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050059
Davide Pesaventoa6f637a2019-08-28 23:23:20 -040060 NFD_LOG_DEBUG("probing-interval=" << m_probing.getProbingInterval()
Alex Lane9cec6992020-03-05 19:10:09 -060061 << " n-silent-timeouts=" << m_nMaxSilentTimeouts);
Vince Lehman8a4c29e2016-07-11 08:49:35 +000062}
63
Junxiao Shi037f4ab2016-12-13 04:27:06 +000064const Name&
65AsfStrategy::getStrategyName()
66{
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050067 static Name strategyName("/localhost/nfd/strategy/asf/%FD%03");
Junxiao Shi037f4ab2016-12-13 04:27:06 +000068 return strategyName;
69}
70
Davide Pesaventoa6f637a2019-08-28 23:23:20 -040071static uint64_t
72getParamValue(const std::string& param, const std::string& value)
73{
74 try {
75 if (!value.empty() && value[0] == '-')
76 NDN_THROW(boost::bad_lexical_cast());
77
78 return boost::lexical_cast<uint64_t>(value);
79 }
80 catch (const boost::bad_lexical_cast&) {
81 NDN_THROW(std::invalid_argument("Value of " + param + " must be a non-negative integer"));
82 }
83}
84
Vince Lehman8a4c29e2016-07-11 08:49:35 +000085void
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050086AsfStrategy::processParams(const PartialName& parsed)
87{
88 for (const auto& component : parsed) {
89 std::string parsedStr(reinterpret_cast<const char*>(component.value()), component.value_size());
90 auto n = parsedStr.find("~");
91 if (n == std::string::npos) {
Davide Pesavento19779d82019-02-14 13:40:04 -050092 NDN_THROW(std::invalid_argument("Format is <parameter>~<value>"));
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -050093 }
94
95 auto f = parsedStr.substr(0, n);
96 auto s = parsedStr.substr(n + 1);
97 if (f == "probing-interval") {
98 m_probing.setProbingInterval(getParamValue(f, s));
99 }
100 else if (f == "n-silent-timeouts") {
Alex Lane9cec6992020-03-05 19:10:09 -0600101 m_nMaxSilentTimeouts = getParamValue(f, s);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500102 }
103 else {
Davide Pesavento19779d82019-02-14 13:40:04 -0500104 NDN_THROW(std::invalid_argument("Parameter should be probing-interval or n-silent-timeouts"));
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500105 }
106 }
107}
108
Saurab Dulala6dec222019-04-01 00:15:10 -0500109void
ashiqopuc7079482019-02-20 05:34:37 +0000110AsfStrategy::afterReceiveInterest(const FaceEndpoint& ingress, const Interest& interest,
Junxiao Shi15e98b02016-08-12 11:21:44 +0000111 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000112{
113 // Should the Interest be suppressed?
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400114 auto suppressResult = m_retxSuppression.decidePerPitEntry(*pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500115 if (suppressResult == RetxSuppressionResult::SUPPRESS) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400116 NFD_LOG_DEBUG(interest << " retx-interest from=" << ingress << " suppressed");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000117 return;
118 }
119
Junxiao Shi8d843142016-07-11 22:42:42 +0000120 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
121 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000122
Saurab Dulala6dec222019-04-01 00:15:10 -0500123 if (suppressResult == RetxSuppressionResult::NEW) {
124 if (nexthops.size() == 0) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400125 NFD_LOG_DEBUG(interest << " new-interest from=" << ingress << " no-nexthop");
Teng Liangebc20f62020-06-23 16:55:20 -0700126 sendNoRouteNack(ingress.face, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500127 return;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000128 }
Saurab Dulala6dec222019-04-01 00:15:10 -0500129
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400130 Face* faceToUse = getBestFaceForForwarding(interest, ingress.face, fibEntry, pitEntry);
131 if (faceToUse != nullptr) {
132 NFD_LOG_DEBUG(interest << " new-interest from=" << ingress << " forward-to=" << faceToUse->getId());
133 forwardInterest(interest, *faceToUse, fibEntry, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500134
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400135 // If necessary, send probe
136 sendProbe(interest, ingress, *faceToUse, fibEntry, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500137 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400138 else {
139 NFD_LOG_DEBUG(interest << " new-interest from=" << ingress << " no-nexthop");
Teng Liangebc20f62020-06-23 16:55:20 -0700140 sendNoRouteNack(ingress.face, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500141 }
142 return;
143 }
144
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400145 Face* faceToUse = getBestFaceForForwarding(interest, ingress.face, fibEntry, pitEntry, false);
Saurab Dulala6dec222019-04-01 00:15:10 -0500146 // if unused face not found, select nexthop with earliest out record
147 if (faceToUse != nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400148 NFD_LOG_DEBUG(interest << " retx-interest from=" << ingress << " forward-to=" << faceToUse->getId());
149 forwardInterest(interest, *faceToUse, fibEntry, pitEntry);
Saurab Dulala6dec222019-04-01 00:15:10 -0500150 // avoid probing in case of forwarding
151 return;
152 }
153
154 // find an eligible upstream that is used earliest
155 auto it = nexthops.end();
156 it = findEligibleNextHopWithEarliestOutRecord(ingress.face, interest, nexthops, pitEntry);
157 if (it == nexthops.end()) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400158 NFD_LOG_DEBUG(interest << " retx-interest from=" << ingress << " no-nexthop");
Saurab Dulala6dec222019-04-01 00:15:10 -0500159 }
160 else {
Teng Liangebc20f62020-06-23 16:55:20 -0700161 NFD_LOG_DEBUG(interest << " retx-interest from=" << ingress << " retry-to=" << it->getFace().getId());
162 this->sendInterest(pitEntry, it->getFace(), interest);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000163 }
164}
165
166void
Junxiao Shi15e98b02016-08-12 11:21:44 +0000167AsfStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
ashiqopuc7079482019-02-20 05:34:37 +0000168 const FaceEndpoint& ingress, const Data& data)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000169{
Junxiao Shifc021862016-08-25 21:51:18 +0000170 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(pitEntry->getName());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000171 if (namespaceInfo == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400172 NFD_LOG_DEBUG(pitEntry->getName() << " data from=" << ingress << " no-measurements");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000173 return;
174 }
175
176 // Record the RTT between the Interest out to Data in
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400177 FaceInfo* faceInfo = namespaceInfo->getFaceInfo(ingress.face.getId());
Ashlesh Gawandecad76b62017-04-04 15:28:30 -0500178 if (faceInfo == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400179 NFD_LOG_DEBUG(pitEntry->getName() << " data from=" << ingress << " no-face-info");
Ashlesh Gawandecad76b62017-04-04 15:28:30 -0500180 return;
181 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400182
Md Ashiqur Rahmanc88d2d42019-08-28 20:19:47 +0000183 auto outRecord = pitEntry->getOutRecord(ingress.face);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400184 if (outRecord == pitEntry->out_end()) {
185 NFD_LOG_DEBUG(pitEntry->getName() << " data from=" << ingress << " no-out-record");
186 }
187 else {
188 faceInfo->recordRtt(time::steady_clock::now() - outRecord->getLastRenewed());
189 NFD_LOG_DEBUG(pitEntry->getName() << " data from=" << ingress
190 << " rtt=" << faceInfo->getLastRtt() << " srtt=" << faceInfo->getSrtt());
191 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000192
193 // Extend lifetime for measurements associated with Face
ashiqopuc7079482019-02-20 05:34:37 +0000194 namespaceInfo->extendFaceInfoLifetime(*faceInfo, ingress.face.getId());
Alex Lane9cec6992020-03-05 19:10:09 -0600195 // Extend PIT entry timer to allow slower probes to arrive
196 this->setExpiryTimer(pitEntry, 50_ms);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400197 faceInfo->cancelTimeout(data.getName());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000198}
199
200void
ashiqopuc7079482019-02-20 05:34:37 +0000201AsfStrategy::afterReceiveNack(const FaceEndpoint& ingress, const lp::Nack& nack,
Junxiao Shi15e98b02016-08-12 11:21:44 +0000202 const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000203{
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400204 NFD_LOG_DEBUG(nack.getInterest() << " nack from=" << ingress << " reason=" << nack.getReason());
Alex Lane9cec6992020-03-05 19:10:09 -0600205 onTimeoutOrNack(pitEntry->getName(), ingress.face.getId(), true);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000206}
207
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000208void
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400209AsfStrategy::forwardInterest(const Interest& interest, Face& outFace, const fib::Entry& fibEntry,
210 const shared_ptr<pit::Entry>& pitEntry, bool wantNewNonce)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000211{
Teng Liangebc20f62020-06-23 16:55:20 -0700212 auto faceId = outFace.getId();
213
Ashlesh Gawande2a73f352016-12-01 15:37:03 +0000214 if (wantNewNonce) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400215 // Send probe: interest with new Nonce
Ashlesh Gawande2a73f352016-12-01 15:37:03 +0000216 Interest probeInterest(interest);
217 probeInterest.refreshNonce();
Teng Liangebc20f62020-06-23 16:55:20 -0700218 NFD_LOG_TRACE("Sending probe for " << probeInterest << " to=" << faceId);
219 this->sendInterest(pitEntry, outFace, probeInterest);
Ashlesh Gawande2a73f352016-12-01 15:37:03 +0000220 }
221 else {
Teng Liangebc20f62020-06-23 16:55:20 -0700222 this->sendInterest(pitEntry, outFace, interest);
Ashlesh Gawande2a73f352016-12-01 15:37:03 +0000223 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000224
Teng Liangebc20f62020-06-23 16:55:20 -0700225 FaceInfo& faceInfo = m_measurements.getOrCreateFaceInfo(fibEntry, interest, faceId);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000226
227 // Refresh measurements since Face is being used for forwarding
228 NamespaceInfo& namespaceInfo = m_measurements.getOrCreateNamespaceInfo(fibEntry, interest);
Teng Liangebc20f62020-06-23 16:55:20 -0700229 namespaceInfo.extendFaceInfoLifetime(faceInfo, faceId);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000230
231 if (!faceInfo.isTimeoutScheduled()) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400232 auto timeout = faceInfo.scheduleTimeout(interest.getName(),
Teng Liangebc20f62020-06-23 16:55:20 -0700233 [this, name = interest.getName(), faceId] {
Alex Lane9cec6992020-03-05 19:10:09 -0600234 onTimeoutOrNack(name, faceId, false);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400235 });
Teng Liangebc20f62020-06-23 16:55:20 -0700236 NFD_LOG_TRACE("Scheduled timeout for " << fibEntry.getPrefix() << " to=" << faceId
ashiqopuc7079482019-02-20 05:34:37 +0000237 << " in " << time::duration_cast<time::milliseconds>(timeout) << " ms");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000238 }
239}
240
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400241void
242AsfStrategy::sendProbe(const Interest& interest, const FaceEndpoint& ingress, const Face& faceToUse,
243 const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry)
244{
245 if (!m_probing.isProbingNeeded(fibEntry, interest))
246 return;
247
248 Face* faceToProbe = m_probing.getFaceToProbe(ingress.face, interest, fibEntry, faceToUse);
249 if (faceToProbe == nullptr)
250 return;
251
252 forwardInterest(interest, *faceToProbe, fibEntry, pitEntry, true);
253 m_probing.afterForwardingProbe(fibEntry, interest);
254}
255
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000256struct FaceStats
257{
Junxiao Shia6de4292016-07-12 02:08:10 +0000258 Face* face;
Ernest McCracken1402fa12019-06-09 00:36:28 -0700259 time::nanoseconds rtt;
260 time::nanoseconds srtt;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000261 uint64_t cost;
262};
263
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400264struct FaceStatsCompare
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000265{
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400266 bool
267 operator()(const FaceStats& lhs, const FaceStats& rhs) const
268 {
269 time::nanoseconds lhsValue = getValueForSorting(lhs);
270 time::nanoseconds rhsValue = getValueForSorting(rhs);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000271
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400272 // Sort by RTT and then by cost
273 return std::tie(lhsValue, lhs.cost) < std::tie(rhsValue, rhs.cost);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000274 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400275
276private:
277 static time::nanoseconds
278 getValueForSorting(const FaceStats& stats)
279 {
280 // These values allow faces with no measurements to be ranked better than timeouts
281 // srtt < RTT_NO_MEASUREMENT < RTT_TIMEOUT
282 if (stats.rtt == FaceInfo::RTT_TIMEOUT) {
283 return time::nanoseconds::max();
284 }
285 else if (stats.rtt == FaceInfo::RTT_NO_MEASUREMENT) {
286 return time::nanoseconds::max() / 2;
287 }
288 else {
289 return stats.srtt;
290 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000291 }
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400292};
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000293
Junxiao Shia6de4292016-07-12 02:08:10 +0000294Face*
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400295AsfStrategy::getBestFaceForForwarding(const Interest& interest, const Face& inFace,
296 const fib::Entry& fibEntry, const shared_ptr<pit::Entry>& pitEntry,
Saurab Dulala6dec222019-04-01 00:15:10 -0500297 bool isInterestNew)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000298{
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400299 std::set<FaceStats, FaceStatsCompare> rankedFaces;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000300
Saurab Dulala6dec222019-04-01 00:15:10 -0500301 auto now = time::steady_clock::now();
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400302 for (const auto& nh : fibEntry.getNextHops()) {
303 if (!isNextHopEligible(inFace, interest, nh, pitEntry, !isInterestNew, now)) {
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000304 continue;
305 }
306
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400307 FaceInfo* info = m_measurements.getFaceInfo(fibEntry, interest, nh.getFace().getId());
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000308 if (info == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400309 rankedFaces.insert({&nh.getFace(), FaceInfo::RTT_NO_MEASUREMENT,
310 FaceInfo::RTT_NO_MEASUREMENT, nh.getCost()});
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000311 }
312 else {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400313 rankedFaces.insert({&nh.getFace(), info->getLastRtt(), info->getSrtt(), nh.getCost()});
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000314 }
315 }
316
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400317 auto it = rankedFaces.begin();
318 return it != rankedFaces.end() ? it->face : nullptr;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000319}
320
321void
Alex Lane9cec6992020-03-05 19:10:09 -0600322AsfStrategy::onTimeoutOrNack(const Name& interestName, FaceId faceId, bool isNack)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000323{
Junxiao Shifc021862016-08-25 21:51:18 +0000324 NamespaceInfo* namespaceInfo = m_measurements.getNamespaceInfo(interestName);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000325 if (namespaceInfo == nullptr) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400326 NFD_LOG_TRACE(interestName << " FibEntry has been removed since timeout scheduling");
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000327 return;
328 }
329
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400330 FaceInfo* fiPtr = namespaceInfo->getFaceInfo(faceId);
331 if (fiPtr == nullptr) {
332 NFD_LOG_TRACE(interestName << " FaceInfo id=" << faceId << " has been removed since timeout scheduling");
333 return;
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000334 }
335
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400336 auto& faceInfo = *fiPtr;
337 size_t nTimeouts = faceInfo.getNSilentTimeouts() + 1;
338 faceInfo.setNSilentTimeouts(nTimeouts);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500339
Alex Lane9cec6992020-03-05 19:10:09 -0600340 if (nTimeouts <= m_nMaxSilentTimeouts && !isNack) {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400341 NFD_LOG_TRACE(interestName << " face=" << faceId << " timeout-count=" << nTimeouts << " ignoring");
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500342 // Extend lifetime for measurements associated with Face
343 namespaceInfo->extendFaceInfoLifetime(faceInfo, faceId);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400344 faceInfo.cancelTimeout(interestName);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500345 }
346 else {
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400347 NFD_LOG_TRACE(interestName << " face=" << faceId << " timeout-count=" << nTimeouts);
Ashlesh Gawande92e4ea52017-07-19 11:38:12 -0500348 faceInfo.recordTimeout(interestName);
349 }
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000350}
351
352void
Teng Liangebc20f62020-06-23 16:55:20 -0700353AsfStrategy::sendNoRouteNack(Face& face, const shared_ptr<pit::Entry>& pitEntry)
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000354{
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000355 lp::NackHeader nackHeader;
356 nackHeader.setReason(lp::NackReason::NO_ROUTE);
Teng Liangebc20f62020-06-23 16:55:20 -0700357 this->sendNack(pitEntry, face, nackHeader);
Davide Pesaventoa6f637a2019-08-28 23:23:20 -0400358 this->rejectPendingInterest(pitEntry);
Vince Lehman8a4c29e2016-07-11 08:49:35 +0000359}
360
361} // namespace asf
362} // namespace fw
363} // namespace nfd