Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2014-2016, Regents of the University of California, |
Junxiao Shi | 6316220 | 2015-01-14 22:27:33 -0700 | [diff] [blame] | 4 | * 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 Afanasyev | 9bcbc7c | 2014-04-06 19:37:37 -0700 | [diff] [blame] | 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/>. |
Junxiao Shi | af6569a | 2014-06-14 00:01:34 -0700 | [diff] [blame] | 24 | */ |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 25 | |
| 26 | #include "ncc-strategy.hpp" |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 27 | #include "pit-algorithm.hpp" |
Junxiao Shi | af6569a | 2014-06-14 00:01:34 -0700 | [diff] [blame] | 28 | #include "core/random.hpp" |
| 29 | #include <boost/random/uniform_int_distribution.hpp> |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 30 | |
| 31 | namespace nfd { |
| 32 | namespace fw { |
| 33 | |
Junxiao Shi | e93d6a3 | 2014-09-07 16:13:22 -0700 | [diff] [blame] | 34 | const Name NccStrategy::STRATEGY_NAME("ndn:/localhost/nfd/strategy/ncc/%FD%01"); |
Junxiao Shi | faf3eb0 | 2015-02-16 10:50:36 -0700 | [diff] [blame] | 35 | NFD_REGISTER_STRATEGY(NccStrategy); |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 36 | |
| 37 | NccStrategy::NccStrategy(Forwarder& forwarder, const Name& name) |
| 38 | : Strategy(forwarder, name) |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 39 | { |
| 40 | } |
| 41 | |
| 42 | NccStrategy::~NccStrategy() |
| 43 | { |
| 44 | } |
| 45 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 46 | const time::microseconds NccStrategy::DEFER_FIRST_WITHOUT_BEST_FACE = time::microseconds(4000); |
| 47 | const time::microseconds NccStrategy::DEFER_RANGE_WITHOUT_BEST_FACE = time::microseconds(75000); |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame] | 48 | const time::nanoseconds NccStrategy::MEASUREMENTS_LIFETIME = time::seconds(16); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 49 | |
| 50 | void |
| 51 | NccStrategy::afterReceiveInterest(const Face& inFace, |
| 52 | const Interest& interest, |
| 53 | shared_ptr<fib::Entry> fibEntry, |
| 54 | shared_ptr<pit::Entry> pitEntry) |
| 55 | { |
| 56 | const fib::NextHopList& nexthops = fibEntry->getNextHops(); |
| 57 | if (nexthops.size() == 0) { |
| 58 | this->rejectPendingInterest(pitEntry); |
| 59 | return; |
| 60 | } |
| 61 | |
| 62 | shared_ptr<PitEntryInfo> pitEntryInfo = |
| 63 | pitEntry->getOrCreateStrategyInfo<PitEntryInfo>(); |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 64 | bool isNewPitEntry = !hasPendingOutRecords(*pitEntry); |
Junxiao Shi | 8bfd56d | 2014-10-08 10:06:00 -0700 | [diff] [blame] | 65 | if (!isNewPitEntry) { |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 66 | return; |
| 67 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 68 | |
| 69 | shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo = |
| 70 | this->getMeasurementsEntryInfo(pitEntry); |
| 71 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 72 | time::microseconds deferFirst = DEFER_FIRST_WITHOUT_BEST_FACE; |
| 73 | time::microseconds deferRange = DEFER_RANGE_WITHOUT_BEST_FACE; |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 74 | size_t nUpstreams = nexthops.size(); |
| 75 | |
| 76 | shared_ptr<Face> bestFace = measurementsEntryInfo->getBestFace(); |
| 77 | if (static_cast<bool>(bestFace) && fibEntry->hasNextHop(bestFace) && |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 78 | canForwardToLegacy(*pitEntry, *bestFace)) { |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 79 | // TODO Should we use `randlow = 100 + nrand48(h->seed) % 4096U;` ? |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 80 | deferFirst = measurementsEntryInfo->prediction; |
| 81 | deferRange = time::microseconds((deferFirst.count() + 1) / 2); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 82 | --nUpstreams; |
| 83 | this->sendInterest(pitEntry, bestFace); |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 84 | pitEntryInfo->bestFaceTimeout = scheduler::schedule( |
| 85 | measurementsEntryInfo->prediction, |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 86 | bind(&NccStrategy::timeoutOnBestFace, this, weak_ptr<pit::Entry>(pitEntry))); |
| 87 | } |
| 88 | else { |
Junxiao Shi | 6316220 | 2015-01-14 22:27:33 -0700 | [diff] [blame] | 89 | // use first eligible nexthop |
| 90 | auto firstEligibleNexthop = std::find_if(nexthops.begin(), nexthops.end(), |
| 91 | [&pitEntry] (const fib::NextHop& nexthop) { |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 92 | return canForwardToLegacy(*pitEntry, *nexthop.getFace()); |
Junxiao Shi | 6316220 | 2015-01-14 22:27:33 -0700 | [diff] [blame] | 93 | }); |
| 94 | if (firstEligibleNexthop != nexthops.end()) { |
| 95 | this->sendInterest(pitEntry, firstEligibleNexthop->getFace()); |
| 96 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 97 | } |
| 98 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 99 | shared_ptr<Face> previousFace = measurementsEntryInfo->previousFace.lock(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 100 | if (static_cast<bool>(previousFace) && fibEntry->hasNextHop(previousFace) && |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 101 | canForwardToLegacy(*pitEntry, *previousFace)) { |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 102 | --nUpstreams; |
| 103 | } |
| 104 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 105 | if (nUpstreams > 0) { |
| 106 | pitEntryInfo->maxInterval = std::max(time::microseconds(1), |
| 107 | time::microseconds((2 * deferRange.count() + nUpstreams - 1) / nUpstreams)); |
| 108 | } |
Junxiao Shi | cbb490a | 2014-08-13 12:24:24 -0700 | [diff] [blame] | 109 | 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 Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 115 | pitEntryInfo->propagateTimer = scheduler::schedule(deferFirst, |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 116 | bind(&NccStrategy::doPropagate, this, |
| 117 | weak_ptr<pit::Entry>(pitEntry), weak_ptr<fib::Entry>(fibEntry))); |
| 118 | } |
| 119 | |
| 120 | void |
| 121 | NccStrategy::doPropagate(weak_ptr<pit::Entry> pitEntryWeak, weak_ptr<fib::Entry> fibEntryWeak) |
| 122 | { |
| 123 | shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock(); |
| 124 | if (!static_cast<bool>(pitEntry)) { |
| 125 | return; |
| 126 | } |
| 127 | shared_ptr<fib::Entry> fibEntry = fibEntryWeak.lock(); |
| 128 | if (!static_cast<bool>(fibEntry)) { |
| 129 | return; |
| 130 | } |
| 131 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 132 | shared_ptr<PitEntryInfo> pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>(); |
| 133 | // pitEntryInfo is guaranteed to exist here, because doPropagate is triggered |
| 134 | // from a timer set by NccStrategy. |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 135 | BOOST_ASSERT(static_cast<bool>(pitEntryInfo)); |
| 136 | |
| 137 | shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo = |
| 138 | this->getMeasurementsEntryInfo(pitEntry); |
| 139 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 140 | shared_ptr<Face> previousFace = measurementsEntryInfo->previousFace.lock(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 141 | if (static_cast<bool>(previousFace) && fibEntry->hasNextHop(previousFace) && |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 142 | canForwardToLegacy(*pitEntry, *previousFace)) { |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 143 | this->sendInterest(pitEntry, previousFace); |
| 144 | } |
| 145 | |
| 146 | const fib::NextHopList& nexthops = fibEntry->getNextHops(); |
| 147 | bool isForwarded = false; |
| 148 | for (fib::NextHopList::const_iterator it = nexthops.begin(); it != nexthops.end(); ++it) { |
| 149 | shared_ptr<Face> face = it->getFace(); |
Junxiao Shi | fef73e4 | 2016-03-29 14:15:05 -0700 | [diff] [blame^] | 150 | if (canForwardToLegacy(*pitEntry, *face)) { |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 151 | isForwarded = true; |
| 152 | this->sendInterest(pitEntry, face); |
| 153 | break; |
| 154 | } |
| 155 | } |
| 156 | |
| 157 | if (isForwarded) { |
Junxiao Shi | cbb490a | 2014-08-13 12:24:24 -0700 | [diff] [blame] | 158 | boost::random::uniform_int_distribution<time::nanoseconds::rep> dist(0, |
| 159 | pitEntryInfo->maxInterval.count() - 1); |
Junxiao Shi | af6569a | 2014-06-14 00:01:34 -0700 | [diff] [blame] | 160 | time::nanoseconds deferNext = time::nanoseconds(dist(getGlobalRng())); |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 161 | pitEntryInfo->propagateTimer = scheduler::schedule(deferNext, |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 162 | bind(&NccStrategy::doPropagate, this, |
| 163 | weak_ptr<pit::Entry>(pitEntry), weak_ptr<fib::Entry>(fibEntry))); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | void |
| 168 | NccStrategy::timeoutOnBestFace(weak_ptr<pit::Entry> pitEntryWeak) |
| 169 | { |
| 170 | shared_ptr<pit::Entry> pitEntry = pitEntryWeak.lock(); |
| 171 | if (!static_cast<bool>(pitEntry)) { |
| 172 | return; |
| 173 | } |
| 174 | shared_ptr<measurements::Entry> measurementsEntry = this->getMeasurements().get(*pitEntry); |
| 175 | |
| 176 | for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) { |
| 177 | if (!static_cast<bool>(measurementsEntry)) { |
| 178 | // going out of this strategy's namespace |
| 179 | return; |
| 180 | } |
Junxiao Shi | e368d99 | 2014-12-02 23:44:31 -0700 | [diff] [blame] | 181 | this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 182 | |
| 183 | shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo = |
| 184 | this->getMeasurementsEntryInfo(measurementsEntry); |
| 185 | measurementsEntryInfo->adjustPredictUp(); |
| 186 | |
Junxiao Shi | e368d99 | 2014-12-02 23:44:31 -0700 | [diff] [blame] | 187 | measurementsEntry = this->getMeasurements().getParent(*measurementsEntry); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 188 | } |
| 189 | } |
| 190 | |
| 191 | void |
Junxiao Shi | 82e7f58 | 2014-09-07 15:15:40 -0700 | [diff] [blame] | 192 | NccStrategy::beforeSatisfyInterest(shared_ptr<pit::Entry> pitEntry, |
| 193 | const Face& inFace, const Data& data) |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 194 | { |
Junxiao Shi | 82e7f58 | 2014-09-07 15:15:40 -0700 | [diff] [blame] | 195 | if (pitEntry->getInRecords().empty()) { |
| 196 | // PIT entry has already been satisfied (and is now waiting for straggler timer to expire) |
| 197 | // NCC does not collect measurements for non-best face |
| 198 | return; |
| 199 | } |
| 200 | |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 201 | shared_ptr<measurements::Entry> measurementsEntry = this->getMeasurements().get(*pitEntry); |
| 202 | |
| 203 | for (int i = 0; i < UPDATE_MEASUREMENTS_N_LEVELS; ++i) { |
| 204 | if (!static_cast<bool>(measurementsEntry)) { |
| 205 | // going out of this strategy's namespace |
| 206 | return; |
| 207 | } |
Junxiao Shi | e368d99 | 2014-12-02 23:44:31 -0700 | [diff] [blame] | 208 | this->getMeasurements().extendLifetime(*measurementsEntry, MEASUREMENTS_LIFETIME); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 209 | |
| 210 | shared_ptr<MeasurementsEntryInfo> measurementsEntryInfo = |
| 211 | this->getMeasurementsEntryInfo(measurementsEntry); |
| 212 | measurementsEntryInfo->updateBestFace(inFace); |
| 213 | |
Junxiao Shi | e368d99 | 2014-12-02 23:44:31 -0700 | [diff] [blame] | 214 | measurementsEntry = this->getMeasurements().getParent(*measurementsEntry); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 215 | } |
| 216 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 217 | shared_ptr<PitEntryInfo> pitEntryInfo = pitEntry->getStrategyInfo<PitEntryInfo>(); |
| 218 | if (static_cast<bool>(pitEntryInfo)) { |
| 219 | scheduler::cancel(pitEntryInfo->propagateTimer); |
| 220 | } |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | shared_ptr<NccStrategy::MeasurementsEntryInfo> |
| 224 | NccStrategy::getMeasurementsEntryInfo(shared_ptr<pit::Entry> entry) |
| 225 | { |
| 226 | shared_ptr<measurements::Entry> measurementsEntry = this->getMeasurements().get(*entry); |
| 227 | return this->getMeasurementsEntryInfo(measurementsEntry); |
| 228 | } |
| 229 | |
| 230 | shared_ptr<NccStrategy::MeasurementsEntryInfo> |
| 231 | NccStrategy::getMeasurementsEntryInfo(shared_ptr<measurements::Entry> entry) |
| 232 | { |
| 233 | shared_ptr<MeasurementsEntryInfo> info = entry->getStrategyInfo<MeasurementsEntryInfo>(); |
| 234 | if (static_cast<bool>(info)) { |
| 235 | return info; |
| 236 | } |
| 237 | |
| 238 | info = make_shared<MeasurementsEntryInfo>(); |
| 239 | entry->setStrategyInfo(info); |
| 240 | |
Junxiao Shi | e368d99 | 2014-12-02 23:44:31 -0700 | [diff] [blame] | 241 | shared_ptr<measurements::Entry> parentEntry = this->getMeasurements().getParent(*entry); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 242 | if (static_cast<bool>(parentEntry)) { |
| 243 | shared_ptr<MeasurementsEntryInfo> parentInfo = this->getMeasurementsEntryInfo(parentEntry); |
| 244 | BOOST_ASSERT(static_cast<bool>(parentInfo)); |
| 245 | info->inheritFrom(*parentInfo); |
| 246 | } |
| 247 | |
| 248 | return info; |
| 249 | } |
| 250 | |
| 251 | |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 252 | const time::microseconds NccStrategy::MeasurementsEntryInfo::INITIAL_PREDICTION = |
| 253 | time::microseconds(8192); |
| 254 | const time::microseconds NccStrategy::MeasurementsEntryInfo::MIN_PREDICTION = |
| 255 | time::microseconds(127); |
| 256 | const time::microseconds NccStrategy::MeasurementsEntryInfo::MAX_PREDICTION = |
| 257 | time::microseconds(160000); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 258 | |
| 259 | NccStrategy::MeasurementsEntryInfo::MeasurementsEntryInfo() |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 260 | : prediction(INITIAL_PREDICTION) |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 261 | { |
| 262 | } |
| 263 | |
| 264 | void |
| 265 | NccStrategy::MeasurementsEntryInfo::inheritFrom(const MeasurementsEntryInfo& other) |
| 266 | { |
| 267 | this->operator=(other); |
| 268 | } |
| 269 | |
| 270 | shared_ptr<Face> |
| 271 | NccStrategy::MeasurementsEntryInfo::getBestFace(void) { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 272 | shared_ptr<Face> best = this->bestFace.lock(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 273 | if (static_cast<bool>(best)) { |
| 274 | return best; |
| 275 | } |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 276 | this->bestFace = best = this->previousFace.lock(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 277 | return best; |
| 278 | } |
| 279 | |
| 280 | void |
| 281 | NccStrategy::MeasurementsEntryInfo::updateBestFace(const Face& face) { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 282 | if (this->bestFace.expired()) { |
| 283 | this->bestFace = const_cast<Face&>(face).shared_from_this(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 284 | return; |
| 285 | } |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 286 | shared_ptr<Face> bestFace = this->bestFace.lock(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 287 | if (bestFace.get() == &face) { |
| 288 | this->adjustPredictDown(); |
| 289 | } |
| 290 | else { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 291 | this->previousFace = this->bestFace; |
| 292 | this->bestFace = const_cast<Face&>(face).shared_from_this(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 293 | } |
| 294 | } |
| 295 | |
| 296 | void |
| 297 | NccStrategy::MeasurementsEntryInfo::adjustPredictDown() { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 298 | prediction = std::max(MIN_PREDICTION, |
| 299 | time::microseconds(prediction.count() - (prediction.count() >> ADJUST_PREDICT_DOWN_SHIFT))); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void |
| 303 | NccStrategy::MeasurementsEntryInfo::adjustPredictUp() { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 304 | prediction = std::min(MAX_PREDICTION, |
| 305 | time::microseconds(prediction.count() + (prediction.count() >> ADJUST_PREDICT_UP_SHIFT))); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | void |
| 309 | NccStrategy::MeasurementsEntryInfo::ageBestFace() { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 310 | this->previousFace = this->bestFace; |
| 311 | this->bestFace.reset(); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 312 | } |
| 313 | |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 314 | NccStrategy::PitEntryInfo::~PitEntryInfo() |
| 315 | { |
Junxiao Shi | 1391d61 | 2014-03-27 22:27:20 -0700 | [diff] [blame] | 316 | scheduler::cancel(this->bestFaceTimeout); |
| 317 | scheduler::cancel(this->propagateTimer); |
Junxiao Shi | 0b5fbbb | 2014-02-20 15:54:03 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | } // namespace fw |
| 321 | } // namespace nfd |