Loading...
Searching...
No Matches
fib.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_ROUTE_FIB_HPP
23#define NLSR_ROUTE_FIB_HPP
24
26#include "nexthop-list.hpp"
27
28#include <ndn-cxx/mgmt/nfd/controller.hpp>
29#include <ndn-cxx/util/scheduler.hpp>
30#include <ndn-cxx/util/time.hpp>
31
32namespace nlsr {
33
35
37{
38 ndn::Name name;
39 ndn::scheduler::ScopedEventId refreshEventId;
40 int32_t seqNo = 1;
42};
43
44using AfterRefreshCallback = std::function<void(FibEntry&, uint64_t)>;
45
46class AdjacencyList;
47class ConfParameter;
48
62class Fib
63{
64public:
65 Fib(ndn::Face& face, ndn::Scheduler& scheduler, AdjacencyList& adjacencyList,
66 ConfParameter& conf, ndn::security::KeyChain& keyChain);
67
76 void
77 remove(const ndn::Name& name);
78
91 void
92 update(const ndn::Name& name, const NexthopList& allHops, uint64_t routeFlags);
93
94 void
95 setEntryRefreshTime(int32_t fert)
96 {
97 m_refreshTime = fert;
98 }
99
120 void
121 registerPrefix(const ndn::Name& namePrefix,
122 const ndn::FaceUri& faceUri,
123 uint64_t faceCost,
124 const ndn::time::milliseconds& timeout,
125 uint64_t flags,
126 uint8_t times);
127
128 void
129 setStrategy(const ndn::Name& name, const ndn::Name& strategy, uint32_t count);
130
131 void
132 writeLog();
133
134private:
139 bool
140 isNotNeighbor(const ndn::Name& name);
141
148 void
149 addNextHopsToFibEntryAndNfd(FibEntry& entry, const NextHopsUriSortedSet& hopsToAdd, uint64_t routeFlags);
150
151 unsigned int
152 getNumberOfFacesForName(const NexthopList& nextHopList);
153
157 void
158 unregisterPrefix(const ndn::Name& namePrefix, const ndn::FaceUri& faceUri);
159
162 void
163 onRegistrationSuccess(const ndn::nfd::ControlParameters& param,
164 const ndn::FaceUri& faceUri);
165
168 void
169 onRegistrationFailure(const ndn::nfd::ControlResponse& response,
170 const ndn::nfd::ControlParameters& parameters,
171 const ndn::FaceUri& faceUri,
172 uint8_t times);
173
176 void
177 onSetStrategySuccess(const ndn::nfd::ControlParameters& commandSuccessResult);
178
181 void
182 onSetStrategyFailure(const ndn::nfd::ControlResponse& response,
183 const ndn::nfd::ControlParameters& parameters,
184 uint32_t count);
185
197 void
198 scheduleEntryRefresh(FibEntry& entry, uint64_t routeFlags, const AfterRefreshCallback& refreshCb);
199
200private:
203 void
204 scheduleLoop(FibEntry& entry, uint64_t routeFlags);
205
208 void
209 refreshEntry(const ndn::Name& name, uint64_t routeFlags, AfterRefreshCallback refreshCb);
210
211public:
212 static inline const ndn::Name MULTICAST_STRATEGY{"/localhost/nfd/strategy/multicast"};
213 static inline const ndn::Name BEST_ROUTE_STRATEGY{"/localhost/nfd/strategy/best-route"};
214
215 ndn::signal::Signal<Fib, ndn::Name> onPrefixRegistrationSuccess;
216
217private:
218 ndn::Scheduler& m_scheduler;
219 int32_t m_refreshTime;
220 ndn::nfd::Controller m_controller;
221
223 std::map<ndn::Name, FibEntry> m_table;
224
225private:
226 AdjacencyList& m_adjacencyList;
227 ConfParameter& m_confParameter;
228
233 static constexpr uint64_t GRACE_PERIOD = 10;
234};
235
236} // namespace nlsr
237
238#endif // NLSR_ROUTE_FIB_HPP
A class to house all the configuration parameters for NLSR.
Maps names to lists of next hops, and exports this information to NFD.
Definition fib.hpp:63
void setStrategy(const ndn::Name &name, const ndn::Name &strategy, uint32_t count)
Definition fib.cpp:265
void writeLog()
Definition fib.cpp:338
void remove(const ndn::Name &name)
Completely remove a name prefix from the FIB.
Definition fib.cpp:48
void setEntryRefreshTime(int32_t fert)
Definition fib.hpp:95
static const ndn::Name MULTICAST_STRATEGY
Definition fib.hpp:212
static const ndn::Name BEST_ROUTE_STRATEGY
Definition fib.hpp:213
void update(const ndn::Name &name, const NexthopList &allHops, uint64_t routeFlags)
Set the nexthop list of a name.
Definition fib.cpp:86
void registerPrefix(const ndn::Name &namePrefix, const ndn::FaceUri &faceUri, uint64_t faceCost, const ndn::time::milliseconds &timeout, uint64_t flags, uint8_t times)
Inform NFD of a next-hop.
Definition fib.cpp:174
ndn::signal::Signal< Fib, ndn::Name > onPrefixRegistrationSuccess
Definition fib.hpp:215
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::function< void(FibEntry &, uint64_t)> AfterRefreshCallback
Definition fib.hpp:44
Definition fib.hpp:37
ndn::scheduler::ScopedEventId refreshEventId
Definition fib.hpp:39
ndn::Name name
Definition fib.hpp:38
NextHopsUriSortedSet nexthopSet
Definition fib.hpp:41
int32_t seqNo
Definition fib.hpp:40
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE