Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "forwarder.hpp" |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 8 | #include "core/logger.hpp" |
| 9 | #include "best-route-strategy.hpp" |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 10 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 11 | namespace nfd { |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 12 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 13 | NFD_LOG_INIT("Forwarder"); |
| 14 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 15 | const Name Forwarder::s_localhostName("ndn:/localhost"); |
| 16 | |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 17 | Forwarder::Forwarder() |
| 18 | : m_lastFaceId(0) |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 19 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 20 | m_strategy = make_shared<fw::BestRouteStrategy>(boost::ref(*this)); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 21 | } |
| 22 | |
| 23 | void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 24 | Forwarder::addFace(shared_ptr<Face> face) |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 25 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 26 | FaceId faceId = ++m_lastFaceId; |
| 27 | face->setId(faceId); |
| 28 | m_faces[faceId] = face; |
| 29 | NFD_LOG_INFO("addFace id=" << faceId); |
| 30 | |
| 31 | face->onReceiveInterest += bind(&Forwarder::onInterest, |
| 32 | this, boost::ref(*face), _1); |
| 33 | face->onReceiveData += bind(&Forwarder::onData, |
| 34 | this, boost::ref(*face), _1); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 38 | Forwarder::removeFace(shared_ptr<Face> face) |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 39 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 40 | FaceId faceId = face->getId(); |
| 41 | m_faces.erase(faceId); |
| 42 | face->setId(INVALID_FACEID); |
| 43 | NFD_LOG_INFO("removeFace id=" << faceId); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 44 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 45 | // XXX This clears all subscriptions, because EventEmitter |
| 46 | // does not support only removing Forwarder's subscription |
| 47 | face->onReceiveInterest.clear(); |
| 48 | face->onReceiveData .clear(); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 49 | |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 50 | m_fib.removeNextHopFromAllEntries(face); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 51 | } |
| 52 | |
Steve DiBenedetto | 26b730f | 2014-02-02 18:36:16 -0700 | [diff] [blame] | 53 | shared_ptr<Face> |
| 54 | Forwarder::getFace(FaceId id) |
| 55 | { |
| 56 | std::map<FaceId, shared_ptr<Face> >::iterator i = m_faces.find(id); |
| 57 | return (i == m_faces.end()) ? (shared_ptr<Face>()) : (i->second); |
| 58 | } |
| 59 | |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 60 | void |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 61 | Forwarder::onInterest(Face& face, const Interest& interest) |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 62 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 63 | this->onIncomingInterest(face, interest); |
| 64 | } |
| 65 | |
| 66 | void |
| 67 | Forwarder::onData(Face& face, const Data& data) |
| 68 | { |
| 69 | this->onIncomingData(face, data); |
Alexander Afanasyev | 33b7277 | 2014-01-26 23:22:58 -0800 | [diff] [blame] | 70 | } |
| 71 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 72 | void |
| 73 | Forwarder::onIncomingInterest(Face& inFace, const Interest& interest) |
| 74 | { |
| 75 | // receive Interest |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 76 | NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() << " interest=" << interest.getName()); |
Junxiao Shi | 06887ac | 2014-02-13 20:15:42 -0700 | [diff] [blame] | 77 | const_cast<Interest&>(interest).setIncomingFaceId(inFace.getId()); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 78 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 79 | // /localhost scope control |
| 80 | bool violatesLocalhost = !inFace.isLocal() && |
| 81 | s_localhostName.isPrefixOf(interest.getName()); |
| 82 | if (violatesLocalhost) { |
| 83 | NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() |
| 84 | << " interest=" << interest.getName() << " violates /localhost"); |
| 85 | return; |
| 86 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 87 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 88 | // PIT insert |
| 89 | std::pair<shared_ptr<pit::Entry>, bool> |
| 90 | pitInsertResult = m_pit.insert(interest); |
| 91 | shared_ptr<pit::Entry> pitEntry = pitInsertResult.first; |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 92 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 93 | // detect loop and record Nonce |
| 94 | bool isLoop = ! pitEntry->addNonce(interest.getNonce()); |
| 95 | if (isLoop) { |
| 96 | // goto Interest loop pipeline |
| 97 | this->onInterestLoop(inFace, interest, pitEntry); |
| 98 | return; |
| 99 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 100 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 101 | // cancel unsatisfy & straggler timer |
| 102 | this->cancelUnsatisfyAndStragglerTimer(pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 103 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 104 | const pit::InRecordCollection& inRecords = pitEntry->getInRecords(); |
| 105 | bool isPending = inRecords.begin() == inRecords.end(); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 106 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 107 | if (!isPending) { |
| 108 | // CS lookup |
| 109 | const Data* csMatch = m_cs.find(interest); |
| 110 | if (csMatch != 0) { |
| 111 | // XXX should we lookup PIT for other Interests that also match csMatch? |
| 112 | |
| 113 | // goto outgoing Data pipeline |
| 114 | this->onOutgoingData(*csMatch, inFace); |
| 115 | return; |
| 116 | } |
| 117 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 118 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 119 | // insert InRecord |
| 120 | pit::InRecordCollection::iterator inRecordIt = |
| 121 | pitEntry->insertOrUpdateInRecord(inFace.shared_from_this(), interest); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 122 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 123 | // app chosen nexthops |
| 124 | bool isAppChosenNexthops = false; // TODO get from local control header |
| 125 | if (isAppChosenNexthops) { |
| 126 | // TODO foreach chosen nexthop: goto outgoing Interest pipeline |
| 127 | return; |
| 128 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 129 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 130 | // FIB lookup |
| 131 | shared_ptr<fib::Entry> fibEntry |
| 132 | = m_fib.findLongestPrefixMatch(interest.getName()); |
| 133 | // TODO use Fib::findParent(pitEntry) |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 134 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 135 | // dispatch to strategy |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 136 | this->dispatchToStrategy(inFace, interest, fibEntry, pitEntry); |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | void |
| 140 | Forwarder::onInterestLoop(Face& inFace, const Interest& interest, |
| 141 | shared_ptr<pit::Entry> pitEntry) |
| 142 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 143 | NFD_LOG_DEBUG("onInterestLoop face=" << inFace.getId() << " interest=" << interest.getName()); |
| 144 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 145 | // do nothing, which means Interest is dropped |
| 146 | } |
| 147 | |
| 148 | void |
| 149 | Forwarder::onOutgoingInterest(shared_ptr<pit::Entry> pitEntry, Face& outFace) |
| 150 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 151 | NFD_LOG_DEBUG("onOutgoingInterest face=" << outFace.getId() << " interest=" << pitEntry->getName()); |
| 152 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 153 | // pick Interest |
| 154 | const Interest& interest = pitEntry->getInterest(); |
| 155 | // TODO pick the last incoming Interest |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 156 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 157 | // insert OutRecord |
| 158 | pit::OutRecordCollection::iterator outRecordIt = |
| 159 | pitEntry->insertOrUpdateOutRecord(outFace.shared_from_this(), interest); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 160 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 161 | // set PIT unsatisfy timer |
| 162 | this->setUnsatisfyTimer(pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 163 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 164 | // send Interest |
| 165 | outFace.sendInterest(interest); |
| 166 | } |
| 167 | |
| 168 | void |
Junxiao Shi | 09498f0 | 2014-02-26 19:41:08 -0700 | [diff] [blame^] | 169 | Forwarder::onInterestReject(shared_ptr<pit::Entry> pitEntry) |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 170 | { |
Junxiao Shi | 09498f0 | 2014-02-26 19:41:08 -0700 | [diff] [blame^] | 171 | NFD_LOG_DEBUG("onInterestReject interest=" << pitEntry->getName()); |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 172 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 173 | // set PIT straggler timer |
| 174 | this->setStragglerTimer(pitEntry); |
| 175 | } |
| 176 | |
| 177 | void |
| 178 | Forwarder::onInterestUnsatisfied(shared_ptr<pit::Entry> pitEntry) |
| 179 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 180 | NFD_LOG_DEBUG("onInterestUnsatisfied interest=" << pitEntry->getName()); |
| 181 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 182 | // invoke PIT unsatisfied callback |
| 183 | // TODO |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 184 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 185 | // PIT delete |
| 186 | m_pit.remove(pitEntry); |
| 187 | } |
| 188 | |
| 189 | void |
| 190 | Forwarder::onIncomingData(Face& inFace, const Data& data) |
| 191 | { |
| 192 | // receive Data |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 193 | NFD_LOG_DEBUG("onIncomingData face=" << inFace.getId() << " data=" << data.getName()); |
Junxiao Shi | 06887ac | 2014-02-13 20:15:42 -0700 | [diff] [blame] | 194 | const_cast<Data&>(data).setIncomingFaceId(inFace.getId()); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 195 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 196 | // /localhost scope control |
| 197 | bool violatesLocalhost = !inFace.isLocal() && |
| 198 | s_localhostName.isPrefixOf(data.getName()); |
| 199 | if (violatesLocalhost) { |
| 200 | NFD_LOG_DEBUG("onIncomingData face=" << inFace.getId() |
| 201 | << " interest=" << data.getName() << " violates /localhost"); |
| 202 | return; |
| 203 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 204 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 205 | // PIT match |
| 206 | shared_ptr<pit::DataMatchResult> pitMatches = m_pit.findAllDataMatches(data); |
| 207 | if (pitMatches->begin() == pitMatches->end()) { |
| 208 | // goto Data unsolicited pipeline |
| 209 | this->onDataUnsolicited(inFace, data); |
| 210 | return; |
| 211 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 212 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 213 | // CS insert |
| 214 | m_cs.insert(data); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 215 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 216 | std::set<shared_ptr<Face> > pendingDownstreams; |
| 217 | // foreach PitEntry |
| 218 | for (pit::DataMatchResult::iterator it = pitMatches->begin(); |
| 219 | it != pitMatches->end(); ++it) { |
| 220 | shared_ptr<pit::Entry> pitEntry = *it; |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 221 | NFD_LOG_DEBUG("onIncomingData matching=" << pitEntry->getName()); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 222 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 223 | // cancel unsatisfy & straggler timer |
| 224 | this->cancelUnsatisfyAndStragglerTimer(pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 225 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 226 | // remember pending downstreams |
| 227 | const pit::InRecordCollection& inRecords = pitEntry->getInRecords(); |
| 228 | for (pit::InRecordCollection::const_iterator it = inRecords.begin(); |
| 229 | it != inRecords.end(); ++it) { |
| 230 | if (it->getExpiry() > time::now()) { |
| 231 | pendingDownstreams.insert(it->getFace()); |
| 232 | } |
| 233 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 234 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 235 | // mark PIT satisfied |
| 236 | pitEntry->deleteInRecords(); |
| 237 | pitEntry->deleteOutRecord(inFace.shared_from_this()); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 238 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 239 | // set PIT straggler timer |
| 240 | this->setStragglerTimer(pitEntry); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 241 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 242 | // invoke PIT satisfy callback |
| 243 | // TODO |
| 244 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 245 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 246 | // foreach pending downstream |
| 247 | for (std::set<shared_ptr<Face> >::iterator it = pendingDownstreams.begin(); |
| 248 | it != pendingDownstreams.end(); ++it) { |
| 249 | // goto outgoing Data pipeline |
| 250 | this->onOutgoingData(data, **it); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | void |
| 255 | Forwarder::onDataUnsolicited(Face& inFace, const Data& data) |
| 256 | { |
| 257 | // accept to cache? |
| 258 | bool acceptToCache = false;// TODO decision |
| 259 | if (acceptToCache) { |
| 260 | // CS insert |
| 261 | m_cs.insert(data); |
| 262 | } |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 263 | |
| 264 | NFD_LOG_DEBUG("onDataUnsolicited face=" << inFace.getId() << " data=" << data.getName() << " acceptToCache=" << acceptToCache); |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | void |
| 268 | Forwarder::onOutgoingData(const Data& data, Face& outFace) |
| 269 | { |
Junxiao Shi | 8c8d218 | 2014-01-30 22:33:00 -0700 | [diff] [blame] | 270 | NFD_LOG_DEBUG("onOutgoingData face=" << outFace.getId() << " data=" << data.getName()); |
| 271 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 272 | // traffic manager |
| 273 | // pass through |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 274 | |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 275 | // send Data |
| 276 | outFace.sendData(data); |
| 277 | } |
| 278 | |
| 279 | static inline bool |
| 280 | compare_InRecord_expiry(const pit::InRecord& a, const pit::InRecord& b) |
| 281 | { |
| 282 | return a.getExpiry() < b.getExpiry(); |
| 283 | } |
| 284 | |
| 285 | void |
| 286 | Forwarder::setUnsatisfyTimer(shared_ptr<pit::Entry> pitEntry) |
| 287 | { |
| 288 | const pit::InRecordCollection& inRecords = pitEntry->getInRecords(); |
| 289 | pit::InRecordCollection::const_iterator lastExpiring = |
| 290 | std::max_element(inRecords.begin(), inRecords.end(), |
| 291 | &compare_InRecord_expiry); |
| 292 | |
| 293 | time::Point lastExpiry = lastExpiring->getExpiry(); |
| 294 | time::Duration lastExpiryFromNow = lastExpiry - time::now(); |
| 295 | if (lastExpiryFromNow <= time::seconds(0)) { |
| 296 | // TODO all InRecords are already expired; will this happen? |
| 297 | } |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 298 | |
| 299 | pitEntry->m_unsatisfyTimer = scheduler::schedule(lastExpiryFromNow, |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 300 | bind(&Forwarder::onInterestUnsatisfied, this, pitEntry)); |
| 301 | } |
| 302 | |
| 303 | void |
| 304 | Forwarder::setStragglerTimer(shared_ptr<pit::Entry> pitEntry) |
| 305 | { |
| 306 | time::Duration stragglerTime = time::milliseconds(100); |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 307 | |
| 308 | pitEntry->m_stragglerTimer = scheduler::schedule(stragglerTime, |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 309 | bind(&Pit::remove, &m_pit, pitEntry)); |
| 310 | } |
| 311 | |
| 312 | void |
| 313 | Forwarder::cancelUnsatisfyAndStragglerTimer(shared_ptr<pit::Entry> pitEntry) |
| 314 | { |
Junxiao Shi | c041ca3 | 2014-02-25 20:01:15 -0700 | [diff] [blame] | 315 | scheduler::cancel(pitEntry->m_unsatisfyTimer); |
| 316 | scheduler::cancel(pitEntry->m_stragglerTimer); |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 317 | } |
| 318 | |
Junxiao Shi | 8888449 | 2014-02-15 15:57:43 -0700 | [diff] [blame] | 319 | void |
| 320 | Forwarder::dispatchToStrategy(const Face& inFace, |
| 321 | const Interest& interest, |
| 322 | shared_ptr<fib::Entry> fibEntry, |
| 323 | shared_ptr<pit::Entry> pitEntry) |
| 324 | { |
| 325 | m_strategy->afterReceiveInterest(inFace, interest, fibEntry, pitEntry); |
| 326 | // TODO dispatch according to fibEntry |
| 327 | } |
Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -0700 | [diff] [blame] | 328 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 329 | } // namespace nfd |