blob: 9c227de705c2e92999ade80513742b520d37c4d1 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoquefdbddb12014-05-02 18:35:19 -050023#ifndef CONF_PARAMETER_HPP
24#define CONF_PARAMETER_HPP
akmhoque53353462014-04-22 08:43:45 -050025
26#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -050027#include <boost/cstdint.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -050028#include <ndn-cxx/common.hpp>
29#include <ndn-cxx/face.hpp>
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070030#include <ndn-cxx/util/time.hpp>
akmhoque53353462014-04-22 08:43:45 -050031
akmhoque674b0b12014-05-20 14:33:28 -050032#include "logger.hpp"
33
akmhoque53353462014-04-22 08:43:45 -050034namespace 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
66enum {
akmhoque157b0a42014-05-13 00:26:37 -050067 HELLO_RETRIES_MIN = 1,
68 HELLO_RETRIES_DEFAULT = 3,
69 HELLO_RETRIES_MAX = 15
70};
71
72enum {
73 HELLO_TIMEOUT_MIN = 1,
74 HELLO_TIMEOUT_DEFAULT = 3,
75 HELLO_TIMEOUT_MAX = 15
76};
77
78enum {
79 HELLO_INTERVAL_MIN = 30,
80 HELLO_INTERVAL_DEFAULT = 60,
81 HELLO_INTERVAL_MAX =90
82};
83
84enum {
85 MAX_FACES_PER_PREFIX_MIN = 0,
alvya2228c62014-12-09 10:25:11 -060086 MAX_FACES_PER_PREFIX_DEFAULT = 0,
akmhoque157b0a42014-05-13 00:26:37 -050087 MAX_FACES_PER_PREFIX_MAX = 60
88};
89
90enum {
91 HYPERBOLIC_STATE_OFF = 0,
92 HYPERBOLIC_STATE_ON = 1,
alvya2228c62014-12-09 10:25:11 -060093 HYPERBOLIC_STATE_DRY_RUN = 2,
94 HYPERBOLIC_STATE_DEFAULT = 0
akmhoque157b0a42014-05-13 00:26:37 -050095};
96
akmhoque53353462014-04-22 08:43:45 -050097class ConfParameter
98{
99
100public:
101 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -0500102 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
Vince Lehman7b616582014-10-17 16:25:39 -0500103 , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
104 , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
105 , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700106 , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -0700107 , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
akmhoque157b0a42014-05-13 00:26:37 -0500108 , m_logLevel("INFO")
109 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
110 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
111 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
112 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -0500113 , m_corR(0)
114 , m_corTheta(0)
akmhoque157b0a42014-05-13 00:26:37 -0500115 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500116 , m_isLog4cxxConfAvailable(false)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700117 {
118 }
akmhoque53353462014-04-22 08:43:45 -0500119
120 void
akmhoque157b0a42014-05-13 00:26:37 -0500121 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -0500122 {
akmhoque157b0a42014-05-13 00:26:37 -0500123 m_network = networkName;
124 m_chronosyncPrefix = m_network;
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