Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -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 | 80ee7cb | 2014-12-14 10:53:05 -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. |
| 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 "access-strategy.hpp" |
Junxiao Shi | 00dc914 | 2016-11-21 14:23:12 +0000 | [diff] [blame] | 27 | #include "algorithm.hpp" |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 28 | #include "core/logger.hpp" |
| 29 | |
| 30 | namespace nfd { |
| 31 | namespace fw { |
| 32 | |
| 33 | NFD_LOG_INIT("AccessStrategy"); |
Junxiao Shi | faf3eb0 | 2015-02-16 10:50:36 -0700 | [diff] [blame] | 34 | NFD_REGISTER_STRATEGY(AccessStrategy); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 35 | |
| 36 | AccessStrategy::AccessStrategy(Forwarder& forwarder, const Name& name) |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame^] | 37 | : Strategy(forwarder) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 38 | , m_removeFaceInfoConn(this->beforeRemoveFace.connect( |
| 39 | bind(&AccessStrategy::removeFaceInfo, this, _1))) |
| 40 | { |
Junxiao Shi | 18739c4 | 2016-12-22 08:03:00 +0000 | [diff] [blame^] | 41 | ParsedInstanceName parsed = parseInstanceName(name); |
| 42 | if (!parsed.parameters.empty()) { |
| 43 | BOOST_THROW_EXCEPTION(std::invalid_argument("AccessStrategy does not accept parameters")); |
| 44 | } |
| 45 | this->setInstanceName(makeInstanceName(name, getStrategyName())); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Junxiao Shi | 037f4ab | 2016-12-13 04:27:06 +0000 | [diff] [blame] | 48 | const Name& |
| 49 | AccessStrategy::getStrategyName() |
| 50 | { |
| 51 | static Name strategyName("/localhost/nfd/strategy/access/%FD%01"); |
| 52 | return strategyName; |
| 53 | } |
| 54 | |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 55 | void |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 56 | AccessStrategy::afterReceiveInterest(const Face& inFace, const Interest& interest, |
| 57 | const shared_ptr<pit::Entry>& pitEntry) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 58 | { |
Junxiao Shi | a788e25 | 2015-01-28 17:06:25 -0700 | [diff] [blame] | 59 | RetxSuppression::Result suppressResult = m_retxSuppression.decide(inFace, interest, *pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 60 | switch (suppressResult) { |
Junxiao Shi | a788e25 | 2015-01-28 17:06:25 -0700 | [diff] [blame] | 61 | case RetxSuppression::NEW: |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 62 | this->afterReceiveNewInterest(inFace, interest, pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 63 | break; |
Junxiao Shi | a788e25 | 2015-01-28 17:06:25 -0700 | [diff] [blame] | 64 | case RetxSuppression::FORWARD: |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 65 | this->afterReceiveRetxInterest(inFace, interest, pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 66 | break; |
Junxiao Shi | a788e25 | 2015-01-28 17:06:25 -0700 | [diff] [blame] | 67 | case RetxSuppression::SUPPRESS: |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 68 | NFD_LOG_DEBUG(interest << " interestFrom " << inFace.getId() << " retx-suppress"); |
| 69 | break; |
| 70 | default: |
| 71 | BOOST_ASSERT(false); |
| 72 | break; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | void |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 77 | AccessStrategy::afterReceiveNewInterest(const Face& inFace, const Interest& interest, |
| 78 | const shared_ptr<pit::Entry>& pitEntry) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 79 | { |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 80 | const fib::Entry& fibEntry = this->lookupFib(*pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 81 | Name miName; |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 82 | MtInfo* mi = nullptr; |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 83 | std::tie(miName, mi) = this->findPrefixMeasurements(*pitEntry); |
| 84 | |
| 85 | // has measurements for Interest Name? |
| 86 | if (mi != nullptr) { |
| 87 | NFD_LOG_DEBUG(interest << " interestFrom " << inFace.getId() << |
| 88 | " new-interest mi=" << miName); |
| 89 | |
| 90 | // send to last working nexthop |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 91 | bool isSentToLastNexthop = this->sendToLastNexthop(inFace, interest, pitEntry, *mi, fibEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 92 | |
| 93 | if (isSentToLastNexthop) { |
| 94 | return; |
| 95 | } |
| 96 | } |
| 97 | else { |
| 98 | NFD_LOG_DEBUG(interest << " interestFrom " << inFace.getId() << |
| 99 | " new-interest no-mi"); |
| 100 | } |
| 101 | |
| 102 | // no measurements, or last working nexthop unavailable |
| 103 | |
Junxiao Shi | 965d3a4 | 2015-06-01 06:55:23 -0700 | [diff] [blame] | 104 | // multicast to all nexthops except incoming face |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 105 | int nMulticastSent = this->multicast(inFace, interest, pitEntry, fibEntry); |
| 106 | |
| 107 | if (nMulticastSent < 1) { |
| 108 | this->rejectPendingInterest(pitEntry); |
| 109 | } |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | void |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 113 | AccessStrategy::afterReceiveRetxInterest(const Face& inFace, const Interest& interest, |
| 114 | const shared_ptr<pit::Entry>& pitEntry) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 115 | { |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 116 | const fib::Entry& fibEntry = this->lookupFib(*pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 117 | NFD_LOG_DEBUG(interest << " interestFrom " << inFace.getId() << " retx-forward"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 118 | this->multicast(inFace, interest, pitEntry, fibEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | bool |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 122 | AccessStrategy::sendToLastNexthop(const Face& inFace, const Interest& interest, |
| 123 | const shared_ptr<pit::Entry>& pitEntry, MtInfo& mi, |
| 124 | const fib::Entry& fibEntry) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 125 | { |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 126 | if (mi.lastNexthop == face::INVALID_FACEID) { |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 127 | NFD_LOG_DEBUG(pitEntry->getInterest() << " no-last-nexthop"); |
| 128 | return false; |
| 129 | } |
| 130 | |
| 131 | if (mi.lastNexthop == inFace.getId()) { |
| 132 | NFD_LOG_DEBUG(pitEntry->getInterest() << " last-nexthop-is-downstream"); |
| 133 | return false; |
| 134 | } |
| 135 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 136 | Face* outFace = this->getFace(mi.lastNexthop); |
| 137 | if (outFace == nullptr || !fibEntry.hasNextHop(*outFace)) { |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 138 | NFD_LOG_DEBUG(pitEntry->getInterest() << " last-nexthop-gone"); |
| 139 | return false; |
| 140 | } |
| 141 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 142 | if (wouldViolateScope(inFace, interest, *outFace)) { |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 143 | NFD_LOG_DEBUG(pitEntry->getInterest() << " last-nexthop-violates-scope"); |
| 144 | return false; |
| 145 | } |
| 146 | |
| 147 | RttEstimator::Duration rto = mi.rtt.computeRto(); |
| 148 | NFD_LOG_DEBUG(pitEntry->getInterest() << " interestTo " << mi.lastNexthop << |
| 149 | " last-nexthop rto=" << time::duration_cast<time::microseconds>(rto).count()); |
| 150 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 151 | this->sendInterest(pitEntry, *outFace, interest); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 152 | |
| 153 | // schedule RTO timeout |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 154 | PitInfo* pi = pitEntry->insertStrategyInfo<PitInfo>().first; |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 155 | pi->rtoTimer = scheduler::schedule(rto, |
| 156 | bind(&AccessStrategy::afterRtoTimeout, this, weak_ptr<pit::Entry>(pitEntry), |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 157 | inFace.getId(), mi.lastNexthop)); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 158 | |
| 159 | return true; |
| 160 | } |
| 161 | |
| 162 | void |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 163 | AccessStrategy::afterRtoTimeout(weak_ptr<pit::Entry> pitWeak, FaceId inFaceId, FaceId firstOutFaceId) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 164 | { |
| 165 | shared_ptr<pit::Entry> pitEntry = pitWeak.lock(); |
| 166 | BOOST_ASSERT(pitEntry != nullptr); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 167 | // if pitEntry is gone, RTO timer should have been cancelled |
| 168 | |
| 169 | Face* inFace = this->getFace(inFaceId); |
| 170 | if (inFace == nullptr) { |
| 171 | NFD_LOG_DEBUG(pitEntry->getInterest() << " timeoutFrom " << firstOutFaceId << |
| 172 | " inFace-gone " << inFaceId); |
| 173 | return; |
| 174 | } |
| 175 | |
| 176 | pit::InRecordCollection::iterator inRecord = pitEntry->getInRecord(*inFace); |
| 177 | BOOST_ASSERT(inRecord != pitEntry->in_end()); |
| 178 | // in-record is erased only if Interest is satisfied, and RTO timer should have been cancelled |
| 179 | // note: if this strategy is extended to send Nacks, that would also erase in-record, |
| 180 | // and RTO timer should be cancelled in that case as well |
| 181 | |
| 182 | const Interest& interest = inRecord->getInterest(); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 183 | |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 184 | const fib::Entry& fibEntry = this->lookupFib(*pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 185 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 186 | NFD_LOG_DEBUG(pitEntry->getInterest() << " timeoutFrom " << firstOutFaceId << |
| 187 | " multicast-except " << firstOutFaceId); |
| 188 | this->multicast(*inFace, interest, pitEntry, fibEntry, firstOutFaceId); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 191 | int |
| 192 | AccessStrategy::multicast(const Face& inFace, const Interest& interest, |
| 193 | const shared_ptr<pit::Entry>& pitEntry, const fib::Entry& fibEntry, |
| 194 | FaceId exceptFace) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 195 | { |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 196 | int nSent = 0; |
Junxiao Shi | 8d84314 | 2016-07-11 22:42:42 +0000 | [diff] [blame] | 197 | for (const fib::NextHop& nexthop : fibEntry.getNextHops()) { |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 198 | Face& outFace = nexthop.getFace(); |
| 199 | if (&outFace == &inFace || outFace.getId() == exceptFace || |
| 200 | wouldViolateScope(inFace, interest, outFace)) { |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 201 | continue; |
| 202 | } |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 203 | NFD_LOG_DEBUG(pitEntry->getInterest() << " interestTo " << outFace.getId() << |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 204 | " multicast"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 205 | this->sendInterest(pitEntry, outFace, interest); |
| 206 | ++nSent; |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 207 | } |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 208 | return nSent; |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | void |
Junxiao Shi | 15e98b0 | 2016-08-12 11:21:44 +0000 | [diff] [blame] | 212 | AccessStrategy::beforeSatisfyInterest(const shared_ptr<pit::Entry>& pitEntry, |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 213 | const Face& inFace, const Data& data) |
| 214 | { |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 215 | PitInfo* pi = pitEntry->getStrategyInfo<PitInfo>(); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 216 | if (pi != nullptr) { |
| 217 | pi->rtoTimer.cancel(); |
| 218 | } |
| 219 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 220 | if (!pitEntry->hasInRecords()) { // already satisfied by another upstream |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 221 | NFD_LOG_DEBUG(pitEntry->getInterest() << " dataFrom " << inFace.getId() << |
| 222 | " not-fastest"); |
| 223 | return; |
| 224 | } |
| 225 | |
Junxiao Shi | 4846f37 | 2016-04-05 13:39:30 -0700 | [diff] [blame] | 226 | pit::OutRecordCollection::iterator outRecord = pitEntry->getOutRecord(inFace); |
| 227 | if (outRecord == pitEntry->out_end()) { // no out-record |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 228 | NFD_LOG_DEBUG(pitEntry->getInterest() << " dataFrom " << inFace.getId() << |
| 229 | " no-out-record"); |
| 230 | return; |
| 231 | } |
| 232 | |
| 233 | time::steady_clock::Duration rtt = time::steady_clock::now() - outRecord->getLastRenewed(); |
| 234 | NFD_LOG_DEBUG(pitEntry->getInterest() << " dataFrom " << inFace.getId() << |
| 235 | " rtt=" << time::duration_cast<time::microseconds>(rtt).count()); |
| 236 | this->updateMeasurements(inFace, data, time::duration_cast<RttEstimator::Duration>(rtt)); |
| 237 | } |
| 238 | |
| 239 | void |
| 240 | AccessStrategy::updateMeasurements(const Face& inFace, const Data& data, |
| 241 | const RttEstimator::Duration& rtt) |
| 242 | { |
Junxiao Shi | f15058a | 2016-12-11 20:15:05 +0000 | [diff] [blame] | 243 | ///\todo move FaceInfoTable out of AccessStrategy instance, to Measurements or somewhere else |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 244 | FaceInfo& fi = m_fit[inFace.getId()]; |
| 245 | fi.rtt.addMeasurement(rtt); |
| 246 | |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 247 | MtInfo* mi = this->addPrefixMeasurements(data); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 248 | if (mi->lastNexthop != inFace.getId()) { |
| 249 | mi->lastNexthop = inFace.getId(); |
| 250 | mi->rtt = fi.rtt; |
| 251 | } |
| 252 | else { |
| 253 | mi->rtt.addMeasurement(rtt); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | AccessStrategy::MtInfo::MtInfo() |
Junxiao Shi | cde37ad | 2015-12-24 01:02:05 -0700 | [diff] [blame] | 258 | : lastNexthop(face::INVALID_FACEID) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 259 | , rtt(1, time::milliseconds(1), 0.1) |
| 260 | { |
| 261 | } |
| 262 | |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 263 | std::tuple<Name, AccessStrategy::MtInfo*> |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 264 | AccessStrategy::findPrefixMeasurements(const pit::Entry& pitEntry) |
| 265 | { |
Junxiao Shi | 80f9fcd | 2016-07-23 02:48:36 +0000 | [diff] [blame] | 266 | measurements::Entry* me = this->getMeasurements().findLongestPrefixMatch(pitEntry); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 267 | if (me == nullptr) { |
Junxiao Shi | 5b3feb6 | 2016-08-19 01:51:41 +0000 | [diff] [blame] | 268 | return std::make_tuple(Name(), nullptr); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 271 | MtInfo* mi = me->getStrategyInfo<MtInfo>(); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 272 | BOOST_ASSERT(mi != nullptr); |
| 273 | // XXX after runtime strategy change, it's possible that me exists but mi doesn't exist; |
| 274 | // this case needs another longest prefix match until mi is found |
Junxiao Shi | 5b3feb6 | 2016-08-19 01:51:41 +0000 | [diff] [blame] | 275 | return std::make_tuple(me->getName(), mi); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 276 | } |
| 277 | |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 278 | AccessStrategy::MtInfo* |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 279 | AccessStrategy::addPrefixMeasurements(const Data& data) |
| 280 | { |
Junxiao Shi | 80f9fcd | 2016-07-23 02:48:36 +0000 | [diff] [blame] | 281 | measurements::Entry* me = nullptr; |
| 282 | if (!data.getName().empty()) { |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 283 | me = this->getMeasurements().get(data.getName().getPrefix(-1)); |
| 284 | } |
| 285 | if (me == nullptr) { // parent of Data Name is not in this strategy, or Data Name is empty |
| 286 | me = this->getMeasurements().get(data.getName()); |
| 287 | // Data Name must be in this strategy |
| 288 | BOOST_ASSERT(me != nullptr); |
| 289 | } |
| 290 | |
Junxiao Shi | 7b0f4d1 | 2015-05-10 21:40:29 -0700 | [diff] [blame] | 291 | static const time::nanoseconds ME_LIFETIME = time::seconds(8); |
| 292 | this->getMeasurements().extendLifetime(*me, ME_LIFETIME); |
| 293 | |
Junxiao Shi | fc02186 | 2016-08-25 21:51:18 +0000 | [diff] [blame] | 294 | return me->insertStrategyInfo<MtInfo>().first; |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | AccessStrategy::FaceInfo::FaceInfo() |
| 298 | : rtt(1, time::milliseconds(1), 0.1) |
| 299 | { |
| 300 | } |
| 301 | |
| 302 | void |
Junxiao Shi | ae04d34 | 2016-07-19 13:20:22 +0000 | [diff] [blame] | 303 | AccessStrategy::removeFaceInfo(const Face& face) |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 304 | { |
Junxiao Shi | ae04d34 | 2016-07-19 13:20:22 +0000 | [diff] [blame] | 305 | m_fit.erase(face.getId()); |
Junxiao Shi | 80ee7cb | 2014-12-14 10:53:05 -0700 | [diff] [blame] | 306 | } |
| 307 | |
| 308 | } // namespace fw |
| 309 | } // namespace nfd |