Loading...
Searching...
No Matches
nlsr.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2025, The University of Memphis,
4 * Regents of the University of California,
5 * Arizona Board of Regents.
6 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef NLSR_NLSR_HPP
23#define NLSR_NLSR_HPP
24
25#include "adjacency-list.hpp"
26#include "conf-parameter.hpp"
27#include "hello-protocol.hpp"
28#include "lsdb.hpp"
29#include "name-prefix-list.hpp"
32#include "route/fib.hpp"
38#include "stats-collector.hpp"
39
40#include <ndn-cxx/face.hpp>
41#include <ndn-cxx/encoding/nfd-constants.hpp>
42#include <ndn-cxx/mgmt/dispatcher.hpp>
43#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
44#include <ndn-cxx/mgmt/nfd/face-monitor.hpp>
45#include <ndn-cxx/mgmt/nfd/face-status.hpp>
46#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
47#include <ndn-cxx/mgmt/nfd/control-response.hpp>
48#include <ndn-cxx/security/key-chain.hpp>
49#include <ndn-cxx/util/scheduler.hpp>
50
51#include <boost/asio/signal_set.hpp>
52namespace nlsr {
53
54class Nlsr
55{
56public:
57 using FetchDatasetCallback = std::function<void(const std::vector<ndn::nfd::FaceStatus>&)>;
58 using FetchDatasetTimeoutCallback = std::function<void(uint32_t, const std::string&)>;
59
60 class Error : public std::runtime_error
61 {
62 public:
63 using std::runtime_error::runtime_error;
64 };
65
66 Nlsr(ndn::Face& face, ndn::KeyChain& keyChain, ConfParameter& confParam);
67
68 Lsdb&
70 {
71 return m_lsdb;
72 }
73
74 Fib&
76 {
77 return m_fib;
78 }
79
80private:
81 void
82 registerStrategyForCerts(const ndn::Name& originRouter);
83
89 void
90 addDispatcherTopPrefix(const ndn::Name& topPrefix);
91
103 void
104 initializeFaces(const FetchDatasetCallback& onFetchSuccess,
105 const FetchDatasetTimeoutCallback& onFetchFailure);
106
107 void
108 onFaceDatasetFetchTimeout(uint32_t code,
109 const std::string& reason,
110 uint32_t nRetriesSoFar);
111
122 void
123 processFaceDataset(const std::vector<ndn::nfd::FaceStatus>& faces);
124
125private:
135 void
136 registerAdjacencyPrefixes(const Adjacent& adj, ndn::time::milliseconds timeout);
137
140 void
141 registerPrefix(const ndn::Name& prefix);
142
145 void
146 onFaceEventNotification(const ndn::nfd::FaceEventNotification& faceEventNotification);
147
148 void
149 scheduleDatasetFetch();
150
158 void
159 enableIncomingFaceIdIndication();
160
161 void
162 terminate(const boost::system::error_code& error, int signalNo);
163
164public:
165 static inline const ndn::Name LOCALHOST_PREFIX{"/localhost/nlsr"};
166
167private:
168 ndn::Face& m_face;
169 ndn::Scheduler m_scheduler;
170 ConfParameter& m_confParam;
171 AdjacencyList& m_adjacencyList;
172 NamePrefixList& m_namePrefixList;
173 std::vector<ndn::Name> m_strategySetOnRouters;
174
176 Fib m_fib;
177 Lsdb m_lsdb;
178 RoutingTable m_routingTable;
179 NamePrefixTable m_namePrefixTable;
180 HelloProtocol m_helloProtocol;
181
182private:
183 ndn::signal::ScopedConnection m_onNewLsaConnection;
184 ndn::signal::ScopedConnection m_onPrefixRegistrationSuccess;
185 ndn::signal::ScopedConnection m_onInitialHelloDataValidated;
186
188 ndn::mgmt::Dispatcher m_dispatcher;
189 DatasetInterestHandler m_datasetHandler;
190
191private:
192 ndn::nfd::Controller m_controller;
193 ndn::nfd::Controller m_faceDatasetController;
194
196 update::PrefixUpdateProcessor m_prefixUpdateProcessor;
197 update::NfdRibCommandProcessor m_nfdRibCommandProcessor;
198
199 StatsCollector m_statsCollector;
200
201private:
202 ndn::nfd::FaceMonitor m_faceMonitor;
203 boost::asio::signal_set m_terminateSignals;
204};
205
206} // namespace nlsr
207
208#endif // NLSR_NLSR_HPP
A neighbor reachable over a Face.
Definition adjacent.hpp:47
A class to house all the configuration parameters for NLSR.
Class to publish all dataset.
Maps names to lists of next hops, and exports this information to NFD.
Definition fib.hpp:63
Lsdb & getLsdb()
Definition nlsr.hpp:69
Fib & getFib()
Definition nlsr.hpp:75
static const ndn::Name LOCALHOST_PREFIX
Definition nlsr.hpp:165
std::function< void(const std::vector< ndn::nfd::FaceStatus > &)> FetchDatasetCallback
Definition nlsr.hpp:57
std::function< void(uint32_t, const std::string &)> FetchDatasetTimeoutCallback
Definition nlsr.hpp:58
a class designed to handle statistical signals in nlsr
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE