conf-parameter.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_CONF_PARAMETER_HPP
23 #define NLSR_CONF_PARAMETER_HPP
24 
25 #include "common.hpp"
26 #include "logger.hpp"
27 
28 #include <iostream>
29 #include <boost/cstdint.hpp>
30 #include <ndn-cxx/face.hpp>
31 #include <ndn-cxx/util/time.hpp>
32 
33 namespace nlsr {
34 
35 enum {
39 };
40 
41 enum {
45 };
46 
47 enum {
51 };
52 
53 enum {
57 };
58 
59 enum {
63 };
64 
65 
66 enum {
70 };
71 
72 enum {
76 };
77 
78 enum {
82 };
83 
84 enum {
88 };
89 
90 enum {
94 };
95 
96 enum {
100 };
101 
107 };
108 
121 {
122 
123 public:
125  : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
126  , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
127  , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
128  , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
129  , m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
130  , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
131  , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
132  , m_logLevel("INFO")
133  , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
134  , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
135  , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
136  , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
137  , m_corR(0)
138  , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
139  , m_isLog4cxxConfAvailable(false)
140  {
141  }
142 
143  void
144  setNetwork(const ndn::Name& networkName)
145  {
146  m_network = networkName;
147 
148  m_chronosyncPrefix.append("localhop");
149  m_chronosyncPrefix.append(m_network);
150  m_chronosyncPrefix.append("NLSR");
151  m_chronosyncPrefix.append("sync");
152 
153  m_lsaPrefix.append("localhop");
154  m_lsaPrefix.append(m_network);
155  m_lsaPrefix.append("NLSR");
156  m_lsaPrefix.append("LSA");
157  }
158 
159  const ndn::Name&
160  getNetwork() const
161  {
162  return m_network;
163  }
164 
165  void
166  setRouterName(const ndn::Name& routerName)
167  {
168  m_routerName = routerName;
169  }
170 
171  const ndn::Name&
173  {
174  return m_routerName;
175  }
176 
177  void
178  setSiteName(const ndn::Name& siteName)
179  {
180  m_siteName = siteName;
181  }
182 
183  const ndn::Name&
184  getSiteName() const
185  {
186  return m_siteName;
187  }
188 
189  void
191  {
192  m_routerPrefix = m_network;
193  m_routerPrefix.append(m_siteName);
194  m_routerPrefix.append(m_routerName);
195  }
196 
197  const ndn::Name&
199  {
200  return m_routerPrefix;
201  }
202 
203 
204  const ndn::Name&
206  {
207  return m_chronosyncPrefix;
208  }
209 
210  const ndn::Name&
211  getLsaPrefix() const
212  {
213  return m_lsaPrefix;
214  }
215 
216  void
217  setLsaRefreshTime(uint32_t lrt)
218  {
219  m_lsaRefreshTime = lrt;
220  }
221 
222  uint32_t
224  {
225  return m_lsaRefreshTime;
226  }
227 
228  void
229  setLsaInterestLifetime(const ndn::time::seconds& lifetime)
230  {
231  m_lsaInterestLifetime = lifetime;
232  }
233 
234  const ndn::time::seconds&
236  {
237  return m_lsaInterestLifetime;
238  }
239 
240  void
241  setAdjLsaBuildInterval(uint32_t interval)
242  {
243  m_adjLsaBuildInterval = interval;
244  }
245 
246  uint32_t
248  {
249  return m_adjLsaBuildInterval;
250  }
251 
252  void
253  setFirstHelloInterval(uint32_t interval)
254  {
255  m_firstHelloInterval = interval;
256  }
257 
258  uint32_t
260  {
261  return m_firstHelloInterval;
262  }
263 
264  void
265  setRoutingCalcInterval(uint32_t interval)
266  {
267  m_routingCalcInterval = interval;
268  }
269 
270  uint32_t
272  {
273  return m_routingCalcInterval;
274  }
275 
276  void
277  setRouterDeadInterval(uint32_t rdt)
278  {
279  m_routerDeadInterval = rdt;
280  }
281 
282  uint32_t
284  {
285  return m_routerDeadInterval;
286  }
287 
288  void
289  setFaceDatasetFetchTries(uint32_t count)
290  {
291  m_faceDatasetFetchTries = count;
292  }
293 
294  uint32_t
296  {
297  return m_faceDatasetFetchTries;
298  }
299 
300  void
301  setFaceDatasetFetchInterval(uint32_t interval)
302  {
303  m_faceDatasetFetchInterval = ndn::time::seconds(interval);
304  }
305 
306  const ndn::time::seconds
308  {
309  return m_faceDatasetFetchInterval;
310  }
311 
312  void
313  setLogLevel(const std::string& logLevel)
314  {
315  m_logLevel = logLevel;
316  }
317 
318  const std::string&
319  getLogLevel() const
320  {
321  return m_logLevel;
322  }
323 
324  void
326  {
327  m_interestRetryNumber = irn;
328  }
329 
330  uint32_t
332  {
333  return m_interestRetryNumber;
334  }
335 
336  void
337  setInterestResendTime(uint32_t irt)
338  {
339  m_interestResendTime = irt;
340  }
341 
342  uint32_t
344  {
345  return m_interestResendTime;
346  }
347 
348  uint32_t
350  {
351  return m_infoInterestInterval;
352  }
353 
354  void
356  {
357  m_infoInterestInterval = iii;
358  }
359 
360  void
361  setHyperbolicState(int32_t ihc)
362  {
363  m_hyperbolicState = ihc;
364  }
365 
366  int32_t
368  {
369  return m_hyperbolicState;
370  }
371 
372  bool
373  setCorR(double cr)
374  {
375  if ( cr >= 0 ) {
376  m_corR = cr;
377  return true;
378  }
379  return false;
380  }
381 
382  double
383  getCorR() const
384  {
385  return m_corR;
386  }
387 
388  void
389  setCorTheta(const std::vector<double>& ct)
390  {
391  m_corTheta = ct;
392  }
393 
394  std::vector<double>
395  getCorTheta() const
396  {
397  return m_corTheta;
398  }
399 
400  void
401  setMaxFacesPerPrefix(uint32_t mfpp)
402  {
403  m_maxFacesPerPrefix = mfpp;
404  }
405 
406  uint32_t
408  {
409  return m_maxFacesPerPrefix;
410  }
411 
412  void
413  setLogDir(const std::string& logDir)
414  {
415  m_logDir = logDir;
416  }
417 
418  const std::string&
419  getLogDir() const
420  {
421  return m_logDir;
422  }
423 
424  void
425  setSeqFileDir(const std::string& ssfd)
426  {
427  m_seqFileDir = ssfd;
428  }
429 
430  const std::string&
432  {
433  return m_seqFileDir;
434  }
435 
436  bool
438  {
439  return m_isLog4cxxConfAvailable;
440  }
441 
442  void
443  setLog4CxxConfPath(const std::string& path)
444  {
445  m_log4CxxConfPath = path;
446  m_isLog4cxxConfAvailable = true;
447  }
448 
449  const std::string&
451  {
452  return m_log4CxxConfPath;
453  }
454 
457  void
458  writeLog();
459 
460 private:
461  ndn::Name m_routerName;
462  ndn::Name m_siteName;
463  ndn::Name m_network;
464 
465  ndn::Name m_routerPrefix;
466  ndn::Name m_lsaRouterPrefix;
467 
468  ndn::Name m_chronosyncPrefix;
469  ndn::Name m_lsaPrefix;
470 
471  uint32_t m_lsaRefreshTime;
472 
473  uint32_t m_adjLsaBuildInterval;
474  uint32_t m_firstHelloInterval;
475  uint32_t m_routingCalcInterval;
476 
477  uint32_t m_faceDatasetFetchTries;
478  ndn::time::seconds m_faceDatasetFetchInterval;
479 
480  ndn::time::seconds m_lsaInterestLifetime;
481  uint32_t m_routerDeadInterval;
482  std::string m_logLevel;
483 
484  uint32_t m_interestRetryNumber;
485  uint32_t m_interestResendTime;
486 
487  uint32_t m_infoInterestInterval;
488 
489  int32_t m_hyperbolicState;
490  double m_corR;
491  std::vector<double> m_corTheta;
492 
493  uint32_t m_maxFacesPerPrefix;
494 
495  std::string m_logDir;
496  std::string m_seqFileDir;
497 
498  bool m_isLog4cxxConfAvailable;
499  std::string m_log4CxxConfPath;
500 };
501 
502 } // namespace nlsr
503 
504 #endif // NLSR_CONF_PARAMETER_HPP
uint32_t getInterestResendTime() const
A class to house all the configuration parameters for NLSR.
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Definition: tlv-nlsr.hpp:27
double getCorR() const
void setLsaInterestLifetime(const ndn::time::seconds &lifetime)
void setMaxFacesPerPrefix(uint32_t mfpp)
void setRoutingCalcInterval(uint32_t interval)
void setNetwork(const ndn::Name &networkName)
const std::string & getSeqFileDir() const
void setAdjLsaBuildInterval(uint32_t interval)
void setSiteName(const ndn::Name &siteName)
uint32_t getInfoInterestInterval() const
const ndn::Name & getRouterPrefix() const
void setInterestResendTime(uint32_t irt)
void setInfoInterestInterval(uint32_t iii)
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California.
void setLog4CxxConfPath(const std::string &path)
const std::string & getLogLevel() const
const ndn::time::seconds & getLsaInterestLifetime() const
const std::string & getLog4CxxConfPath() const
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California.
void setCorTheta(const std::vector< double > &ct)
uint32_t getInterestRetryNumber() const
uint32_t getMaxFacesPerPrefix() const
std::vector< double > getCorTheta() const
const ndn::Name & getLsaPrefix() const
void setRouterName(const ndn::Name &routerName)
void setFaceDatasetFetchInterval(uint32_t interval)
void setLogLevel(const std::string &logLevel)
uint32_t getLsaRefreshTime() const
void setInterestRetryNumber(uint32_t irn)
const ndn::Name & getChronosyncPrefix() const
bool setCorR(double cr)
bool isLog4CxxConfAvailable() const
Copyright (c) 2014-2017, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
uint32_t getAdjLsaBuildInterval() const
void setRouterDeadInterval(uint32_t rdt)
void setFirstHelloInterval(uint32_t interval)
void setSeqFileDir(const std::string &ssfd)
uint32_t getFirstHelloInterval() const
void setLsaRefreshTime(uint32_t lrt)
uint32_t getFaceDatasetFetchTries() const
const ndn::Name & getNetwork() const
void setHyperbolicState(int32_t ihc)
void setFaceDatasetFetchTries(uint32_t count)
const ndn::Name & getRouterName() const
int32_t getHyperbolicState() const
uint32_t getRoutingCalcInterval() const
void setLogDir(const std::string &logDir)
const ndn::Name & getSiteName() const
const ndn::time::seconds getFaceDatasetFetchInterval() const
uint32_t getRouterDeadInterval() const
const std::string & getLogDir() const
void writeLog()
Dump the current state of all attributes to the log.