Loading...
Searching...
No Matches
routing-table.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2023, The University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef NLSR_ROUTING_TABLE_HPP
22#define NLSR_ROUTING_TABLE_HPP
23
24#include "conf-parameter.hpp"
26#include "signals.hpp"
27#include "lsdb.hpp"
28#include "route/fib.hpp"
31
32#include <ndn-cxx/util/scheduler.hpp>
33
34namespace nlsr {
35
36class NextHop;
37
46{
47public:
48 using Error = ndn::tlv::Error;
49
50 RoutingTableStatus() = default;
51
52 RoutingTableStatus(const ndn::Block& block)
53 {
54 wireDecode(block);
55 }
56
57 const std::list<RoutingTableEntry>&
59 {
60 return m_rTable;
61 }
62
63 const std::list<RoutingTableEntry>&
65 {
66 return m_dryTable;
67 }
68
69 const ndn::Block&
70 wireEncode() const;
71
72private:
73 void
74 wireDecode(const ndn::Block& wire);
75
76 template<ndn::encoding::Tag TAG>
77 size_t
78 wireEncode(ndn::EncodingImpl<TAG>& block) const;
79
81 std::list<RoutingTableEntry> m_dryTable;
82 std::list<RoutingTableEntry> m_rTable;
83 mutable ndn::Block m_wire;
84};
85
86std::ostream&
87operator<<(std::ostream& os, const RoutingTableStatus& rts);
88
90{
91public:
92 explicit
93 RoutingTable(ndn::Scheduler& scheduler, Lsdb& lsdb, ConfParameter& confParam);
94
96 {
97 m_afterLsdbModified.disconnect();
98 }
99
104 void
105 calculate();
106
111 void
112 addNextHop(const ndn::Name& destRouter, NextHop& nh);
113
118 void
119 addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh);
120
122 findRoutingTableEntry(const ndn::Name& destRouter);
123
127 void
129
130private:
132 void
133 calculateLsRoutingTable();
134
136 void
137 calculateHypRoutingTable(bool isDryRun);
138
139 void
140 clearRoutingTable();
141
142 void
143 clearDryRoutingTable();
144
145public:
147
148private:
149 ndn::Scheduler& m_scheduler;
150 Lsdb& m_lsdb;
151
153 ndn::time::seconds m_routingCalcInterval;
154 bool m_isRoutingTableCalculating;
155 bool m_isRouteCalculationScheduled;
156
157 ConfParameter& m_confParam;
158 ndn::signal::Connection m_afterLsdbModified;
159 int32_t m_hyperbolicState;
160 bool m_ownAdjLsaExist = false;
161};
162
163} // namespace nlsr
164
165#endif // NLSR_ROUTING_TABLE_HPP
A class to house all the configuration parameters for NLSR.
Data abstraction for Nexthop.
Definition nexthop.hpp:47
Data abstraction for RouteTableInfo.
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.
AfterRoutingChange afterRoutingChange
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
RoutingTableStatus(const ndn::Block &block)
const std::list< RoutingTableEntry > & getRoutingTableEntry() const
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition adjacent.cpp:176
ndn::signal::Signal< RoutingTable, std::list< RoutingTableEntry > > AfterRoutingChange
Definition signals.hpp:35
#define PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE