blob: 6f1dc86d5d485f3dbbcb99f1da4360ebcdbde399 [file] [log] [blame]
akmhoquefdbddb12014-05-02 18:35:19 -05001#ifndef CONF_PARAMETER_HPP
2#define CONF_PARAMETER_HPP
akmhoque53353462014-04-22 08:43:45 -05003
4#include <iostream>
akmhoquefdbddb12014-05-02 18:35:19 -05005#include <boost/cstdint.hpp>
akmhoque31d1d4b2014-05-05 22:08:14 -05006#include <ndn-cxx/common.hpp>
7#include <ndn-cxx/face.hpp>
akmhoque53353462014-04-22 08:43:45 -05008
9namespace nlsr {
akmhoque157b0a42014-05-13 00:26:37 -050010
11enum {
12 LSA_REFRESH_TIME_MIN = 240,
13 LSA_REFRESH_TIME_DEFAULT = 1800,
14 LSA_REFRESH_TIME_MAX = 7200
15};
16
17enum {
18 HELLO_RETRIES_MIN = 1,
19 HELLO_RETRIES_DEFAULT = 3,
20 HELLO_RETRIES_MAX = 15
21};
22
23enum {
24 HELLO_TIMEOUT_MIN = 1,
25 HELLO_TIMEOUT_DEFAULT = 3,
26 HELLO_TIMEOUT_MAX = 15
27};
28
29enum {
30 HELLO_INTERVAL_MIN = 30,
31 HELLO_INTERVAL_DEFAULT = 60,
32 HELLO_INTERVAL_MAX =90
33};
34
35enum {
36 MAX_FACES_PER_PREFIX_MIN = 0,
37 MAX_FACES_PER_PREFIX_MAX = 60
38};
39
40enum {
41 HYPERBOLIC_STATE_OFF = 0,
42 HYPERBOLIC_STATE_ON = 1,
43 HYPERBOLIC_STATE_DRY_RUN = 2
44};
45
akmhoque53353462014-04-22 08:43:45 -050046class ConfParameter
47{
48
49public:
50 ConfParameter()
akmhoque157b0a42014-05-13 00:26:37 -050051 : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
52 , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT)
53 , m_logLevel("INFO")
54 , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
55 , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
56 , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
57 , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
akmhoque53353462014-04-22 08:43:45 -050058 , m_corR(0)
59 , m_corTheta(0)
akmhoque157b0a42014-05-13 00:26:37 -050060 , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
akmhoque53353462014-04-22 08:43:45 -050061 {}
62
63 void
akmhoque157b0a42014-05-13 00:26:37 -050064 setNetwork(const ndn::Name& networkName)
akmhoque53353462014-04-22 08:43:45 -050065 {
akmhoque157b0a42014-05-13 00:26:37 -050066 m_network = networkName;
67 m_chronosyncPrefix = m_network;
68 m_chronosyncPrefix.append("nlsr");
69 m_chronosyncPrefix.append("sync");
70
71 m_lsaPrefix = m_network;
72 m_lsaPrefix.append("nlsr");
73 m_lsaPrefix.append("LSA");
akmhoque53353462014-04-22 08:43:45 -050074 }
75
akmhoque31d1d4b2014-05-05 22:08:14 -050076 const ndn::Name&
akmhoque53353462014-04-22 08:43:45 -050077 getNetwork()
78 {
79 return m_network;
80 }
81
82 void
akmhoque157b0a42014-05-13 00:26:37 -050083 setRouterName(const ndn::Name& routerName)
84 {
85 m_routerName = routerName;
86 }
87
88 const ndn::Name&
89 getRouterName()
90 {
91 return m_routerName;
92 }
93
94 void
95 setSiteName(const ndn::Name& siteName)
96 {
97 m_siteName = siteName;
98 }
99
100 const ndn::Name&
101 getSiteName()
102 {
103 return m_siteName;
104 }
105
106 void
akmhoque53353462014-04-22 08:43:45 -0500107 buildRouterPrefix()
108 {
akmhoque31d1d4b2014-05-05 22:08:14 -0500109 m_routerPrefix = m_network;
110 m_routerPrefix.append(m_siteName);
111 m_routerPrefix.append(m_routerName);
akmhoque53353462014-04-22 08:43:45 -0500112 }
113
akmhoque31d1d4b2014-05-05 22:08:14 -0500114 const ndn::Name&
akmhoque53353462014-04-22 08:43:45 -0500115 getRouterPrefix()
116 {
117 return m_routerPrefix;
118 }
119
akmhoque157b0a42014-05-13 00:26:37 -0500120
akmhoque31d1d4b2014-05-05 22:08:14 -0500121 const ndn::Name&
akmhoque157b0a42014-05-13 00:26:37 -0500122 getChronosyncPrefix()
akmhoque53353462014-04-22 08:43:45 -0500123 {
akmhoque157b0a42014-05-13 00:26:37 -0500124 return m_chronosyncPrefix;
akmhoque53353462014-04-22 08:43:45 -0500125 }
126
akmhoque157b0a42014-05-13 00:26:37 -0500127 const ndn::Name&
128 getLsaPrefix()
akmhoque53353462014-04-22 08:43:45 -0500129 {
akmhoque157b0a42014-05-13 00:26:37 -0500130 return m_lsaPrefix;
akmhoque53353462014-04-22 08:43:45 -0500131 }
132
133 void
akmhoquefdbddb12014-05-02 18:35:19 -0500134 setLsaRefreshTime(int32_t lrt)
akmhoque53353462014-04-22 08:43:45 -0500135 {
136 m_lsaRefreshTime = lrt;
137 m_routerDeadInterval = 2 * m_lsaRefreshTime;
138 }
139
akmhoquefdbddb12014-05-02 18:35:19 -0500140 int32_t
akmhoque53353462014-04-22 08:43:45 -0500141 getLsaRefreshTime()
142 {
143 return m_lsaRefreshTime;
144 }
145
146 void
akmhoquefdbddb12014-05-02 18:35:19 -0500147 setRouterDeadInterval(int64_t rdt)
akmhoque53353462014-04-22 08:43:45 -0500148 {
149 m_routerDeadInterval = rdt;
150 }
151
akmhoquefdbddb12014-05-02 18:35:19 -0500152 int64_t
akmhoque53353462014-04-22 08:43:45 -0500153 getRouterDeadInterval()
154 {
155 return m_routerDeadInterval;
156 }
akmhoque157b0a42014-05-13 00:26:37 -0500157
158 void
159 setLogLevel(const std::string& logLevel)
160 {
161 m_logLevel = logLevel;
162 }
163
164 const std::string&
165 getLogLevel()
166 {
167 return m_logLevel;
168 }
akmhoque53353462014-04-22 08:43:45 -0500169
170 void
akmhoque157b0a42014-05-13 00:26:37 -0500171 setInterestRetryNumber(uint32_t irn)
akmhoque53353462014-04-22 08:43:45 -0500172 {
akmhoque157b0a42014-05-13 00:26:37 -0500173 m_interestRetryNumber = irn;
174 }
175
176 uint32_t
177 getInterestRetryNumber()
178 {
179 return m_interestRetryNumber;
180 }
181
182 void
183 setInterestResendTime(int32_t irt)
184 {
185 m_interestResendTime = irt;
akmhoque53353462014-04-22 08:43:45 -0500186 }
187
akmhoquefdbddb12014-05-02 18:35:19 -0500188 int32_t
akmhoque157b0a42014-05-13 00:26:37 -0500189 getInterestResendTime()
akmhoque53353462014-04-22 08:43:45 -0500190 {
akmhoque157b0a42014-05-13 00:26:37 -0500191 return m_interestResendTime;
akmhoque53353462014-04-22 08:43:45 -0500192 }
193
akmhoquefdbddb12014-05-02 18:35:19 -0500194 int32_t
akmhoque157b0a42014-05-13 00:26:37 -0500195 getInfoInterestInterval()
akmhoque53353462014-04-22 08:43:45 -0500196 {
akmhoque157b0a42014-05-13 00:26:37 -0500197 return m_infoInterestInterval;
akmhoque53353462014-04-22 08:43:45 -0500198 }
199
200 void
akmhoque157b0a42014-05-13 00:26:37 -0500201 setInfoInterestInterval(int32_t iii)
akmhoque53353462014-04-22 08:43:45 -0500202 {
akmhoque157b0a42014-05-13 00:26:37 -0500203 m_infoInterestInterval = iii;
204 }
205
206 void
207 setHyperbolicState(int32_t ihc)
208 {
209 m_hyperbolicState = ihc;
akmhoque53353462014-04-22 08:43:45 -0500210 }
211
akmhoquefdbddb12014-05-02 18:35:19 -0500212 int32_t
akmhoque157b0a42014-05-13 00:26:37 -0500213 getHyperbolicState()
akmhoque53353462014-04-22 08:43:45 -0500214 {
akmhoque157b0a42014-05-13 00:26:37 -0500215 return m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500216 }
217
akmhoque157b0a42014-05-13 00:26:37 -0500218 bool
akmhoque53353462014-04-22 08:43:45 -0500219 setCorR(double cr)
220 {
akmhoque157b0a42014-05-13 00:26:37 -0500221 if ( cr >= 0 ) {
222 m_corR = cr;
223 return true;
224 }
225 return false;
akmhoque53353462014-04-22 08:43:45 -0500226 }
227
228 double
229 getCorR()
230 {
231 return m_corR;
232 }
233
234 void
235 setCorTheta(double ct)
236 {
237 m_corTheta = ct;
238 }
239
240 double
241 getCorTheta()
242 {
243 return m_corTheta;
244 }
akmhoque157b0a42014-05-13 00:26:37 -0500245
akmhoque53353462014-04-22 08:43:45 -0500246 void
akmhoque157b0a42014-05-13 00:26:37 -0500247 setMaxFacesPerPrefix(int32_t mfpp)
akmhoque53353462014-04-22 08:43:45 -0500248 {
akmhoque157b0a42014-05-13 00:26:37 -0500249 m_maxFacesPerPrefix = mfpp;
akmhoque53353462014-04-22 08:43:45 -0500250 }
251
akmhoquefdbddb12014-05-02 18:35:19 -0500252 int32_t
akmhoque157b0a42014-05-13 00:26:37 -0500253 getMaxFacesPerPrefix()
akmhoque53353462014-04-22 08:43:45 -0500254 {
akmhoque157b0a42014-05-13 00:26:37 -0500255 return m_maxFacesPerPrefix;
akmhoque53353462014-04-22 08:43:45 -0500256 }
257
258 void
akmhoque157b0a42014-05-13 00:26:37 -0500259 setSeqFileDir(const std::string& ssfd)
akmhoque53353462014-04-22 08:43:45 -0500260 {
akmhoque157b0a42014-05-13 00:26:37 -0500261 m_seqFileDir = ssfd;
akmhoque53353462014-04-22 08:43:45 -0500262 }
263
akmhoque157b0a42014-05-13 00:26:37 -0500264 const std::string&
265 getSeqFileDir()
akmhoque53353462014-04-22 08:43:45 -0500266 {
akmhoque157b0a42014-05-13 00:26:37 -0500267 return m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500268 }
269
akmhoque53353462014-04-22 08:43:45 -0500270
271private:
akmhoque31d1d4b2014-05-05 22:08:14 -0500272 ndn::Name m_routerName;
273 ndn::Name m_siteName;
274 ndn::Name m_network;
akmhoque53353462014-04-22 08:43:45 -0500275
akmhoque31d1d4b2014-05-05 22:08:14 -0500276 ndn::Name m_routerPrefix;
277 ndn::Name m_lsaRouterPrefix;
akmhoque53353462014-04-22 08:43:45 -0500278
akmhoque157b0a42014-05-13 00:26:37 -0500279 ndn::Name m_chronosyncPrefix;
280 ndn::Name m_lsaPrefix;
281
282 int32_t m_lsaRefreshTime;
283 int64_t m_routerDeadInterval;
284 std::string m_logLevel;
akmhoque53353462014-04-22 08:43:45 -0500285
akmhoquefdbddb12014-05-02 18:35:19 -0500286 uint32_t m_interestRetryNumber;
akmhoque157b0a42014-05-13 00:26:37 -0500287 int32_t m_interestResendTime;
288
289
290 int32_t m_infoInterestInterval;
291
292 int32_t m_hyperbolicState;
akmhoque53353462014-04-22 08:43:45 -0500293 double m_corR;
294 double m_corTheta;
295
akmhoque157b0a42014-05-13 00:26:37 -0500296 int32_t m_maxFacesPerPrefix;
297
298 std::string m_seqFileDir;
akmhoque53353462014-04-22 08:43:45 -0500299
300};
301
akmhoque157b0a42014-05-13 00:26:37 -0500302inline std::ostream&
303operator<<(std::ostream& os, ConfParameter& cfp)
304{
305 os << "Router Name: " << cfp.getRouterName() << std::endl;
306 os << "Site Name: " << cfp.getSiteName() << std::endl;
307 os << "Network: " << cfp.getNetwork() << std::endl;
308 os << "Router Prefix: " << cfp.getRouterPrefix() << std::endl;
309 os << "ChronoSync sync Prifex: " << cfp.getChronosyncPrefix() << std::endl;
310 os << "ChronoSync LSA prefix: " << cfp.getLsaPrefix() << std::endl;
311 os << "Interest Retry number: " << cfp.getInterestRetryNumber() << std::endl;
312 os << "Interest Resend second: " << cfp.getInterestResendTime() << std::endl;
313 os << "Info Interest Interval: " << cfp.getInfoInterestInterval() << std::endl;
314 os << "LSA refresh time: " << cfp.getLsaRefreshTime() << std::endl;
315 os << "Max Faces Per Prefix: " << cfp.getMaxFacesPerPrefix() << std::endl;
316 os << "Hyperbolic ROuting: " << cfp.getHyperbolicState() << std::endl;
317 os << "Hyp R: " << cfp.getCorR() << std::endl;
318 os << "Hyp theta: " << cfp.getCorTheta() << std::endl;
319 return os;
320}
akmhoque53353462014-04-22 08:43:45 -0500321
322} // namespace nlsr
323
akmhoquefdbddb12014-05-02 18:35:19 -0500324#endif //CONF_PARAMETER_HPP