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 
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 
140  onIncomingInterest(const Interest& interest, const FaceEndpoint& ingress);
141 
145  onInterestLoop(const Interest& interest, const FaceEndpoint& ingress);
146 
150  onContentStoreMiss(const Interest& interest, const FaceEndpoint& ingress,
151  const shared_ptr<pit::Entry>& pitEntry);
152 
156  onContentStoreHit(const Interest& interest, const FaceEndpoint& ingress,
157  const shared_ptr<pit::Entry>& pitEntry, const Data& data);
158 
163  onOutgoingInterest(const Interest& interest, Face& egress,
164  const shared_ptr<pit::Entry>& pitEntry);
165 
169  onInterestFinalize(const shared_ptr<pit::Entry>& pitEntry);
170 
176  onIncomingData(const Data& data, const FaceEndpoint& ingress);
177 
181  onDataUnsolicited(const Data& data, const FaceEndpoint& ingress);
182 
187  onOutgoingData(const Data& data, Face& egress);
188 
194  onIncomingNack(const lp::Nack& nack, const FaceEndpoint& ingress);
195 
200  onOutgoingNack(const lp::NackHeader& nack, Face& egress,
201  const shared_ptr<pit::Entry>& pitEntry);
202 
204  onDroppedInterest(const Interest& interest, Face& egress);
205 
207  onNewNextHop(const Name& prefix, const fib::NextHop& nextHop);
208 
209 private:
212  void
213  setExpiryTimer(const shared_ptr<pit::Entry>& pitEntry, time::milliseconds duration);
214 
219  void
220  insertDeadNonceList(pit::Entry& pitEntry, const Face* upstream);
221 
222  void
223  processConfig(const ConfigSection& configSection, bool isDryRun,
224  const std::string& filename);
225 
230  struct Config
231  {
234  uint8_t defaultHopLimit = 0;
235  };
236  Config m_config;
237 
238 private:
239  ForwarderCounters m_counters;
240 
241  FaceTable& m_faceTable;
242  unique_ptr<fw::UnsolicitedDataPolicy> m_unsolicitedDataPolicy;
243 
244  NameTree m_nameTree;
245  Fib m_fib;
246  Pit m_pit;
247  Cs m_cs;
248  Measurements m_measurements;
249  StrategyChoice m_strategyChoice;
250  DeadNonceList m_deadNonceList;
251  NetworkRegionTable m_networkRegionTable;
252 
253  // allow Strategy (base class) to enter pipelines
254  friend class fw::Strategy;
255 };
256 
257 } // namespace nfd
258 
259 #endif // NFD_DAEMON_FW_FORWARDER_HPP
configuration file parsing utility
Definition: config-file.hpp:58
Represents the Dead Nonce List.
Represents a face-endpoint pair in the forwarder.
container of all faces
Definition: face-table.hpp:39
Counters provided by Forwarder.
Main class of NFD's forwarding engine.
Definition: forwarder.hpp:54
void setConfigFile(ConfigFile &configFile)
register handler for forwarder section of NFD configuration file
Definition: forwarder.cpp:608
Measurements & getMeasurements()
Definition: forwarder.hpp:106
DeadNonceList & getDeadNonceList()
Definition: forwarder.hpp:118
const ForwarderCounters & getCounters() const
Definition: forwarder.hpp:63
Fib & getFib()
Definition: forwarder.hpp:88
Pit & getPit()
Definition: forwarder.hpp:94
fw::UnsolicitedDataPolicy & getUnsolicitedDataPolicy() const
Definition: forwarder.hpp:69
Forwarder(FaceTable &faceTable)
Definition: forwarder.cpp:51
NameTree & getNameTree()
Definition: forwarder.hpp:82
void setUnsolicitedDataPolicy(unique_ptr< fw::UnsolicitedDataPolicy > policy)
Definition: forwarder.hpp:75
NetworkRegionTable & getNetworkRegionTable()
Definition: forwarder.hpp:124
StrategyChoice & getStrategyChoice()
Definition: forwarder.hpp:112
stores a collection of producer region names
implements the Content Store
Definition: cs.hpp:45
generalization of a network interface
Definition: face.hpp:55
Represents the Forwarding Information Base (FIB)
Definition: fib.hpp:48
Represents a nexthop record in a FIB entry.
Definition: fib-nexthop.hpp:38
Represents a forwarding strategy.
Definition: strategy.hpp:39
determines how to process an unsolicited Data
The Measurements table.
A common index structure for FIB, PIT, StrategyChoice, and Measurements.
Definition: name-tree.hpp:37
An Interest table entry.
Definition: pit-entry.hpp:59
Contains information about an Interest toward an outgoing face.
Represents the Interest Table.
Definition: pit.hpp:48
Represents the Strategy Choice table.
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
#define NFD_VIRTUAL_WITH_TESTS
Definition: common.hpp:39
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents,...
Definition: algorithm.hpp:32
boost::property_tree::ptree ConfigSection
a config file section
Definition: config-file.hpp:37