blob: 6f51d7034d49f615162adaa750f2e9e111fcab3d [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)))
akmhoque157b0a42014-05-13 00:26:37 -0500105 , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT)
106 , 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)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700114 {
115 }
akmhoque53353462014-04-22 08:43:45 -0500116
117 void
akmhoque157b0a42014-05-13 00:26:37 -0500118 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -0500119 {
akmhoque157b0a42014-05-13 00:26:37 -0500120 m_network = networkName;
121 m_chronosyncPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500122 m_chronosyncPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500123 m_chronosyncPrefix.append("sync");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700124
akmhoque157b0a42014-05-13 00:26:37 -0500125 m_lsaPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500126 m_lsaPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500127 m_lsaPrefix.append("LSA");
akmhoque53353462014-04-22 08:43:45 -0500128 }
129
akmhoque31d1d4b2014-05-05 22:08:14 -0500130 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700131 getNetwork() const
akmhoque53353462014-04-22 08:43:45 -0500132 {
133 return m_network;
134 }
135
136 void
akmhoque157b0a42014-05-13 00:26:37 -0500137 setRouterName(const ndn::Name& routerName)
138 {
139 m_routerName = routerName;
140 }
141
142 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700143 getRouterName() const
akmhoque157b0a42014-05-13 00:26:37 -0500144 {
145 return m_routerName;
146 }
147
148 void
149 setSiteName(const ndn::Name& siteName)
150 {
151 m_siteName = siteName;
152 }
153
154 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700155 getSiteName() const
akmhoque157b0a42014-05-13 00:26:37 -0500156 {
157 return m_siteName;
158 }
159
160 void
akmhoque53353462014-04-22 08:43:45 -0500161 buildRouterPrefix()
162 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500163 m_routerPrefix = m_network;
164 m_routerPrefix.append(m_siteName);
165 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500166 }
167
akmhoque31d1d4b2014-05-05 22:08:14 -0500168 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700169 getRouterPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500170 {
171 return m_routerPrefix;
172 }
173
akmhoque157b0a42014-05-13 00:26:37 -0500174
akmhoque31d1d4b2014-05-05 22:08:14 -0500175 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700176 getChronosyncPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500177 {
akmhoque157b0a42014-05-13 00:26:37 -0500178 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500179 }
180
akmhoque157b0a42014-05-13 00:26:37 -0500181 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700182 getLsaPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500183 {
akmhoque157b0a42014-05-13 00:26:37 -0500184 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500185 }
186
187 void
akmhoquefdbddb12014-05-02 18:35:19 -0500188 setLsaRefreshTime(int32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500189 {
190 m_lsaRefreshTime = lrt;
191 m_routerDeadInterval = 2 * m_lsaRefreshTime;
192 }
193
akmhoquefdbddb12014-05-02 18:35:19 -0500194 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700195 getLsaRefreshTime() const
akmhoque53353462014-04-22 08:43:45 -0500196 {
197 return m_lsaRefreshTime;
198 }
199
200 void
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700201 setLsaInterestLifetime(const ndn::time::seconds& lifetime)
202 {
203 m_lsaInterestLifetime = lifetime;
204 }
205
206 const ndn::time::seconds&
207 getLsaInterestLifetime() const
208 {
209 return m_lsaInterestLifetime;
210 }
211
212 void
Vince Lehman7b616582014-10-17 16:25:39 -0500213 setAdjLsaBuildInterval(uint32_t interval)
214 {
215 m_adjLsaBuildInterval = interval;
216 }
217
218 uint32_t
219 getAdjLsaBuildInterval() const
220 {
221 return m_adjLsaBuildInterval;
222 }
223
224 void
225 setFirstHelloInterval(uint32_t interval)
226 {
227 m_firstHelloInterval = interval;
228 }
229
230 uint32_t
231 getFirstHelloInterval() const
232 {
233 return m_firstHelloInterval;
234 }
235
236 void
237 setRoutingCalcInterval(uint32_t interval)
238 {
239 m_routingCalcInterval = interval;
240 }
241
242 uint32_t
243 getRoutingCalcInterval() const
244 {
245 return m_routingCalcInterval;
246 }
247
248 void
akmhoquefdbddb12014-05-02 18:35:19 -0500249 setRouterDeadInterval(int64_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500250 {
251 m_routerDeadInterval = rdt;
252 }
253
akmhoquefdbddb12014-05-02 18:35:19 -0500254 int64_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700255 getRouterDeadInterval() const
akmhoque53353462014-04-22 08:43:45 -0500256 {
257 return m_routerDeadInterval;
258 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700259
260 void
akmhoque157b0a42014-05-13 00:26:37 -0500261 setLogLevel(const std::string& logLevel)
262 {
263 m_logLevel = logLevel;
264 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700265
266 const std::string&
267 getLogLevel() const
akmhoque157b0a42014-05-13 00:26:37 -0500268 {
269 return m_logLevel;
270 }
akmhoque53353462014-04-22 08:43:45 -0500271
272 void
akmhoque157b0a42014-05-13 00:26:37 -0500273 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500274 {
akmhoque157b0a42014-05-13 00:26:37 -0500275 m_interestRetryNumber = irn;
276 }
277
278 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700279 getInterestRetryNumber() const
akmhoque157b0a42014-05-13 00:26:37 -0500280 {
281 return m_interestRetryNumber;
282 }
283
284 void
285 setInterestResendTime(int32_t irt)
286 {
287 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500288 }
289
akmhoquefdbddb12014-05-02 18:35:19 -0500290 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700291 getInterestResendTime() const
akmhoque53353462014-04-22 08:43:45 -0500292 {
akmhoque157b0a42014-05-13 00:26:37 -0500293 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500294 }
295
akmhoquefdbddb12014-05-02 18:35:19 -0500296 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700297 getInfoInterestInterval() const
akmhoque53353462014-04-22 08:43:45 -0500298 {
akmhoque157b0a42014-05-13 00:26:37 -0500299 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500300 }
301
302 void
akmhoque157b0a42014-05-13 00:26:37 -0500303 setInfoInterestInterval(int32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500304 {
akmhoque157b0a42014-05-13 00:26:37 -0500305 m_infoInterestInterval = iii;
306 }
307
308 void
309 setHyperbolicState(int32_t ihc)
310 {
311 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500312 }
313
akmhoquefdbddb12014-05-02 18:35:19 -0500314 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700315 getHyperbolicState() const
akmhoque53353462014-04-22 08:43:45 -0500316 {
akmhoque157b0a42014-05-13 00:26:37 -0500317 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500318 }
319
akmhoque157b0a42014-05-13 00:26:37 -0500320 bool
akmhoque53353462014-04-22 08:43:45 -0500321 setCorR(double cr)
322 {
akmhoque157b0a42014-05-13 00:26:37 -0500323 if ( cr >= 0 ) {
324 m_corR = cr;
325 return true;
326 }
327 return false;
akmhoque53353462014-04-22 08:43:45 -0500328 }
329
330 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700331 getCorR() const
akmhoque53353462014-04-22 08:43:45 -0500332 {
333 return m_corR;
334 }
335
336 void
337 setCorTheta(double ct)
338 {
339 m_corTheta = ct;
340 }
341
342 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700343 getCorTheta() const
akmhoque53353462014-04-22 08:43:45 -0500344 {
345 return m_corTheta;
346 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700347
akmhoque53353462014-04-22 08:43:45 -0500348 void
Vince Lehman942eb7b2014-10-02 10:09:27 -0500349 setMaxFacesPerPrefix(uint32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500350 {
akmhoque157b0a42014-05-13 00:26:37 -0500351 m_maxFacesPerPrefix = mfpp;
akmhoque53353462014-04-22 08:43:45 -0500352 }
353
Vince Lehman942eb7b2014-10-02 10:09:27 -0500354 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700355 getMaxFacesPerPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500356 {
akmhoque157b0a42014-05-13 00:26:37 -0500357 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500358 }
359
360 void
akmhoque674b0b12014-05-20 14:33:28 -0500361 setLogDir(const std::string& logDir)
362 {
363 m_logDir = logDir;
364 }
365
366 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700367 getLogDir() const
akmhoque674b0b12014-05-20 14:33:28 -0500368 {
369 return m_logDir;
370 }
371
372 void
akmhoque157b0a42014-05-13 00:26:37 -0500373 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500374 {
akmhoque157b0a42014-05-13 00:26:37 -0500375 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500376 }
377
akmhoque157b0a42014-05-13 00:26:37 -0500378 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700379 getSeqFileDir() const
akmhoque53353462014-04-22 08:43:45 -0500380 {
akmhoque157b0a42014-05-13 00:26:37 -0500381 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500382 }
383
akmhoque674b0b12014-05-20 14:33:28 -0500384 void
385 writeLog();
akmhoque53353462014-04-22 08:43:45 -0500386
387private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500388 ndn::Name m_routerName;
389 ndn::Name m_siteName;
390 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500391
akmhoque31d1d4b2014-05-05 22:08:14 -0500392 ndn::Name m_routerPrefix;
393 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500394
akmhoque157b0a42014-05-13 00:26:37 -0500395 ndn::Name m_chronosyncPrefix;
396 ndn::Name m_lsaPrefix;
397
398 int32_t m_lsaRefreshTime;
Vince Lehman7b616582014-10-17 16:25:39 -0500399
400 uint32_t m_adjLsaBuildInterval;
401 uint32_t m_firstHelloInterval;
402 uint32_t m_routingCalcInterval;
403
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700404 ndn::time::seconds m_lsaInterestLifetime;
akmhoque157b0a42014-05-13 00:26:37 -0500405 int64_t m_routerDeadInterval;
406 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500407
akmhoquefdbddb12014-05-02 18:35:19 -0500408 uint32_t m_interestRetryNumber;
akmhoque157b0a42014-05-13 00:26:37 -0500409 int32_t m_interestResendTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700410
411
akmhoque157b0a42014-05-13 00:26:37 -0500412 int32_t m_infoInterestInterval;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700413
akmhoque157b0a42014-05-13 00:26:37 -0500414 int32_t m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500415 double m_corR;
416 double m_corTheta;
417
Vince Lehman942eb7b2014-10-02 10:09:27 -0500418 uint32_t m_maxFacesPerPrefix;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700419
akmhoque674b0b12014-05-20 14:33:28 -0500420 std::string m_logDir;
akmhoque157b0a42014-05-13 00:26:37 -0500421 std::string m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500422
423};
424
akmhoque53353462014-04-22 08:43:45 -0500425} // namespace nlsr
426
akmhoquefdbddb12014-05-02 18:35:19 -0500427#endif //CONF_PARAMETER_HPP