NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
forwarder.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, 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 #ifndef NFD_DAEMON_FW_FORWARDER_HPP
27 #define NFD_DAEMON_FW_FORWARDER_HPP
28 
29 #include "face-table.hpp"
30 #include "forwarder-counters.hpp"
32 #include "face/face-endpoint.hpp"
33 #include "table/fib.hpp"
34 #include "table/pit.hpp"
35 #include "table/cs.hpp"
36 #include "table/measurements.hpp"
40 
41 namespace nfd {
42 
43 namespace fw {
44 class Strategy;
45 } // namespace fw
46 
51 class Forwarder
52 {
53 public:
54  explicit
55  Forwarder(FaceTable& faceTable);
56 
59 
60  const ForwarderCounters&
61  getCounters() const
62  {
63  return m_counters;
64  }
65 
68  {
69  return *m_unsolicitedDataPolicy;
70  }
71 
72  void
73  setUnsolicitedDataPolicy(unique_ptr<fw::UnsolicitedDataPolicy> policy)
74  {
75  BOOST_ASSERT(policy != nullptr);
76  m_unsolicitedDataPolicy = std::move(policy);
77  }
78 
79 public: // forwarding entrypoints and tables
84  void
85  startProcessInterest(const FaceEndpoint& ingress, const Interest& interest)
86  {
87  this->onIncomingInterest(ingress, interest);
88  }
89 
94  void
95  startProcessData(const FaceEndpoint& ingress, const Data& data)
96  {
97  this->onIncomingData(ingress, data);
98  }
99 
104  void
105  startProcessNack(const FaceEndpoint& ingress, const lp::Nack& nack)
106  {
107  this->onIncomingNack(ingress, nack);
108  }
109 
114  void
115  startProcessNewNextHop(const Name& prefix, const fib::NextHop& nextHop)
116  {
117  this->onNewNextHop(prefix, nextHop);
118  }
119 
120  NameTree&
122  {
123  return m_nameTree;
124  }
125 
126  Fib&
128  {
129  return m_fib;
130  }
131 
132  Pit&
134  {
135  return m_pit;
136  }
137 
138  Cs&
140  {
141  return m_cs;
142  }
143 
144  Measurements&
146  {
147  return m_measurements;
148  }
149 
152  {
153  return m_strategyChoice;
154  }
155 
158  {
159  return m_deadNonceList;
160  }
161 
164  {
165  return m_networkRegionTable;
166  }
167 
168 public:
173 
178 
182 
186 
187 PUBLIC_WITH_TESTS_ELSE_PRIVATE: // pipelines
190  VIRTUAL_WITH_TESTS void
191  onIncomingInterest(const FaceEndpoint& ingress, const Interest& interest);
192 
195  VIRTUAL_WITH_TESTS void
196  onInterestLoop(const FaceEndpoint& ingress, const Interest& interest);
197 
200  VIRTUAL_WITH_TESTS void
201  onContentStoreMiss(const FaceEndpoint& ingress,
202  const shared_ptr<pit::Entry>& pitEntry, const Interest& interest);
203 
206  VIRTUAL_WITH_TESTS void
207  onContentStoreHit(const FaceEndpoint& ingress, const shared_ptr<pit::Entry>& pitEntry,
208  const Interest& interest, const Data& data);
209 
212  VIRTUAL_WITH_TESTS void
213  onOutgoingInterest(const shared_ptr<pit::Entry>& pitEntry,
214  const FaceEndpoint& egress, const Interest& interest);
215 
218  VIRTUAL_WITH_TESTS void
219  onInterestFinalize(const shared_ptr<pit::Entry>& pitEntry);
220 
223  VIRTUAL_WITH_TESTS void
224  onIncomingData(const FaceEndpoint& ingress, const Data& data);
225 
228  VIRTUAL_WITH_TESTS void
229  onDataUnsolicited(const FaceEndpoint& ingress, const Data& data);
230 
233  VIRTUAL_WITH_TESTS void
234  onOutgoingData(const Data& data, const FaceEndpoint& egress);
235 
238  VIRTUAL_WITH_TESTS void
239  onIncomingNack(const FaceEndpoint& ingress, const lp::Nack& nack);
240 
243  VIRTUAL_WITH_TESTS void
244  onOutgoingNack(const shared_ptr<pit::Entry>& pitEntry,
245  const FaceEndpoint& egress, const lp::NackHeader& nack);
246 
247  VIRTUAL_WITH_TESTS void
248  onDroppedInterest(const FaceEndpoint& egress, const Interest& interest);
249 
250  VIRTUAL_WITH_TESTS void
251  onNewNextHop(const Name& prefix, const fib::NextHop& nextHop);
252 
256  void
257  setExpiryTimer(const shared_ptr<pit::Entry>& pitEntry, time::milliseconds duration);
258 
263  VIRTUAL_WITH_TESTS void
264  insertDeadNonceList(pit::Entry& pitEntry, Face* upstream);
265 
268 #ifdef WITH_TESTS
269  virtual void
270  dispatchToStrategy(pit::Entry& pitEntry, std::function<void(fw::Strategy&)> trigger)
271 #else
272  template<class Function>
273  void
274  dispatchToStrategy(pit::Entry& pitEntry, Function trigger)
275 #endif
276  {
277  trigger(m_strategyChoice.findEffectiveStrategy(pitEntry));
278  }
279 
280 private:
281  ForwarderCounters m_counters;
282 
283  FaceTable& m_faceTable;
284  unique_ptr<fw::UnsolicitedDataPolicy> m_unsolicitedDataPolicy;
285 
286  NameTree m_nameTree;
287  Fib m_fib;
288  Pit m_pit;
289  Cs m_cs;
290  Measurements m_measurements;
291  StrategyChoice m_strategyChoice;
292  DeadNonceList m_deadNonceList;
293  NetworkRegionTable m_networkRegionTable;
294  shared_ptr<Face> m_csFace;
295 
296  // allow Strategy (base class) to enter pipelines
297  friend class fw::Strategy;
298 };
299 
300 } // namespace nfd
301 
302 #endif // NFD_DAEMON_FW_FORWARDER_HPP
PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
nfd::Forwarder::getStrategyChoice
StrategyChoice & getStrategyChoice()
Definition: forwarder.hpp:151
nfd::Forwarder::beforeExpirePendingInterest
signal::Signal< Forwarder, pit::Entry > beforeExpirePendingInterest
trigger before PIT entry expires
Definition: forwarder.hpp:177
nfd::Forwarder::afterCsMiss
signal::Signal< Forwarder, Interest > afterCsMiss
Signals when the incoming interest pipeline gets a miss from the content store.
Definition: forwarder.hpp:185
nfd::Forwarder::afterCsHit
signal::Signal< Forwarder, Interest, Data > afterCsHit
Signals when the incoming interest pipeline gets a hit from the content store.
Definition: forwarder.hpp:181
nfd::Forwarder::startProcessNack
void startProcessNack(const FaceEndpoint &ingress, const lp::Nack &nack)
start incoming Nack processing
Definition: forwarder.hpp:105
nonstd::optional_lite::std11::move
T & move(T &t)
Definition: optional.hpp:421
ndn::lp::NackHeader
represents a Network NACK header
Definition: nack-header.hpp:58
nfd::name_tree::NameTree
A common index structure for FIB, PIT, StrategyChoice, and Measurements.
Definition: name-tree.hpp:37
nfd::Forwarder::getUnsolicitedDataPolicy
fw::UnsolicitedDataPolicy & getUnsolicitedDataPolicy() const
Definition: forwarder.hpp:67
nfd::fw::Strategy
Strategy
Definition: strategy.cpp:38
nfd::Forwarder::getPit
Pit & getPit()
Definition: forwarder.hpp:133
nfd::cs::Cs
implements the Content Store
Definition: cs.hpp:45
nfd::Forwarder::getCs
Cs & getCs()
Definition: forwarder.hpp:139
VIRTUAL_WITH_TESTS
#define VIRTUAL_WITH_TESTS
Definition: common.hpp:39
fib.hpp
unsolicited-data-policy.hpp
face-table.hpp
nfd::Forwarder::startProcessInterest
void startProcessInterest(const FaceEndpoint &ingress, const Interest &interest)
start incoming Interest processing
Definition: forwarder.hpp:85
pit.hpp
network-region-table.hpp
nfd::ForwarderCounters
counters provided by Forwarder
Definition: forwarder-counters.hpp:36
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition: signal.hpp:52
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
nfd::fw::UnsolicitedDataPolicy
determines how to process an unsolicited Data
Definition: unsolicited-data-policy.hpp:51
nfd::Forwarder::getMeasurements
Measurements & getMeasurements()
Definition: forwarder.hpp:145
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::Forwarder::~Forwarder
~Forwarder()
nfd::Forwarder::getNameTree
NameTree & getNameTree()
Definition: forwarder.hpp:121
strategy-choice.hpp
nfd::Forwarder::getCounters
const ForwarderCounters & getCounters() const
Definition: forwarder.hpp:61
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::FaceTable
container of all faces
Definition: face-table.hpp:39
nfd::Forwarder::getNetworkRegionTable
NetworkRegionTable & getNetworkRegionTable()
Definition: forwarder.hpp:163
nfd::strategy_choice::StrategyChoice::findEffectiveStrategy
fw::Strategy & findEffectiveStrategy(const Name &prefix) const
Get effective strategy for prefix.
Definition: strategy-choice.cpp:191
face-endpoint.hpp
nfd::measurements::Measurements
The Measurements table.
Definition: measurements.hpp:80
nfd::pit::Entry
An Interest table entry.
Definition: pit-entry.hpp:59
nfd::FaceEndpoint
Represents a face-endpoint pair in the forwarder.
Definition: face-endpoint.hpp:37
cs.hpp
nfd::Forwarder::setUnsolicitedDataPolicy
void setUnsolicitedDataPolicy(unique_ptr< fw::UnsolicitedDataPolicy > policy)
Definition: forwarder.hpp:73
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
nfd::fib::NextHop
Represents a nexthop record in a FIB entry.
Definition: fib-nexthop.hpp:38
nfd::Forwarder::getDeadNonceList
DeadNonceList & getDeadNonceList()
Definition: forwarder.hpp:157
nfd::Forwarder::startProcessNewNextHop
void startProcessNewNextHop(const Name &prefix, const fib::NextHop &nextHop)
start new nexthop processing
Definition: forwarder.hpp:115
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::fw::Strategy
represents a forwarding strategy
Definition: strategy.hpp:38
nfd::Forwarder
Main class of NFD's forwarding engine.
Definition: forwarder.hpp:52
nfd::DeadNonceList
Represents the Dead Nonce List.
Definition: dead-nonce-list.hpp:55
nfd::Forwarder::startProcessData
void startProcessData(const FaceEndpoint &ingress, const Data &data)
start incoming Data processing
Definition: forwarder.hpp:95
nfd::Forwarder::beforeSatisfyInterest
signal::Signal< Forwarder, pit::Entry, Face, Data > beforeSatisfyInterest
trigger before PIT entry is satisfied
Definition: forwarder.hpp:172
nfd::pit::Pit
Represents the Interest Table.
Definition: pit.hpp:48
nfd::Forwarder::getFib
Fib & getFib()
Definition: forwarder.hpp:127
dead-nonce-list.hpp
ndn::lp::Nack
represents a Network Nack
Definition: nack.hpp:39
PROTECTED_WITH_TESTS_ELSE_PRIVATE
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:42
nfd::Forwarder::Forwarder
Forwarder(FaceTable &faceTable)
Definition: forwarder.cpp:49
nfd::fib::Fib
Represents the Forwarding Information Base (FIB)
Definition: fib.hpp:48
forwarder-counters.hpp
nfd::strategy_choice::StrategyChoice
Represents the Strategy Choice table.
Definition: strategy-choice.hpp:52
nfd::NetworkRegionTable
stores a collection of producer region names
Definition: network-region-table.hpp:41
measurements.hpp