blob: e25c4d34b2692239b6ecd1fb1422df830c71e0e3 [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,
86 MAX_FACES_PER_PREFIX_MAX = 60
87};
88
89enum {
90 HYPERBOLIC_STATE_OFF = 0,
91 HYPERBOLIC_STATE_ON = 1,
92 HYPERBOLIC_STATE_DRY_RUN = 2
93};
94
akmhoque53353462014-04-22 08:43:45 -050095class ConfParameter
96{
97
98public:
99 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -0500100 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
Vince Lehman7b616582014-10-17 16:25:39 -0500101 , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
102 , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
103 , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700104 , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
Alexander Afanasyev1cf1e102014-08-17 19:47:57 -0700105 , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
akmhoque157b0a42014-05-13 00:26:37 -0500106 , m_logLevel("INFO")
107 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
108 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
109 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
110 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -0500111 , m_corR(0)
112 , m_corTheta(0)
akmhoque157b0a42014-05-13 00:26:37 -0500113 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500114 , m_isLog4cxxConfAvailable(false)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700115 {
116 }
akmhoque53353462014-04-22 08:43:45 -0500117
118 void
akmhoque157b0a42014-05-13 00:26:37 -0500119 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -0500120 {
akmhoque157b0a42014-05-13 00:26:37 -0500121 m_network = networkName;
122 m_chronosyncPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500123 m_chronosyncPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500124 m_chronosyncPrefix.append("sync");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700125
akmhoque157b0a42014-05-13 00:26:37 -0500126 m_lsaPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500127 m_lsaPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500128 m_lsaPrefix.append("LSA");
akmhoque53353462014-04-22 08:43:45 -0500129 }
130
akmhoque31d1d4b2014-05-05 22:08:14 -0500131 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700132 getNetwork() const
akmhoque53353462014-04-22 08:43:45 -0500133 {
134 return m_network;
135 }
136
137 void
akmhoque157b0a42014-05-13 00:26:37 -0500138 setRouterName(const ndn::Name& routerName)
139 {
140 m_routerName = routerName;
141 }
142
143 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700144 getRouterName() const
akmhoque157b0a42014-05-13 00:26:37 -0500145 {
146 return m_routerName;
147 }
148
149 void
150 setSiteName(const ndn::Name& siteName)
151 {
152 m_siteName = siteName;
153 }
154
155 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700156 getSiteName() const
akmhoque157b0a42014-05-13 00:26:37 -0500157 {
158 return m_siteName;
159 }
160
161 void
akmhoque53353462014-04-22 08:43:45 -0500162 buildRouterPrefix()
163 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500164 m_routerPrefix = m_network;
165 m_routerPrefix.append(m_siteName);
166 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500167 }
168
akmhoque31d1d4b2014-05-05 22:08:14 -0500169 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700170 getRouterPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500171 {
172 return m_routerPrefix;
173 }
174
akmhoque157b0a42014-05-13 00:26:37 -0500175
akmhoque31d1d4b2014-05-05 22:08:14 -0500176 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700177 getChronosyncPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500178 {
akmhoque157b0a42014-05-13 00:26:37 -0500179 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500180 }
181
akmhoque157b0a42014-05-13 00:26:37 -0500182 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700183 getLsaPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500184 {
akmhoque157b0a42014-05-13 00:26:37 -0500185 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500186 }
187
188 void
akmhoquefdbddb12014-05-02 18:35:19 -0500189 setLsaRefreshTime(int32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500190 {
191 m_lsaRefreshTime = lrt;
192 m_routerDeadInterval = 2 * m_lsaRefreshTime;
193 }
194
akmhoquefdbddb12014-05-02 18:35:19 -0500195 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700196 getLsaRefreshTime() const
akmhoque53353462014-04-22 08:43:45 -0500197 {
198 return m_lsaRefreshTime;
199 }
200
201 void
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700202 setLsaInterestLifetime(const ndn::time::seconds& lifetime)
203 {
204 m_lsaInterestLifetime = lifetime;
205 }
206
207 const ndn::time::seconds&
208 getLsaInterestLifetime() const
209 {
210 return m_lsaInterestLifetime;
211 }
212
213 void
Vince Lehman7b616582014-10-17 16:25:39 -0500214 setAdjLsaBuildInterval(uint32_t interval)
215 {
216 m_adjLsaBuildInterval = interval;
217 }
218
219 uint32_t
220 getAdjLsaBuildInterval() const
221 {
222 return m_adjLsaBuildInterval;
223 }
224
225 void
226 setFirstHelloInterval(uint32_t interval)
227 {
228 m_firstHelloInterval = interval;
229 }
230
231 uint32_t
232 getFirstHelloInterval() const
233 {
234 return m_firstHelloInterval;
235 }
236
237 void
238 setRoutingCalcInterval(uint32_t interval)
239 {
240 m_routingCalcInterval = interval;
241 }
242
243 uint32_t
244 getRoutingCalcInterval() const
245 {
246 return m_routingCalcInterval;
247 }
248
249 void
akmhoquefdbddb12014-05-02 18:35:19 -0500250 setRouterDeadInterval(int64_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500251 {
252 m_routerDeadInterval = rdt;
253 }
254
akmhoquefdbddb12014-05-02 18:35:19 -0500255 int64_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700256 getRouterDeadInterval() const
akmhoque53353462014-04-22 08:43:45 -0500257 {
258 return m_routerDeadInterval;
259 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700260
261 void
akmhoque157b0a42014-05-13 00:26:37 -0500262 setLogLevel(const std::string& logLevel)
263 {
264 m_logLevel = logLevel;
265 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700266
267 const std::string&
268 getLogLevel() const
akmhoque157b0a42014-05-13 00:26:37 -0500269 {
270 return m_logLevel;
271 }
akmhoque53353462014-04-22 08:43:45 -0500272
273 void
akmhoque157b0a42014-05-13 00:26:37 -0500274 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500275 {
akmhoque157b0a42014-05-13 00:26:37 -0500276 m_interestRetryNumber = irn;
277 }
278
279 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700280 getInterestRetryNumber() const
akmhoque157b0a42014-05-13 00:26:37 -0500281 {
282 return m_interestRetryNumber;
283 }
284
285 void
286 setInterestResendTime(int32_t irt)
287 {
288 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500289 }
290
akmhoquefdbddb12014-05-02 18:35:19 -0500291 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700292 getInterestResendTime() const
akmhoque53353462014-04-22 08:43:45 -0500293 {
akmhoque157b0a42014-05-13 00:26:37 -0500294 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500295 }
296
akmhoquefdbddb12014-05-02 18:35:19 -0500297 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700298 getInfoInterestInterval() const
akmhoque53353462014-04-22 08:43:45 -0500299 {
akmhoque157b0a42014-05-13 00:26:37 -0500300 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500301 }
302
303 void
akmhoque157b0a42014-05-13 00:26:37 -0500304 setInfoInterestInterval(int32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500305 {
akmhoque157b0a42014-05-13 00:26:37 -0500306 m_infoInterestInterval = iii;
307 }
308
309 void
310 setHyperbolicState(int32_t ihc)
311 {
312 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500313 }
314
akmhoquefdbddb12014-05-02 18:35:19 -0500315 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700316 getHyperbolicState() const
akmhoque53353462014-04-22 08:43:45 -0500317 {
akmhoque157b0a42014-05-13 00:26:37 -0500318 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500319 }
320
akmhoque157b0a42014-05-13 00:26:37 -0500321 bool
akmhoque53353462014-04-22 08:43:45 -0500322 setCorR(double cr)
323 {
akmhoque157b0a42014-05-13 00:26:37 -0500324 if ( cr >= 0 ) {
325 m_corR = cr;
326 return true;
327 }
328 return false;
akmhoque53353462014-04-22 08:43:45 -0500329 }
330
331 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700332 getCorR() const
akmhoque53353462014-04-22 08:43:45 -0500333 {
334 return m_corR;
335 }
336
337 void
338 setCorTheta(double ct)
339 {
340 m_corTheta = ct;
341 }
342
343 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700344 getCorTheta() const
akmhoque53353462014-04-22 08:43:45 -0500345 {
346 return m_corTheta;
347 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700348
akmhoque53353462014-04-22 08:43:45 -0500349 void
Vince Lehman942eb7b2014-10-02 10:09:27 -0500350 setMaxFacesPerPrefix(uint32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500351 {
akmhoque157b0a42014-05-13 00:26:37 -0500352 m_maxFacesPerPrefix = mfpp;
akmhoque53353462014-04-22 08:43:45 -0500353 }
354
Vince Lehman942eb7b2014-10-02 10:09:27 -0500355 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700356 getMaxFacesPerPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500357 {
akmhoque157b0a42014-05-13 00:26:37 -0500358 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500359 }
360
361 void
akmhoque674b0b12014-05-20 14:33:28 -0500362 setLogDir(const std::string& logDir)
363 {
364 m_logDir = logDir;
365 }
366
367 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700368 getLogDir() const
akmhoque674b0b12014-05-20 14:33:28 -0500369 {
370 return m_logDir;
371 }
372
373 void
akmhoque157b0a42014-05-13 00:26:37 -0500374 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500375 {
akmhoque157b0a42014-05-13 00:26:37 -0500376 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500377 }
378
akmhoque157b0a42014-05-13 00:26:37 -0500379 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700380 getSeqFileDir() const
akmhoque53353462014-04-22 08:43:45 -0500381 {
akmhoque157b0a42014-05-13 00:26:37 -0500382 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500383 }
384
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -0500385 bool
386 isLog4CxxConfAvailable() const
387 {
388 return m_isLog4cxxConfAvailable;
389 }
390
391 void
392 setLog4CxxConfPath(const std::string& path)
393 {
394 m_log4CxxConfPath = path;
395 m_isLog4cxxConfAvailable = true;
396 }
397
398 const std::string&
399 getLog4CxxConfPath() const
400 {
401 return m_log4CxxConfPath;
402 }
403
akmhoque674b0b12014-05-20 14:33:28 -0500404 void
405 writeLog();
akmhoque53353462014-04-22 08:43:45 -0500406
407private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500408 ndn::Name m_routerName;
409 ndn::Name m_siteName;
410 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500411
akmhoque31d1d4b2014-05-05 22:08:14 -0500412 ndn::Name m_routerPrefix;
413 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500414
akmhoque157b0a42014-05-13 00:26:37 -0500415 ndn::Name m_chronosyncPrefix;
416 ndn::Name m_lsaPrefix;
417
418 int32_t m_lsaRefreshTime;
Vince Lehman7b616582014-10-17 16:25:39 -0500419
420 uint32_t m_adjLsaBuildInterval;
421 uint32_t m_firstHelloInterval;
422 uint32_t m_routingCalcInterval;
423
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700424 ndn::time::seconds m_lsaInterestLifetime;
akmhoque157b0a42014-05-13 00:26:37 -0500425 int64_t m_routerDeadInterval;
426 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500427
akmhoquefdbddb12014-05-02 18:35:19 -0500428 uint32_t m_interestRetryNumber;
akmhoque157b0a42014-05-13 00:26:37 -0500429 int32_t m_interestResendTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700430
431
akmhoque157b0a42014-05-13 00:26:37 -0500432 int32_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