blob: 8c0e1a9e26610ed66175981da8476fa6614f50a4 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
dmcoomescf8d0ed2017-02-21 11:39:01 -06003 * 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 **/
Vince Lehmanc2e51f62015-01-20 15:03:11 -060021
dmcoomese689dd62017-03-29 11:05:12 -050022#ifndef NLSR_CONF_PARAMETER_HPP
23#define NLSR_CONF_PARAMETER_HPP
akmhoque53353462014-04-22 08:43:45 -050024
Nick Gordone98480b2017-05-24 11:23:03 -050025#include "common.hpp"
Ashlesh Gawande3909aa12017-07-28 16:01:35 -050026#include "logger.hpp"
Ashlesh Gawande982a58f2018-02-14 17:39:12 -060027#include "test-access-control.hpp"
Ashlesh Gawande3909aa12017-07-28 16:01:35 -050028
akmhoque53353462014-04-22 08:43:45 -050029#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -050030#include <boost/cstdint.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -050031#include <ndn-cxx/face.hpp>
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070032#include <ndn-cxx/util/time.hpp>
akmhoque53353462014-04-22 08:43:45 -050033
34namespace nlsr {
akmhoque157b0a42014-05-13 00:26:37 -050035
36enum {
37 LSA_REFRESH_TIME_MIN = 240,
38 LSA_REFRESH_TIME_DEFAULT = 1800,
39 LSA_REFRESH_TIME_MAX = 7200
40};
41
42enum {
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070043 LSA_INTEREST_LIFETIME_MIN = 1,
44 LSA_INTEREST_LIFETIME_DEFAULT = 4,
45 LSA_INTEREST_LIFETIME_MAX = 60
46};
47
48enum {
Vince Lehman7b616582014-10-17 16:25:39 -050049 ADJ_LSA_BUILD_INTERVAL_MIN = 0,
50 ADJ_LSA_BUILD_INTERVAL_DEFAULT = 5,
51 ADJ_LSA_BUILD_INTERVAL_MAX = 5
52};
53
54enum {
55 FIRST_HELLO_INTERVAL_MIN = 0,
56 FIRST_HELLO_INTERVAL_DEFAULT = 10,
57 FIRST_HELLO_INTERVAL_MAX = 10
58};
59
60enum {
61 ROUTING_CALC_INTERVAL_MIN = 0,
62 ROUTING_CALC_INTERVAL_DEFAULT = 15,
63 ROUTING_CALC_INTERVAL_MAX = 15
64};
65
Nick Gordond5c1a372016-10-31 13:56:23 -050066
67enum {
68 FACE_DATASET_FETCH_TRIES_MIN = 1,
69 FACE_DATASET_FETCH_TRIES_MAX = 10,
70 FACE_DATASET_FETCH_TRIES_DEFAULT = 3
71};
72
73enum {
74 FACE_DATASET_FETCH_INTERVAL_MIN = 1800,
75 FACE_DATASET_FETCH_INTERVAL_MAX = 5400,
76 FACE_DATASET_FETCH_INTERVAL_DEFAULT = 3600
77};
78
Vince Lehman7b616582014-10-17 16:25:39 -050079enum {
akmhoque157b0a42014-05-13 00:26:37 -050080 HELLO_RETRIES_MIN = 1,
81 HELLO_RETRIES_DEFAULT = 3,
82 HELLO_RETRIES_MAX = 15
83};
84
85enum {
86 HELLO_TIMEOUT_MIN = 1,
87 HELLO_TIMEOUT_DEFAULT = 3,
88 HELLO_TIMEOUT_MAX = 15
89};
90
91enum {
92 HELLO_INTERVAL_MIN = 30,
93 HELLO_INTERVAL_DEFAULT = 60,
94 HELLO_INTERVAL_MAX =90
95};
96
97enum {
98 MAX_FACES_PER_PREFIX_MIN = 0,
alvya2228c62014-12-09 10:25:11 -060099 MAX_FACES_PER_PREFIX_DEFAULT = 0,
akmhoque157b0a42014-05-13 00:26:37 -0500100 MAX_FACES_PER_PREFIX_MAX = 60
101};
102
Nick Gordon5c467f02016-07-13 13:40:10 -0500103enum HyperbolicState {
akmhoque157b0a42014-05-13 00:26:37 -0500104 HYPERBOLIC_STATE_OFF = 0,
105 HYPERBOLIC_STATE_ON = 1,
alvya2228c62014-12-09 10:25:11 -0600106 HYPERBOLIC_STATE_DRY_RUN = 2,
107 HYPERBOLIC_STATE_DEFAULT = 0
akmhoque157b0a42014-05-13 00:26:37 -0500108};
109
Ashlesh Gawandef7da9c52018-02-06 17:36:46 -0600110enum {
111 SYNC_INTEREST_LIFETIME_MIN = 1000,
112 SYNC_INTEREST_LIFETIME_DEFAULT = 60000,
113 SYNC_INTEREST_LIFETIME_MAX = 120000,
114};
115
Nick Gordond0a7df32017-05-30 16:44:34 -0500116/*! \brief A class to house all the configuration parameters for NLSR.
117 *
118 * This class is conceptually a singleton (but not mechanically) which
119 * is just a collection of attributes that serve as a
120 * separation-of-data for NLSR's configuration variables. NLSR refers
121 * to an instance of this class for all its configuration
122 * parameters. This object is typically populated by a
123 * ConfFileProcessor reading a configuration file.
124 *
125 * \sa nlsr::ConfFileProcessor
126 */
akmhoque53353462014-04-22 08:43:45 -0500127class ConfParameter
128{
129
130public:
131 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -0500132 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
Vince Lehman7b616582014-10-17 16:25:39 -0500133 , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
134 , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
135 , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
Ashlesh Gawande3909aa12017-07-28 16:01:35 -0500136 , m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700137 , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -0700138 , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
akmhoque157b0a42014-05-13 00:26:37 -0500139 , m_logLevel("INFO")
140 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
141 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
142 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
143 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -0500144 , m_corR(0)
akmhoque157b0a42014-05-13 00:26:37 -0500145 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
Alexander Afanasyevb0bf8df2018-02-19 12:25:44 -0500146 , m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700147 {
148 }
akmhoque53353462014-04-22 08:43:45 -0500149
150 void
Ashlesh Gawande982a58f2018-02-14 17:39:12 -0600151 setNetwork(const ndn::Name& networkName);
akmhoque53353462014-04-22 08:43:45 -0500152
akmhoque31d1d4b2014-05-05 22:08:14 -0500153 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700154 getNetwork() const
akmhoque53353462014-04-22 08:43:45 -0500155 {
156 return m_network;
157 }
158
159 void
akmhoque157b0a42014-05-13 00:26:37 -0500160 setRouterName(const ndn::Name& routerName)
161 {
162 m_routerName = routerName;
163 }
164
165 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700166 getRouterName() const
akmhoque157b0a42014-05-13 00:26:37 -0500167 {
168 return m_routerName;
169 }
170
171 void
172 setSiteName(const ndn::Name& siteName)
173 {
174 m_siteName = siteName;
175 }
176
177 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700178 getSiteName() const
akmhoque157b0a42014-05-13 00:26:37 -0500179 {
180 return m_siteName;
181 }
182
183 void
akmhoque53353462014-04-22 08:43:45 -0500184 buildRouterPrefix()
185 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500186 m_routerPrefix = m_network;
187 m_routerPrefix.append(m_siteName);
188 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500189 }
190
akmhoque31d1d4b2014-05-05 22:08:14 -0500191 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700192 getRouterPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500193 {
194 return m_routerPrefix;
195 }
196
akmhoque157b0a42014-05-13 00:26:37 -0500197
akmhoque31d1d4b2014-05-05 22:08:14 -0500198 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700199 getChronosyncPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500200 {
akmhoque157b0a42014-05-13 00:26:37 -0500201 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500202 }
203
akmhoque157b0a42014-05-13 00:26:37 -0500204 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700205 getLsaPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500206 {
akmhoque157b0a42014-05-13 00:26:37 -0500207 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500208 }
209
210 void
alvy5a454952014-12-15 12:49:54 -0600211 setLsaRefreshTime(uint32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500212 {
213 m_lsaRefreshTime = lrt;
akmhoque53353462014-04-22 08:43:45 -0500214 }
215
alvy5a454952014-12-15 12:49:54 -0600216 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700217 getLsaRefreshTime() const
akmhoque53353462014-04-22 08:43:45 -0500218 {
219 return m_lsaRefreshTime;
220 }
221
222 void
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700223 setLsaInterestLifetime(const ndn::time::seconds& lifetime)
224 {
225 m_lsaInterestLifetime = lifetime;
226 }
227
228 const ndn::time::seconds&
229 getLsaInterestLifetime() const
230 {
231 return m_lsaInterestLifetime;
232 }
233
234 void
Vince Lehman7b616582014-10-17 16:25:39 -0500235 setAdjLsaBuildInterval(uint32_t interval)
236 {
237 m_adjLsaBuildInterval = interval;
238 }
239
240 uint32_t
241 getAdjLsaBuildInterval() const
242 {
243 return m_adjLsaBuildInterval;
244 }
245
246 void
247 setFirstHelloInterval(uint32_t interval)
248 {
249 m_firstHelloInterval = interval;
250 }
251
252 uint32_t
253 getFirstHelloInterval() const
254 {
255 return m_firstHelloInterval;
256 }
257
258 void
259 setRoutingCalcInterval(uint32_t interval)
260 {
261 m_routingCalcInterval = interval;
262 }
263
264 uint32_t
265 getRoutingCalcInterval() const
266 {
267 return m_routingCalcInterval;
268 }
269
270 void
alvy5a454952014-12-15 12:49:54 -0600271 setRouterDeadInterval(uint32_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500272 {
273 m_routerDeadInterval = rdt;
274 }
275
alvy5a454952014-12-15 12:49:54 -0600276 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700277 getRouterDeadInterval() const
akmhoque53353462014-04-22 08:43:45 -0500278 {
279 return m_routerDeadInterval;
280 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700281
282 void
Nick Gordond5c1a372016-10-31 13:56:23 -0500283 setFaceDatasetFetchTries(uint32_t count)
284 {
285 m_faceDatasetFetchTries = count;
286 }
287
288 uint32_t
289 getFaceDatasetFetchTries() const
290 {
291 return m_faceDatasetFetchTries;
292 }
293
294 void
Ashlesh Gawande3909aa12017-07-28 16:01:35 -0500295 setFaceDatasetFetchInterval(uint32_t interval)
Nick Gordond5c1a372016-10-31 13:56:23 -0500296 {
Ashlesh Gawande3909aa12017-07-28 16:01:35 -0500297 m_faceDatasetFetchInterval = ndn::time::seconds(interval);
Nick Gordond5c1a372016-10-31 13:56:23 -0500298 }
299
300 const ndn::time::seconds
301 getFaceDatasetFetchInterval() const
302 {
303 return m_faceDatasetFetchInterval;
304 }
305
306 void
akmhoque157b0a42014-05-13 00:26:37 -0500307 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500308 {
akmhoque157b0a42014-05-13 00:26:37 -0500309 m_interestRetryNumber = irn;
310 }
311
312 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700313 getInterestRetryNumber() const
akmhoque157b0a42014-05-13 00:26:37 -0500314 {
315 return m_interestRetryNumber;
316 }
317
318 void
alvy5a454952014-12-15 12:49:54 -0600319 setInterestResendTime(uint32_t irt)
akmhoque157b0a42014-05-13 00:26:37 -0500320 {
321 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500322 }
323
alvy5a454952014-12-15 12:49:54 -0600324 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700325 getInterestResendTime() const
akmhoque53353462014-04-22 08:43:45 -0500326 {
akmhoque157b0a42014-05-13 00:26:37 -0500327 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500328 }
329
alvy5a454952014-12-15 12:49:54 -0600330 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700331 getInfoInterestInterval() const
akmhoque53353462014-04-22 08:43:45 -0500332 {
akmhoque157b0a42014-05-13 00:26:37 -0500333 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500334 }
335
336 void
alvy5a454952014-12-15 12:49:54 -0600337 setInfoInterestInterval(uint32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500338 {
akmhoque157b0a42014-05-13 00:26:37 -0500339 m_infoInterestInterval = iii;
340 }
341
342 void
343 setHyperbolicState(int32_t ihc)
344 {
345 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500346 }
347
akmhoquefdbddb12014-05-02 18:35:19 -0500348 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700349 getHyperbolicState() const
akmhoque53353462014-04-22 08:43:45 -0500350 {
akmhoque157b0a42014-05-13 00:26:37 -0500351 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500352 }
353
akmhoque157b0a42014-05-13 00:26:37 -0500354 bool
akmhoque53353462014-04-22 08:43:45 -0500355 setCorR(double cr)
356 {
akmhoque157b0a42014-05-13 00:26:37 -0500357 if ( cr >= 0 ) {
358 m_corR = cr;
359 return true;
360 }
361 return false;
akmhoque53353462014-04-22 08:43:45 -0500362 }
363
364 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700365 getCorR() const
akmhoque53353462014-04-22 08:43:45 -0500366 {
367 return m_corR;
368 }
369
370 void
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600371 setCorTheta(const std::vector<double>& ct)
akmhoque53353462014-04-22 08:43:45 -0500372 {
373 m_corTheta = ct;
374 }
375
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600376 std::vector<double>
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700377 getCorTheta() const
akmhoque53353462014-04-22 08:43:45 -0500378 {
379 return m_corTheta;
380 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700381
akmhoque53353462014-04-22 08:43:45 -0500382 void
Vince Lehman942eb7b2014-10-02 10:09:27 -0500383 setMaxFacesPerPrefix(uint32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500384 {
akmhoque157b0a42014-05-13 00:26:37 -0500385 m_maxFacesPerPrefix = mfpp;
akmhoque53353462014-04-22 08:43:45 -0500386 }
387
Vince Lehman942eb7b2014-10-02 10:09:27 -0500388 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700389 getMaxFacesPerPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500390 {
akmhoque157b0a42014-05-13 00:26:37 -0500391 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500392 }
393
394 void
akmhoque157b0a42014-05-13 00:26:37 -0500395 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500396 {
akmhoque157b0a42014-05-13 00:26:37 -0500397 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500398 }
399
akmhoque157b0a42014-05-13 00:26:37 -0500400 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700401 getSeqFileDir() const
akmhoque53353462014-04-22 08:43:45 -0500402 {
akmhoque157b0a42014-05-13 00:26:37 -0500403 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500404 }
405
akmhoque674b0b12014-05-20 14:33:28 -0500406 void
Ashlesh Gawandef7da9c52018-02-06 17:36:46 -0600407 setSyncInterestLifetime(uint32_t syncInterestLifetime)
408 {
409 m_syncInterestLifetime = ndn::time::milliseconds(syncInterestLifetime);
410 }
411
412 const ndn::time::milliseconds&
413 getSyncInterestLifetime() const
414 {
415 return m_syncInterestLifetime;
416 }
417
418 void
akmhoque674b0b12014-05-20 14:33:28 -0500419 writeLog();
akmhoque53353462014-04-22 08:43:45 -0500420
421private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500422 ndn::Name m_routerName;
423 ndn::Name m_siteName;
424 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500425
akmhoque31d1d4b2014-05-05 22:08:14 -0500426 ndn::Name m_routerPrefix;
427 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500428
akmhoque157b0a42014-05-13 00:26:37 -0500429 ndn::Name m_chronosyncPrefix;
430 ndn::Name m_lsaPrefix;
431
alvy5a454952014-12-15 12:49:54 -0600432 uint32_t m_lsaRefreshTime;
Vince Lehman7b616582014-10-17 16:25:39 -0500433
434 uint32_t m_adjLsaBuildInterval;
435 uint32_t m_firstHelloInterval;
436 uint32_t m_routingCalcInterval;
437
Nick Gordond5c1a372016-10-31 13:56:23 -0500438 uint32_t m_faceDatasetFetchTries;
439 ndn::time::seconds m_faceDatasetFetchInterval;
440
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700441 ndn::time::seconds m_lsaInterestLifetime;
alvy5a454952014-12-15 12:49:54 -0600442 uint32_t m_routerDeadInterval;
akmhoque157b0a42014-05-13 00:26:37 -0500443 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500444
akmhoquefdbddb12014-05-02 18:35:19 -0500445 uint32_t m_interestRetryNumber;
alvy5a454952014-12-15 12:49:54 -0600446 uint32_t m_interestResendTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700447
alvy5a454952014-12-15 12:49:54 -0600448 uint32_t m_infoInterestInterval;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700449
akmhoque157b0a42014-05-13 00:26:37 -0500450 int32_t m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500451 double m_corR;
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600452 std::vector<double> m_corTheta;
akmhoque53353462014-04-22 08:43:45 -0500453
Vince Lehman942eb7b2014-10-02 10:09:27 -0500454 uint32_t m_maxFacesPerPrefix;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700455
akmhoque157b0a42014-05-13 00:26:37 -0500456 std::string m_seqFileDir;
Ashlesh Gawandef7da9c52018-02-06 17:36:46 -0600457 ndn::time::milliseconds m_syncInterestLifetime;
Ashlesh Gawande982a58f2018-02-14 17:39:12 -0600458
459PUBLIC_WITH_TESTS_ELSE_PRIVATE:
460 static const uint64_t SYNC_VERSION;
akmhoque53353462014-04-22 08:43:45 -0500461};
462
akmhoque53353462014-04-22 08:43:45 -0500463} // namespace nlsr
464
dmcoomese689dd62017-03-29 11:05:12 -0500465#endif // NLSR_CONF_PARAMETER_HPP