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  int
80  {
81  return m_NO_NEXT_HOP;
82  }
83 
84  void
85  setRoutingCalcInterval(uint32_t interval)
86  {
87  m_routingCalcInterval = ndn::time::seconds(interval);
88  }
89 
90  const ndn::time::seconds&
92  {
93  return m_routingCalcInterval;
94  }
95 
96  const std::list<RoutingTableEntry>&
98  {
99  return m_rTable;
100  }
101 
102  const std::list<RoutingTableEntry>&
104  {
105  return m_dryTable;
106  }
107 
108  uint64_t
110  {
111  return m_rTable.size();
112  }
113 
114 private:
116  void
117  calculateLsRoutingTable();
118 
120  void
121  calculateHypRoutingTable(bool isDryRun);
122 
123  void
124  clearRoutingTable();
125 
126  void
127  clearDryRoutingTable();
128 
129  void
130  writeLog();
131 
132 public:
133  std::unique_ptr<AfterRoutingChange> afterRoutingChange;
134 
136  std::list<RoutingTableEntry> m_rTable;
137 
138 private:
139  ndn::Scheduler& m_scheduler;
140  Fib& m_fib;
141  Lsdb& m_lsdb;
142  NamePrefixTable& m_namePrefixTable;
143 
144  const int m_NO_NEXT_HOP;
145 
146  std::list<RoutingTableEntry> m_dryTable;
147 
148  ndn::time::seconds m_routingCalcInterval;
149 
150  bool m_isRoutingTableCalculating;
151  bool m_isRouteCalculationScheduled;
152 
153  ConfParameter& m_confParam;
154 };
155 
156 } // namespace nlsr
157 
158 #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:53
const std::list< RoutingTableEntry > & getDryRoutingTableEntry() const
void setRoutingCalcInterval(uint32_t interval)
Copyright (c) 2014-2018, 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