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-2021, 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 "common/config-file.hpp"
33 #include "face/face-endpoint.hpp"
34 #include "table/fib.hpp"
35 #include "table/pit.hpp"
36 #include "table/cs.hpp"
37 #include "table/measurements.hpp"
41 
42 namespace nfd {
43 
44 namespace fw {
45 class Strategy;
46 } // namespace fw
47 
53 class Forwarder
54 {
55 public:
56  explicit
57  Forwarder(FaceTable& faceTable);
58 
60  ~Forwarder();
61 
62  const ForwarderCounters&
63  getCounters() const
64  {
65  return m_counters;
66  }
67 
70  {
71  return *m_unsolicitedDataPolicy;
72  }
73 
74  void
75  setUnsolicitedDataPolicy(unique_ptr<fw::UnsolicitedDataPolicy> policy)
76  {
77  BOOST_ASSERT(policy != nullptr);
78  m_unsolicitedDataPolicy = std::move(policy);
79  }
80 
81  NameTree&
83  {
84  return m_nameTree;
85  }
86 
87  Fib&
89  {
90  return m_fib;
91  }
92 
93  Pit&
95  {
96  return m_pit;
97  }
98 
99  Cs&
101  {
102  return m_cs;
103  }
104 
105  Measurements&
107  {
108  return m_measurements;
109  }
110 
113  {
114  return m_strategyChoice;
115  }
116 
119  {
120  return m_deadNonceList;
121  }
122 
125  {
126  return m_networkRegionTable;
127  }
128 
131  void
132  setConfigFile(ConfigFile& configFile);
133 
134 public:
139 
144 
148 
152 
159  onIncomingInterest(const Interest& interest, const FaceEndpoint& ingress);
160 
164  onInterestLoop(const Interest& interest, const FaceEndpoint& ingress);
165 
169  onContentStoreMiss(const Interest& interest, const FaceEndpoint& ingress,
170  const shared_ptr<pit::Entry>& pitEntry);
171 
175  onContentStoreHit(const Interest& interest, const FaceEndpoint& ingress,
176  const shared_ptr<pit::Entry>& pitEntry, const Data& data);
177 
182  onOutgoingInterest(const Interest& interest, Face& egress,
183  const shared_ptr<pit::Entry>& pitEntry);
184 
188  onInterestFinalize(const shared_ptr<pit::Entry>& pitEntry);
189 
195  onIncomingData(const Data& data, const FaceEndpoint& ingress);
196 
200  onDataUnsolicited(const Data& data, const FaceEndpoint& ingress);
201 
206  onOutgoingData(const Data& data, Face& egress);
207 
213  onIncomingNack(const lp::Nack& nack, const FaceEndpoint& ingress);
214 
219  onOutgoingNack(const lp::NackHeader& nack, Face& egress,
220  const shared_ptr<pit::Entry>& pitEntry);
221 
223  onDroppedInterest(const Interest& interest, Face& egress);
224 
226  onNewNextHop(const Name& prefix, const fib::NextHop& nextHop);
227 
228 private:
231  void
232  setExpiryTimer(const shared_ptr<pit::Entry>& pitEntry, time::milliseconds duration);
233 
238  void
239  insertDeadNonceList(pit::Entry& pitEntry, const Face* upstream);
240 
241  void
242  processConfig(const ConfigSection& configSection, bool isDryRun,
243  const std::string& filename);
244 
249  struct Config
250  {
253  uint8_t defaultHopLimit = 0;
254  };
255  Config m_config;
256 
257 private:
258  ForwarderCounters m_counters;
259 
260  FaceTable& m_faceTable;
261  unique_ptr<fw::UnsolicitedDataPolicy> m_unsolicitedDataPolicy;
262 
263  NameTree m_nameTree;
264  Fib m_fib;
265  Pit m_pit;
266  Cs m_cs;
267  Measurements m_measurements;
268  StrategyChoice m_strategyChoice;
269  DeadNonceList m_deadNonceList;
270  NetworkRegionTable m_networkRegionTable;
271  shared_ptr<Face> m_csFace;
272 
273  // allow Strategy (base class) to enter pipelines
274  friend class fw::Strategy;
275 };
276 
277 } // namespace nfd
278 
279 #endif // NFD_DAEMON_FW_FORWARDER_HPP
#define NFD_VIRTUAL_WITH_TESTS
Definition: common.hpp:39
signal::Signal< Forwarder, pit::Entry, Face, Data > beforeSatisfyInterest
trigger before PIT entry is satisfied
Definition: forwarder.hpp:138
const ForwarderCounters & getCounters() const
Definition: forwarder.hpp:63
Represents the Dead Nonce List.
Counters provided by Forwarder.
void setConfigFile(ConfigFile &config)
Represents a face-endpoint pair in the forwarder.
DeadNonceList & getDeadNonceList()
Definition: forwarder.hpp:118
configuration file parsing utility
Definition: config-file.hpp:57
Fib & getFib()
Definition: forwarder.hpp:88
determines how to process an unsolicited Data
Main class of NFD&#39;s forwarding engine.
Definition: forwarder.hpp:53
boost::chrono::duration< Rep, Period > duration
Definition: time.hpp:34
Represents an Interest packet.
Definition: interest.hpp:48
stores a collection of producer region names
StrategyChoice & getStrategyChoice()
Definition: forwarder.hpp:112
provides a lightweight signal / event system
Definition: signal.hpp:52
represents a Network Nack
Definition: nack.hpp:38
Represents the Interest Table.
Definition: pit.hpp:47
ndn Face
Definition: face-impl.hpp:42
container of all faces
Definition: face-table.hpp:38
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
An Interest table entry.
Definition: pit-entry.hpp:58
signal::Signal< Forwarder, pit::Entry > beforeExpirePendingInterest
trigger before PIT entry expires
Definition: forwarder.hpp:143
Represents the Forwarding Information Base (FIB)
Definition: fib.hpp:47
The Measurements table.
signal::Signal< Forwarder, Interest > afterCsMiss
Signals when the incoming interest pipeline gets a miss from the content store.
Definition: forwarder.hpp:151
signal::Signal< Forwarder, Interest, Data > afterCsHit
Signals when the incoming interest pipeline gets a hit from the content store.
Definition: forwarder.hpp:147
boost::property_tree::ptree ConfigSection
a config file section
Represents an absolute name.
Definition: name.hpp:41
Forwarder
Definition: forwarder.cpp:43
implements the Content Store
Definition: cs.hpp:44
fw::UnsolicitedDataPolicy & getUnsolicitedDataPolicy() const
Definition: forwarder.hpp:69
Represents a forwarding strategy.
Definition: strategy.hpp:38
A common index structure for FIB, PIT, StrategyChoice, and Measurements.
Definition: name-tree.hpp:36
Represents the Strategy Choice table.
NetworkRegionTable & getNetworkRegionTable()
Definition: forwarder.hpp:124
Contains information about an Interest toward an outgoing face.
Measurements & getMeasurements()
Definition: forwarder.hpp:106
Pit & getPit()
Definition: forwarder.hpp:94
Represents a Data packet.
Definition: data.hpp:37
represents a Network NACK header
Definition: nack-header.hpp:57
NameTree & getNameTree()
Definition: forwarder.hpp:82
void setUnsolicitedDataPolicy(unique_ptr< fw::UnsolicitedDataPolicy > policy)
Definition: forwarder.hpp:75
Represents a nexthop record in a FIB entry.
Definition: fib-nexthop.hpp:37
boost::chrono::milliseconds milliseconds
Definition: time.hpp:48