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 static std::unique_ptr<ndn::security::v2::CertificateFetcherDirectFetch>
35 makeCertificateFetcher(ndn::Face& face)
36 {
37  auto fetcher = std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face);
38  fetcher->setSendDirectInterestOnly(true);
39  return fetcher;
40 }
41 
42 ConfParameter::ConfParameter(ndn::Face& face, const std::string& confFileName)
43  : m_confFileName(confFileName)
44  , m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT)
45  , m_adjLsaBuildInterval(ADJ_LSA_BUILD_INTERVAL_DEFAULT)
46  , m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
47  , m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
48  , m_faceDatasetFetchInterval(ndn::time::seconds(static_cast<int>(FACE_DATASET_FETCH_INTERVAL_DEFAULT)))
49  , m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
50  , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
51  , m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
52  , m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
53  , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT)
54  , m_hyperbolicState(HYPERBOLIC_STATE_OFF)
55  , m_corR(0)
56  , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN)
57  , m_syncInterestLifetime(ndn::time::milliseconds(SYNC_INTEREST_LIFETIME_DEFAULT))
58  , m_syncProtocol(SYNC_PROTOCOL_CHRONOSYNC)
59  , m_adjl()
60  , m_npl()
61  , m_validator(makeCertificateFetcher(face))
62  , m_prefixUpdateValidator(std::make_unique<ndn::security::v2::CertificateFetcherDirectFetch>(face))
63 {
64 }
65 
66 void
68 {
69  NLSR_LOG_INFO("Router Name: " << m_routerName);
70  NLSR_LOG_INFO("Site Name: " << m_siteName);
71  NLSR_LOG_INFO("Network: " << m_network);
72  NLSR_LOG_INFO("Router Prefix: " << m_routerPrefix);
73  NLSR_LOG_INFO("Sync Prefix: " << m_syncPrefix);
74  NLSR_LOG_INFO("Sync LSA prefix: " << m_lsaPrefix);
75  NLSR_LOG_INFO("Hello Interest retry number: " << m_interestRetryNumber);
76  NLSR_LOG_INFO("Hello Interest resend second: " << m_interestResendTime);
77  NLSR_LOG_INFO("Info Interest interval: " << m_infoInterestInterval);
78  NLSR_LOG_INFO("LSA refresh time: " << m_lsaRefreshTime);
79  NLSR_LOG_INFO("FIB Entry refresh time: " << m_lsaRefreshTime * 2);
80  NLSR_LOG_INFO("LSA Interest lifetime: " << getLsaInterestLifetime());
81  NLSR_LOG_INFO("Router dead interval: " << getRouterDeadInterval());
82  NLSR_LOG_INFO("Max Faces Per Prefix: " << m_maxFacesPerPrefix);
83  NLSR_LOG_INFO("Hyperbolic Routing: " << m_hyperbolicState);
84  NLSR_LOG_INFO("Hyp R: " << m_corR);
85  int i=0;
86  for (auto const& value: m_corTheta) {
87  NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
88  }
89  NLSR_LOG_INFO("State Directory: " << m_stateFileDir);
90 
91  // Event Intervals
92  NLSR_LOG_INFO("Adjacency LSA build interval: " << m_adjLsaBuildInterval);
93  NLSR_LOG_INFO("First Hello Interest interval: " << m_firstHelloInterval);
94  NLSR_LOG_INFO("Routing calculation interval: " << m_routingCalcInterval);
95 }
96 
97 void
98 ConfParameter::setNetwork(const ndn::Name& networkName)
99 {
100  m_network = networkName;
101 
102  m_syncPrefix.append("localhop");
103  m_syncPrefix.append(m_network);
104  m_syncPrefix.append("nlsr");
105  m_syncPrefix.append("sync");
106  m_syncPrefix.appendVersion(SYNC_VERSION);
107 
108  m_lsaPrefix.append("localhop");
109  m_lsaPrefix.append(m_network);
110  m_lsaPrefix.append("nlsr");
111  m_lsaPrefix.append("LSA");
112 }
113 
114 } // 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
static std::unique_ptr< ndn::security::v2::CertificateFetcherDirectFetch > makeCertificateFetcher(ndn::Face &face)
#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.