A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
hwmp-rtable.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008,2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#ifndef HWMP_RTABLE_H
21#define HWMP_RTABLE_H
22
23#include "hwmp-protocol.h"
24
25#include "ns3/mac48-address.h"
26#include "ns3/nstime.h"
27
28#include <map>
29
30namespace ns3
31{
32namespace dot11s
33{
34/**
35 * \ingroup dot11s
36 *
37 * \brief Routing table for HWMP -- 802.11s routing protocol
38 */
39class HwmpRtable : public Object
40{
41 public:
42 /// Means all interfaces
43 const static uint32_t INTERFACE_ANY = 0xffffffff;
44 /// Maximum (the best?) path metric
45 const static uint32_t MAX_METRIC = 0xffffffff;
46
47 /// Route lookup result, return type of LookupXXX methods
49 {
50 Mac48Address retransmitter; ///< retransmitter
51 uint32_t ifIndex; ///< IF index
52 uint32_t metric; ///< metric
53 uint32_t seqnum; ///< sequence number
54 Time lifetime; ///< lifetime
55 /**
56 * Lookup result function
57 *
58 * \param r the result address
59 * \param i the interface
60 * \param m the metric
61 * \param s the sequence number
62 * \param l the lifetime
63 */
67 uint32_t s = 0,
68 Time l = Seconds(0.0));
69 /**
70 * \returns True for valid route
71 */
72 bool IsValid() const;
73 /**
74 * Compare route lookup results, used by tests
75 * \param o the lookup result to compare
76 * \returns true if equal
77 */
78 bool operator==(const LookupResult& o) const;
79 };
80
81 /// Path precursor = {MAC, interface ID}
82 typedef std::vector<std::pair<uint32_t, Mac48Address>> PrecursorList;
83
84 public:
85 /**
86 * \brief Get the type ID.
87 * \return the object TypeId
88 */
89 static TypeId GetTypeId();
90 HwmpRtable();
91 ~HwmpRtable() override;
92 void DoDispose() override;
93
94 /// \name Add/delete paths
95 ///@{
96
97 /**
98 * Add a reactive path
99 * \param destination the destination address
100 * \param retransmitter the retransmitter address
101 * \param interface the interface
102 * \param metric the metric
103 * \param lifetime the lifetime
104 * \param seqnum the sequence number
105 */
106 void AddReactivePath(Mac48Address destination,
107 Mac48Address retransmitter,
108 uint32_t interface,
109 uint32_t metric,
110 Time lifetime,
111 uint32_t seqnum);
112 /**
113 * Add a proactive path
114 * \param metric the metric
115 * \param root the address of the root
116 * \param retransmitter the retransmitter address
117 * \param interface the interface
118 * \param lifetime the lifetime
119 * \param seqnum the sequence number
120 */
121 void AddProactivePath(uint32_t metric,
122 Mac48Address root,
123 Mac48Address retransmitter,
124 uint32_t interface,
125 Time lifetime,
126 uint32_t seqnum);
127 /**
128 * Add a precursor
129 * \param destination the destination address
130 * \param precursorInterface the precursor interface
131 * \param precursorAddress the address of the precursor
132 * \param lifetime the lifetime
133 */
134 void AddPrecursor(Mac48Address destination,
135 uint32_t precursorInterface,
136 Mac48Address precursorAddress,
137 Time lifetime);
138
139 /**
140 * Get the precursors list
141 * \param destination the destination
142 * \return the precursors list
143 */
145
146 /**
147 * Delete all the proactive paths
148 */
149 void DeleteProactivePath();
150 /**
151 * Delete all the proactive paths from a given root
152 * \param root the address of the root
153 */
155 /**
156 * Delete the reactive paths toward a destination
157 * \param destination the destination
158 */
159 void DeleteReactivePath(Mac48Address destination);
160 ///@}
161
162 /// \name Lookup
163 ///@{
164 /**
165 * Lookup path to destination
166 * \param destination the destination
167 * \return The lookup result
168 */
170 /**
171 * Return all reactive paths, including expired
172 * \param destination the destination
173 * \return The lookup result
174 */
176 /**
177 * Find proactive path to tree root. Note that calling this method has side effect of deleting
178 * expired proactive path
179 * \return The lookup result
180 */
182 /**
183 * Return all proactive paths, including expired
184 * \return The lookup result
185 */
187 ///@}
188
189 /**
190 * When peer link with a given MAC-address fails - it returns list of unreachable destination
191 * addresses
192 * \param peerAddress the peer address
193 * \returns the list of unreachable destinations
194 */
195 std::vector<HwmpProtocol::FailedDestination> GetUnreachableDestinations(
196 Mac48Address peerAddress);
197
198 private:
199 /// Route found in reactive mode
201 {
202 Mac48Address address; ///< address
203 uint32_t interface; ///< interface
204 Time whenExpire; ///< expire time
205 };
206
207 /// Route found in reactive mode
209 {
210 Mac48Address retransmitter; ///< transmitter
211 uint32_t interface; ///< interface
212 uint32_t metric; ///< metric
213 Time whenExpire; ///< expire time
214 uint32_t seqnum; ///< sequence number
215 std::vector<Precursor> precursors; ///< precursors
216 };
217
218 /// Route found in proactive mode
220 {
222 Mac48Address retransmitter; ///< retransmitter
223 uint32_t interface; ///< interface
224 uint32_t metric; ///< metric
225 Time whenExpire; ///< expire time
226 uint32_t seqnum; ///< sequence number
227 std::vector<Precursor> precursors; ///< precursors
228 };
229
230 /// List of routes
231 std::map<Mac48Address, ReactiveRoute> m_routes;
232 /// Path to proactive tree root MP
234};
235} // namespace dot11s
236} // namespace ns3
237#endif
an EUI-48 address
Definition: mac48-address.h:46
static Mac48Address GetBroadcast()
A base class which provides memory management and object aggregation.
Definition: object.h:89
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Routing table for HWMP – 802.11s routing protocol.
Definition: hwmp-rtable.h:40
void DeleteReactivePath(Mac48Address destination)
Delete the reactive paths toward a destination.
Definition: hwmp-rtable.cc:161
void DoDispose() override
Destructor implementation.
Definition: hwmp-rtable.cc:58
static const uint32_t INTERFACE_ANY
Means all interfaces.
Definition: hwmp-rtable.h:43
static const uint32_t MAX_METRIC
Maximum (the best?) path metric.
Definition: hwmp-rtable.h:45
LookupResult LookupReactive(Mac48Address destination)
Lookup path to destination.
Definition: hwmp-rtable.cc:172
LookupResult LookupReactiveExpired(Mac48Address destination)
Return all reactive paths, including expired.
Definition: hwmp-rtable.cc:189
static TypeId GetTypeId()
Get the type ID.
Definition: hwmp-rtable.cc:39
std::map< Mac48Address, ReactiveRoute > m_routes
List of routes.
Definition: hwmp-rtable.h:231
PrecursorList GetPrecursors(Mac48Address destination)
Get the precursors list.
Definition: hwmp-rtable.cc:256
void DeleteProactivePath()
Delete all the proactive paths.
Definition: hwmp-rtable.cc:139
LookupResult LookupProactiveExpired()
Return all proactive paths, including expired.
Definition: hwmp-rtable.cc:218
std::vector< std::pair< uint32_t, Mac48Address > > PrecursorList
Path precursor = {MAC, interface ID}.
Definition: hwmp-rtable.h:82
std::vector< HwmpProtocol::FailedDestination > GetUnreachableDestinations(Mac48Address peerAddress)
When peer link with a given MAC-address fails - it returns list of unreachable destination addresses.
Definition: hwmp-rtable.cc:230
ProactiveRoute m_root
Path to proactive tree root MP.
Definition: hwmp-rtable.h:233
LookupResult LookupProactive()
Find proactive path to tree root.
Definition: hwmp-rtable.cc:206
void AddPrecursor(Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress, Time lifetime)
Add a precursor.
Definition: hwmp-rtable.cc:106
void AddProactivePath(uint32_t metric, Mac48Address root, Mac48Address retransmitter, uint32_t interface, Time lifetime, uint32_t seqnum)
Add a proactive path.
Definition: hwmp-rtable.cc:89
void AddReactivePath(Mac48Address destination, Mac48Address retransmitter, uint32_t interface, uint32_t metric, Time lifetime, uint32_t seqnum)
Add a reactive path.
Definition: hwmp-rtable.cc:64
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Route lookup result, return type of LookupXXX methods.
Definition: hwmp-rtable.h:49
bool operator==(const LookupResult &o) const
Compare route lookup results, used by tests.
Definition: hwmp-rtable.cc:276
uint32_t seqnum
sequence number
Definition: hwmp-rtable.h:53
Mac48Address retransmitter
retransmitter
Definition: hwmp-rtable.h:50
Route found in reactive mode.
Definition: hwmp-rtable.h:201
Route found in proactive mode.
Definition: hwmp-rtable.h:220
std::vector< Precursor > precursors
precursors
Definition: hwmp-rtable.h:227
Mac48Address retransmitter
retransmitter
Definition: hwmp-rtable.h:222
Route found in reactive mode.
Definition: hwmp-rtable.h:209
Mac48Address retransmitter
transmitter
Definition: hwmp-rtable.h:210
std::vector< Precursor > precursors
precursors
Definition: hwmp-rtable.h:215
uint32_t seqnum
sequence number
Definition: hwmp-rtable.h:214