blob: 2d50838f1abd099e07b7d576873dc951d3ca8bea [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Ashlesh Gawande85998a12017-12-07 22:22:13 -06003 * Copyright (c) 2014-2019, The University of Memphis,
Nick Gordonf8b5bcd2016-08-11 15:06:50 -05004 * Regents of the University of California
akmhoque3d06e792014-05-27 16:23:20 -05005 *
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 **/
Muktadir R Chowdhurybfa27602014-10-31 10:57:41 -050023
akmhoque674b0b12014-05-20 14:33:28 -050024#include "conf-parameter.hpp"
25#include "logger.hpp"
26
27namespace nlsr {
28
dmcoomescf8d0ed2017-02-21 11:39:01 -060029INIT_LOGGER(ConfParameter);
akmhoque674b0b12014-05-20 14:33:28 -050030
Ashlesh Gawande982a58f2018-02-14 17:39:12 -060031// To be changed when breaking changes are made to sync
Ashlesh Gawande32ec3fd2018-07-18 13:42:32 -050032const uint64_t ConfParameter::SYNC_VERSION = 6;
Ashlesh Gawande982a58f2018-02-14 17:39:12 -060033
Ashlesh Gawande85998a12017-12-07 22:22:13 -060034ConfParameter::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
akmhoque674b0b12014-05-20 14:33:28 -050058void
59ConfParameter::writeLog()
60{
dmcoomes5bcb39e2017-10-31 15:07:55 -050061 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);
Ashlesh Gawande85998a12017-12-07 22:22:13 -060065 NLSR_LOG_INFO("Sync Prefix: " << m_syncPrefix);
66 NLSR_LOG_INFO("Sync LSA prefix: " << m_lsaPrefix);
dmcoomes5bcb39e2017-10-31 15:07:55 -050067 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);
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -060077 int i=0;
78 for (auto const& value: m_corTheta) {
dmcoomes5bcb39e2017-10-31 15:07:55 -050079 NLSR_LOG_INFO("Hyp Angle " << i++ << ": "<< value);
Muktadir R Chowdhuryb00dc2a2016-11-05 10:48:58 -060080 }
dmcoomes5bcb39e2017-10-31 15:07:55 -050081 NLSR_LOG_INFO("Seq Directory: " << m_seqFileDir);
Vince Lehman7b616582014-10-17 16:25:39 -050082
83 // Event Intervals
dmcoomes5bcb39e2017-10-31 15:07:55 -050084 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);
akmhoque674b0b12014-05-20 14:33:28 -050087}
88
Ashlesh Gawande982a58f2018-02-14 17:39:12 -060089void
90ConfParameter::setNetwork(const ndn::Name& networkName)
91{
92 m_network = networkName;
93
Ashlesh Gawande85998a12017-12-07 22:22:13 -060094 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);
Ashlesh Gawande982a58f2018-02-14 17:39:12 -060099
100 m_lsaPrefix.append("localhop");
101 m_lsaPrefix.append(m_network);
Ashlesh Gawandecba0ae22018-03-27 17:57:56 -0500102 m_lsaPrefix.append("nlsr");
Ashlesh Gawande982a58f2018-02-14 17:39:12 -0600103 m_lsaPrefix.append("LSA");
104}
105
akmhoque674b0b12014-05-20 14:33:28 -0500106} // namespace nlsr