blob: d1aabd953ee375e1b6c8c1fbad67c6a461bb50d0 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Nick Gordonc6a85222017-01-03 16:54:34 -06003 * Copyright (c) 2014-2017, 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
akmhoquefdbddb12014-05-02 18:35:19 -050022#ifndef CONF_PARAMETER_HPP
23#define CONF_PARAMETER_HPP
akmhoque53353462014-04-22 08:43:45 -050024
25#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -050026#include <boost/cstdint.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -050027#include <ndn-cxx/common.hpp>
28#include <ndn-cxx/face.hpp>
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070029#include <ndn-cxx/util/time.hpp>
akmhoque53353462014-04-22 08:43:45 -050030
akmhoque674b0b12014-05-20 14:33:28 -050031#include "logger.hpp"
32
akmhoque53353462014-04-22 08:43:45 -050033namespace 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
65enum {
akmhoque157b0a42014-05-13 00:26:37 -050066 HELLO_RETRIES_MIN = 1,
67 HELLO_RETRIES_DEFAULT = 3,
68 HELLO_RETRIES_MAX = 15
69};
70
71enum {
72 HELLO_TIMEOUT_MIN = 1,
73 HELLO_TIMEOUT_DEFAULT = 3,
74 HELLO_TIMEOUT_MAX = 15
75};
76
77enum {
78 HELLO_INTERVAL_MIN = 30,
79 HELLO_INTERVAL_DEFAULT = 60,
80 HELLO_INTERVAL_MAX =90
81};
82
83enum {
84 MAX_FACES_PER_PREFIX_MIN = 0,
alvya2228c62014-12-09 10:25:11 -060085 MAX_FACES_PER_PREFIX_DEFAULT = 0,
akmhoque157b0a42014-05-13 00:26:37 -050086 MAX_FACES_PER_PREFIX_MAX = 60
87};
88
Nick Gordon5c467f02016-07-13 13:40:10 -050089enum HyperbolicState {
akmhoque157b0a42014-05-13 00:26:37 -050090 HYPERBOLIC_STATE_OFF = 0,
91 HYPERBOLIC_STATE_ON = 1,
alvya2228c62014-12-09 10:25:11 -060092 HYPERBOLIC_STATE_DRY_RUN = 2,
93 HYPERBOLIC_STATE_DEFAULT = 0
akmhoque157b0a42014-05-13 00:26:37 -050094};
95
akmhoque53353462014-04-22 08:43:45 -050096class ConfParameter
97{
98
99public:
100 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -0500101 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
Vince Lehman7b616582014-10-17 16:25:39 -0500102 , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
103 , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
104 , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700105 , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -0700106 , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
akmhoque157b0a42014-05-13 00:26:37 -0500107 , m_logLevel("INFO")
108 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
109 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
110 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
111 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -0500112 , m_corR(0)
113 , m_corTheta(0)
akmhoque157b0a42014-05-13 00:26:37 -0500114 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500115 , m_isLog4cxxConfAvailable(false)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700116 {
117 }
akmhoque53353462014-04-22 08:43:45 -0500118
119 void
akmhoque157b0a42014-05-13 00:26:37 -0500120 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -0500121 {
akmhoque157b0a42014-05-13 00:26:37 -0500122 m_network = networkName;
Ashlesh Gawande44395232016-12-13 14:35:29 -0600123
124 m_chronosyncPrefix.append("localhop");
akmhoquea816bee2014-06-24 14:37:40 -0500125 m_chronosyncPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500126 m_chronosyncPrefix.append("sync");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700127
akmhoque157b0a42014-05-13 00:26:37 -0500128 m_lsaPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500129 m_lsaPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500130 m_lsaPrefix.append("LSA");
akmhoque53353462014-04-22 08:43:45 -0500131 }
132
akmhoque31d1d4b2014-05-05 22:08:14 -0500133 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700134 getNetwork() const
akmhoque53353462014-04-22 08:43:45 -0500135 {
136 return m_network;
137 }
138
139 void
akmhoque157b0a42014-05-13 00:26:37 -0500140 setRouterName(const ndn::Name& routerName)
141 {
142 m_routerName = routerName;
143 }
144
145 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700146 getRouterName() const
akmhoque157b0a42014-05-13 00:26:37 -0500147 {
148 return m_routerName;
149 }
150
151 void
152 setSiteName(const ndn::Name& siteName)
153 {
154 m_siteName = siteName;
155 }
156
157 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700158 getSiteName() const
akmhoque157b0a42014-05-13 00:26:37 -0500159 {
160 return m_siteName;
161 }
162
163 void
akmhoque53353462014-04-22 08:43:45 -0500164 buildRouterPrefix()
165 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500166 m_routerPrefix = m_network;
167 m_routerPrefix.append(m_siteName);
168 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500169 }
170
akmhoque31d1d4b2014-05-05 22:08:14 -0500171 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700172 getRouterPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500173 {
174 return m_routerPrefix;
175 }
176
akmhoque157b0a42014-05-13 00:26:37 -0500177
akmhoque31d1d4b2014-05-05 22:08:14 -0500178 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700179 getChronosyncPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500180 {
akmhoque157b0a42014-05-13 00:26:37 -0500181 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500182 }
183
akmhoque157b0a42014-05-13 00:26:37 -0500184 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700185 getLsaPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500186 {
akmhoque157b0a42014-05-13 00:26:37 -0500187 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500188 }
189
190 void
alvy5a454952014-12-15 12:49:54 -0600191 setLsaRefreshTime(uint32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500192 {
193 m_lsaRefreshTime = lrt;
akmhoque53353462014-04-22 08:43:45 -0500194 }
195
alvy5a454952014-12-15 12:49:54 -0600196 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700197 getLsaRefreshTime() const
akmhoque53353462014-04-22 08:43:45 -0500198 {
199 return m_lsaRefreshTime;
200 }
201
202 void
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700203 setLsaInterestLifetime(const ndn::time::seconds& lifetime)
204 {
205 m_lsaInterestLifetime = lifetime;
206 }
207
208 const ndn::time::seconds&
209 getLsaInterestLifetime() const
210 {
211 return m_lsaInterestLifetime;
212 }
213
214 void
Vince Lehman7b616582014-10-17 16:25:39 -0500215 setAdjLsaBuildInterval(uint32_t interval)
216 {
217 m_adjLsaBuildInterval = interval;
218 }
219
220 uint32_t
221 getAdjLsaBuildInterval() const
222 {
223 return m_adjLsaBuildInterval;
224 }
225
226 void
227 setFirstHelloInterval(uint32_t interval)
228 {
229 m_firstHelloInterval = interval;
230 }
231
232 uint32_t
233 getFirstHelloInterval() const
234 {
235 return m_firstHelloInterval;
236 }
237
238 void
239 setRoutingCalcInterval(uint32_t interval)
240 {
241 m_routingCalcInterval = interval;
242 }
243
244 uint32_t
245 getRoutingCalcInterval() const
246 {
247 return m_routingCalcInterval;
248 }
249
250 void
alvy5a454952014-12-15 12:49:54 -0600251 setRouterDeadInterval(uint32_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500252 {
253 m_routerDeadInterval = rdt;
254 }
255
alvy5a454952014-12-15 12:49:54 -0600256 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700257 getRouterDeadInterval() const
akmhoque53353462014-04-22 08:43:45 -0500258 {
259 return m_routerDeadInterval;
260 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700261
262 void
akmhoque157b0a42014-05-13 00:26:37 -0500263 setLogLevel(const std::string& logLevel)
264 {
265 m_logLevel = logLevel;
266 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700267
268 const std::string&
269 getLogLevel() const
akmhoque157b0a42014-05-13 00:26:37 -0500270 {
271 return m_logLevel;
272 }
akmhoque53353462014-04-22 08:43:45 -0500273
274 void
akmhoque157b0a42014-05-13 00:26:37 -0500275 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500276 {
akmhoque157b0a42014-05-13 00:26:37 -0500277 m_interestRetryNumber = irn;
278 }
279
280 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700281 getInterestRetryNumber() const
akmhoque157b0a42014-05-13 00:26:37 -0500282 {
283 return m_interestRetryNumber;
284 }
285
286 void
alvy5a454952014-12-15 12:49:54 -0600287 setInterestResendTime(uint32_t irt)
akmhoque157b0a42014-05-13 00:26:37 -0500288 {
289 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500290 }
291
alvy5a454952014-12-15 12:49:54 -0600292 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700293 getInterestResendTime() const
akmhoque53353462014-04-22 08:43:45 -0500294 {
akmhoque157b0a42014-05-13 00:26:37 -0500295 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500296 }
297
alvy5a454952014-12-15 12:49:54 -0600298 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700299 getInfoInterestInterval() const
akmhoque53353462014-04-22 08:43:45 -0500300 {
akmhoque157b0a42014-05-13 00:26:37 -0500301 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500302 }
303
304 void
alvy5a454952014-12-15 12:49:54 -0600305 setInfoInterestInterval(uint32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500306 {
akmhoque157b0a42014-05-13 00:26:37 -0500307 m_infoInterestInterval = iii;
308 }
309
310 void
311 setHyperbolicState(int32_t ihc)
312 {
313 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500314 }
315
akmhoquefdbddb12014-05-02 18:35:19 -0500316 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700317 getHyperbolicState() const
akmhoque53353462014-04-22 08:43:45 -0500318 {
akmhoque157b0a42014-05-13 00:26:37 -0500319 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500320 }
321
akmhoque157b0a42014-05-13 00:26:37 -0500322 bool
akmhoque53353462014-04-22 08:43:45 -0500323 setCorR(double cr)
324 {
akmhoque157b0a42014-05-13 00:26:37 -0500325 if ( cr >= 0 ) {
326 m_corR = cr;
327 return true;
328 }
329 return false;
akmhoque53353462014-04-22 08:43:45 -0500330 }
331
332 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700333 getCorR() const
akmhoque53353462014-04-22 08:43:45 -0500334 {
335 return m_corR;
336 }
337
338 void
339 setCorTheta(double ct)
340 {
341 m_corTheta = ct;
342 }
343
344 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700345 getCorTheta() const
akmhoque53353462014-04-22 08:43:45 -0500346 {
347 return m_corTheta;
348 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700349
akmhoque53353462014-04-22 08:43:45 -0500350 void
Vince Lehman942eb7b2014-10-02 10:09:27 -0500351 setMaxFacesPerPrefix(uint32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500352 {
akmhoque157b0a42014-05-13 00:26:37 -0500353 m_maxFacesPerPrefix = mfpp;
akmhoque53353462014-04-22 08:43:45 -0500354 }
355
Vince Lehman942eb7b2014-10-02 10:09:27 -0500356 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700357 getMaxFacesPerPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500358 {
akmhoque157b0a42014-05-13 00:26:37 -0500359 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500360 }
361
362 void
akmhoque674b0b12014-05-20 14:33:28 -0500363 setLogDir(const std::string& logDir)
364 {
365 m_logDir = logDir;
366 }
367
368 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700369 getLogDir() const
akmhoque674b0b12014-05-20 14:33:28 -0500370 {
371 return m_logDir;
372 }
373
374 void
akmhoque157b0a42014-05-13 00:26:37 -0500375 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500376 {
akmhoque157b0a42014-05-13 00:26:37 -0500377 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500378 }
379
akmhoque157b0a42014-05-13 00:26:37 -0500380 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700381 getSeqFileDir() const
akmhoque53353462014-04-22 08:43:45 -0500382 {
akmhoque157b0a42014-05-13 00:26:37 -0500383 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500384 }
385
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500386 bool
387 isLog4CxxConfAvailable() const
388 {
389 return m_isLog4cxxConfAvailable;
390 }
391
392 void
393 setLog4CxxConfPath(const std::string& path)
394 {
395 m_log4CxxConfPath = path;
396 m_isLog4cxxConfAvailable = true;
397 }
398
399 const std::string&
400 getLog4CxxConfPath() const
401 {
402 return m_log4CxxConfPath;
403 }
404
akmhoque674b0b12014-05-20 14:33:28 -0500405 void
406 writeLog();
akmhoque53353462014-04-22 08:43:45 -0500407
408private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500409 ndn::Name m_routerName;
410 ndn::Name m_siteName;
411 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500412
akmhoque31d1d4b2014-05-05 22:08:14 -0500413 ndn::Name m_routerPrefix;
414 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500415
akmhoque157b0a42014-05-13 00:26:37 -0500416 ndn::Name m_chronosyncPrefix;
417 ndn::Name m_lsaPrefix;
418
alvy5a454952014-12-15 12:49:54 -0600419 uint32_t m_lsaRefreshTime;
Vince Lehman7b616582014-10-17 16:25:39 -0500420
421 uint32_t m_adjLsaBuildInterval;
422 uint32_t m_firstHelloInterval;
423 uint32_t m_routingCalcInterval;
424
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700425 ndn::time::seconds m_lsaInterestLifetime;
alvy5a454952014-12-15 12:49:54 -0600426 uint32_t m_routerDeadInterval;
akmhoque157b0a42014-05-13 00:26:37 -0500427 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500428
akmhoquefdbddb12014-05-02 18:35:19 -0500429 uint32_t m_interestRetryNumber;
alvy5a454952014-12-15 12:49:54 -0600430 uint32_t m_interestResendTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700431
alvy5a454952014-12-15 12:49:54 -0600432 uint32_t m_infoInterestInterval;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700433
akmhoque157b0a42014-05-13 00:26:37 -0500434 int32_t m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500435 double m_corR;
436 double m_corTheta;
437
Vince Lehman942eb7b2014-10-02 10:09:27 -0500438 uint32_t m_maxFacesPerPrefix;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700439
akmhoque674b0b12014-05-20 14:33:28 -0500440 std::string m_logDir;
akmhoque157b0a42014-05-13 00:26:37 -0500441 std::string m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500442
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500443 bool m_isLog4cxxConfAvailable;
444 std::string m_log4CxxConfPath;
akmhoque53353462014-04-22 08:43:45 -0500445};
446
akmhoque53353462014-04-22 08:43:45 -0500447} // namespace nlsr
448
akmhoquefdbddb12014-05-02 18:35:19 -0500449#endif //CONF_PARAMETER_HPP