blob: 2ebb952e5cd3fb7d3c2e5c8b76b750ca475efb11 [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>
Ashlesh Gawande744e4812018-08-22 16:26:24 -050036#include <ndn-cxx/util/segment-fetcher.hpp>
37
Alejandro Gil Torrese0d20482016-03-06 23:56:19 -060038#include <utility>
39#include <boost/cstdint.hpp>
akmhoque53353462014-04-22 08:43:45 -050040
Nick Gordone98480b2017-05-24 11:23:03 -050041namespace nlsr {
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070042
akmhoque53353462014-04-22 08:43:45 -050043class Nlsr;
44
45class Lsdb
46{
47public:
Ashlesh Gawande3e105a02017-05-16 17:36:56 -050048 Lsdb(Nlsr& nlsr, ndn::Scheduler& scheduler);
49
Ashlesh Gawande744e4812018-08-22 16:26:24 -050050 ~Lsdb();
51
Ashlesh Gawande3e105a02017-05-16 17:36:56 -050052 SyncLogicHandler&
53 getSyncLogicHandler()
54 {
55 return m_sync;
56 }
akmhoque53353462014-04-22 08:43:45 -050057
akmhoque53353462014-04-22 08:43:45 -050058 bool
Nick Gordon727d4832017-10-13 18:04:25 -050059 isLsaNew(const ndn::Name& routerName, const Lsa::Type& lsaType, const uint64_t& sequenceNumber);
akmhoque53353462014-04-22 08:43:45 -050060
Nick Gordon8f23b5d2017-08-31 17:53:07 -050061 bool
Nick Gordon727d4832017-10-13 18:04:25 -050062 doesLsaExist(const ndn::Name& key, const Lsa::Type& lsType);
Nick G97e34942016-07-11 14:46:27 -050063
64 /*! \brief Builds a name LSA for this router and then installs it
65 into the LSDB.
66 */
akmhoque53353462014-04-22 08:43:45 -050067 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050068 buildAndInstallOwnNameLsa();
akmhoque53353462014-04-22 08:43:45 -050069
Nick G97e34942016-07-11 14:46:27 -050070 /*! \brief Returns the name LSA with the given key.
71 \param key The name of the router that the desired LSA comes from.
72 */
akmhoqueb6450b12014-04-24 00:01:03 -050073 NameLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -050074 findNameLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -050075
Nick G97e34942016-07-11 14:46:27 -050076 /*! \brief Installs a name LSA into the LSDB
77 \param nlsa The name LSA to install into the LSDB.
78 */
akmhoque53353462014-04-22 08:43:45 -050079 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050080 installNameLsa(NameLsa& nlsa);
akmhoque53353462014-04-22 08:43:45 -050081
Nick G97e34942016-07-11 14:46:27 -050082 /*! \brief Remove a name LSA from the LSDB.
83 \param key The name of the router that published the LSA to remove.
84
85 This function will remove a name LSA from the LSDB by finding an
86 LSA whose name matches key. This removal also causes the NPT to
87 remove those name prefixes if no more LSAs advertise them.
88 */
akmhoque53353462014-04-22 08:43:45 -050089 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050090 removeNameLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -050091
Nick G97e34942016-07-11 14:46:27 -050092 /*! Returns whether a seq. no. from a certain router signals a new LSA.
93 \param key The name of the originating router.
94 \param seqNo The sequence number to check.
95 */
akmhoque53353462014-04-22 08:43:45 -050096 bool
akmhoque31d1d4b2014-05-05 22:08:14 -050097 isNameLsaNew(const ndn::Name& key, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -050098
99 void
akmhoque2f423352014-06-03 11:49:35 -0500100 writeNameLsdbLog();
akmhoque53353462014-04-22 08:43:45 -0500101
Jiewen Tana0497d82015-02-02 21:59:18 -0800102 const std::list<NameLsa>&
Nick Gordon114537f2017-08-09 14:51:37 -0500103 getNameLsdb() const;
Jiewen Tana0497d82015-02-02 21:59:18 -0800104
Nick G97e34942016-07-11 14:46:27 -0500105 /*! \brief Builds a cor. LSA for this router and installs it into the LSDB. */
akmhoque53353462014-04-22 08:43:45 -0500106 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500107 buildAndInstallOwnCoordinateLsa();
akmhoque53353462014-04-22 08:43:45 -0500108
Nick G97e34942016-07-11 14:46:27 -0500109 /*! \brief Finds a cor. LSA in the LSDB.
110 \param key The name of the originating router that published the LSA.
111 */
akmhoqueb6450b12014-04-24 00:01:03 -0500112 CoordinateLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -0500113 findCoordinateLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500114
Nick G97e34942016-07-11 14:46:27 -0500115 /*! \brief Installs a cor. LSA into the LSDB.
116 \param clsa The cor. LSA to install.
117 */
akmhoque53353462014-04-22 08:43:45 -0500118 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500119 installCoordinateLsa(CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -0500120
Nick G97e34942016-07-11 14:46:27 -0500121 /*! \brief Removes a cor. LSA from the LSDB.
122 \param key The name of the router that published the LSA to remove.
123
124 Removes the coordinate LSA whose origin router name matches that
125 given by key. Additionally, ask the NPT to remove the prefix,
126 which will occur if no other LSAs point there.
127 */
akmhoque53353462014-04-22 08:43:45 -0500128 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500129 removeCoordinateLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500130
Nick G97e34942016-07-11 14:46:27 -0500131 /*! \brief Returns whether a cor. LSA from a router is new or not.
132 \param key The name prefix of the originating router.
133 \param seqNo The sequence number of the candidate LSA.
134 */
akmhoque53353462014-04-22 08:43:45 -0500135 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500136 isCoordinateLsaNew(const ndn::Name& key, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500137
138 void
akmhoque2f423352014-06-03 11:49:35 -0500139 writeCorLsdbLog();
akmhoque53353462014-04-22 08:43:45 -0500140
Jiewen Tana0497d82015-02-02 21:59:18 -0800141 const std::list<CoordinateLsa>&
Nick Gordon114537f2017-08-09 14:51:37 -0500142 getCoordinateLsdb() const;
Jiewen Tana0497d82015-02-02 21:59:18 -0800143
Nick G97e34942016-07-11 14:46:27 -0500144 //function related to Adj LSDB
145
146 /*! \brief Schedules a build of this router's LSA. */
akmhoque53353462014-04-22 08:43:45 -0500147 void
Vince Lehman50df6b72015-03-03 12:06:40 -0600148 scheduleAdjLsaBuild();
akmhoque53353462014-04-22 08:43:45 -0500149
Nick G97e34942016-07-11 14:46:27 -0500150 /*! \brief Wrapper event to build and install an adj. LSA for this router. */
akmhoque53353462014-04-22 08:43:45 -0500151 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500152 buildAndInstallOwnAdjLsa();
akmhoque53353462014-04-22 08:43:45 -0500153
Nick G97e34942016-07-11 14:46:27 -0500154 /*! \brief Removes an adj. LSA from the LSDB.
155 \param key The name of the publishing router whose LSA to remove.
156 */
akmhoque53353462014-04-22 08:43:45 -0500157 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500158 removeAdjLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500159
Nick G97e34942016-07-11 14:46:27 -0500160 /*! \brief Returns whether an LSA is new.
161 \param key The name of the publishing router.
162 \param seqNo The seq. no. of the candidate LSA.
163
164 This function determines whether the LSA with the name key and
165 seq. no. seqNo would be new to this LSDB.
166 */
akmhoque53353462014-04-22 08:43:45 -0500167 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500168 isAdjLsaNew(const ndn::Name& key, uint64_t seqNo);
Jiewen Tana0497d82015-02-02 21:59:18 -0800169
Nick G97e34942016-07-11 14:46:27 -0500170 /*! \brief Installs an adj. LSA into the LSDB.
171 \param alsa The adj. LSA to add to the LSDB.
172 */
akmhoque53353462014-04-22 08:43:45 -0500173 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500174 installAdjLsa(AdjLsa& alsa);
akmhoque53353462014-04-22 08:43:45 -0500175
Nick G97e34942016-07-11 14:46:27 -0500176 /*! \brief Finds an adj. LSA in the LSDB.
177 \param key The name of the publishing router whose LSA to find.
178 */
akmhoqueb6450b12014-04-24 00:01:03 -0500179 AdjLsa*
akmhoque31d1d4b2014-05-05 22:08:14 -0500180 findAdjLsa(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500181
Jiewen Tana0497d82015-02-02 21:59:18 -0800182 const std::list<AdjLsa>&
Nick Gordon114537f2017-08-09 14:51:37 -0500183 getAdjLsdb() const;
akmhoque53353462014-04-22 08:43:45 -0500184
185 void
Vince Lehman50df6b72015-03-03 12:06:40 -0600186 setAdjLsaBuildInterval(uint32_t interval)
187 {
188 m_adjLsaBuildInterval = ndn::time::seconds(interval);
189 }
190
191 const ndn::time::seconds&
192 getAdjLsaBuildInterval() const
193 {
194 return m_adjLsaBuildInterval;
195 }
196
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500197 SequencingManager&
198 getSequencingManager()
199 {
200 return m_sequencingManager;
201 }
202
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +0000203 LsaSegmentStorage&
Ashlesh Gawande304bebf2018-02-07 17:10:35 -0600204 getLsaStorage()
205 {
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +0000206 return m_lsaStorage;
207 }
208
Vince Lehman50df6b72015-03-03 12:06:40 -0600209 void
akmhoque2f423352014-06-03 11:49:35 -0500210 writeAdjLsdbLog();
akmhoque53353462014-04-22 08:43:45 -0500211
akmhoque53353462014-04-22 08:43:45 -0500212 void
Nick Gordone98480b2017-05-24 11:23:03 -0500213 setLsaRefreshTime(const ndn::time::seconds& lsaRefreshTime);
akmhoque53353462014-04-22 08:43:45 -0500214
215 void
216 setThisRouterPrefix(std::string trp);
217
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500218 void
219 expressInterest(const ndn::Name& interestName, uint32_t timeoutCount,
Nick Gordone98480b2017-05-24 11:23:03 -0500220 ndn::time::steady_clock::TimePoint deadline = DEFAULT_LSA_RETRIEVAL_DEADLINE);
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500221
222 void
223 processInterest(const ndn::Name& name, const ndn::Interest& interest);
224
akmhoque53353462014-04-22 08:43:45 -0500225private:
Nick G97e34942016-07-11 14:46:27 -0500226 /* \brief Add a name LSA to the LSDB if it isn't already there.
227 \param nlsa The candidade name LSA.
228 */
akmhoque53353462014-04-22 08:43:45 -0500229 bool
230 addNameLsa(NameLsa& nlsa);
231
Nick G97e34942016-07-11 14:46:27 -0500232 /*! \brief Returns whether the LSDB contains some LSA.
233 \param key The name of the publishing router whose LSA to check for.
234 */
akmhoque53353462014-04-22 08:43:45 -0500235 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500236 doesNameLsaExist(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500237
Nick G97e34942016-07-11 14:46:27 -0500238 /*! \brief Adds a cor. LSA to the LSDB if it isn't already there.
239 \param clsa The candidate cor. LSA.
240 */
akmhoque53353462014-04-22 08:43:45 -0500241 bool
akmhoqueb6450b12014-04-24 00:01:03 -0500242 addCoordinateLsa(CoordinateLsa& clsa);
akmhoque53353462014-04-22 08:43:45 -0500243
Nick G97e34942016-07-11 14:46:27 -0500244 /*! \brief Returns whether a cor. LSA is in the LSDB.
245 \param key The name of the router that published the queried LSA.
246 */
akmhoque53353462014-04-22 08:43:45 -0500247 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500248 doesCoordinateLsaExist(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500249
Nick G97e34942016-07-11 14:46:27 -0500250 /*! \brief Attempts to construct an adj. LSA.
251
252 This function will attempt to construct an adjacency LSA. An LSA
253 can only be built when the status of all of the router's neighbors
254 is known. That is, when we are not currently trying to contact any
255 neighbor.
256 */
Vince Lehman50df6b72015-03-03 12:06:40 -0600257 void
258 buildAdjLsa();
259
Nick G97e34942016-07-11 14:46:27 -0500260 /*! \brief Adds an adj. LSA to the LSDB if it isn't already there.
261 \param alsa The candidate adj. LSA to add to the LSDB.
262 */
akmhoque53353462014-04-22 08:43:45 -0500263 bool
264 addAdjLsa(AdjLsa& alsa);
265
Nick G97e34942016-07-11 14:46:27 -0500266 /*! \brief Returns whether the LSDB contains an LSA.
267 \param key The name of a router whose LSA to check for in the LSDB.
268 */
akmhoque53353462014-04-22 08:43:45 -0500269 bool
akmhoque31d1d4b2014-05-05 22:08:14 -0500270 doesAdjLsaExist(const ndn::Name& key);
akmhoque53353462014-04-22 08:43:45 -0500271
Nick G97e34942016-07-11 14:46:27 -0500272 /*! \brief Schedules a refresh/expire event in the scheduler.
273 \param key The name of the router that published the LSA.
274 \param seqNo The seq. no. associated with the LSA.
275 \param expTime How many seconds to wait before triggering the event.
276 */
akmhoque53353462014-04-22 08:43:45 -0500277 ndn::EventId
akmhoquec7a79b22014-05-26 08:06:19 -0500278 scheduleNameLsaExpiration(const ndn::Name& key, int seqNo,
Nick Gordone98480b2017-05-24 11:23:03 -0500279 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -0500280
Nick G97e34942016-07-11 14:46:27 -0500281 /*! \brief Either allow to expire, or refresh a name LSA.
282 \param lsaKey The name of the router that published the LSA.
283 \param seqNo The seq. no. of the LSA to check.
284 */
akmhoque53353462014-04-22 08:43:45 -0500285 void
Ashlesh Gawande90173ad2017-08-09 15:19:50 -0500286 expireOrRefreshNameLsa(const ndn::Name& lsaKey, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500287
Vince Lehman199e9cf2015-04-07 13:22:16 -0500288PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Nick G97e34942016-07-11 14:46:27 -0500289 /*! \brief Schedules an expire/refresh event in the LSA.
290 \param key The name of the router whose LSA is in question.
291 \param seqNo The sequence number of the LSA to check.
292 \param expTime The number of seconds to wait before triggering the event.
293 */
akmhoque53353462014-04-22 08:43:45 -0500294 ndn::EventId
akmhoquec7a79b22014-05-26 08:06:19 -0500295 scheduleAdjLsaExpiration(const ndn::Name& key, int seqNo,
Nick Gordone98480b2017-05-24 11:23:03 -0500296 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -0500297
Vince Lehman199e9cf2015-04-07 13:22:16 -0500298private:
Nick G97e34942016-07-11 14:46:27 -0500299
akmhoque53353462014-04-22 08:43:45 -0500300 void
Ashlesh Gawande90173ad2017-08-09 15:19:50 -0500301 expireOrRefreshAdjLsa(const ndn::Name& lsaKey, uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500302
303 ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -0500304 scheduleCoordinateLsaExpiration(const ndn::Name& key, int seqNo,
Nick Gordone98480b2017-05-24 11:23:03 -0500305 const ndn::time::seconds& expTime);
akmhoque53353462014-04-22 08:43:45 -0500306
307 void
Ashlesh Gawande90173ad2017-08-09 15:19:50 -0500308 expireOrRefreshCoordinateLsa(const ndn::Name& lsaKey,
akmhoqueb6450b12014-04-24 00:01:03 -0500309 uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500310
Nick G97e34942016-07-11 14:46:27 -0500311private:
312
akmhoque31d1d4b2014-05-05 22:08:14 -0500313 void
akmhoque69c9aa92014-07-23 15:15:05 -0500314 putLsaData(const ndn::Interest& interest, const std::string& content);
315
316 void
akmhoque31d1d4b2014-05-05 22:08:14 -0500317 processInterestForNameLsa(const ndn::Interest& interest,
318 const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500319 uint64_t seqNo);
akmhoque53353462014-04-22 08:43:45 -0500320
akmhoque31d1d4b2014-05-05 22:08:14 -0500321 void
322 processInterestForAdjacencyLsa(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
326 void
327 processInterestForCoordinateLsa(const ndn::Interest& interest,
328 const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500329 uint64_t seqNo);
akmhoque31d1d4b2014-05-05 22:08:14 -0500330 void
dmcoomes9f936662017-03-02 10:33:09 -0600331 onContentValidated(const std::shared_ptr<const ndn::Data>& data);
Yingdi Yu20e3a6e2014-05-26 23:16:10 -0700332
333 void
akmhoque31d1d4b2014-05-05 22:08:14 -0500334 processContentNameLsa(const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500335 uint64_t lsSeqNo, std::string& dataContent);
akmhoque31d1d4b2014-05-05 22:08:14 -0500336
337 void
338 processContentAdjacencyLsa(const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500339 uint64_t lsSeqNo, std::string& dataContent);
akmhoque31d1d4b2014-05-05 22:08:14 -0500340
341 void
342 processContentCoordinateLsa(const ndn::Name& lsaKey,
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500343 uint64_t lsSeqNo, std::string& dataContent);
akmhoque31d1d4b2014-05-05 22:08:14 -0500344
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500345PUBLIC_WITH_TESTS_ELSE_PRIVATE:
Nick G97e34942016-07-11 14:46:27 -0500346 /*!
347 \brief Error callback when SegmentFetcher fails to return an LSA
348
349 In all error cases, a reattempt to fetch the LSA will be made.
350
351 Segment validation can fail either because the packet does not have a
352 valid signature (fatal) or because some of the certificates in the trust chain
353 could not be fetched (non-fatal).
354
355 Currently, the library does not provide clear indication (besides a plain-text message
356 in the error callback) of the reason for the failure nor the segment that failed
357 to be validated, thus we will continue to try to fetch the LSA until the deadline
358 is reached.
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500359 */
akmhoque31d1d4b2014-05-05 22:08:14 -0500360 void
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500361 onFetchLsaError(uint32_t errorCode,
362 const std::string& msg,
Ashlesh Gawande744e4812018-08-22 16:26:24 -0500363 const ndn::Name& interestName,
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500364 uint32_t retransmitNo,
365 const ndn::time::steady_clock::TimePoint& deadline,
366 ndn::Name lsaName,
367 uint64_t seqNo);
368
Nick G97e34942016-07-11 14:46:27 -0500369 /*!
370 \brief Success callback when SegmentFetcher returns a valid LSA
371
Nick Gordonb50e51b2016-07-22 16:05:57 -0500372 \param interestName The base Interest used to fetch the LSA in the format:
Nick G97e34942016-07-11 14:46:27 -0500373 /<network>/NLSR/LSA/<site>/%C1.Router/<router>/<lsa-type>/<seqNo>
Muktadir R Chowdhuryaa3b0852015-08-06 13:08:56 -0500374 */
375 void
Ashlesh Gawande744e4812018-08-22 16:26:24 -0500376 afterFetchLsa(const ndn::ConstBufferPtr& data, const ndn::Name& interestName);
akmhoque31d1d4b2014-05-05 22:08:14 -0500377
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500378private:
Nick Gordone98480b2017-05-24 11:23:03 -0500379 ndn::time::system_clock::TimePoint
akmhoquec7a79b22014-05-26 08:06:19 -0500380 getLsaExpirationTimePoint();
381
Nick G97e34942016-07-11 14:46:27 -0500382 /*! \brief Cancels an event in the event scheduler. */
akmhoque31d1d4b2014-05-05 22:08:14 -0500383 void
384 cancelScheduleLsaExpiringEvent(ndn::EventId eid);
385
Jiewen Tana0497d82015-02-02 21:59:18 -0800386public:
387 static const ndn::Name::Component NAME_COMPONENT;
388
Alejandro Gil Torrese0d20482016-03-06 23:56:19 -0600389 ndn::util::signal::Signal<Lsdb, Statistics::PacketType> lsaIncrementSignal;
390
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500391private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500392 Nlsr& m_nlsr;
Vince Lehman7c603292014-09-11 17:48:16 -0500393 ndn::Scheduler& m_scheduler;
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500394 SyncLogicHandler m_sync;
Muktadir Chowdhuryc3ea26f2018-01-05 21:40:59 +0000395 LsaSegmentStorage m_lsaStorage;
Vince Lehman7c603292014-09-11 17:48:16 -0500396
akmhoque53353462014-04-22 08:43:45 -0500397 std::list<NameLsa> m_nameLsdb;
398 std::list<AdjLsa> m_adjLsdb;
akmhoqueb6450b12014-04-24 00:01:03 -0500399 std::list<CoordinateLsa> m_corLsdb;
akmhoque53353462014-04-22 08:43:45 -0500400
Nick Gordone98480b2017-05-24 11:23:03 -0500401 ndn::time::seconds m_lsaRefreshTime;
akmhoque53353462014-04-22 08:43:45 -0500402 std::string m_thisRouterPrefix;
403
Ashlesh Gawande5bf83172014-09-19 12:38:17 -0500404 typedef std::map<ndn::Name, uint64_t> SequenceNumberMap;
405
406 // Maps the name of an LSA to its highest known sequence number from sync;
407 // Used to stop NLSR from trying to fetch outdated LSAs
408 SequenceNumberMap m_highestSeqNo;
409
Vince Lehman18841082014-08-19 17:15:24 -0500410 static const ndn::time::seconds GRACE_PERIOD;
Nick Gordone98480b2017-05-24 11:23:03 -0500411 static const ndn::time::steady_clock::TimePoint DEFAULT_LSA_RETRIEVAL_DEADLINE;
Vince Lehman50df6b72015-03-03 12:06:40 -0600412
413 ndn::time::seconds m_adjLsaBuildInterval;
Ashlesh Gawande3e105a02017-05-16 17:36:56 -0500414
415 SequencingManager m_sequencingManager;
Nick Gordon9eac4d92017-08-29 17:31:29 -0500416
417 ndn::util::signal::ScopedConnection m_onNewLsaConnection;
Ashlesh Gawande744e4812018-08-22 16:26:24 -0500418
419 std::set<std::shared_ptr<ndn::util::SegmentFetcher>> m_fetchers;
akmhoque53353462014-04-22 08:43:45 -0500420};
421
Nick Gordonfad8e252016-08-11 14:21:38 -0500422} // namespace nlsr
akmhoque53353462014-04-22 08:43:45 -0500423
dmcoomes9f936662017-03-02 10:33:09 -0600424#endif // NLSR_LSDB_HPP