conf-parameter.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #include "conf-parameter.hpp"
25 #include "logger.hpp"
26 
27 namespace nlsr {
28 
29 INIT_LOGGER(ConfParameter);
30 
31 // To be changed when breaking changes are made to sync
32 const uint64_t ConfParameter::SYNC_VERSION = 6;
33 
34 ConfParameter::ConfParameter(ndn::Face& face, const std::string& confFileName)
35  : m_confFileName(confFileName)
36  , m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
37  , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
38  , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
39  , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
40  , m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
41  , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
42  , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
43  , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
44  , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
45  , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
46  , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
47  , m_corR(0)
48  , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
49  , m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
50  , m_syncProtocol(SYNC_PROTOCOL_CHRONOSYNC)
51  , m_adjl()
52  , m_npl()
53  , m_validator(std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
54  , m_prefixUpdateValidator(std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
55  {
56  }
57 
58 void
60 {
61  NLSR_LOG_INFO("Router Name: " << m_routerName);
62  NLSR_LOG_INFO("Site Name: " << m_siteName);
63  NLSR_LOG_INFO("Network: " << m_network);
64  NLSR_LOG_INFO("Router Prefix: " << m_routerPrefix);
65  NLSR_LOG_INFO("Sync Prefix: " << m_syncPrefix);
66  NLSR_LOG_INFO("Sync LSA prefix: " << m_lsaPrefix);
67  NLSR_LOG_INFO("Hello Interest retry number: " << m_interestRetryNumber);
68  NLSR_LOG_INFO("Hello Interest resend second: " << m_interestResendTime);
69  NLSR_LOG_INFO("Info Interest interval: " << m_infoInterestInterval);
70  NLSR_LOG_INFO("LSA refresh time: " << m_lsaRefreshTime);
71  NLSR_LOG_INFO("FIB Entry refresh time: " << m_lsaRefreshTime * 2);
72  NLSR_LOG_INFO("LSA Interest lifetime: " << getLsaInterestLifetime());
73  NLSR_LOG_INFO("Router dead interval: " << getRouterDeadInterval());
74  NLSR_LOG_INFO("Max Faces Per Prefix: " << m_maxFacesPerPrefix);
75  NLSR_LOG_INFO("Hyperbolic Routing: " << m_hyperbolicState);
76  NLSR_LOG_INFO("Hyp R: " << m_corR);
77  int i=0;
78  for (auto const& value: m_corTheta) {
79  NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
80  }
81  NLSR_LOG_INFO("State Directory: " << m_stateFileDir);
82 
83  // Event Intervals
84  NLSR_LOG_INFO("Adjacency LSA build interval: " << m_adjLsaBuildInterval);
85  NLSR_LOG_INFO("First Hello Interest interval: " << m_firstHelloInterval);
86  NLSR_LOG_INFO("Routing calculation interval: " << m_routingCalcInterval);
87 }
88 
89 void
90 ConfParameter::setNetwork(const ndn::Name& networkName)
91 {
92  m_network = networkName;
93 
94  m_syncPrefix.append("localhop");
95  m_syncPrefix.append(m_network);
96  m_syncPrefix.append("nlsr");
97  m_syncPrefix.append("sync");
98  m_syncPrefix.appendVersion(SYNC_VERSION);
99 
100  m_lsaPrefix.append("localhop");
101  m_lsaPrefix.append(m_network);
102  m_lsaPrefix.append("nlsr");
103  m_lsaPrefix.append("LSA");
104 }
105 
106 } // namespace nlsr
ConfParameter(ndn::Face &face, const std::string &confFileName="nlsr.conf")
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
Definition: tlv-nlsr.hpp:28
void setNetwork(const ndn::Name &networkName)
STL namespace.
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
const ndn::time::seconds & getLsaInterestLifetime() const
#define INIT_LOGGER(name)
Definition: logger.hpp:35
#define NLSR_LOG_INFO(x)
Definition: logger.hpp:39
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
uint32_t getRouterDeadInterval() const
void writeLog()
Dump the current state of all attributes to the log.