blob: b8b5b724197b387be4fd79b4bd9af8b791207a37 [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 {
akmhoque157b0a42014-05-13 00:26:37 -050049 HELLO_RETRIES_MIN = 1,
50 HELLO_RETRIES_DEFAULT = 3,
51 HELLO_RETRIES_MAX = 15
52};
53
54enum {
55 HELLO_TIMEOUT_MIN = 1,
56 HELLO_TIMEOUT_DEFAULT = 3,
57 HELLO_TIMEOUT_MAX = 15
58};
59
60enum {
61 HELLO_INTERVAL_MIN = 30,
62 HELLO_INTERVAL_DEFAULT = 60,
63 HELLO_INTERVAL_MAX =90
64};
65
66enum {
67 MAX_FACES_PER_PREFIX_MIN = 0,
68 MAX_FACES_PER_PREFIX_MAX = 60
69};
70
71enum {
72 HYPERBOLIC_STATE_OFF = 0,
73 HYPERBOLIC_STATE_ON = 1,
74 HYPERBOLIC_STATE_DRY_RUN = 2
75};
76
akmhoque53353462014-04-22 08:43:45 -050077class ConfParameter
78{
79
80public:
81 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -050082 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070083 , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
akmhoque157b0a42014-05-13 00:26:37 -050084 , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT)
85 , m_logLevel("INFO")
86 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
87 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
88 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
89 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -050090 , m_corR(0)
91 , m_corTheta(0)
akmhoque157b0a42014-05-13 00:26:37 -050092 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070093 {
94 }
akmhoque53353462014-04-22 08:43:45 -050095
96 void
akmhoque157b0a42014-05-13 00:26:37 -050097 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -050098 {
akmhoque157b0a42014-05-13 00:26:37 -050099 m_network = networkName;
100 m_chronosyncPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500101 m_chronosyncPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500102 m_chronosyncPrefix.append("sync");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700103
akmhoque157b0a42014-05-13 00:26:37 -0500104 m_lsaPrefix = m_network;
akmhoquea816bee2014-06-24 14:37:40 -0500105 m_lsaPrefix.append("NLSR");
akmhoque157b0a42014-05-13 00:26:37 -0500106 m_lsaPrefix.append("LSA");
akmhoque53353462014-04-22 08:43:45 -0500107 }
108
akmhoque31d1d4b2014-05-05 22:08:14 -0500109 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700110 getNetwork() const
akmhoque53353462014-04-22 08:43:45 -0500111 {
112 return m_network;
113 }
114
115 void
akmhoque157b0a42014-05-13 00:26:37 -0500116 setRouterName(const ndn::Name& routerName)
117 {
118 m_routerName = routerName;
119 }
120
121 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700122 getRouterName() const
akmhoque157b0a42014-05-13 00:26:37 -0500123 {
124 return m_routerName;
125 }
126
127 void
128 setSiteName(const ndn::Name& siteName)
129 {
130 m_siteName = siteName;
131 }
132
133 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700134 getSiteName() const
akmhoque157b0a42014-05-13 00:26:37 -0500135 {
136 return m_siteName;
137 }
138
139 void
akmhoque53353462014-04-22 08:43:45 -0500140 buildRouterPrefix()
141 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500142 m_routerPrefix = m_network;
143 m_routerPrefix.append(m_siteName);
144 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500145 }
146
akmhoque31d1d4b2014-05-05 22:08:14 -0500147 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700148 getRouterPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500149 {
150 return m_routerPrefix;
151 }
152
akmhoque157b0a42014-05-13 00:26:37 -0500153
akmhoque31d1d4b2014-05-05 22:08:14 -0500154 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700155 getChronosyncPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500156 {
akmhoque157b0a42014-05-13 00:26:37 -0500157 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500158 }
159
akmhoque157b0a42014-05-13 00:26:37 -0500160 const ndn::Name&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700161 getLsaPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500162 {
akmhoque157b0a42014-05-13 00:26:37 -0500163 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500164 }
165
166 void
akmhoquefdbddb12014-05-02 18:35:19 -0500167 setLsaRefreshTime(int32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500168 {
169 m_lsaRefreshTime = lrt;
170 m_routerDeadInterval = 2 * m_lsaRefreshTime;
171 }
172
akmhoquefdbddb12014-05-02 18:35:19 -0500173 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700174 getLsaRefreshTime() const
akmhoque53353462014-04-22 08:43:45 -0500175 {
176 return m_lsaRefreshTime;
177 }
178
179 void
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700180 setLsaInterestLifetime(const ndn::time::seconds& lifetime)
181 {
182 m_lsaInterestLifetime = lifetime;
183 }
184
185 const ndn::time::seconds&
186 getLsaInterestLifetime() const
187 {
188 return m_lsaInterestLifetime;
189 }
190
191 void
akmhoquefdbddb12014-05-02 18:35:19 -0500192 setRouterDeadInterval(int64_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500193 {
194 m_routerDeadInterval = rdt;
195 }
196
akmhoquefdbddb12014-05-02 18:35:19 -0500197 int64_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700198 getRouterDeadInterval() const
akmhoque53353462014-04-22 08:43:45 -0500199 {
200 return m_routerDeadInterval;
201 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700202
203 void
akmhoque157b0a42014-05-13 00:26:37 -0500204 setLogLevel(const std::string& logLevel)
205 {
206 m_logLevel = logLevel;
207 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700208
209 const std::string&
210 getLogLevel() const
akmhoque157b0a42014-05-13 00:26:37 -0500211 {
212 return m_logLevel;
213 }
akmhoque53353462014-04-22 08:43:45 -0500214
215 void
akmhoque157b0a42014-05-13 00:26:37 -0500216 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500217 {
akmhoque157b0a42014-05-13 00:26:37 -0500218 m_interestRetryNumber = irn;
219 }
220
221 uint32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700222 getInterestRetryNumber() const
akmhoque157b0a42014-05-13 00:26:37 -0500223 {
224 return m_interestRetryNumber;
225 }
226
227 void
228 setInterestResendTime(int32_t irt)
229 {
230 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500231 }
232
akmhoquefdbddb12014-05-02 18:35:19 -0500233 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700234 getInterestResendTime() const
akmhoque53353462014-04-22 08:43:45 -0500235 {
akmhoque157b0a42014-05-13 00:26:37 -0500236 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500237 }
238
akmhoquefdbddb12014-05-02 18:35:19 -0500239 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700240 getInfoInterestInterval() const
akmhoque53353462014-04-22 08:43:45 -0500241 {
akmhoque157b0a42014-05-13 00:26:37 -0500242 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500243 }
244
245 void
akmhoque157b0a42014-05-13 00:26:37 -0500246 setInfoInterestInterval(int32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500247 {
akmhoque157b0a42014-05-13 00:26:37 -0500248 m_infoInterestInterval = iii;
249 }
250
251 void
252 setHyperbolicState(int32_t ihc)
253 {
254 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500255 }
256
akmhoquefdbddb12014-05-02 18:35:19 -0500257 int32_t
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700258 getHyperbolicState() const
akmhoque53353462014-04-22 08:43:45 -0500259 {
akmhoque157b0a42014-05-13 00:26:37 -0500260 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500261 }
262
akmhoque157b0a42014-05-13 00:26:37 -0500263 bool
akmhoque53353462014-04-22 08:43:45 -0500264 setCorR(double cr)
265 {
akmhoque157b0a42014-05-13 00:26:37 -0500266 if ( cr >= 0 ) {
267 m_corR = cr;
268 return true;
269 }
270 return false;
akmhoque53353462014-04-22 08:43:45 -0500271 }
272
273 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700274 getCorR() const
akmhoque53353462014-04-22 08:43:45 -0500275 {
276 return m_corR;
277 }
278
279 void
280 setCorTheta(double ct)
281 {
282 m_corTheta = ct;
283 }
284
285 double
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700286 getCorTheta() const
akmhoque53353462014-04-22 08:43:45 -0500287 {
288 return m_corTheta;
289 }
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700290
akmhoque53353462014-04-22 08:43:45 -0500291 void
akmhoque157b0a42014-05-13 00:26:37 -0500292 setMaxFacesPerPrefix(int32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500293 {
akmhoque157b0a42014-05-13 00:26:37 -0500294 m_maxFacesPerPrefix = mfpp;
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 getMaxFacesPerPrefix() const
akmhoque53353462014-04-22 08:43:45 -0500299 {
akmhoque157b0a42014-05-13 00:26:37 -0500300 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500301 }
302
303 void
akmhoque674b0b12014-05-20 14:33:28 -0500304 setLogDir(const std::string& logDir)
305 {
306 m_logDir = logDir;
307 }
308
309 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700310 getLogDir() const
akmhoque674b0b12014-05-20 14:33:28 -0500311 {
312 return m_logDir;
313 }
314
315 void
akmhoque157b0a42014-05-13 00:26:37 -0500316 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500317 {
akmhoque157b0a42014-05-13 00:26:37 -0500318 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500319 }
320
akmhoque157b0a42014-05-13 00:26:37 -0500321 const std::string&
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700322 getSeqFileDir() const
akmhoque53353462014-04-22 08:43:45 -0500323 {
akmhoque157b0a42014-05-13 00:26:37 -0500324 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500325 }
326
akmhoque674b0b12014-05-20 14:33:28 -0500327 void
328 writeLog();
akmhoque53353462014-04-22 08:43:45 -0500329
330private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500331 ndn::Name m_routerName;
332 ndn::Name m_siteName;
333 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500334
akmhoque31d1d4b2014-05-05 22:08:14 -0500335 ndn::Name m_routerPrefix;
336 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500337
akmhoque157b0a42014-05-13 00:26:37 -0500338 ndn::Name m_chronosyncPrefix;
339 ndn::Name m_lsaPrefix;
340
341 int32_t m_lsaRefreshTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700342 ndn::time::seconds m_lsaInterestLifetime;
akmhoque157b0a42014-05-13 00:26:37 -0500343 int64_t m_routerDeadInterval;
344 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500345
akmhoquefdbddb12014-05-02 18:35:19 -0500346 uint32_t m_interestRetryNumber;
akmhoque157b0a42014-05-13 00:26:37 -0500347 int32_t m_interestResendTime;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700348
349
akmhoque157b0a42014-05-13 00:26:37 -0500350 int32_t m_infoInterestInterval;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700351
akmhoque157b0a42014-05-13 00:26:37 -0500352 int32_t m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500353 double m_corR;
354 double m_corTheta;
355
akmhoque157b0a42014-05-13 00:26:37 -0500356 int32_t m_maxFacesPerPrefix;
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -0700357
akmhoque674b0b12014-05-20 14:33:28 -0500358 std::string m_logDir;
akmhoque157b0a42014-05-13 00:26:37 -0500359 std::string m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500360
361};
362
akmhoque53353462014-04-22 08:43:45 -0500363} // namespace nlsr
364
akmhoquefdbddb12014-05-02 18:35:19 -0500365#endif //CONF_PARAMETER_HPP