39 : afterRoutingChange{std::make_unique<AfterRoutingChange>()}
40 , m_scheduler(scheduler)
43 , m_namePrefixTable(namePrefixTable)
44 , m_routingCalcInterval{confParam.getRoutingCalcInterval()}
45 , m_isRoutingTableCalculating(
false)
46 , m_isRouteCalculationScheduled(
false)
47 , m_confParam(confParam)
58 if (m_isRoutingTableCalculating ==
false) {
60 m_isRoutingTableCalculating =
true;
77 clearDryRoutingTable();
84 calculateLsRoutingTable();
88 calculateHypRoutingTable(
false);
92 calculateHypRoutingTable(
true);
96 (*afterRoutingChange)(m_rTable);
103 " routing table can not be calculated :(");
108 " so Routing table can not be calculated :(");
110 clearDryRoutingTable();
113 (*afterRoutingChange)(m_rTable);
119 m_isRouteCalculationScheduled =
false;
120 m_isRoutingTableCalculating =
false;
128 RoutingTable::calculateLsRoutingTable()
144 RoutingTable::calculateHypRoutingTable(
bool isDryRun)
161 if (!m_isRouteCalculationScheduled) {
162 NLSR_LOG_DEBUG(
"Scheduling routing table calculation in " << m_routingCalcInterval);
163 m_scheduler.schedule(m_routingCalcInterval, [
this] {
calculate(); });
164 m_isRouteCalculationScheduled =
true;
177 NLSR_LOG_DEBUG(
"Adding " << nh <<
" for destination: " << destRouter);
180 if (rteChk ==
nullptr) {
183 m_rTable.push_back(rte);
193 auto it = std::find_if(m_rTable.begin(), m_rTable.end(),
195 if (it != m_rTable.end()) {
202 RoutingTable::writeLog()
205 for (
const auto& rte : m_rTable) {
208 rte.getNexthopList().writeLog();
213 for (
const auto& rte : m_dryTable) {
216 rte.getNexthopList().writeLog();
224 NLSR_LOG_DEBUG(
"Adding " << nh <<
" to dry table for destination: " << destRouter);
226 auto it = std::find_if(m_dryTable.begin(), m_dryTable.end(),
228 if (it == m_dryTable.end()) {
231 m_dryTable.push_back(rte);
234 it->getNexthopList().addNextHop(nh);
239 RoutingTable::clearRoutingTable()
241 if (m_rTable.size() > 0) {
247 RoutingTable::clearDryRoutingTable()
249 if (m_dryTable.size() > 0) {
NexthopList & getNexthopList()
void calculate()
Calculates a list of next hops for each router in the network.
A class to house all the configuration parameters for NLSR.
void calculatePath(Map &map, RoutingTable &rt, Lsdb &lsdb, AdjacencyList &adjacencies)
const std::list< CoordinateLsa > & getCoordinateLsdb() const
void createFromCoordinateLsdb(IteratorType begin, IteratorType end)
void scheduleRoutingTableCalculation()
Schedules a calculation event in the event scheduler only if one isn't already scheduled.
AdjacencyList & getAdjacencyList()
#define NLSR_LOG_DEBUG(x)
const ndn::Name & getRouterPrefix() const
RoutingTable(ndn::Scheduler &scheduler, Fib &fib, Lsdb &lsdb, NamePrefixTable &namePrefixTable, ConfParameter &confParam)
bool getIsBuildAdjLsaSheduled()
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
Maps names to lists of next hops, and exports this information to NFD.
size_t getMapSize() const
#define INIT_LOGGER(name)
static bool routingTableEntryCompare(RoutingTableEntry &rte, ndn::Name &destRouter)
const ndn::Name & getDestination() const
bool doesLsaExist(const ndn::Name &key, const Lsa::Type &lsType)
void createFromAdjLsdb(IteratorType begin, IteratorType end)
int32_t getHyperbolicState() const
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
void calculatePath(Map &pMap, RoutingTable &rt, ConfParameter &confParam, const std::list< AdjLsa > &adjLsaList)
void addNextHop(const NextHop &nh)
Adds a next hop to the list.
const std::list< AdjLsa > & getAdjLsdb() const
void addNextHopToDryTable(const ndn::Name &destRouter, NextHop &nh)
Adds a next hop to a routing table entry in a dry run scenario.
RoutingTableEntry * findRoutingTableEntry(const ndn::Name &destRouter)
void addNextHop(const ndn::Name &destRouter, NextHop &nh)
Adds a next hop to a routing table entry.
#define NLSR_LOG_TRACE(x)