blob: ee227642e9eb548632996dd9eb3c1028d3e9d6e5 [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"
27
akmhoque53353462014-04-22 08:43:45 -050028#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -050029#include <boost/cstdint.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -050030#include <ndn-cxx/face.hpp>
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070031#include <ndn-cxx/util/time.hpp>
akmhoque53353462014-04-22 08:43:45 -050032
33namespace nlsr {
akmhoque157b0a42014-05-13 00:26:37 -050034
35enum {
36 LSA_REFRESH_TIME_MIN = 240,
37 LSA_REFRESH_TIME_DEFAULT = 1800,
38 LSA_REFRESH_TIME_MAX = 7200
39};
40
41enum {
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070042 LSA_INTEREST_LIFETIME_MIN = 1,
43 LSA_INTEREST_LIFETIME_DEFAULT = 4,
44 LSA_INTEREST_LIFETIME_MAX = 60
45};
46
47enum {
Vince Lehman7b616582014-10-17 16:25:39 -050048 ADJ_LSA_BUILD_INTERVAL_MIN = 0,
49 ADJ_LSA_BUILD_INTERVAL_DEFAULT = 5,
50 ADJ_LSA_BUILD_INTERVAL_MAX = 5
51};
52
53enum {
54 FIRST_HELLO_INTERVAL_MIN = 0,
55 FIRST_HELLO_INTERVAL_DEFAULT = 10,
56 FIRST_HELLO_INTERVAL_MAX = 10
57};
58
59enum {
60 ROUTING_CALC_INTERVAL_MIN = 0,
61 ROUTING_CALC_INTERVAL_DEFAULT = 15,
62 ROUTING_CALC_INTERVAL_MAX = 15
63};
64
Nick Gordond5c1a372016-10-31 13:56:23 -050065
66enum {
67 FACE_DATASET_FETCH_TRIES_MIN = 1,
68 FACE_DATASET_FETCH_TRIES_MAX = 10,
69 FACE_DATASET_FETCH_TRIES_DEFAULT = 3
70};
71
72enum {
73 FACE_DATASET_FETCH_INTERVAL_MIN = 1800,
74 FACE_DATASET_FETCH_INTERVAL_MAX = 5400,
75 FACE_DATASET_FETCH_INTERVAL_DEFAULT = 3600
76};
77
Vince Lehman7b616582014-10-17 16:25:39 -050078enum {
akmhoque157b0a42014-05-13 00:26:37 -050079 HELLO_RETRIES_MIN = 1,
80 HELLO_RETRIES_DEFAULT = 3,
81 HELLO_RETRIES_MAX = 15
82};
83
84enum {
85 HELLO_TIMEOUT_MIN = 1,
86 HELLO_TIMEOUT_DEFAULT = 3,
87 HELLO_TIMEOUT_MAX = 15
88};
89
90enum {
91 HELLO_INTERVAL_MIN = 30,
92 HELLO_INTERVAL_DEFAULT = 60,
93 HELLO_INTERVAL_MAX =90
94};
95
96enum {
97 MAX_FACES_PER_PREFIX_MIN = 0,
alvya2228c62014-12-09 10:25:11 -060098 MAX_FACES_PER_PREFIX_DEFAULT = 0,
akmhoque157b0a42014-05-13 00:26:37 -050099 MAX_FACES_PER_PREFIX_MAX = 60
100};
101
Nick Gordon5c467f02016-07-13 13:40:10 -0500102enum HyperbolicState {
akmhoque157b0a42014-05-13 00:26:37 -0500103 HYPERBOLIC_STATE_OFF = 0,
104 HYPERBOLIC_STATE_ON = 1,
alvya2228c62014-12-09 10:25:11 -0600105 HYPERBOLIC_STATE_DRY_RUN = 2,
106 HYPERBOLIC_STATE_DEFAULT = 0
akmhoque157b0a42014-05-13 00:26:37 -0500107};
108
Nick Gordond0a7df32017-05-30 16:44:34 -0500109/*! \brief A class to house all the configuration parameters for NLSR.
110 *
111 * This class is conceptually a singleton (but not mechanically) which
112 * is just a collection of attributes that serve as a
113 * separation-of-data for NLSR's configuration variables. NLSR refers
114 * to an instance of this class for all its configuration
115 * parameters. This object is typically populated by a
116 * ConfFileProcessor reading a configuration file.
117 *
118 * \sa nlsr::ConfFileProcessor
119 */
akmhoque53353462014-04-22 08:43:45 -0500120class ConfParameter
121{
122
123public:
124 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -0500125 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
Vince Lehman7b616582014-10-17 16:25:39 -0500126 , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
127 , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
128 , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
Ashlesh Gawande3909aa12017-07-28 16:01:35 -0500129 , m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700130 , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -0700131 , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
akmhoque157b0a42014-05-13 00:26:37 -0500132 , m_logLevel("INFO")
133 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
134 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
135 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
136 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -0500137 , m_corR(0)
akmhoque157b0a42014-05-13 00:26:37 -0500138 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700139 {
140 }
akmhoque53353462014-04-22 08:43:45 -0500141
142 void
akmhoque157b0a42014-05-13 00:26:37 -0500143 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -0500144 {
akmhoque157b0a42014-05-13 00:26:37 -0500145 m_network = networkName;
Ashlesh Gawande44395232016-12-13 14:35:29 -0600146
147 m_chronosyncPrefix.append("localhop");
Ashlesh Gawande8bfd1242017-06-21 14:55:27 -0500148 m_chronosyncPrefix.append(m_network);
akmhoquea816bee2014-06-24 14:37:40 -0500149 m_chronosyncPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500150 m_chronosyncPrefix.append("sync");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700151
Ashlesh Gawande6077ea92017-01-19 11:48:29 -0600152 m_lsaPrefix.append("localhop");
153 m_lsaPrefix.append(m_network);
akmhoquea816bee2014-06-24 14:37:40 -0500154 m_lsaPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500155 m_lsaPrefix.append("LSA");
akmhoque53353462014-04-22 08:43:45 -0500156 }
157
akmhoque31d1d4b2014-05-05 22:08:14 -0500158 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700159 getNetwork() const
akmhoque53353462014-04-22 08:43:45 -0500160 {
161 return m_network;
162 }
163
164 void
akmhoque157b0a42014-05-13 00:26:37 -0500165 setRouterName(const ndn::Name& routerName)
166 {
167 m_routerName = routerName;
168 }
169
170 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700171 getRouterName() const
akmhoque157b0a42014-05-13 00:26:37 -0500172 {
173 return m_routerName;
174 }
175
176 void
177 setSiteName(const ndn::Name& siteName)
178 {
179 m_siteName = siteName;
180 }
181
182 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700183 getSiteName() const
akmhoque157b0a42014-05-13 00:26:37 -0500184 {
185 return m_siteName;
186 }
187
188 void
akmhoque53353462014-04-22 08:43:45 -0500189 buildRouterPrefix()
190 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500191 m_routerPrefix = m_network;
192 m_routerPrefix.append(m_siteName);
193 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500194 }
195
akmhoque31d1d4b2014-05-05 22:08:14 -0500196 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700197 getRouterPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500198 {
199 return m_routerPrefix;
200 }
201
akmhoque157b0a42014-05-13 00:26:37 -0500202
akmhoque31d1d4b2014-05-05 22:08:14 -0500203 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700204 getChronosyncPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500205 {
akmhoque157b0a42014-05-13 00:26:37 -0500206 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500207 }
208
akmhoque157b0a42014-05-13 00:26:37 -0500209 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700210 getLsaPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500211 {
akmhoque157b0a42014-05-13 00:26:37 -0500212 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500213 }
214
215 void
alvy5a454952014-12-15 12:49:54 -0600216 setLsaRefreshTime(uint32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500217 {
218 m_lsaRefreshTime = lrt;
akmhoque53353462014-04-22 08:43:45 -0500219 }
220
alvy5a454952014-12-15 12:49:54 -0600221 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700222 getLsaRefreshTime() const
akmhoque53353462014-04-22 08:43:45 -0500223 {
224 return m_lsaRefreshTime;
225 }
226
227 void
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700228 setLsaInterestLifetime(const ndn::time::seconds& lifetime)
229 {
230 m_lsaInterestLifetime = lifetime;
231 }
232
233 const ndn::time::seconds&
234 getLsaInterestLifetime() const
235 {
236 return m_lsaInterestLifetime;
237 }
238
239 void
Vince Lehman7b616582014-10-17 16:25:39 -0500240 setAdjLsaBuildInterval(uint32_t interval)
241 {
242 m_adjLsaBuildInterval = interval;
243 }
244
245 uint32_t
246 getAdjLsaBuildInterval() const
247 {
248 return m_adjLsaBuildInterval;
249 }
250
251 void
252 setFirstHelloInterval(uint32_t interval)
253 {
254 m_firstHelloInterval = interval;
255 }
256
257 uint32_t
258 getFirstHelloInterval() const
259 {
260 return m_firstHelloInterval;
261 }
262
263 void
264 setRoutingCalcInterval(uint32_t interval)
265 {
266 m_routingCalcInterval = interval;
267 }
268
269 uint32_t
270 getRoutingCalcInterval() const
271 {
272 return m_routingCalcInterval;
273 }
274
275 void
alvy5a454952014-12-15 12:49:54 -0600276 setRouterDeadInterval(uint32_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500277 {
278 m_routerDeadInterval = rdt;
279 }
280
alvy5a454952014-12-15 12:49:54 -0600281 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700282 getRouterDeadInterval() const
akmhoque53353462014-04-22 08:43:45 -0500283 {
284 return m_routerDeadInterval;
285 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700286
287 void
Nick Gordond5c1a372016-10-31 13:56:23 -0500288 setFaceDatasetFetchTries(uint32_t count)
289 {
290 m_faceDatasetFetchTries = count;
291 }
292
293 uint32_t
294 getFaceDatasetFetchTries() const
295 {
296 return m_faceDatasetFetchTries;
297 }
298
299 void
Ashlesh Gawande3909aa12017-07-28 16:01:35 -0500300 setFaceDatasetFetchInterval(uint32_t interval)
Nick Gordond5c1a372016-10-31 13:56:23 -0500301 {
Ashlesh Gawande3909aa12017-07-28 16:01:35 -0500302 m_faceDatasetFetchInterval = ndn::time::seconds(interval);
Nick Gordond5c1a372016-10-31 13:56:23 -0500303 }
304
305 const ndn::time::seconds
306 getFaceDatasetFetchInterval() const
307 {
308 return m_faceDatasetFetchInterval;
309 }
310
311 void
akmhoque157b0a42014-05-13 00:26:37 -0500312 setLogLevel(const std::string& logLevel)
313 {
314 m_logLevel = logLevel;
315 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700316
317 const std::string&
318 getLogLevel() const
akmhoque157b0a42014-05-13 00:26:37 -0500319 {
320 return m_logLevel;
321 }
akmhoque53353462014-04-22 08:43:45 -0500322
323 void
akmhoque157b0a42014-05-13 00:26:37 -0500324 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500325 {
akmhoque157b0a42014-05-13 00:26:37 -0500326 m_interestRetryNumber = irn;
327 }
328
329 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700330 getInterestRetryNumber() const
akmhoque157b0a42014-05-13 00:26:37 -0500331 {
332 return m_interestRetryNumber;
333 }
334
335 void
alvy5a454952014-12-15 12:49:54 -0600336 setInterestResendTime(uint32_t irt)
akmhoque157b0a42014-05-13 00:26:37 -0500337 {
338 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500339 }
340
alvy5a454952014-12-15 12:49:54 -0600341 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700342 getInterestResendTime() const
akmhoque53353462014-04-22 08:43:45 -0500343 {
akmhoque157b0a42014-05-13 00:26:37 -0500344 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500345 }
346
alvy5a454952014-12-15 12:49:54 -0600347 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700348 getInfoInterestInterval() const
akmhoque53353462014-04-22 08:43:45 -0500349 {
akmhoque157b0a42014-05-13 00:26:37 -0500350 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500351 }
352
353 void
alvy5a454952014-12-15 12:49:54 -0600354 setInfoInterestInterval(uint32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500355 {
akmhoque157b0a42014-05-13 00:26:37 -0500356 m_infoInterestInterval = iii;
357 }
358
359 void
360 setHyperbolicState(int32_t ihc)
361 {
362 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500363 }
364
akmhoquefdbddb12014-05-02 18:35:19 -0500365 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700366 getHyperbolicState() const
akmhoque53353462014-04-22 08:43:45 -0500367 {
akmhoque157b0a42014-05-13 00:26:37 -0500368 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500369 }
370
akmhoque157b0a42014-05-13 00:26:37 -0500371 bool
akmhoque53353462014-04-22 08:43:45 -0500372 setCorR(double cr)
373 {
akmhoque157b0a42014-05-13 00:26:37 -0500374 if ( cr >= 0 ) {
375 m_corR = cr;
376 return true;
377 }
378 return false;
akmhoque53353462014-04-22 08:43:45 -0500379 }
380
381 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700382 getCorR() const
akmhoque53353462014-04-22 08:43:45 -0500383 {
384 return m_corR;
385 }
386
387 void
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600388 setCorTheta(const std::vector<double>& ct)
akmhoque53353462014-04-22 08:43:45 -0500389 {
390 m_corTheta = ct;
391 }
392
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600393 std::vector<double>
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700394 getCorTheta() const
akmhoque53353462014-04-22 08:43:45 -0500395 {
396 return m_corTheta;
397 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700398
akmhoque53353462014-04-22 08:43:45 -0500399 void
Vince Lehman942eb7b2014-10-02 10:09:27 -0500400 setMaxFacesPerPrefix(uint32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500401 {
akmhoque157b0a42014-05-13 00:26:37 -0500402 m_maxFacesPerPrefix = mfpp;
akmhoque53353462014-04-22 08:43:45 -0500403 }
404
Vince Lehman942eb7b2014-10-02 10:09:27 -0500405 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700406 getMaxFacesPerPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500407 {
akmhoque157b0a42014-05-13 00:26:37 -0500408 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500409 }
410
411 void
akmhoque157b0a42014-05-13 00:26:37 -0500412 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500413 {
akmhoque157b0a42014-05-13 00:26:37 -0500414 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500415 }
416
akmhoque157b0a42014-05-13 00:26:37 -0500417 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700418 getSeqFileDir() const
akmhoque53353462014-04-22 08:43:45 -0500419 {
akmhoque157b0a42014-05-13 00:26:37 -0500420 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500421 }
422
akmhoque674b0b12014-05-20 14:33:28 -0500423 void
424 writeLog();
akmhoque53353462014-04-22 08:43:45 -0500425
426private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500427 ndn::Name m_routerName;
428 ndn::Name m_siteName;
429 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500430
akmhoque31d1d4b2014-05-05 22:08:14 -0500431 ndn::Name m_routerPrefix;
432 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500433
akmhoque157b0a42014-05-13 00:26:37 -0500434 ndn::Name m_chronosyncPrefix;
435 ndn::Name m_lsaPrefix;
436
alvy5a454952014-12-15 12:49:54 -0600437 uint32_t m_lsaRefreshTime;
Vince Lehman7b616582014-10-17 16:25:39 -0500438
439 uint32_t m_adjLsaBuildInterval;
440 uint32_t m_firstHelloInterval;
441 uint32_t m_routingCalcInterval;
442
Nick Gordond5c1a372016-10-31 13:56:23 -0500443 uint32_t m_faceDatasetFetchTries;
444 ndn::time::seconds m_faceDatasetFetchInterval;
445
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700446 ndn::time::seconds m_lsaInterestLifetime;
alvy5a454952014-12-15 12:49:54 -0600447 uint32_t m_routerDeadInterval;
akmhoque157b0a42014-05-13 00:26:37 -0500448 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500449
akmhoquefdbddb12014-05-02 18:35:19 -0500450 uint32_t m_interestRetryNumber;
alvy5a454952014-12-15 12:49:54 -0600451 uint32_t m_interestResendTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700452
alvy5a454952014-12-15 12:49:54 -0600453 uint32_t m_infoInterestInterval;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700454
akmhoque157b0a42014-05-13 00:26:37 -0500455 int32_t m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500456 double m_corR;
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -0600457 std::vector<double> m_corTheta;
akmhoque53353462014-04-22 08:43:45 -0500458
Vince Lehman942eb7b2014-10-02 10:09:27 -0500459 uint32_t m_maxFacesPerPrefix;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700460
akmhoque157b0a42014-05-13 00:26:37 -0500461 std::string m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500462
463};
464
akmhoque53353462014-04-22 08:43:45 -0500465} // namespace nlsr
466
dmcoomese689dd62017-03-29 11:05:12 -0500467#endif // NLSR_CONF_PARAMETER_HPP