40 : afterRoutingChange{std::make_unique<AfterRoutingChange>()}
41 , m_scheduler(scheduler)
44 , m_namePrefixTable(namePrefixTable)
45 , m_NO_NEXT_HOP{-12345}
46 , m_routingCalcInterval{confParam.getRoutingCalcInterval()}
47 , m_isRoutingTableCalculating(
false)
48 , m_isRouteCalculationScheduled(
false)
49 , m_confParam(confParam)
60 if (m_isRoutingTableCalculating ==
false) {
62 m_isRoutingTableCalculating =
true;
79 clearDryRoutingTable();
86 calculateLsRoutingTable();
90 calculateHypRoutingTable(
false);
94 calculateHypRoutingTable(
true);
98 (*afterRoutingChange)(m_rTable);
105 " routing table can not be calculated :(");
110 " so Routing table can not be calculated :(");
112 clearDryRoutingTable();
115 (*afterRoutingChange)(m_rTable);
121 m_isRouteCalculationScheduled =
false;
122 m_isRoutingTableCalculating =
false;
130 RoutingTable::calculateLsRoutingTable()
146 RoutingTable::calculateHypRoutingTable(
bool isDryRun)
163 if (m_isRouteCalculationScheduled !=
true) {
164 NLSR_LOG_DEBUG(
"Scheduling routing table calculation in " << m_routingCalcInterval);
166 m_scheduler.scheduleEvent(m_routingCalcInterval,
169 m_isRouteCalculationScheduled =
true;
182 NLSR_LOG_DEBUG(
"Adding " << nh <<
" for destination: " << destRouter);
188 m_rTable.push_back(rte);
198 std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(),
202 if (it != m_rTable.end()) {
209 RoutingTable::writeLog()
212 for (
const auto& rte : m_rTable) {
215 rte.getNexthopList().writeLog();
220 for (
const auto& rte : m_dryTable) {
223 rte.getNexthopList().writeLog();
231 NLSR_LOG_DEBUG(
"Adding " << nh <<
" to dry table for destination: " << destRouter);
233 std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(),
237 if (it == m_dryTable.end()) {
240 m_dryTable.push_back(rte);
243 (*it).getNexthopList().addNextHop(nh);
248 RoutingTable::clearRoutingTable()
250 if (m_rTable.size() > 0) {
256 RoutingTable::clearDryRoutingTable()
258 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)
size_t getMapSize() 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.
#define INIT_LOGGER(name)
const std::list< CoordinateLsa > & getCoordinateLsdb() const
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)
Copyright (c) 2014-2018, 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.
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)
int32_t getHyperbolicState() const
void addNextHop(const ndn::Name &destRouter, NextHop &nh)
Adds a next hop to a routing table entry.
const std::list< AdjLsa > & getAdjLsdb() const
#define NLSR_LOG_TRACE(x)