routing-table.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NLSR_ROUTING_TABLE_HPP
23 #define NLSR_ROUTING_TABLE_HPP
24 
25 #include "conf-parameter.hpp"
26 #include "routing-table-entry.hpp"
27 #include "signals.hpp"
28 #include "lsdb.hpp"
29 #include "route/fib.hpp"
30 
31 #include <iostream>
32 #include <utility>
33 #include <string>
34 #include <boost/cstdint.hpp>
35 #include <ndn-cxx/util/scheduler.hpp>
36 
37 namespace nlsr {
38 
39 class NextHop;
40 
41 class RoutingTable : boost::noncopyable
42 {
43 public:
44  explicit
45  RoutingTable(ndn::Scheduler& scheduler, Fib& fib, Lsdb& lsdb,
46  NamePrefixTable& namePrefixTable, ConfParameter& confParam);
47 
52  void
53  calculate();
54 
59  void
60  addNextHop(const ndn::Name& destRouter, NextHop& nh);
61 
66  void
67  addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
68 
70  findRoutingTableEntry(const ndn::Name& destRouter);
71 
75  void
77 
78  void
79  setRoutingCalcInterval(uint32_t interval)
80  {
81  m_routingCalcInterval = ndn::time::seconds(interval);
82  }
83 
84  const ndn::time::seconds&
86  {
87  return m_routingCalcInterval;
88  }
89 
90  const std::list<RoutingTableEntry>&
92  {
93  return m_rTable;
94  }
95 
96  const std::list<RoutingTableEntry>&
98  {
99  return m_dryTable;
100  }
101 
102  uint64_t
104  {
105  return m_rTable.size();
106  }
107 
108 private:
110  void
111  calculateLsRoutingTable();
112 
114  void
115  calculateHypRoutingTable(bool isDryRun);
116 
117  void
118  clearRoutingTable();
119 
120  void
121  clearDryRoutingTable();
122 
123  void
124  writeLog();
125 
126 public:
127  std::unique_ptr<AfterRoutingChange> afterRoutingChange;
128 
130  std::list<RoutingTableEntry> m_rTable;
131 
132 private:
133  ndn::Scheduler& m_scheduler;
134  Fib& m_fib;
135  Lsdb& m_lsdb;
136  NamePrefixTable& m_namePrefixTable;
137 
138  std::list<RoutingTableEntry> m_dryTable;
139 
140  ndn::time::seconds m_routingCalcInterval;
141 
142  bool m_isRoutingTableCalculating;
143  bool m_isRouteCalculationScheduled;
144 
145  ConfParameter& m_confParam;
146 };
147 
148 } // namespace nlsr
149 
150 #endif // NLSR_ROUTING_TABLE_HPP
void calculate()
Calculates a list of next hops for each router in the network.
A class to house all the configuration parameters for NLSR.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
void scheduleRoutingTableCalculation()
Schedules a calculation event in the event scheduler only if one isn&#39;t already scheduled.
RoutingTable(ndn::Scheduler &scheduler, Fib &fib, Lsdb &lsdb, NamePrefixTable &namePrefixTable, ConfParameter &confParam)
Maps names to lists of next hops, and exports this information to NFD.
Definition: fib.hpp:52
const std::list< RoutingTableEntry > & getDryRoutingTableEntry() const
void setRoutingCalcInterval(uint32_t interval)
Copyright (c) 2014-2019, The University of Memphis, Regents of the University of California, Arizona Board of Regents.
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)
std::unique_ptr< AfterRoutingChange > afterRoutingChange
void addNextHop(const ndn::Name &destRouter, NextHop &nh)
Adds a next hop to a routing table entry.
const ndn::time::seconds & getRoutingCalcInterval() const
const std::list< RoutingTableEntry > & getRoutingTableEntry() const