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 
29 #include <iostream>
30 #include <utility>
31 #include <string>
32 #include <boost/cstdint.hpp>
33 #include <ndn-cxx/util/scheduler.hpp>
34 
35 namespace nlsr {
36 
37 class Nlsr;
38 class NextHop;
39 
40 class RoutingTable : boost::noncopyable
41 {
42 public:
43  explicit
44  RoutingTable(ndn::Scheduler& scheduler);
45 
51  void
53 
58  void
59  addNextHop(const ndn::Name& destRouter, NextHop& nh);
60 
65  void
66  addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
67 
69  findRoutingTableEntry(const ndn::Name& destRouter);
70 
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(Nlsr& pnlsr);
118 
120  void
121  calculateHypRoutingTable(Nlsr& pnlsr);
122 
124  void
125  calculateHypDryRoutingTable(Nlsr& pnlsr);
126 
127  void
128  clearRoutingTable();
129 
130  void
131  clearDryRoutingTable();
132 
133  void
134  writeLog(int hyperbolicState);
135 
136 public:
137  std::unique_ptr<AfterRoutingChange> afterRoutingChange;
138 
140  std::list<RoutingTableEntry> m_rTable;
141 
142 private:
143  ndn::Scheduler& m_scheduler;
144 
145  const int m_NO_NEXT_HOP;
146 
147  std::list<RoutingTableEntry> m_dryTable;
148 
149  ndn::time::seconds m_routingCalcInterval;
150 };
151 
152 } // namespace nlsr
153 
154 #endif // NLSR_ROUTING_TABLE_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
const std::list< RoutingTableEntry > & getDryRoutingTableEntry() const
RoutingTable(ndn::Scheduler &scheduler)
void scheduleRoutingTableCalculation(Nlsr &pnlsr)
Schedules a calculation event in the event scheduler only if one isn&#39;t already scheduled.
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
void calculate(Nlsr &nlsr)
Calculates a list of next hops for each router in the network.
const std::list< RoutingTableEntry > & getRoutingTableEntry() const