blob: 14c884233a7d750a93483f5e164b7c7e5ac164e8 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +00003 * Copyright (c) 2014-2018, The University of Memphis,
Vince Lehmanc2e51f62015-01-20 15:03:11 -06004 * Regents of the University of California,
5 * Arizona Board of Regents.
akmhoque3d06e792014-05-27 16:23:20 -05006 *
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/>.
akmhoque3d06e792014-05-27 16:23:20 -050020 **/
Ashlesh Gawande5bf83172014-09-19 12:38:17 -050021
akmhoque53353462014-04-22 08:43:45 -050022#ifndef NLSR_LSDB_HPP
23#define NLSR_LSDB_HPP
24
Vince Lehman50df6b72015-03-03 12:06:40 -060025#include "conf-parameter.hpp"
akmhoque53353462014-04-22 08:43:45 -050026#include "lsa.hpp"
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +000027#include "lsa-segment-storage.hpp"
Ashlesh Gawande3e105a02017-05-16 17:36:56 -050028#include "sequencing-manager.hpp"
Ashlesh Gawande5bf83172014-09-19 12:38:17 -050029#include "test-access-control.hpp"
Ashlesh Gawande3e105a02017-05-16 17:36:56 -050030#include "communication/sync-logic-handler.hpp"
Alejandro Gil Torrese0d20482016-03-06 23:56:19 -060031#include "statistics.hpp"
32
33#include <ndn-cxx/security/key-chain.hpp>
34#include <ndn-cxx/util/signal.hpp>
35#include <ndn-cxx/util/time.hpp>
Alejandro Gil Torrese0d20482016-03-06 23:56:19 -060036#include <utility>
37#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -050038
Nick Gordone98480b2017-05-24 11:23:03 -050039namespace nlsr {
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070040
akmhoque53353462014-04-22 08:43:45 -050041class Nlsr;
42
43class Lsdb
44{
45public:
Ashlesh Gawande3e105a02017-05-16 17:36:56 -050046 Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler);
47
48 SyncLogicHandler&
49 getSyncLogicHandler()
50 {
51 return m_sync;
52 }
akmhoque53353462014-04-22 08:43:45 -050053
akmhoque53353462014-04-22 08:43:45 -050054 bool
Nick Gordon727d4832017-10-13 18:04:25 -050055 isLsaNew(const ndn::Name& routerName, const Lsa::Type& lsaType, const uint64_t& sequenceNumber);
akmhoque53353462014-04-22 08:43:45 -050056
Nick Gordon8f23b5d2017-08-31 17:53:07 -050057 bool
Nick Gordon727d4832017-10-13 18:04:25 -050058 doesLsaExist(const ndn::Name& key, const Lsa::Type& lsType);
Nick G97e34942016-07-11 14:46:27 -050059
60 /*! \brief Builds a name LSA for this router and then installs it
61 into the LSDB.
62 */
akmhoque53353462014-04-22 08:43:45 -050063 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050064 buildAndInstallOwnNameLsa();
akmhoque53353462014-04-22 08:43:45 -050065
Nick G97e34942016-07-11 14:46:27 -050066 /*! \brief Returns the name LSA with the given key.
67 \param key The name of the router that the desired LSA comes from.
68 */
akmhoqueb6450b12014-04-24 00:01:03 -050069 NameLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -050070 findNameLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -050071
Nick G97e34942016-07-11 14:46:27 -050072 /*! \brief Installs a name LSA into the LSDB
73 \param nlsa The name LSA to install into the LSDB.
74 */
akmhoque53353462014-04-22 08:43:45 -050075 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050076 installNameLsa(NameLsa& nlsa);
akmhoque53353462014-04-22 08:43:45 -050077
Nick G97e34942016-07-11 14:46:27 -050078 /*! \brief Remove a name LSA from the LSDB.
79 \param key The name of the router that published the LSA to remove.
80
81 This function will remove a name LSA from the LSDB by finding an
82 LSA whose name matches key. This removal also causes the NPT to
83 remove those name prefixes if no more LSAs advertise them.
84 */
akmhoque53353462014-04-22 08:43:45 -050085 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050086 removeNameLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -050087
Nick G97e34942016-07-11 14:46:27 -050088 /*! Returns whether a seq. no. from a certain router signals a new LSA.
89 \param key The name of the originating router.
90 \param seqNo The sequence number to check.
91 */
akmhoque53353462014-04-22 08:43:45 -050092 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050093 isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050094
95 void
akmhoque2f423352014-06-03 11:49:35 -050096 writeNameLsdbLog();
akmhoque53353462014-04-22 08:43:45 -050097
Jiewen Tana0497d82015-02-02 21:59:18 -080098 const std::list<NameLsa>&
Nick Gordon114537f2017-08-09 14:51:37 -050099 getNameLsdb() const;
Jiewen Tana0497d82015-02-02 21:59:18 -0800100
Nick G97e34942016-07-11 14:46:27 -0500101 /*! \brief Builds a cor. LSA for this router and installs it into the LSDB. */
akmhoque53353462014-04-22 08:43:45 -0500102 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500103 buildAndInstallOwnCoordinateLsa();
akmhoque53353462014-04-22 08:43:45 -0500104
Nick G97e34942016-07-11 14:46:27 -0500105 /*! \brief Finds a cor. LSA in the LSDB.
106 \param key The name of the originating router that published the LSA.
107 */
akmhoqueb6450b12014-04-24 00:01:03 -0500108 CoordinateLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -0500109 findCoordinateLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500110
Nick G97e34942016-07-11 14:46:27 -0500111 /*! \brief Installs a cor. LSA into the LSDB.
112 \param clsa The cor. LSA to install.
113 */
akmhoque53353462014-04-22 08:43:45 -0500114 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500115 installCoordinateLsa(CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -0500116
Nick G97e34942016-07-11 14:46:27 -0500117 /*! \brief Removes a cor. LSA from the LSDB.
118 \param key The name of the router that published the LSA to remove.
119
120 Removes the coordinate LSA whose origin router name matches that
121 given by key. Additionally, ask the NPT to remove the prefix,
122 which will occur if no other LSAs point there.
123 */
akmhoque53353462014-04-22 08:43:45 -0500124 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500125 removeCoordinateLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500126
Nick G97e34942016-07-11 14:46:27 -0500127 /*! \brief Returns whether a cor. LSA from a router is new or not.
128 \param key The name prefix of the originating router.
129 \param seqNo The sequence number of the candidate LSA.
130 */
akmhoque53353462014-04-22 08:43:45 -0500131 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500132 isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500133
134 void
akmhoque2f423352014-06-03 11:49:35 -0500135 writeCorLsdbLog();
akmhoque53353462014-04-22 08:43:45 -0500136
Jiewen Tana0497d82015-02-02 21:59:18 -0800137 const std::list<CoordinateLsa>&
Nick Gordon114537f2017-08-09 14:51:37 -0500138 getCoordinateLsdb() const;
Jiewen Tana0497d82015-02-02 21:59:18 -0800139
Nick G97e34942016-07-11 14:46:27 -0500140 //function related to Adj LSDB
141
142 /*! \brief Schedules a build of this router's LSA. */
akmhoque53353462014-04-22 08:43:45 -0500143 void
Vince Lehman50df6b72015-03-03 12:06:40 -0600144 scheduleAdjLsaBuild();
akmhoque53353462014-04-22 08:43:45 -0500145
Nick G97e34942016-07-11 14:46:27 -0500146 /*! \brief Wrapper event to build and install an adj. LSA for this router. */
akmhoque53353462014-04-22 08:43:45 -0500147 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500148 buildAndInstallOwnAdjLsa();
akmhoque53353462014-04-22 08:43:45 -0500149
Nick G97e34942016-07-11 14:46:27 -0500150 /*! \brief Removes an adj. LSA from the LSDB.
151 \param key The name of the publishing router whose LSA to remove.
152 */
akmhoque53353462014-04-22 08:43:45 -0500153 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500154 removeAdjLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500155
Nick G97e34942016-07-11 14:46:27 -0500156 /*! \brief Returns whether an LSA is new.
157 \param key The name of the publishing router.
158 \param seqNo The seq. no. of the candidate LSA.
159
160 This function determines whether the LSA with the name key and
161 seq. no. seqNo would be new to this LSDB.
162 */
akmhoque53353462014-04-22 08:43:45 -0500163 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500164 isAdjLsaNew(const ndn::Name& key, uint64_t seqNo);
Jiewen Tana0497d82015-02-02 21:59:18 -0800165
Nick G97e34942016-07-11 14:46:27 -0500166 /*! \brief Installs an adj. LSA into the LSDB.
167 \param alsa The adj. LSA to add to the LSDB.
168 */
akmhoque53353462014-04-22 08:43:45 -0500169 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500170 installAdjLsa(AdjLsa& alsa);
akmhoque53353462014-04-22 08:43:45 -0500171
Nick G97e34942016-07-11 14:46:27 -0500172 /*! \brief Finds an adj. LSA in the LSDB.
173 \param key The name of the publishing router whose LSA to find.
174 */
akmhoqueb6450b12014-04-24 00:01:03 -0500175 AdjLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -0500176 findAdjLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500177
Jiewen Tana0497d82015-02-02 21:59:18 -0800178 const std::list<AdjLsa>&
Nick Gordon114537f2017-08-09 14:51:37 -0500179 getAdjLsdb() const;
akmhoque53353462014-04-22 08:43:45 -0500180
181 void
Vince Lehman50df6b72015-03-03 12:06:40 -0600182 setAdjLsaBuildInterval(uint32_t interval)
183 {
184 m_adjLsaBuildInterval = ndn::time::seconds(interval);
185 }
186
187 const ndn::time::seconds&
188 getAdjLsaBuildInterval() const
189 {
190 return m_adjLsaBuildInterval;
191 }
192
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500193 SequencingManager&
194 getSequencingManager()
195 {
196 return m_sequencingManager;
197 }
198
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +0000199 LsaSegmentStorage&
200 getLsaStorage() {
201 return m_lsaStorage;
202 }
203
Vince Lehman50df6b72015-03-03 12:06:40 -0600204 void
akmhoque2f423352014-06-03 11:49:35 -0500205 writeAdjLsdbLog();
akmhoque53353462014-04-22 08:43:45 -0500206
akmhoque53353462014-04-22 08:43:45 -0500207 void
Nick Gordone98480b2017-05-24 11:23:03 -0500208 setLsaRefreshTime(const ndn::time::seconds& lsaRefreshTime);
akmhoque53353462014-04-22 08:43:45 -0500209
210 void
211 setThisRouterPrefix(std::string trp);
212
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500213 void
214 expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
Nick Gordone98480b2017-05-24 11:23:03 -0500215 ndn::time::steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500216
217 void
218 processInterest(const ndn::Name& name, const ndn::Interest& interest);
219
akmhoque53353462014-04-22 08:43:45 -0500220private:
Nick G97e34942016-07-11 14:46:27 -0500221 /* \brief Add a name LSA to the LSDB if it isn't already there.
222 \param nlsa The candidade name LSA.
223 */
akmhoque53353462014-04-22 08:43:45 -0500224 bool
225 addNameLsa(NameLsa& nlsa);
226
Nick G97e34942016-07-11 14:46:27 -0500227 /*! \brief Returns whether the LSDB contains some LSA.
228 \param key The name of the publishing router whose LSA to check for.
229 */
akmhoque53353462014-04-22 08:43:45 -0500230 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500231 doesNameLsaExist(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500232
Nick G97e34942016-07-11 14:46:27 -0500233 /*! \brief Adds a cor. LSA to the LSDB if it isn't already there.
234 \param clsa The candidate cor. LSA.
235 */
akmhoque53353462014-04-22 08:43:45 -0500236 bool
akmhoqueb6450b12014-04-24 00:01:03 -0500237 addCoordinateLsa(CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -0500238
Nick G97e34942016-07-11 14:46:27 -0500239 /*! \brief Returns whether a cor. LSA is in the LSDB.
240 \param key The name of the router that published the queried LSA.
241 */
akmhoque53353462014-04-22 08:43:45 -0500242 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500243 doesCoordinateLsaExist(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500244
Nick G97e34942016-07-11 14:46:27 -0500245 /*! \brief Attempts to construct an adj. LSA.
246
247 This function will attempt to construct an adjacency LSA. An LSA
248 can only be built when the status of all of the router's neighbors
249 is known. That is, when we are not currently trying to contact any
250 neighbor.
251 */
Vince Lehman50df6b72015-03-03 12:06:40 -0600252 void
253 buildAdjLsa();
254
Nick G97e34942016-07-11 14:46:27 -0500255 /*! \brief Adds an adj. LSA to the LSDB if it isn't already there.
256 \param alsa The candidate adj. LSA to add to the LSDB.
257 */
akmhoque53353462014-04-22 08:43:45 -0500258 bool
259 addAdjLsa(AdjLsa& alsa);
260
Nick G97e34942016-07-11 14:46:27 -0500261 /*! \brief Returns whether the LSDB contains an LSA.
262 \param key The name of a router whose LSA to check for in the LSDB.
263 */
akmhoque53353462014-04-22 08:43:45 -0500264 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500265 doesAdjLsaExist(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500266
Nick G97e34942016-07-11 14:46:27 -0500267 /*! \brief Schedules a refresh/expire event in the scheduler.
268 \param key The name of the router that published the LSA.
269 \param seqNo The seq. no. associated with the LSA.
270 \param expTime How many seconds to wait before triggering the event.
271 */
akmhoque53353462014-04-22 08:43:45 -0500272 ndn::EventId
akmhoquec7a79b22014-05-26 08:06:19 -0500273 scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
Nick Gordone98480b2017-05-24 11:23:03 -0500274 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -0500275
Nick G97e34942016-07-11 14:46:27 -0500276 /*! \brief Either allow to expire, or refresh a name LSA.
277 \param lsaKey The name of the router that published the LSA.
278 \param seqNo The seq. no. of the LSA to check.
279 */
akmhoque53353462014-04-22 08:43:45 -0500280 void
Ashlesh Gawande90173ad2017-08-09 15:19:50 -0500281 expireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500282
Vince Lehman199e9cf2015-04-07 13:22:16 -0500283PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Nick G97e34942016-07-11 14:46:27 -0500284 /*! \brief Schedules an expire/refresh event in the LSA.
285 \param key The name of the router whose LSA is in question.
286 \param seqNo The sequence number of the LSA to check.
287 \param expTime The number of seconds to wait before triggering the event.
288 */
akmhoque53353462014-04-22 08:43:45 -0500289 ndn::EventId
akmhoquec7a79b22014-05-26 08:06:19 -0500290 scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
Nick Gordone98480b2017-05-24 11:23:03 -0500291 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -0500292
Vince Lehman199e9cf2015-04-07 13:22:16 -0500293private:
Nick G97e34942016-07-11 14:46:27 -0500294
akmhoque53353462014-04-22 08:43:45 -0500295 void
Ashlesh Gawande90173ad2017-08-09 15:19:50 -0500296 expireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500297
298 ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -0500299 scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
Nick Gordone98480b2017-05-24 11:23:03 -0500300 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -0500301
302 void
Ashlesh Gawande90173ad2017-08-09 15:19:50 -0500303 expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
akmhoqueb6450b12014-04-24 00:01:03 -0500304 uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500305
Nick G97e34942016-07-11 14:46:27 -0500306private:
307
akmhoque31d1d4b2014-05-05 22:08:14 -0500308 void
akmhoque69c9aa92014-07-23 15:15:05 -0500309 putLsaData(const ndn::Interest& interest, const std::string& content);
310
311 void
akmhoque31d1d4b2014-05-05 22:08:14 -0500312 processInterestForNameLsa(const ndn::Interest& interest,
313 const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500314 uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500315
akmhoque31d1d4b2014-05-05 22:08:14 -0500316 void
317 processInterestForAdjacencyLsa(const ndn::Interest& interest,
318 const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500319 uint64_t seqNo);
akmhoque31d1d4b2014-05-05 22:08:14 -0500320
321 void
322 processInterestForCoordinateLsa(const ndn::Interest& interest,
323 const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500324 uint64_t seqNo);
akmhoque31d1d4b2014-05-05 22:08:14 -0500325 void
dmcoomes9f936662017-03-02 10:33:09 -0600326 onContentValidated(const std::shared_ptr<const ndn::Data>& data);
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700327
328 void
akmhoque31d1d4b2014-05-05 22:08:14 -0500329 processContentNameLsa(const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500330 uint64_t lsSeqNo, std::string& dataContent);
akmhoque31d1d4b2014-05-05 22:08:14 -0500331
332 void
333 processContentAdjacencyLsa(const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500334 uint64_t lsSeqNo, std::string& dataContent);
akmhoque31d1d4b2014-05-05 22:08:14 -0500335
336 void
337 processContentCoordinateLsa(const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500338 uint64_t lsSeqNo, std::string& dataContent);
akmhoque31d1d4b2014-05-05 22:08:14 -0500339
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500340PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Nick G97e34942016-07-11 14:46:27 -0500341 /*!
342 \brief Error callback when SegmentFetcher fails to return an LSA
343
344 In all error cases, a reattempt to fetch the LSA will be made.
345
346 Segment validation can fail either because the packet does not have a
347 valid signature (fatal) or because some of the certificates in the trust chain
348 could not be fetched (non-fatal).
349
350 Currently, the library does not provide clear indication (besides a plain-text message
351 in the error callback) of the reason for the failure nor the segment that failed
352 to be validated, thus we will continue to try to fetch the LSA until the deadline
353 is reached.
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500354 */
akmhoque31d1d4b2014-05-05 22:08:14 -0500355 void
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500356 onFetchLsaError(uint32_t errorCode,
357 const std::string& msg,
358 ndn::Name& interestName,
359 uint32_t retransmitNo,
360 const ndn::time::steady_clock::TimePoint& deadline,
361 ndn::Name lsaName,
362 uint64_t seqNo);
363
Nick G97e34942016-07-11 14:46:27 -0500364 /*!
365 \brief Success callback when SegmentFetcher returns a valid LSA
366
Nick Gordonb50e51b2016-07-22 16:05:57 -0500367 \param interestName The base Interest used to fetch the LSA in the format:
Nick G97e34942016-07-11 14:46:27 -0500368 /<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500369 */
370 void
371 afterFetchLsa(const ndn::ConstBufferPtr& data, ndn::Name& interestName);
akmhoque31d1d4b2014-05-05 22:08:14 -0500372
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500373private:
Nick Gordone98480b2017-05-24 11:23:03 -0500374 ndn::time::system_clock::TimePoint
akmhoquec7a79b22014-05-26 08:06:19 -0500375 getLsaExpirationTimePoint();
376
Nick G97e34942016-07-11 14:46:27 -0500377 /*! \brief Cancels an event in the event scheduler. */
akmhoque31d1d4b2014-05-05 22:08:14 -0500378 void
379 cancelScheduleLsaExpiringEvent(ndn::EventId eid);
380
Jiewen Tana0497d82015-02-02 21:59:18 -0800381public:
382 static const ndn::Name::Component NAME_COMPONENT;
383
Alejandro Gil Torrese0d20482016-03-06 23:56:19 -0600384 ndn::util::signal::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
385
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500386private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500387 Nlsr& m_nlsr;
Vince Lehman7c603292014-09-11 17:48:16 -0500388 ndn::Scheduler& m_scheduler;
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500389 SyncLogicHandler m_sync;
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +0000390 LsaSegmentStorage m_lsaStorage;
Vince Lehman7c603292014-09-11 17:48:16 -0500391
akmhoque53353462014-04-22 08:43:45 -0500392 std::list<NameLsa> m_nameLsdb;
393 std::list<AdjLsa> m_adjLsdb;
akmhoqueb6450b12014-04-24 00:01:03 -0500394 std::list<CoordinateLsa> m_corLsdb;
akmhoque53353462014-04-22 08:43:45 -0500395
Nick Gordone98480b2017-05-24 11:23:03 -0500396 ndn::time::seconds m_lsaRefreshTime;
akmhoque53353462014-04-22 08:43:45 -0500397 std::string m_thisRouterPrefix;
398
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500399 typedef std::map<ndn::Name, uint64_t> SequenceNumberMap;
400
401 // Maps the name of an LSA to its highest known sequence number from sync;
402 // Used to stop NLSR from trying to fetch outdated LSAs
403 SequenceNumberMap m_highestSeqNo;
404
Vince Lehman18841082014-08-19 17:15:24 -0500405 static const ndn::time::seconds GRACE_PERIOD;
Nick Gordone98480b2017-05-24 11:23:03 -0500406 static const ndn::time::steady_clock::TimePoint DEFAULT_LSA_RETRIEVAL_DEADLINE;
Vince Lehman50df6b72015-03-03 12:06:40 -0600407
408 ndn::time::seconds m_adjLsaBuildInterval;
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500409
410 SequencingManager m_sequencingManager;
Nick Gordon9eac4d92017-08-29 17:31:29 -0500411
412 ndn::util::signal::ScopedConnection m_onNewLsaConnection;
akmhoque53353462014-04-22 08:43:45 -0500413};
414
Nick Gordonfad8e252016-08-11 14:21:38 -0500415} // namespace nlsr
akmhoque53353462014-04-22 08:43:45 -0500416
dmcoomes9f936662017-03-02 10:33:09 -0600417#endif // NLSR_LSDB_HPP