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 
41 {
42 public:
43  RoutingTable(ndn::Scheduler& scheduler);
44 
50  void
51  calculate(Nlsr& pnlsr);
52 
57  void
58  addNextHop(const ndn::Name& destRouter, NextHop& nh);
59 
64  void
65  addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
66 
68  findRoutingTableEntry(const ndn::Name& destRouter);
69 
74  void
76 
77  int
79  {
80  return m_NO_NEXT_HOP;
81  }
82 
83  void
84  setRoutingCalcInterval(uint32_t interval)
85  {
86  m_routingCalcInterval = ndn::time::seconds(interval);
87  }
88 
89  const ndn::time::seconds&
91  {
92  return m_routingCalcInterval;
93  }
94 
95 private:
97  void
98  calculateLsRoutingTable(Nlsr& pnlsr);
99 
101  void
102  calculateHypRoutingTable(Nlsr& pnlsr);
103 
105  void
106  calculateHypDryRoutingTable(Nlsr& pnlsr);
107 
108  void
109  clearRoutingTable();
110 
111  void
112  clearDryRoutingTable();
113 
114  void
115  writeLog(int hyperbolicState);
116 
117 public:
118  std::unique_ptr<AfterRoutingChange> afterRoutingChange;
119 
121  std::list<RoutingTableEntry> m_rTable;
122 
123 private:
124  ndn::Scheduler& m_scheduler;
125 
126  const int m_NO_NEXT_HOP;
127 
128  std::list<RoutingTableEntry> m_dryTable;
129 
130  ndn::time::seconds m_routingCalcInterval;
131 };
132 
133 } // namespace nlsr
134 
135 #endif // NLSR_ROUTING_TABLE_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
void calculate(Nlsr &pnlsr)
Calculates a list of next hops for each router in the network.
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-2017, 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