conf: Add `general.router-dead-interval` configuration setting
refs: #1878
Change-Id: I21f2837118cda424904e0b0e60708a12deeabc8e
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index bf07bee..3728a09 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -271,6 +271,23 @@
}
try {
+ int32_t routerDeadInterval = section.get<int32_t>("router-dead-interval");
+
+ if (routerDeadInterval > m_nlsr.getConfParameter().getLsaRefreshTime()) {
+ m_nlsr.getConfParameter().setRouterDeadInterval(routerDeadInterval);
+ }
+ else {
+ std::cerr << "Value of router-dead-interval must be larger than lsa-refresh-time"
+ << std::endl;
+ return false;
+ }
+ }
+ catch (const std::exception& ex) {
+ std::cerr << ex.what() << std::endl;
+ // non-critical error. default value is 2 * lsa-refresh-time
+ }
+
+ try {
int lifetime = section.get<int>("lsa-interest-lifetime");
if (lifetime >= LSA_INTEREST_LIFETIME_MIN && lifetime <= LSA_INTEREST_LIFETIME_MAX) {
m_nlsr.getConfParameter().setLsaInterestLifetime(ndn::time::seconds(lifetime));
@@ -284,7 +301,7 @@
}
catch (const std::exception& ex) {
std::cerr << ex.what() << std::endl;
- // return false;
+ // non-critical error. default value is 4
}
try {
diff --git a/src/conf-parameter.cpp b/src/conf-parameter.cpp
index f2b8bd2..763d771 100644
--- a/src/conf-parameter.cpp
+++ b/src/conf-parameter.cpp
@@ -41,6 +41,7 @@
_LOG_DEBUG("Info Interest interval: " << m_infoInterestInterval);
_LOG_DEBUG("LSA refresh time: " << m_lsaRefreshTime);
_LOG_DEBUG("LSA Interest lifetime: " << getLsaInterestLifetime());
+ _LOG_DEBUG("Router dead interval: " << getRouterDeadInterval());
_LOG_DEBUG("Max Faces Per Prefix: " << m_maxFacesPerPrefix);
_LOG_DEBUG("Hyperbolic Routing: " << m_hyperbolicState);
_LOG_DEBUG("Hyp R: " << m_corR);
diff --git a/src/conf-parameter.hpp b/src/conf-parameter.hpp
index 6f51d70..02eee7b 100644
--- a/src/conf-parameter.hpp
+++ b/src/conf-parameter.hpp
@@ -102,7 +102,7 @@
, m_firstHelloInterval(FIRST_HELLO_INTERVAL_DEFAULT)
, m_routingCalcInterval(ROUTING_CALC_INTERVAL_DEFAULT)
, m_lsaInterestLifetime(ndn::time::seconds(static_cast<int>(LSA_INTEREST_LIFETIME_DEFAULT)))
- , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT)
+ , m_routerDeadInterval(2 * LSA_REFRESH_TIME_DEFAULT)
, m_logLevel("INFO")
, m_interestRetryNumber(HELLO_RETRIES_DEFAULT)
, m_interestResendTime(HELLO_TIMEOUT_DEFAULT)
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index fc0d663..5b70a65 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -43,6 +43,7 @@
" router /cs/pollux/\n"
" lsa-refresh-time 1800\n"
" lsa-interest-lifetime 3\n"
+ " router-dead-interval 86400\n"
" log-level INFO\n"
" log-dir /tmp\n"
" seq-dir /tmp\n"
@@ -158,7 +159,7 @@
BOOST_CHECK_EQUAL(conf.getLsaPrefix(), "/ndn/NLSR/LSA");
BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), 1800);
BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(), ndn::time::seconds(3));
- BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 3600);
+ BOOST_CHECK_EQUAL(conf.getRouterDeadInterval(), 86400);
BOOST_CHECK_EQUAL(conf.getLogLevel(), "INFO");
BOOST_CHECK_EQUAL(conf.getLogDir(), "/tmp");
BOOST_CHECK_EQUAL(conf.getSeqFileDir(), "/tmp");