blob: 0c8b53ac85b28b5a1e3f778641f1de96a68e7fe3 [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)
40 : Strategy(forwarder, name)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070041{
42}
43
Junxiao Shi037f4ab2016-12-13 04:27:06 +000044const Name&
45NccStrategy::getStrategyName()
46{
47 static Name strategyName("/localhost/nfd/strategy/ncc/%FD%01");
48 return strategyName;
49}
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070050
51void
Junxiao Shi15e98b02016-08-12 11:21:44 +000052NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
53 const shared_ptr<pit::Entry>& pitEntry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070054{
Junxiao Shi8d843142016-07-11 22:42:42 +000055 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
56 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070057 if (nexthops.size() == 0) {
58 this->rejectPendingInterest(pitEntry);
59 return;
60 }
61
Junxiao Shifc021862016-08-25 21:51:18 +000062 PitEntryInfo* pitEntryInfo = pitEntry->insertStrategyInfo<PitEntryInfo>().first;
Junxiao Shifef73e42016-03-29 14:15:05 -070063 bool isNewPitEntry = !hasPendingOutRecords(*pitEntry);
Junxiao Shi8bfd56d2014-10-08 10:06:00 -070064 if (!isNewPitEntry) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070065 return;
66 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070067
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000068 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070069
Junxiao Shi1391d612014-03-27 22:27:20 -070070 time::microseconds deferFirst = DEFER_FIRST_WITHOUT_BEST_FACE;
71 time::microseconds deferRange = DEFER_RANGE_WITHOUT_BEST_FACE;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070072 size_t nUpstreams = nexthops.size();
73
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000074 shared_ptr<Face> bestFace = meInfo.getBestFace();
Junxiao Shia6de4292016-07-12 02:08:10 +000075 if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +000076 !wouldViolateScope(inFace, interest, *bestFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -070077 canForwardToLegacy(*pitEntry, *bestFace)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070078 // TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ?
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000079 deferFirst = meInfo.prediction;
Junxiao Shi1391d612014-03-27 22:27:20 -070080 deferRange = time::microseconds((deferFirst.count() + 1) / 2);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070081 --nUpstreams;
Junxiao Shie21b3f32016-11-24 14:13:46 +000082 this->sendInterest(pitEntry, *bestFace, interest);
Junxiao Shi1391d612014-03-27 22:27:20 -070083 pitEntryInfo->bestFaceTimeout = scheduler::schedule(
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000084 meInfo.prediction,
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070085 bind(&NccStrategy::timeoutOnBestFace, this, weak_ptr<pit::Entry>(pitEntry)));
86 }
87 else {
Junxiao Shi63162202015-01-14 22:27:33 -070088 // use first eligible nexthop
89 auto firstEligibleNexthop = std::find_if(nexthops.begin(), nexthops.end(),
Junxiao Shie21b3f32016-11-24 14:13:46 +000090 [&] (const fib::NextHop& nexthop) {
91 Face& outFace = nexthop.getFace();
92 return !wouldViolateScope(inFace, interest, outFace) &&
93 canForwardToLegacy(*pitEntry, outFace);
Junxiao Shi63162202015-01-14 22:27:33 -070094 });
95 if (firstEligibleNexthop != nexthops.end()) {
Junxiao Shie21b3f32016-11-24 14:13:46 +000096 this->sendInterest(pitEntry, firstEligibleNexthop->getFace(), interest);
97 }
98 else {
99 this->rejectPendingInterest(pitEntry);
100 return;
Junxiao Shi63162202015-01-14 22:27:33 -0700101 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700102 }
103
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000104 shared_ptr<Face> previousFace = meInfo.previousFace.lock();
Junxiao Shia6de4292016-07-12 02:08:10 +0000105 if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +0000106 !wouldViolateScope(inFace, interest, *previousFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -0700107 canForwardToLegacy(*pitEntry, *previousFace)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700108 --nUpstreams;
109 }
110
Junxiao Shi1391d612014-03-27 22:27:20 -0700111 if (nUpstreams > 0) {
112 pitEntryInfo->maxInterval = std::max(time::microseconds(1),
113 time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
114 }
Junxiao Shicbb490a2014-08-13 12:24:24 -0700115 else {
116 // Normally, maxInterval is unused if there aren't any face beyond best and previousBest.
117 // However, in case FIB entry gains a new nexthop before doPropagate executes (bug 1853),
118 // this maxInterval would be used to determine when the next doPropagate would happen.
119 pitEntryInfo->maxInterval = deferFirst;
120 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700121 pitEntryInfo->propagateTimer = scheduler::schedule(deferFirst,
Junxiao Shie21b3f32016-11-24 14:13:46 +0000122 bind(&NccStrategy::doPropagate, this, inFace.getId(), weak_ptr<pit::Entry>(pitEntry)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700123}
124
125void
Junxiao Shie21b3f32016-11-24 14:13:46 +0000126NccStrategy::doPropagate(FaceId inFaceId, weak_ptr<pit::Entry> pitEntryWeak)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700127{
Junxiao Shie21b3f32016-11-24 14:13:46 +0000128 Face* inFace = this->getFace(inFaceId);
129 if (inFace == nullptr) {
130 return;
131 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700132 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
Junxiao Shi8d843142016-07-11 22:42:42 +0000133 if (pitEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700134 return;
135 }
Junxiao Shie21b3f32016-11-24 14:13:46 +0000136 pit::InRecordCollection::const_iterator inRecord = pitEntry->getInRecord(*inFace);
137 if (inRecord == pitEntry->in_end()) {
138 return;
139 }
140 const Interest& interest = inRecord->getInterest();
Junxiao Shi8d843142016-07-11 22:42:42 +0000141 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700142
Junxiao Shifc021862016-08-25 21:51:18 +0000143 PitEntryInfo* pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>();
Junxiao Shi1391d612014-03-27 22:27:20 -0700144 // pitEntryInfo is guaranteed to exist here, because doPropagate is triggered
145 // from a timer set by NccStrategy.
Junxiao Shi8d843142016-07-11 22:42:42 +0000146 BOOST_ASSERT(pitEntryInfo != nullptr);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700147
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000148 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700149
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000150 shared_ptr<Face> previousFace = meInfo.previousFace.lock();
Junxiao Shia6de4292016-07-12 02:08:10 +0000151 if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +0000152 !wouldViolateScope(*inFace, interest, *previousFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -0700153 canForwardToLegacy(*pitEntry, *previousFace)) {
Junxiao Shie21b3f32016-11-24 14:13:46 +0000154 this->sendInterest(pitEntry, *previousFace, interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700155 }
156
Junxiao Shi8d843142016-07-11 22:42:42 +0000157 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700158 bool isForwarded = false;
159 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
Junxiao Shia6de4292016-07-12 02:08:10 +0000160 Face& face = it->getFace();
Junxiao Shie21b3f32016-11-24 14:13:46 +0000161 if (!wouldViolateScope(*inFace, interest, face) &&
162 canForwardToLegacy(*pitEntry, face)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700163 isForwarded = true;
Junxiao Shie21b3f32016-11-24 14:13:46 +0000164 this->sendInterest(pitEntry, face, interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700165 break;
166 }
167 }
168
169 if (isForwarded) {
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200170 std::uniform_int_distribution<time::nanoseconds::rep> dist(0, pitEntryInfo->maxInterval.count() - 1);
Junxiao Shiaf6569a2014-06-14 00:01:34 -0700171 time::nanoseconds deferNext = time::nanoseconds(dist(getGlobalRng()));
Junxiao Shi1391d612014-03-27 22:27:20 -0700172 pitEntryInfo->propagateTimer = scheduler::schedule(deferNext,
Junxiao Shie21b3f32016-11-24 14:13:46 +0000173 bind(&NccStrategy::doPropagate, this, inFaceId, weak_ptr<pit::Entry>(pitEntry)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700174 }
175}
176
177void
178NccStrategy::timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak)
179{
180 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000181 if (pitEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700182 return;
183 }
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000184 measurements::Entry* measurementsEntry = this->getMeasurements().get(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700185
186 for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000187 if (measurementsEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700188 // going out of this strategy's namespace
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000189 break;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700190 }
Junxiao Shie368d992014-12-02 23:44:31 -0700191 this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700192
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000193 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(measurementsEntry);
194 meInfo.adjustPredictUp();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700195
Junxiao Shie368d992014-12-02 23:44:31 -0700196 measurementsEntry = this->getMeasurements().getParent(*measurementsEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700197 }
198}
199
200void
Junxiao Shi15e98b02016-08-12 11:21:44 +0000201NccStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
Junxiao Shi82e7f582014-09-07 15:15:40 -0700202 const Face& inFace, const Data& data)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700203{
Junxiao Shi4846f372016-04-05 13:39:30 -0700204 if (!pitEntry->hasInRecords()) {
Junxiao Shi82e7f582014-09-07 15:15:40 -0700205 // PIT entry has already been satisfied (and is now waiting for straggler timer to expire)
206 // NCC does not collect measurements for non-best face
207 return;
208 }
209
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000210 measurements::Entry* measurementsEntry = this->getMeasurements().get(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700211
212 for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000213 if (measurementsEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700214 // going out of this strategy's namespace
215 return;
216 }
Junxiao Shie368d992014-12-02 23:44:31 -0700217 this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700218
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000219 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(measurementsEntry);
220 meInfo.updateBestFace(inFace);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700221
Junxiao Shie368d992014-12-02 23:44:31 -0700222 measurementsEntry = this->getMeasurements().getParent(*measurementsEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700223 }
224
Junxiao Shifc021862016-08-25 21:51:18 +0000225 PitEntryInfo* pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>();
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700226 if (pitEntryInfo != nullptr) {
Junxiao Shi1391d612014-03-27 22:27:20 -0700227 scheduler::cancel(pitEntryInfo->propagateTimer);
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700228
229 // Verify that the best face satisfied the interest before canceling the timeout call
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000230 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
231 shared_ptr<Face> bestFace = meInfo.getBestFace();
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700232
233 if (bestFace.get() == &inFace)
234 scheduler::cancel(pitEntryInfo->bestFaceTimeout);
Junxiao Shi1391d612014-03-27 22:27:20 -0700235 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700236}
237
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000238NccStrategy::MeasurementsEntryInfo&
Junxiao Shi15e98b02016-08-12 11:21:44 +0000239NccStrategy::getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700240{
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000241 measurements::Entry* measurementsEntry = this->getMeasurements().get(*entry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700242 return this->getMeasurementsEntryInfo(measurementsEntry);
243}
244
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000245NccStrategy::MeasurementsEntryInfo&
246NccStrategy::getMeasurementsEntryInfo(measurements::Entry* entry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700247{
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000248 BOOST_ASSERT(entry != nullptr);
Junxiao Shifc021862016-08-25 21:51:18 +0000249 MeasurementsEntryInfo* info = nullptr;
250 bool isNew = false;
251 std::tie(info, isNew) = entry->insertStrategyInfo<MeasurementsEntryInfo>();
252 if (!isNew) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000253 return *info;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700254 }
255
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000256 measurements::Entry* parentEntry = this->getMeasurements().getParent(*entry);
257 if (parentEntry != nullptr) {
258 MeasurementsEntryInfo& parentInfo = this->getMeasurementsEntryInfo(parentEntry);
259 info->inheritFrom(parentInfo);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700260 }
261
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000262 return *info;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700263}
264
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200265const time::microseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION = time::microseconds(8192);
266const time::microseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION = time::microseconds(127);
267const time::microseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION = time::milliseconds(160);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700268
269NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo()
Junxiao Shi1391d612014-03-27 22:27:20 -0700270 : prediction(INITIAL_PREDICTION)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700271{
272}
273
274void
275NccStrategy::MeasurementsEntryInfo::inheritFrom(const MeasurementsEntryInfo& other)
276{
277 this->operator=(other);
278}
279
280shared_ptr<Face>
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200281NccStrategy::MeasurementsEntryInfo::getBestFace()
282{
Junxiao Shi1391d612014-03-27 22:27:20 -0700283 shared_ptr<Face> best = this->bestFace.lock();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000284 if (best != nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700285 return best;
286 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700287 this->bestFace = best = this->previousFace.lock();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700288 return best;
289}
290
291void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200292NccStrategy::MeasurementsEntryInfo::updateBestFace(const Face& face)
293{
Junxiao Shi1391d612014-03-27 22:27:20 -0700294 if (this->bestFace.expired()) {
295 this->bestFace = const_cast<Face&>(face).shared_from_this();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700296 return;
297 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700298 shared_ptr<Face> bestFace = this->bestFace.lock();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700299 if (bestFace.get() == &face) {
300 this->adjustPredictDown();
301 }
302 else {
Junxiao Shi1391d612014-03-27 22:27:20 -0700303 this->previousFace = this->bestFace;
304 this->bestFace = const_cast<Face&>(face).shared_from_this();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700305 }
306}
307
308void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200309NccStrategy::MeasurementsEntryInfo::adjustPredictDown()
310{
Junxiao Shi1391d612014-03-27 22:27:20 -0700311 prediction = std::max(MIN_PREDICTION,
312 time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700313}
314
315void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200316NccStrategy::MeasurementsEntryInfo::adjustPredictUp()
317{
Junxiao Shi1391d612014-03-27 22:27:20 -0700318 prediction = std::min(MAX_PREDICTION,
319 time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700320}
321
322void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200323NccStrategy::MeasurementsEntryInfo::ageBestFace()
324{
Junxiao Shi1391d612014-03-27 22:27:20 -0700325 this->previousFace = this->bestFace;
326 this->bestFace.reset();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700327}
328
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700329NccStrategy::PitEntryInfo::~PitEntryInfo()
330{
Junxiao Shi1391d612014-03-27 22:27:20 -0700331 scheduler::cancel(this->bestFaceTimeout);
332 scheduler::cancel(this->propagateTimer);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700333}
334
335} // namespace fw
336} // namespace nfd