conf: Make event intervals configurable
User can specify the intervals for the first Hello Interest,
AdjLsa building, and routing calculation in the conf file.
refs: #2071
Change-Id: Ic8eb29d433069086955178bc42b5f8fc8f4149d3
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 09b9430..371d977 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -156,7 +156,7 @@
RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr)
{
if (pnlsr.getIsRouteCalculationScheduled() != true) {
- m_scheduler.scheduleEvent(ndn::time::seconds(15),
+ m_scheduler.scheduleEvent(m_routingCalcInterval,
ndn::bind(&RoutingTable::calculate, this, ndn::ref(pnlsr)));
pnlsr.setIsRouteCalculationScheduled(true);
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index 6dd3ef2..c85efe9 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -29,6 +29,7 @@
#include <boost/cstdint.hpp>
#include <ndn-cxx/util/scheduler.hpp>
+#include "conf-parameter.hpp"
#include "routing-table-entry.hpp"
namespace nlsr {
@@ -42,8 +43,10 @@
RoutingTable(ndn::Scheduler& scheduler)
: m_scheduler(scheduler)
, m_NO_NEXT_HOP(-12345)
+ , m_routingCalcInterval(static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT))
{
}
+
void
calculate(Nlsr& pnlsr);
@@ -65,6 +68,18 @@
return m_NO_NEXT_HOP;
}
+ void
+ setRoutingCalcInterval(uint32_t interval)
+ {
+ m_routingCalcInterval = ndn::time::seconds(interval);
+ }
+
+ const ndn::time::seconds&
+ getRoutingCalcInterval() const
+ {
+ return m_routingCalcInterval;
+ }
+
private:
void
calculateLsRoutingTable(Nlsr& pnlsr);
@@ -91,6 +106,8 @@
std::list<RoutingTableEntry> m_rTable;
std::list<RoutingTableEntry> m_dryTable;
+
+ ndn::time::seconds m_routingCalcInterval;
};
}//namespace nlsr