blob: 650182c1f9b2089849da0991b43444f9691c17a3 [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 Shie93d6a32014-09-07 16:13:22 -070033const Name NccStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/ncc/%FD%01");
Junxiao Shifaf3eb02015-02-16 10:50:36 -070034NFD_REGISTER_STRATEGY(NccStrategy);
Junxiao Shif3c07812014-03-11 21:48:49 -070035
36NccStrategy::NccStrategy(Forwarder& forwarder, const Name& name)
37 : Strategy(forwarder, name)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070038{
39}
40
Junxiao Shi1391d612014-03-27 22:27:20 -070041const time::microseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000);
42const time::microseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000);
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070043const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070044
45void
Junxiao Shi15e98b02016-08-12 11:21:44 +000046NccStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest,
47 const shared_ptr<pit::Entry>& pitEntry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070048{
Junxiao Shi8d843142016-07-11 22:42:42 +000049 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
50 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070051 if (nexthops.size() == 0) {
52 this->rejectPendingInterest(pitEntry);
53 return;
54 }
55
Junxiao Shifc021862016-08-25 21:51:18 +000056 PitEntryInfo* pitEntryInfo = pitEntry->insertStrategyInfo<PitEntryInfo>().first;
Junxiao Shifef73e42016-03-29 14:15:05 -070057 bool isNewPitEntry = !hasPendingOutRecords(*pitEntry);
Junxiao Shi8bfd56d2014-10-08 10:06:00 -070058 if (!isNewPitEntry) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070059 return;
60 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070061
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000062 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070063
Junxiao Shi1391d612014-03-27 22:27:20 -070064 time::microseconds deferFirst = DEFER_FIRST_WITHOUT_BEST_FACE;
65 time::microseconds deferRange = DEFER_RANGE_WITHOUT_BEST_FACE;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070066 size_t nUpstreams = nexthops.size();
67
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000068 shared_ptr<Face> bestFace = meInfo.getBestFace();
Junxiao Shia6de4292016-07-12 02:08:10 +000069 if (bestFace != nullptr && fibEntry.hasNextHop(*bestFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +000070 !wouldViolateScope(inFace, interest, *bestFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -070071 canForwardToLegacy(*pitEntry, *bestFace)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070072 // TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ?
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000073 deferFirst = meInfo.prediction;
Junxiao Shi1391d612014-03-27 22:27:20 -070074 deferRange = time::microseconds((deferFirst.count() + 1) / 2);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070075 --nUpstreams;
Junxiao Shie21b3f32016-11-24 14:13:46 +000076 this->sendInterest(pitEntry, *bestFace, interest);
Junxiao Shi1391d612014-03-27 22:27:20 -070077 pitEntryInfo->bestFaceTimeout = scheduler::schedule(
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000078 meInfo.prediction,
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070079 bind(&NccStrategy::timeoutOnBestFace, this, weak_ptr<pit::Entry>(pitEntry)));
80 }
81 else {
Junxiao Shi63162202015-01-14 22:27:33 -070082 // use first eligible nexthop
83 auto firstEligibleNexthop = std::find_if(nexthops.begin(), nexthops.end(),
Junxiao Shie21b3f32016-11-24 14:13:46 +000084 [&] (const fib::NextHop& nexthop) {
85 Face& outFace = nexthop.getFace();
86 return !wouldViolateScope(inFace, interest, outFace) &&
87 canForwardToLegacy(*pitEntry, outFace);
Junxiao Shi63162202015-01-14 22:27:33 -070088 });
89 if (firstEligibleNexthop != nexthops.end()) {
Junxiao Shie21b3f32016-11-24 14:13:46 +000090 this->sendInterest(pitEntry, firstEligibleNexthop->getFace(), interest);
91 }
92 else {
93 this->rejectPendingInterest(pitEntry);
94 return;
Junxiao Shi63162202015-01-14 22:27:33 -070095 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -070096 }
97
Junxiao Shi80f9fcd2016-07-23 02:48:36 +000098 shared_ptr<Face> previousFace = meInfo.previousFace.lock();
Junxiao Shia6de4292016-07-12 02:08:10 +000099 if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +0000100 !wouldViolateScope(inFace, interest, *previousFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -0700101 canForwardToLegacy(*pitEntry, *previousFace)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700102 --nUpstreams;
103 }
104
Junxiao Shi1391d612014-03-27 22:27:20 -0700105 if (nUpstreams > 0) {
106 pitEntryInfo->maxInterval = std::max(time::microseconds(1),
107 time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams));
108 }
Junxiao Shicbb490a2014-08-13 12:24:24 -0700109 else {
110 // Normally, maxInterval is unused if there aren't any face beyond best and previousBest.
111 // However, in case FIB entry gains a new nexthop before doPropagate executes (bug 1853),
112 // this maxInterval would be used to determine when the next doPropagate would happen.
113 pitEntryInfo->maxInterval = deferFirst;
114 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700115 pitEntryInfo->propagateTimer = scheduler::schedule(deferFirst,
Junxiao Shie21b3f32016-11-24 14:13:46 +0000116 bind(&NccStrategy::doPropagate, this, inFace.getId(), weak_ptr<pit::Entry>(pitEntry)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700117}
118
119void
Junxiao Shie21b3f32016-11-24 14:13:46 +0000120NccStrategy::doPropagate(FaceId inFaceId, weak_ptr<pit::Entry> pitEntryWeak)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700121{
Junxiao Shie21b3f32016-11-24 14:13:46 +0000122 Face* inFace = this->getFace(inFaceId);
123 if (inFace == nullptr) {
124 return;
125 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700126 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
Junxiao Shi8d843142016-07-11 22:42:42 +0000127 if (pitEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700128 return;
129 }
Junxiao Shie21b3f32016-11-24 14:13:46 +0000130 pit::InRecordCollection::const_iterator inRecord = pitEntry->getInRecord(*inFace);
131 if (inRecord == pitEntry->in_end()) {
132 return;
133 }
134 const Interest& interest = inRecord->getInterest();
Junxiao Shi8d843142016-07-11 22:42:42 +0000135 const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700136
Junxiao Shifc021862016-08-25 21:51:18 +0000137 PitEntryInfo* pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>();
Junxiao Shi1391d612014-03-27 22:27:20 -0700138 // pitEntryInfo is guaranteed to exist here, because doPropagate is triggered
139 // from a timer set by NccStrategy.
Junxiao Shi8d843142016-07-11 22:42:42 +0000140 BOOST_ASSERT(pitEntryInfo != nullptr);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700141
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000142 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700143
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000144 shared_ptr<Face> previousFace = meInfo.previousFace.lock();
Junxiao Shia6de4292016-07-12 02:08:10 +0000145 if (previousFace != nullptr && fibEntry.hasNextHop(*previousFace) &&
Junxiao Shie21b3f32016-11-24 14:13:46 +0000146 !wouldViolateScope(*inFace, interest, *previousFace) &&
Junxiao Shifef73e42016-03-29 14:15:05 -0700147 canForwardToLegacy(*pitEntry, *previousFace)) {
Junxiao Shie21b3f32016-11-24 14:13:46 +0000148 this->sendInterest(pitEntry, *previousFace, interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700149 }
150
Junxiao Shi8d843142016-07-11 22:42:42 +0000151 const fib::NextHopList& nexthops = fibEntry.getNextHops();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700152 bool isForwarded = false;
153 for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) {
Junxiao Shia6de4292016-07-12 02:08:10 +0000154 Face& face = it->getFace();
Junxiao Shie21b3f32016-11-24 14:13:46 +0000155 if (!wouldViolateScope(*inFace, interest, face) &&
156 canForwardToLegacy(*pitEntry, face)) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700157 isForwarded = true;
Junxiao Shie21b3f32016-11-24 14:13:46 +0000158 this->sendInterest(pitEntry, face, interest);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700159 break;
160 }
161 }
162
163 if (isForwarded) {
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200164 std::uniform_int_distribution<time::nanoseconds::rep> dist(0, pitEntryInfo->maxInterval.count() - 1);
Junxiao Shiaf6569a2014-06-14 00:01:34 -0700165 time::nanoseconds deferNext = time::nanoseconds(dist(getGlobalRng()));
Junxiao Shi1391d612014-03-27 22:27:20 -0700166 pitEntryInfo->propagateTimer = scheduler::schedule(deferNext,
Junxiao Shie21b3f32016-11-24 14:13:46 +0000167 bind(&NccStrategy::doPropagate, this, inFaceId, weak_ptr<pit::Entry>(pitEntry)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700168 }
169}
170
171void
172NccStrategy::timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak)
173{
174 shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000175 if (pitEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700176 return;
177 }
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000178 measurements::Entry* measurementsEntry = this->getMeasurements().get(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700179
180 for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000181 if (measurementsEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700182 // going out of this strategy's namespace
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000183 break;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700184 }
Junxiao Shie368d992014-12-02 23:44:31 -0700185 this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700186
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000187 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(measurementsEntry);
188 meInfo.adjustPredictUp();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700189
Junxiao Shie368d992014-12-02 23:44:31 -0700190 measurementsEntry = this->getMeasurements().getParent(*measurementsEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700191 }
192}
193
194void
Junxiao Shi15e98b02016-08-12 11:21:44 +0000195NccStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry,
Junxiao Shi82e7f582014-09-07 15:15:40 -0700196 const Face& inFace, const Data& data)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700197{
Junxiao Shi4846f372016-04-05 13:39:30 -0700198 if (!pitEntry->hasInRecords()) {
Junxiao Shi82e7f582014-09-07 15:15:40 -0700199 // PIT entry has already been satisfied (and is now waiting for straggler timer to expire)
200 // NCC does not collect measurements for non-best face
201 return;
202 }
203
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000204 measurements::Entry* measurementsEntry = this->getMeasurements().get(*pitEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700205
206 for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000207 if (measurementsEntry == nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700208 // going out of this strategy's namespace
209 return;
210 }
Junxiao Shie368d992014-12-02 23:44:31 -0700211 this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700212
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000213 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(measurementsEntry);
214 meInfo.updateBestFace(inFace);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700215
Junxiao Shie368d992014-12-02 23:44:31 -0700216 measurementsEntry = this->getMeasurements().getParent(*measurementsEntry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700217 }
218
Junxiao Shifc021862016-08-25 21:51:18 +0000219 PitEntryInfo* pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>();
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700220 if (pitEntryInfo != nullptr) {
Junxiao Shi1391d612014-03-27 22:27:20 -0700221 scheduler::cancel(pitEntryInfo->propagateTimer);
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700222
223 // Verify that the best face satisfied the interest before canceling the timeout call
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000224 MeasurementsEntryInfo& meInfo = this->getMeasurementsEntryInfo(pitEntry);
225 shared_ptr<Face> bestFace = meInfo.getBestFace();
Hila Ben Abraham39a79be2016-03-30 22:00:55 -0700226
227 if (bestFace.get() == &inFace)
228 scheduler::cancel(pitEntryInfo->bestFaceTimeout);
Junxiao Shi1391d612014-03-27 22:27:20 -0700229 }
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700230}
231
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000232NccStrategy::MeasurementsEntryInfo&
Junxiao Shi15e98b02016-08-12 11:21:44 +0000233NccStrategy::getMeasurementsEntryInfo(const shared_ptr<pit::Entry>& entry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700234{
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000235 measurements::Entry* measurementsEntry = this->getMeasurements().get(*entry);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700236 return this->getMeasurementsEntryInfo(measurementsEntry);
237}
238
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000239NccStrategy::MeasurementsEntryInfo&
240NccStrategy::getMeasurementsEntryInfo(measurements::Entry* entry)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700241{
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000242 BOOST_ASSERT(entry != nullptr);
Junxiao Shifc021862016-08-25 21:51:18 +0000243 MeasurementsEntryInfo* info = nullptr;
244 bool isNew = false;
245 std::tie(info, isNew) = entry->insertStrategyInfo<MeasurementsEntryInfo>();
246 if (!isNew) {
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000247 return *info;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700248 }
249
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000250 measurements::Entry* parentEntry = this->getMeasurements().getParent(*entry);
251 if (parentEntry != nullptr) {
252 MeasurementsEntryInfo& parentInfo = this->getMeasurementsEntryInfo(parentEntry);
253 info->inheritFrom(parentInfo);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700254 }
255
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000256 return *info;
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700257}
258
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200259const time::microseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION = time::microseconds(8192);
260const time::microseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION = time::microseconds(127);
261const time::microseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION = time::milliseconds(160);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700262
263NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo()
Junxiao Shi1391d612014-03-27 22:27:20 -0700264 : prediction(INITIAL_PREDICTION)
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700265{
266}
267
268void
269NccStrategy::MeasurementsEntryInfo::inheritFrom(const MeasurementsEntryInfo& other)
270{
271 this->operator=(other);
272}
273
274shared_ptr<Face>
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200275NccStrategy::MeasurementsEntryInfo::getBestFace()
276{
Junxiao Shi1391d612014-03-27 22:27:20 -0700277 shared_ptr<Face> best = this->bestFace.lock();
Junxiao Shi80f9fcd2016-07-23 02:48:36 +0000278 if (best != nullptr) {
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700279 return best;
280 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700281 this->bestFace = best = this->previousFace.lock();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700282 return best;
283}
284
285void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200286NccStrategy::MeasurementsEntryInfo::updateBestFace(const Face& face)
287{
Junxiao Shi1391d612014-03-27 22:27:20 -0700288 if (this->bestFace.expired()) {
289 this->bestFace = const_cast<Face&>(face).shared_from_this();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700290 return;
291 }
Junxiao Shi1391d612014-03-27 22:27:20 -0700292 shared_ptr<Face> bestFace = this->bestFace.lock();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700293 if (bestFace.get() == &face) {
294 this->adjustPredictDown();
295 }
296 else {
Junxiao Shi1391d612014-03-27 22:27:20 -0700297 this->previousFace = this->bestFace;
298 this->bestFace = const_cast<Face&>(face).shared_from_this();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700299 }
300}
301
302void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200303NccStrategy::MeasurementsEntryInfo::adjustPredictDown()
304{
Junxiao Shi1391d612014-03-27 22:27:20 -0700305 prediction = std::max(MIN_PREDICTION,
306 time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700307}
308
309void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200310NccStrategy::MeasurementsEntryInfo::adjustPredictUp()
311{
Junxiao Shi1391d612014-03-27 22:27:20 -0700312 prediction = std::min(MAX_PREDICTION,
313 time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT)));
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700314}
315
316void
Davide Pesavento5f47aa62016-10-07 22:09:09 +0200317NccStrategy::MeasurementsEntryInfo::ageBestFace()
318{
Junxiao Shi1391d612014-03-27 22:27:20 -0700319 this->previousFace = this->bestFace;
320 this->bestFace.reset();
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700321}
322
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700323NccStrategy::PitEntryInfo::~PitEntryInfo()
324{
Junxiao Shi1391d612014-03-27 22:27:20 -0700325 scheduler::cancel(this->bestFaceTimeout);
326 scheduler::cancel(this->propagateTimer);
Junxiao Shi0b5fbbb2014-02-20 15:54:03 -0700327}
328
329} // namespace fw
330} // namespace nfd