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