41 , m_scheduler(scheduler)
44 , m_namePrefixTable(namePrefixTable)
45 , m_routingCalcInterval{confParam.getRoutingCalcInterval()}
46 , m_isRoutingTableCalculating(false)
47 , m_isRouteCalculationScheduled(false)
48 , m_confParam(confParam)
57 if (m_isRoutingTableCalculating ==
false) {
59 m_isRoutingTableCalculating =
true;
72 clearDryRoutingTable();
79 calculateLsRoutingTable();
83 calculateHypRoutingTable(
false);
87 calculateHypRoutingTable(
true);
97 NLSR_LOG_DEBUG(
"Adjacency building is scheduled, so routing table can not be calculated :(");
101 NLSR_LOG_DEBUG(
"No Adj LSA of router itself, so Routing table can not be calculated :(");
103 clearDryRoutingTable();
112 m_isRouteCalculationScheduled =
false;
113 m_isRoutingTableCalculating =
false;
121 RoutingTable::calculateLsRoutingTable()
134 calculator.calculatePath(map, *
this, m_confParam, m_lsdb);
138 RoutingTable::calculateHypRoutingTable(
bool isDryRun)
142 map.createFromCoordinateLsdb(lsaRange.first, lsaRange.second);
145 size_t nRouters = map.getMapSize();
147 HyperbolicRoutingCalculator calculator(nRouters, isDryRun, m_confParam.
getRouterPrefix());
149 calculator.calculatePath(map, *
this, m_lsdb, m_confParam.
getAdjacencyList());
155 if (!m_isRouteCalculationScheduled) {
156 NLSR_LOG_DEBUG(
"Scheduling routing table calculation in " << m_routingCalcInterval);
157 m_scheduler.schedule(m_routingCalcInterval, [
this] {
calculate(); });
158 m_isRouteCalculationScheduled =
true;
171 NLSR_LOG_DEBUG(
"Adding " << nh <<
" for destination: " << destRouter);
174 if (rteChk ==
nullptr) {
198 NLSR_LOG_DEBUG(
"Adding " << nh <<
" to dry table for destination: " << destRouter);
208 it->getNexthopList().addNextHop(nh);
213 RoutingTable::clearRoutingTable()
221 RoutingTable::clearDryRoutingTable()
228 template<ndn::encoding::Tag TAG>
232 size_t totalLength = 0;
235 totalLength += it->wireEncode(block);
239 totalLength += it->wireEncode(block);
242 totalLength += block.prependVarNumber(totalLength);
257 ndn::EncodingEstimator estimator;
260 ndn::EncodingBuffer buffer(estimatedSize, 0);
269 RoutingTableStatus::wireDecode(
const ndn::Block& wire)
280 auto val =
m_wire.elements_begin();
282 std::set<ndn::Name> destinations;
286 if (destinations.emplace(entry.getDestination()).second) {
295 if (val !=
m_wire.elements_end()) {
296 NDN_THROW(
Error(
"Unrecognized TLV of type " + ndn::to_string(val->type()) +
" in RoutingTable"));
303 os <<
"Routing Table:\n";
309 os <<
"Dry-Run Hyperbolic Routing Table:\n";
Data abstraction for AdjLsa AdjacencyLsa := ADJACENCY-LSA-TYPE TLV-LENGTH Lsa Adjacency*.
A class to house all the configuration parameters for NLSR.
int32_t getHyperbolicState() const
const ndn::Name & getRouterPrefix() const
AdjacencyList & getAdjacencyList()
Maps names to lists of next hops, and exports this information to NFD.
bool doesLsaExist(const ndn::Name &router, Lsa::Type lsaType)
Returns whether the LSDB contains some LSA.
bool getIsBuildAdjLsaSheduled() const
std::pair< LsaContainer::index< Lsdb::byType >::type::iterator, LsaContainer::index< Lsdb::byType >::type::iterator > getLsdbIterator() const
void createFromAdjLsdb(IteratorType begin, IteratorType end)
size_t getMapSize() const
Data abstraction for Nexthop.
void addNextHop(const NextHop &nh)
Adds a next hop to the list.
Data abstraction for RouteTableInfo.
const ndn::Name & getDestination() const
NexthopList & getNexthopList()
RoutingTable(ndn::Scheduler &scheduler, Fib &fib, Lsdb &lsdb, NamePrefixTable &namePrefixTable, ConfParameter &confParam)
void calculate()
Calculates a list of next hops for each router in the network.
void scheduleRoutingTableCalculation()
Schedules a calculation event in the event scheduler only if one isn't already scheduled.
void addNextHopToDryTable(const ndn::Name &destRouter, NextHop &nh)
Adds a next hop to a routing table entry in a dry run scenario.
void addNextHop(const ndn::Name &destRouter, NextHop &nh)
Adds a next hop to a routing table entry.
RoutingTableEntry * findRoutingTableEntry(const ndn::Name &destRouter)
Data abstraction for routing table status.
const std::list< RoutingTableEntry > & getDryRoutingTableEntry() const
std::list< RoutingTableEntry > m_dryTable
std::list< RoutingTableEntry > m_rTable
const ndn::Block & wireEncode() const
const std::list< RoutingTableEntry > & getRoutingTableEntry() const
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
#define NLSR_LOG_DEBUG(x)
#define INIT_LOGGER(name)
#define NLSR_LOG_TRACE(x)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California,...
ndn::util::Signal< RoutingTable, const std::list< RoutingTableEntry > & > AfterRoutingChange
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
static bool routingTableEntryCompare(RoutingTableEntry &rte, ndn::Name &destRouter)
@ HYPERBOLIC_STATE_DRY_RUN
NDN_CXX_DEFINE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)