blob: cfc22cb0f48c7fd0450267e23c701d511b32071a [file] [log] [blame]
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shifef73e42016-03-29 14:15:05 -07003 * Copyright (c) 2014-2016, Regents of the University of California,
Junxiao Shi63162202015-01-14 22:27:33 -07004 * 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.
Alexander Afanasyev9bcbc7c2014-04-06 19:37:37 -070010 *
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/>.
Junxiao Shiaf6569a2014-06-14 00:01:34 -070024 */
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070025
26#include "ncc-strategy.hpp"
Junxiao Shi00dc9142016-11-21 14:23:12 +000027#include "algorithm.hpp"
Junxiao Shiaf6569a2014-06-14 00:01:34 -070028#include "core/random.hpp"
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070029
30namespace nfd {
31namespace fw {
32
Junxiao Shifaf3eb02015-02-16 10:50:36 -070033NFD_REGISTER_STRATEGY(NccStrategy);
Junxiao Shif3c07812014-03-11 21:48:49 -070034
Junxiao Shi037f4ab2016-12-13 04:27:06 +000035const time::microseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
36const time::microseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
37const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
38
Junxiao Shif3c07812014-03-11 21:48:49 -070039NccStrategy::NccStrategy(Forwarder& forwarder, const Name& name)
Junxiao Shi18739c42016-12-22 08:03:00 +000040 : Strategy(forwarder)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070041{
Junxiao Shi18739c42016-12-22 08:03:00 +000042 ParsedInstanceName parsed = parseInstanceName(name);
43 if (!parsed.parameters.empty()) {
44 BOOST_THROW_EXCEPTION(std::invalid_argument("NccStrategy does not accept parameters"));
45 }
46 this->setInstanceName(makeInstanceName(name, getStrategyName()));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070047}
48
Junxiao Shi037f4ab2016-12-13 04:27:06 +000049const Name&
50NccStrategy::getStrategyName()
51{
52 static Name strategyName("/localhost/nfd/strategy/ncc/%FD%01");
53 return strategyName;
54}
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070055
56void
Junxiao Shi15e98b02016-08-12 11:21:44 +000057NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
58 const shared_ptr<pit::Entry>& pitEntry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070059{
Junxiao Shi8d843142016-07-11 22:42:42 +000060 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
61 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070062 if (nexthops.size() == 0) {
63 this->rejectPendingInterest(pitEntry);
64 return;
65 }
66
Junxiao Shifc021862016-08-25 21:51:18 +000067 PitEntryInfo* pitEntryInfo = pitEntry->insertStrategyInfo<PitEntryInfo>().first;
Junxiao Shifef73e42016-03-29 14:15:05 -070068 bool isNewPitEntry = !hasPendingOutRecords(*pitEntry);
Junxiao Shi8bfd56d2014-10-08 10:06:00 -070069 if (!isNewPitEntry) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070070 return;
71 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070072
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000073 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070074
Junxiao Shi1391d612014-03-27 22:27:20 -070075 time::microseconds deferFirst = DEFER_FIRST_WITHOUT_BEST_FACE;
76 time::microseconds deferRange = DEFER_RANGE_WITHOUT_BEST_FACE;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070077 size_t nUpstreams = nexthops.size();
78
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000079 shared_ptr<Face> bestFace = meInfo.getBestFace();
Junxiao Shia6de4292016-07-12 02:08:10 +000080 if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +000081 !wouldViolateScope(inFace, interest, *bestFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -070082 canForwardToLegacy(*pitEntry, *bestFace)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070083 // TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ?
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000084 deferFirst = meInfo.prediction;
Junxiao Shi1391d612014-03-27 22:27:20 -070085 deferRange = time::microseconds((deferFirst.count() + 1) / 2);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070086 --nUpstreams;
Junxiao Shie21b3f32016-11-24 14:13:46 +000087 this->sendInterest(pitEntry, *bestFace, interest);
Junxiao Shi1391d612014-03-27 22:27:20 -070088 pitEntryInfo->bestFaceTimeout = scheduler::schedule(
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000089 meInfo.prediction,
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070090 bind(&NccStrategy::timeoutOnBestFace, this, weak_ptr<pit::Entry>(pitEntry)));
91 }
92 else {
Junxiao Shi63162202015-01-14 22:27:33 -070093 // use first eligible nexthop
94 auto firstEligibleNexthop = std::find_if(nexthops.begin(), nexthops.end(),
Junxiao Shie21b3f32016-11-24 14:13:46 +000095 [&] (const fib::NextHop& nexthop) {
96 Face& outFace = nexthop.getFace();
97 return !wouldViolateScope(inFace, interest, outFace) &&
98 canForwardToLegacy(*pitEntry, outFace);
Junxiao Shi63162202015-01-14 22:27:33 -070099 });
100 if (firstEligibleNexthop != nexthops.end()) {
Junxiao Shie21b3f32016-11-24 14:13:46 +0000101 this->sendInterest(pitEntry, firstEligibleNexthop->getFace(), interest);
102 }
103 else {
104 this->rejectPendingInterest(pitEntry);
105 return;
Junxiao Shi63162202015-01-14 22:27:33 -0700106 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700107 }
108
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000109 shared_ptr<Face> previousFace = meInfo.previousFace.lock();
Junxiao Shia6de4292016-07-12 02:08:10 +0000110 if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +0000111 !wouldViolateScope(inFace, interest, *previousFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -0700112 canForwardToLegacy(*pitEntry, *previousFace)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700113 --nUpstreams;
114 }
115
Junxiao Shi1391d612014-03-27 22:27:20 -0700116 if (nUpstreams > 0) {
117 pitEntryInfo->maxInterval = std::max(time::microseconds(1),
118 time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
119 }
Junxiao Shicbb490a2014-08-13 12:24:24 -0700120 else {
121 // Normally, maxInterval is unused if there aren't any face beyond best and previousBest.
122 // However, in case FIB entry gains a new nexthop before doPropagate executes (bug 1853),
123 // this maxInterval would be used to determine when the next doPropagate would happen.
124 pitEntryInfo->maxInterval = deferFirst;
125 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700126 pitEntryInfo->propagateTimer = scheduler::schedule(deferFirst,
Junxiao Shie21b3f32016-11-24 14:13:46 +0000127 bind(&NccStrategy::doPropagate, this, inFace.getId(), weak_ptr<pit::Entry>(pitEntry)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700128}
129
130void
Junxiao Shie21b3f32016-11-24 14:13:46 +0000131NccStrategy::doPropagate(FaceId inFaceId, weak_ptr<pit::Entry> pitEntryWeak)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700132{
Junxiao Shie21b3f32016-11-24 14:13:46 +0000133 Face* inFace = this->getFace(inFaceId);
134 if (inFace == nullptr) {
135 return;
136 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700137 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
Junxiao Shi8d843142016-07-11 22:42:42 +0000138 if (pitEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700139 return;
140 }
Junxiao Shie21b3f32016-11-24 14:13:46 +0000141 pit::InRecordCollection::const_iterator inRecord = pitEntry->getInRecord(*inFace);
142 if (inRecord == pitEntry->in_end()) {
143 return;
144 }
145 const Interest& interest = inRecord->getInterest();
Junxiao Shi8d843142016-07-11 22:42:42 +0000146 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700147
Junxiao Shifc021862016-08-25 21:51:18 +0000148 PitEntryInfo* pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>();
Junxiao Shi1391d612014-03-27 22:27:20 -0700149 // pitEntryInfo is guaranteed to exist here, because doPropagate is triggered
150 // from a timer set by NccStrategy.
Junxiao Shi8d843142016-07-11 22:42:42 +0000151 BOOST_ASSERT(pitEntryInfo != nullptr);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700152
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000153 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700154
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000155 shared_ptr<Face> previousFace = meInfo.previousFace.lock();
Junxiao Shia6de4292016-07-12 02:08:10 +0000156 if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +0000157 !wouldViolateScope(*inFace, interest, *previousFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -0700158 canForwardToLegacy(*pitEntry, *previousFace)) {
Junxiao Shie21b3f32016-11-24 14:13:46 +0000159 this->sendInterest(pitEntry, *previousFace, interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700160 }
161
Junxiao Shi8d843142016-07-11 22:42:42 +0000162 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700163 bool isForwarded = false;
164 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
Junxiao Shia6de4292016-07-12 02:08:10 +0000165 Face& face = it->getFace();
Junxiao Shie21b3f32016-11-24 14:13:46 +0000166 if (!wouldViolateScope(*inFace, interest, face) &&
167 canForwardToLegacy(*pitEntry, face)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700168 isForwarded = true;
Junxiao Shie21b3f32016-11-24 14:13:46 +0000169 this->sendInterest(pitEntry, face, interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700170 break;
171 }
172 }
173
174 if (isForwarded) {
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200175 std::uniform_int_distribution<time::nanoseconds::rep> dist(0, pitEntryInfo->maxInterval.count() - 1);
Junxiao Shiaf6569a2014-06-14 00:01:34 -0700176 time::nanoseconds deferNext = time::nanoseconds(dist(getGlobalRng()));
Junxiao Shi1391d612014-03-27 22:27:20 -0700177 pitEntryInfo->propagateTimer = scheduler::schedule(deferNext,
Junxiao Shie21b3f32016-11-24 14:13:46 +0000178 bind(&NccStrategy::doPropagate, this, inFaceId, weak_ptr<pit::Entry>(pitEntry)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700179 }
180}
181
182void
183NccStrategy::timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak)
184{
185 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000186 if (pitEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700187 return;
188 }
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000189 measurements::Entry* measurementsEntry = this->getMeasurements().get(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700190
191 for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000192 if (measurementsEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700193 // going out of this strategy's namespace
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000194 break;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700195 }
Junxiao Shie368d992014-12-02 23:44:31 -0700196 this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700197
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000198 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(measurementsEntry);
199 meInfo.adjustPredictUp();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700200
Junxiao Shie368d992014-12-02 23:44:31 -0700201 measurementsEntry = this->getMeasurements().getParent(*measurementsEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700202 }
203}
204
205void
Junxiao Shi15e98b02016-08-12 11:21:44 +0000206NccStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
Junxiao Shi82e7f582014-09-07 15:15:40 -0700207 const Face& inFace, const Data& data)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700208{
Junxiao Shi4846f372016-04-05 13:39:30 -0700209 if (!pitEntry->hasInRecords()) {
Junxiao Shi82e7f582014-09-07 15:15:40 -0700210 // PIT entry has already been satisfied (and is now waiting for straggler timer to expire)
211 // NCC does not collect measurements for non-best face
212 return;
213 }
214
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000215 measurements::Entry* measurementsEntry = this->getMeasurements().get(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700216
217 for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000218 if (measurementsEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700219 // going out of this strategy's namespace
220 return;
221 }
Junxiao Shie368d992014-12-02 23:44:31 -0700222 this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700223
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000224 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(measurementsEntry);
225 meInfo.updateBestFace(inFace);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700226
Junxiao Shie368d992014-12-02 23:44:31 -0700227 measurementsEntry = this->getMeasurements().getParent(*measurementsEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700228 }
229
Junxiao Shifc021862016-08-25 21:51:18 +0000230 PitEntryInfo* pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>();
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700231 if (pitEntryInfo != nullptr) {
Junxiao Shi1391d612014-03-27 22:27:20 -0700232 scheduler::cancel(pitEntryInfo->propagateTimer);
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700233
234 // Verify that the best face satisfied the interest before canceling the timeout call
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000235 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
236 shared_ptr<Face> bestFace = meInfo.getBestFace();
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700237
238 if (bestFace.get() == &inFace)
239 scheduler::cancel(pitEntryInfo->bestFaceTimeout);
Junxiao Shi1391d612014-03-27 22:27:20 -0700240 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700241}
242
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000243NccStrategy::MeasurementsEntryInfo&
Junxiao Shi15e98b02016-08-12 11:21:44 +0000244NccStrategy::getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700245{
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000246 measurements::Entry* measurementsEntry = this->getMeasurements().get(*entry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700247 return this->getMeasurementsEntryInfo(measurementsEntry);
248}
249
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000250NccStrategy::MeasurementsEntryInfo&
251NccStrategy::getMeasurementsEntryInfo(measurements::Entry* entry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700252{
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000253 BOOST_ASSERT(entry != nullptr);
Junxiao Shifc021862016-08-25 21:51:18 +0000254 MeasurementsEntryInfo* info = nullptr;
255 bool isNew = false;
256 std::tie(info, isNew) = entry->insertStrategyInfo<MeasurementsEntryInfo>();
257 if (!isNew) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000258 return *info;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700259 }
260
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000261 measurements::Entry* parentEntry = this->getMeasurements().getParent(*entry);
262 if (parentEntry != nullptr) {
263 MeasurementsEntryInfo& parentInfo = this->getMeasurementsEntryInfo(parentEntry);
264 info->inheritFrom(parentInfo);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700265 }
266
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000267 return *info;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700268}
269
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200270const time::microseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION = time::microseconds(8192);
271const time::microseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION = time::microseconds(127);
272const time::microseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION = time::milliseconds(160);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700273
274NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo()
Junxiao Shi1391d612014-03-27 22:27:20 -0700275 : prediction(INITIAL_PREDICTION)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700276{
277}
278
279void
280NccStrategy::MeasurementsEntryInfo::inheritFrom(const MeasurementsEntryInfo& other)
281{
282 this->operator=(other);
283}
284
285shared_ptr<Face>
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200286NccStrategy::MeasurementsEntryInfo::getBestFace()
287{
Junxiao Shi1391d612014-03-27 22:27:20 -0700288 shared_ptr<Face> best = this->bestFace.lock();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000289 if (best != nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700290 return best;
291 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700292 this->bestFace = best = this->previousFace.lock();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700293 return best;
294}
295
296void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200297NccStrategy::MeasurementsEntryInfo::updateBestFace(const Face& face)
298{
Junxiao Shi1391d612014-03-27 22:27:20 -0700299 if (this->bestFace.expired()) {
300 this->bestFace = const_cast<Face&>(face).shared_from_this();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700301 return;
302 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700303 shared_ptr<Face> bestFace = this->bestFace.lock();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700304 if (bestFace.get() == &face) {
305 this->adjustPredictDown();
306 }
307 else {
Junxiao Shi1391d612014-03-27 22:27:20 -0700308 this->previousFace = this->bestFace;
309 this->bestFace = const_cast<Face&>(face).shared_from_this();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700310 }
311}
312
313void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200314NccStrategy::MeasurementsEntryInfo::adjustPredictDown()
315{
Junxiao Shi1391d612014-03-27 22:27:20 -0700316 prediction = std::max(MIN_PREDICTION,
317 time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700318}
319
320void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200321NccStrategy::MeasurementsEntryInfo::adjustPredictUp()
322{
Junxiao Shi1391d612014-03-27 22:27:20 -0700323 prediction = std::min(MAX_PREDICTION,
324 time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700325}
326
327void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200328NccStrategy::MeasurementsEntryInfo::ageBestFace()
329{
Junxiao Shi1391d612014-03-27 22:27:20 -0700330 this->previousFace = this->bestFace;
331 this->bestFace.reset();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700332}
333
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700334NccStrategy::PitEntryInfo::~PitEntryInfo()
335{
Junxiao Shi1391d612014-03-27 22:27:20 -0700336 scheduler::cancel(this->bestFaceTimeout);
337 scheduler::cancel(this->propagateTimer);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700338}
339
340} // namespace fw
341} // namespace nfd