forwarder.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2017, Regents of the University of California,
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 "forwarder.hpp"
27 #include "algorithm.hpp"
28 #include "best-route-strategy2.hpp"
29 #include "strategy.hpp"
30 #include "core/logger.hpp"
31 #include "table/cleanup.hpp"
32 #include <ndn-cxx/lp/tags.hpp>
33 
34 namespace nfd {
35 
36 NFD_LOG_INIT("Forwarder");
37 
38 static Name
40 {
42 }
43 
45  : m_unsolicitedDataPolicy(new fw::DefaultUnsolicitedDataPolicy())
46  , m_fib(m_nameTree)
47  , m_pit(m_nameTree)
48  , m_measurements(m_nameTree)
49  , m_strategyChoice(*this)
50 {
51  m_faceTable.afterAdd.connect([this] (Face& face) {
52  face.afterReceiveInterest.connect(
53  [this, &face] (const Interest& interest) {
54  this->startProcessInterest(face, interest);
55  });
56  face.afterReceiveData.connect(
57  [this, &face] (const Data& data) {
58  this->startProcessData(face, data);
59  });
60  face.afterReceiveNack.connect(
61  [this, &face] (const lp::Nack& nack) {
62  this->startProcessNack(face, nack);
63  });
64  face.onDroppedInterest.connect(
65  [this, &face] (const Interest& interest) {
66  this->onDroppedInterest(face, interest);
67  });
68  });
69 
70  m_faceTable.beforeRemove.connect([this] (Face& face) {
71  cleanupOnFaceRemoval(m_nameTree, m_fib, m_pit, face);
72  });
73 
74  m_strategyChoice.setDefaultStrategy(getDefaultStrategyName());
75 }
76 
77 Forwarder::~Forwarder() = default;
78 
79 void
80 Forwarder::onIncomingInterest(Face& inFace, const Interest& interest)
81 {
82  // receive Interest
83  NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() <<
84  " interest=" << interest.getName());
85  interest.setTag(make_shared<lp::IncomingFaceIdTag>(inFace.getId()));
86  ++m_counters.nInInterests;
87 
88  // /localhost scope control
89  bool isViolatingLocalhost = inFace.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL &&
90  scope_prefix::LOCALHOST.isPrefixOf(interest.getName());
91  if (isViolatingLocalhost) {
92  NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() <<
93  " interest=" << interest.getName() << " violates /localhost");
94  // (drop)
95  return;
96  }
97 
98  // detect duplicate Nonce with Dead Nonce List
99  bool hasDuplicateNonceInDnl = m_deadNonceList.has(interest.getName(), interest.getNonce());
100  if (hasDuplicateNonceInDnl) {
101  // goto Interest loop pipeline
102  this->onInterestLoop(inFace, interest);
103  return;
104  }
105 
106  // strip forwarding hint if Interest has reached producer region
107  if (!interest.getForwardingHint().empty() &&
108  m_networkRegionTable.isInProducerRegion(interest.getForwardingHint())) {
109  NFD_LOG_DEBUG("onIncomingInterest face=" << inFace.getId() <<
110  " interest=" << interest.getName() << " reaching-producer-region");
111  const_cast<Interest&>(interest).setForwardingHint({});
112  }
113 
114  // PIT insert
115  shared_ptr<pit::Entry> pitEntry = m_pit.insert(interest).first;
116 
117  // detect duplicate Nonce in PIT entry
118  int dnw = fw::findDuplicateNonce(*pitEntry, interest.getNonce(), inFace);
119  bool hasDuplicateNonceInPit = dnw != fw::DUPLICATE_NONCE_NONE;
120  if (inFace.getLinkType() == ndn::nfd::LINK_TYPE_POINT_TO_POINT) {
121  // for p2p face: duplicate Nonce from same incoming face is not loop
122  hasDuplicateNonceInPit = hasDuplicateNonceInPit && !(dnw & fw::DUPLICATE_NONCE_IN_SAME);
123  }
124  if (hasDuplicateNonceInPit) {
125  // goto Interest loop pipeline
126  this->onInterestLoop(inFace, interest);
127  return;
128  }
129 
130  // cancel unsatisfy & straggler timer
131  this->cancelUnsatisfyAndStragglerTimer(*pitEntry);
132 
133  // is pending?
134  if (!pitEntry->hasInRecords()) {
135  m_cs.find(interest,
136  bind(&Forwarder::onContentStoreHit, this, ref(inFace), pitEntry, _1, _2),
137  bind(&Forwarder::onContentStoreMiss, this, ref(inFace), pitEntry, _1));
138  }
139  else {
140  this->onContentStoreMiss(inFace, pitEntry, interest);
141  }
142 }
143 
144 void
145 Forwarder::onInterestLoop(Face& inFace, const Interest& interest)
146 {
147  // if multi-access or ad hoc face, drop
148  if (inFace.getLinkType() != ndn::nfd::LINK_TYPE_POINT_TO_POINT) {
149  NFD_LOG_DEBUG("onInterestLoop face=" << inFace.getId() <<
150  " interest=" << interest.getName() <<
151  " drop");
152  return;
153  }
154 
155  NFD_LOG_DEBUG("onInterestLoop face=" << inFace.getId() <<
156  " interest=" << interest.getName() <<
157  " send-Nack-duplicate");
158 
159  // send Nack with reason=DUPLICATE
160  // note: Don't enter outgoing Nack pipeline because it needs an in-record.
161  lp::Nack nack(interest);
162  nack.setReason(lp::NackReason::DUPLICATE);
163  inFace.sendNack(nack);
164 }
165 
166 void
167 Forwarder::onContentStoreMiss(const Face& inFace, const shared_ptr<pit::Entry>& pitEntry,
168  const Interest& interest)
169 {
170  NFD_LOG_DEBUG("onContentStoreMiss interest=" << interest.getName());
171  ++m_counters.nCsMisses;
172 
173  // insert in-record
174  pitEntry->insertOrUpdateInRecord(const_cast<Face&>(inFace), interest);
175 
176  // set PIT unsatisfy timer
177  this->setUnsatisfyTimer(pitEntry);
178 
179  // has NextHopFaceId?
180  shared_ptr<lp::NextHopFaceIdTag> nextHopTag = interest.getTag<lp::NextHopFaceIdTag>();
181  if (nextHopTag != nullptr) {
182  // chosen NextHop face exists?
183  Face* nextHopFace = m_faceTable.get(*nextHopTag);
184  if (nextHopFace != nullptr) {
185  NFD_LOG_DEBUG("onContentStoreMiss interest=" << interest.getName() << " nexthop-faceid=" << nextHopFace->getId());
186  // go to outgoing Interest pipeline
187  // scope control is unnecessary, because privileged app explicitly wants to forward
188  this->onOutgoingInterest(pitEntry, *nextHopFace, interest);
189  }
190  return;
191  }
192 
193  // dispatch to strategy: after incoming Interest
194  this->dispatchToStrategy(*pitEntry,
195  [&] (fw::Strategy& strategy) { strategy.afterReceiveInterest(inFace, interest, pitEntry); });
196 }
197 
198 void
199 Forwarder::onContentStoreHit(const Face& inFace, const shared_ptr<pit::Entry>& pitEntry,
200  const Interest& interest, const Data& data)
201 {
202  NFD_LOG_DEBUG("onContentStoreHit interest=" << interest.getName());
203  ++m_counters.nCsHits;
204 
205  data.setTag(make_shared<lp::IncomingFaceIdTag>(face::FACEID_CONTENT_STORE));
206  // XXX should we lookup PIT for other Interests that also match csMatch?
207 
208  // set PIT straggler timer
209  this->setStragglerTimer(pitEntry, true, data.getFreshnessPeriod());
210 
211  // goto outgoing Data pipeline
212  this->onOutgoingData(data, *const_pointer_cast<Face>(inFace.shared_from_this()));
213 }
214 
215 void
216 Forwarder::onOutgoingInterest(const shared_ptr<pit::Entry>& pitEntry, Face& outFace, const Interest& interest)
217 {
218  NFD_LOG_DEBUG("onOutgoingInterest face=" << outFace.getId() <<
219  " interest=" << pitEntry->getName());
220 
221  // insert out-record
222  pitEntry->insertOrUpdateOutRecord(outFace, interest);
223 
224  // send Interest
225  outFace.sendInterest(interest);
226  ++m_counters.nOutInterests;
227 }
228 
229 void
230 Forwarder::onInterestReject(const shared_ptr<pit::Entry>& pitEntry)
231 {
232  if (fw::hasPendingOutRecords(*pitEntry)) {
233  NFD_LOG_ERROR("onInterestReject interest=" << pitEntry->getName() <<
234  " cannot reject forwarded Interest");
235  return;
236  }
237  NFD_LOG_DEBUG("onInterestReject interest=" << pitEntry->getName());
238 
239  // cancel unsatisfy & straggler timer
240  this->cancelUnsatisfyAndStragglerTimer(*pitEntry);
241 
242  // set PIT straggler timer
243  this->setStragglerTimer(pitEntry, false);
244 }
245 
246 void
247 Forwarder::onInterestUnsatisfied(const shared_ptr<pit::Entry>& pitEntry)
248 {
249  NFD_LOG_DEBUG("onInterestUnsatisfied interest=" << pitEntry->getName());
250 
251  // invoke PIT unsatisfied callback
252  this->dispatchToStrategy(*pitEntry,
253  [&] (fw::Strategy& strategy) { strategy.beforeExpirePendingInterest(pitEntry); });
254 
255  // goto Interest Finalize pipeline
256  this->onInterestFinalize(pitEntry, false);
257 }
258 
259 void
260 Forwarder::onInterestFinalize(const shared_ptr<pit::Entry>& pitEntry, bool isSatisfied,
261  ndn::optional<time::milliseconds> dataFreshnessPeriod)
262 {
263  NFD_LOG_DEBUG("onInterestFinalize interest=" << pitEntry->getName() <<
264  (isSatisfied ? " satisfied" : " unsatisfied"));
265 
266  // Dead Nonce List insert if necessary
267  this->insertDeadNonceList(*pitEntry, isSatisfied, dataFreshnessPeriod, 0);
268 
269  // PIT delete
270  this->cancelUnsatisfyAndStragglerTimer(*pitEntry);
271  m_pit.erase(pitEntry.get());
272 }
273 
274 void
275 Forwarder::onIncomingData(Face& inFace, const Data& data)
276 {
277  // receive Data
278  NFD_LOG_DEBUG("onIncomingData face=" << inFace.getId() << " data=" << data.getName());
279  data.setTag(make_shared<lp::IncomingFaceIdTag>(inFace.getId()));
280  ++m_counters.nInData;
281 
282  // /localhost scope control
283  bool isViolatingLocalhost = inFace.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL &&
284  scope_prefix::LOCALHOST.isPrefixOf(data.getName());
285  if (isViolatingLocalhost) {
286  NFD_LOG_DEBUG("onIncomingData face=" << inFace.getId() <<
287  " data=" << data.getName() << " violates /localhost");
288  // (drop)
289  return;
290  }
291 
292  // PIT match
293  pit::DataMatchResult pitMatches = m_pit.findAllDataMatches(data);
294  if (pitMatches.begin() == pitMatches.end()) {
295  // goto Data unsolicited pipeline
296  this->onDataUnsolicited(inFace, data);
297  return;
298  }
299 
300  // CS insert
301  m_cs.insert(data);
302 
303  std::set<Face*> pendingDownstreams;
304  // foreach PitEntry
305  auto now = time::steady_clock::now();
306  for (const shared_ptr<pit::Entry>& pitEntry : pitMatches) {
307  NFD_LOG_DEBUG("onIncomingData matching=" << pitEntry->getName());
308 
309  // cancel unsatisfy & straggler timer
310  this->cancelUnsatisfyAndStragglerTimer(*pitEntry);
311 
312  // remember pending downstreams
313  for (const pit::InRecord& inRecord : pitEntry->getInRecords()) {
314  if (inRecord.getExpiry() > now) {
315  pendingDownstreams.insert(&inRecord.getFace());
316  }
317  }
318 
319  // invoke PIT satisfy callback
320  this->dispatchToStrategy(*pitEntry,
321  [&] (fw::Strategy& strategy) { strategy.beforeSatisfyInterest(pitEntry, inFace, data); });
322 
323  // Dead Nonce List insert if necessary (for out-record of inFace)
324  this->insertDeadNonceList(*pitEntry, true, data.getFreshnessPeriod(), &inFace);
325 
326  // mark PIT satisfied
327  pitEntry->clearInRecords();
328  pitEntry->deleteOutRecord(inFace);
329 
330  // set PIT straggler timer
331  this->setStragglerTimer(pitEntry, true, data.getFreshnessPeriod());
332  }
333 
334  // foreach pending downstream
335  for (Face* pendingDownstream : pendingDownstreams) {
336  if (pendingDownstream->getId() == inFace.getId() &&
337  pendingDownstream->getLinkType() != ndn::nfd::LINK_TYPE_AD_HOC) {
338  continue;
339  }
340  // goto outgoing Data pipeline
341  this->onOutgoingData(data, *pendingDownstream);
342  }
343 }
344 
345 void
346 Forwarder::onDataUnsolicited(Face& inFace, const Data& data)
347 {
348  // accept to cache?
349  fw::UnsolicitedDataDecision decision = m_unsolicitedDataPolicy->decide(inFace, data);
350  if (decision == fw::UnsolicitedDataDecision::CACHE) {
351  // CS insert
352  m_cs.insert(data, true);
353  }
354 
355  NFD_LOG_DEBUG("onDataUnsolicited face=" << inFace.getId() <<
356  " data=" << data.getName() <<
357  " decision=" << decision);
358 }
359 
360 void
361 Forwarder::onOutgoingData(const Data& data, Face& outFace)
362 {
363  if (outFace.getId() == face::INVALID_FACEID) {
364  NFD_LOG_WARN("onOutgoingData face=invalid data=" << data.getName());
365  return;
366  }
367  NFD_LOG_DEBUG("onOutgoingData face=" << outFace.getId() << " data=" << data.getName());
368 
369  // /localhost scope control
370  bool isViolatingLocalhost = outFace.getScope() == ndn::nfd::FACE_SCOPE_NON_LOCAL &&
371  scope_prefix::LOCALHOST.isPrefixOf(data.getName());
372  if (isViolatingLocalhost) {
373  NFD_LOG_DEBUG("onOutgoingData face=" << outFace.getId() <<
374  " data=" << data.getName() << " violates /localhost");
375  // (drop)
376  return;
377  }
378 
379  // TODO traffic manager
380 
381  // send Data
382  outFace.sendData(data);
383  ++m_counters.nOutData;
384 }
385 
386 void
387 Forwarder::onIncomingNack(Face& inFace, const lp::Nack& nack)
388 {
389  // receive Nack
390  nack.setTag(make_shared<lp::IncomingFaceIdTag>(inFace.getId()));
391  ++m_counters.nInNacks;
392 
393  // if multi-access or ad hoc face, drop
394  if (inFace.getLinkType() != ndn::nfd::LINK_TYPE_POINT_TO_POINT) {
395  NFD_LOG_DEBUG("onIncomingNack face=" << inFace.getId() <<
396  " nack=" << nack.getInterest().getName() <<
397  "~" << nack.getReason() << " face-is-multi-access");
398  return;
399  }
400 
401  // PIT match
402  shared_ptr<pit::Entry> pitEntry = m_pit.find(nack.getInterest());
403  // if no PIT entry found, drop
404  if (pitEntry == nullptr) {
405  NFD_LOG_DEBUG("onIncomingNack face=" << inFace.getId() <<
406  " nack=" << nack.getInterest().getName() <<
407  "~" << nack.getReason() << " no-PIT-entry");
408  return;
409  }
410 
411  // has out-record?
412  pit::OutRecordCollection::iterator outRecord = pitEntry->getOutRecord(inFace);
413  // if no out-record found, drop
414  if (outRecord == pitEntry->out_end()) {
415  NFD_LOG_DEBUG("onIncomingNack face=" << inFace.getId() <<
416  " nack=" << nack.getInterest().getName() <<
417  "~" << nack.getReason() << " no-out-record");
418  return;
419  }
420 
421  // if out-record has different Nonce, drop
422  if (nack.getInterest().getNonce() != outRecord->getLastNonce()) {
423  NFD_LOG_DEBUG("onIncomingNack face=" << inFace.getId() <<
424  " nack=" << nack.getInterest().getName() <<
425  "~" << nack.getReason() << " wrong-Nonce " <<
426  nack.getInterest().getNonce() << "!=" << outRecord->getLastNonce());
427  return;
428  }
429 
430  NFD_LOG_DEBUG("onIncomingNack face=" << inFace.getId() <<
431  " nack=" << nack.getInterest().getName() <<
432  "~" << nack.getReason() << " OK");
433 
434  // record Nack on out-record
435  outRecord->setIncomingNack(nack);
436 
437  // trigger strategy: after receive NACK
438  this->dispatchToStrategy(*pitEntry,
439  [&] (fw::Strategy& strategy) { strategy.afterReceiveNack(inFace, nack, pitEntry); });
440 }
441 
442 void
443 Forwarder::onOutgoingNack(const shared_ptr<pit::Entry>& pitEntry, const Face& outFace,
444  const lp::NackHeader& nack)
445 {
446  if (outFace.getId() == face::INVALID_FACEID) {
447  NFD_LOG_WARN("onOutgoingNack face=invalid" <<
448  " nack=" << pitEntry->getInterest().getName() <<
449  "~" << nack.getReason() << " no-in-record");
450  return;
451  }
452 
453  // has in-record?
454  pit::InRecordCollection::iterator inRecord = pitEntry->getInRecord(outFace);
455 
456  // if no in-record found, drop
457  if (inRecord == pitEntry->in_end()) {
458  NFD_LOG_DEBUG("onOutgoingNack face=" << outFace.getId() <<
459  " nack=" << pitEntry->getInterest().getName() <<
460  "~" << nack.getReason() << " no-in-record");
461  return;
462  }
463 
464  // if multi-access or ad hoc face, drop
465  if (outFace.getLinkType() != ndn::nfd::LINK_TYPE_POINT_TO_POINT) {
466  NFD_LOG_DEBUG("onOutgoingNack face=" << outFace.getId() <<
467  " nack=" << pitEntry->getInterest().getName() <<
468  "~" << nack.getReason() << " face-is-multi-access");
469  return;
470  }
471 
472  NFD_LOG_DEBUG("onOutgoingNack face=" << outFace.getId() <<
473  " nack=" << pitEntry->getInterest().getName() <<
474  "~" << nack.getReason() << " OK");
475 
476  // create Nack packet with the Interest from in-record
477  lp::Nack nackPkt(inRecord->getInterest());
478  nackPkt.setHeader(nack);
479 
480  // erase in-record
481  pitEntry->deleteInRecord(outFace);
482 
483  // send Nack on face
484  const_cast<Face&>(outFace).sendNack(nackPkt);
485  ++m_counters.nOutNacks;
486 }
487 
488 void
489 Forwarder::onDroppedInterest(Face& outFace, const Interest& interest)
490 {
491  m_strategyChoice.findEffectiveStrategy(interest.getName()).onDroppedInterest(outFace, interest);
492 }
493 
494 static inline bool
496 {
497  return a.getExpiry() < b.getExpiry();
498 }
499 
500 void
501 Forwarder::setUnsatisfyTimer(const shared_ptr<pit::Entry>& pitEntry)
502 {
503  pit::InRecordCollection::iterator lastExpiring =
504  std::max_element(pitEntry->in_begin(), pitEntry->in_end(), &compare_InRecord_expiry);
505 
506  time::steady_clock::TimePoint lastExpiry = lastExpiring->getExpiry();
507  time::nanoseconds lastExpiryFromNow = lastExpiry - time::steady_clock::now();
508  if (lastExpiryFromNow <= time::seconds::zero()) {
509  // TODO all in-records are already expired; will this happen?
510  }
511 
512  scheduler::cancel(pitEntry->m_unsatisfyTimer);
513  pitEntry->m_unsatisfyTimer = scheduler::schedule(lastExpiryFromNow,
514  bind(&Forwarder::onInterestUnsatisfied, this, pitEntry));
515 }
516 
517 void
518 Forwarder::setStragglerTimer(const shared_ptr<pit::Entry>& pitEntry, bool isSatisfied,
519  ndn::optional<time::milliseconds> dataFreshnessPeriod)
520 {
521  time::nanoseconds stragglerTime = time::milliseconds(100);
522 
523  scheduler::cancel(pitEntry->m_stragglerTimer);
524  pitEntry->m_stragglerTimer = scheduler::schedule(stragglerTime,
525  bind(&Forwarder::onInterestFinalize, this, pitEntry, isSatisfied, dataFreshnessPeriod));
526 }
527 
528 void
529 Forwarder::cancelUnsatisfyAndStragglerTimer(pit::Entry& pitEntry)
530 {
533 }
534 
535 static inline void
537  const pit::OutRecord& outRecord)
538 {
539  dnl.add(pitEntry.getName(), outRecord.getLastNonce());
540 }
541 
542 void
543 Forwarder::insertDeadNonceList(pit::Entry& pitEntry, bool isSatisfied,
544  ndn::optional<time::milliseconds> dataFreshnessPeriod, Face* upstream)
545 {
546  // need Dead Nonce List insert?
547  bool needDnl = true;
548  if (isSatisfied) {
549  BOOST_ASSERT(dataFreshnessPeriod);
550  BOOST_ASSERT(*dataFreshnessPeriod >= time::milliseconds::zero());
551  needDnl = static_cast<bool>(pitEntry.getInterest().getMustBeFresh()) &&
552  *dataFreshnessPeriod < m_deadNonceList.getLifetime();
553  }
554 
555  if (!needDnl) {
556  return;
557  }
558 
559  // Dead Nonce List insert
560  if (upstream == nullptr) {
561  // insert all outgoing Nonces
562  const pit::OutRecordCollection& outRecords = pitEntry.getOutRecords();
563  std::for_each(outRecords.begin(), outRecords.end(),
564  bind(&insertNonceToDnl, ref(m_deadNonceList), cref(pitEntry), _1));
565  }
566  else {
567  // insert outgoing Nonce of a specific face
568  pit::OutRecordCollection::iterator outRecord = pitEntry.getOutRecord(*upstream);
569  if (outRecord != pitEntry.getOutRecords().end()) {
570  m_deadNonceList.add(pitEntry.getName(), outRecord->getLastNonce());
571  }
572  }
573 }
574 
575 } // namespace nfd
OutRecordCollection::iterator getOutRecord(const Face &face)
get the out-record for face
Definition: pit-entry.cpp:90
void cleanupOnFaceRemoval(NameTree &nt, Fib &fib, Pit &pit, const Face &face)
cleanup tables when a face is destroyed
Definition: cleanup.cpp:31
#define NFD_LOG_DEBUG(expression)
Definition: logger.hpp:161
void cancel(const EventId &eventId)
cancel a scheduled event
Definition: scheduler.cpp:53
virtual void afterReceiveInterest(const Face &inFace, const Interest &interest, const shared_ptr< pit::Entry > &pitEntry)=0
trigger after Interest is received
contains information about an Interest toward an outgoing face
static const Name & getStrategyName()
scheduler::EventId m_unsatisfyTimer
unsatisfy timer
Definition: pit-entry.hpp:227
time::steady_clock::TimePoint getExpiry() const
gives the time point this record expires
scheduler::EventId m_stragglerTimer
straggler timer
Definition: pit-entry.hpp:237
virtual void beforeSatisfyInterest(const shared_ptr< pit::Entry > &pitEntry, const Face &inFace, const Data &data)
trigger before PIT entry is satisfied
Definition: strategy.cpp:152
Face * get(FaceId id) const
get face by FaceId
Definition: face-table.cpp:44
#define NFD_LOG_ERROR(expression)
Definition: logger.hpp:164
const time::nanoseconds & getLifetime() const
void add(const Name &name, uint32_t nonce)
records name+nonce
static bool compare_InRecord_expiry(const pit::InRecord &a, const pit::InRecord &b)
Definition: forwarder.cpp:495
bool has(const Name &name, uint32_t nonce) const
determines if name+nonce exists
DropAllUnsolicitedDataPolicy DefaultUnsolicitedDataPolicy
the default UnsolicitedDataPolicy
Table::const_iterator iterator
Definition: cs-internal.hpp:41
in-record of same face
Definition: algorithm.hpp:93
#define NFD_LOG_WARN(expression)
Definition: logger.hpp:163
an Interest table entry
Definition: pit-entry.hpp:57
static void insertNonceToDnl(DeadNonceList &dnl, const pit::Entry &pitEntry, const pit::OutRecord &outRecord)
Definition: forwarder.cpp:536
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
contains information about an Interest from an incoming face
virtual void afterReceiveNack(const Face &inFace, const lp::Nack &nack, const shared_ptr< pit::Entry > &pitEntry)
trigger after Nack is received
Definition: strategy.cpp:166
signal::Signal< FaceTable, Face & > beforeRemove
fires before a face is removed
Definition: face-table.hpp:90
void startProcessInterest(Face &face, const Interest &interest)
start incoming Interest processing
Definition: forwarder.hpp:112
represents the Dead Nonce list
signal::Signal< FaceTable, Face & > afterAdd
fires after a face is added
Definition: face-table.hpp:84
bool hasPendingOutRecords(const pit::Entry &pitEntry)
determine whether pitEntry has any pending out-records
Definition: algorithm.cpp:113
const Interest & getInterest() const
Definition: pit-entry.hpp:69
const Name LOCALHOST
ndn:/localhost
no duplicate Nonce is found
Definition: algorithm.hpp:92
int findDuplicateNonce(const pit::Entry &pitEntry, uint32_t nonce, const Face &face)
determine whether pitEntry has duplicate Nonce nonce
Definition: algorithm.cpp:83
std::list< OutRecord > OutRecordCollection
an unordered collection of out-records
Definition: pit-entry.hpp:47
static Name getDefaultStrategyName()
Definition: forwarder.cpp:39
represents a forwarding strategy
Definition: strategy.hpp:37
This file contains common algorithms used by forwarding strategies.
#define NFD_LOG_INIT(name)
Definition: logger.hpp:122
UnsolicitedDataDecision
a decision made by UnsolicitedDataPolicy
EventId schedule(time::nanoseconds after, const EventCallback &event)
schedule an event
Definition: scheduler.cpp:47
the Data should be cached in the ContentStore
bool isInProducerRegion(const DelegationList &forwardingHint) const
determines whether an Interest has reached a producer region
uint32_t getLastNonce() const
virtual void beforeExpirePendingInterest(const shared_ptr< pit::Entry > &pitEntry)
trigger before PIT entry expires
Definition: strategy.cpp:160
const OutRecordCollection & getOutRecords() const
Definition: pit-entry.hpp:159
void startProcessData(Face &face, const Data &data)
start incoming Data processing
Definition: forwarder.hpp:122
const FaceId FACEID_CONTENT_STORE
identifies a packet comes from the ContentStore
Definition: face.hpp:46
std::vector< shared_ptr< Entry > > DataMatchResult
Definition: pit.hpp:42
const FaceId INVALID_FACEID
indicates an invalid FaceId
Definition: face.hpp:42
const Name & getName() const
Definition: pit-entry.hpp:77
void startProcessNack(Face &face, const lp::Nack &nack)
start incoming Nack processing
Definition: forwarder.hpp:132