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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#ifndef HWMP_RTABLE_H
10#define HWMP_RTABLE_H
11
12#include "hwmp-protocol.h"
13
14#include "ns3/mac48-address.h"
15#include "ns3/nstime.h"
16
17#include <map>
18
19namespace ns3
20{
21namespace dot11s
22{
23/**
24 * \ingroup dot11s
25 *
26 * \brief Routing table for HWMP -- 802.11s routing protocol
27 */
28class HwmpRtable : public Object
29{
30 public:
31 /// Means all interfaces
32 const static uint32_t INTERFACE_ANY = 0xffffffff;
33 /// Maximum (the best?) path metric
34 const static uint32_t MAX_METRIC = 0xffffffff;
35
36 /// Route lookup result, return type of LookupXXX methods
38 {
39 Mac48Address retransmitter; ///< retransmitter
40 uint32_t ifIndex; ///< IF index
41 uint32_t metric; ///< metric
42 uint32_t seqnum; ///< sequence number
43 Time lifetime; ///< lifetime
44 /**
45 * Lookup result function
46 *
47 * \param r the result address
48 * \param i the interface
49 * \param m the metric
50 * \param s the sequence number
51 * \param l the lifetime
52 */
56 uint32_t s = 0,
57 Time l = Seconds(0.0));
58 /**
59 * \returns True for valid route
60 */
61 bool IsValid() const;
62 /**
63 * Compare route lookup results, used by tests
64 * \param o the lookup result to compare
65 * \returns true if equal
66 */
67 bool operator==(const LookupResult& o) const;
68 };
69
70 /// Path precursor = {MAC, interface ID}
71 typedef std::vector<std::pair<uint32_t, Mac48Address>> PrecursorList;
72
73 public:
74 /**
75 * \brief Get the type ID.
76 * \return the object TypeId
77 */
78 static TypeId GetTypeId();
79 HwmpRtable();
80 ~HwmpRtable() override;
81 void DoDispose() override;
82
83 /// \name Add/delete paths
84 ///@{
85
86 /**
87 * Add a reactive path
88 * \param destination the destination address
89 * \param retransmitter the retransmitter address
90 * \param interface the interface
91 * \param metric the metric
92 * \param lifetime the lifetime
93 * \param seqnum the sequence number
94 */
95 void AddReactivePath(Mac48Address destination,
96 Mac48Address retransmitter,
97 uint32_t interface,
98 uint32_t metric,
99 Time lifetime,
100 uint32_t seqnum);
101 /**
102 * Add a proactive path
103 * \param metric the metric
104 * \param root the address of the root
105 * \param retransmitter the retransmitter address
106 * \param interface the interface
107 * \param lifetime the lifetime
108 * \param seqnum the sequence number
109 */
110 void AddProactivePath(uint32_t metric,
111 Mac48Address root,
112 Mac48Address retransmitter,
113 uint32_t interface,
114 Time lifetime,
115 uint32_t seqnum);
116 /**
117 * Add a precursor
118 * \param destination the destination address
119 * \param precursorInterface the precursor interface
120 * \param precursorAddress the address of the precursor
121 * \param lifetime the lifetime
122 */
123 void AddPrecursor(Mac48Address destination,
124 uint32_t precursorInterface,
125 Mac48Address precursorAddress,
126 Time lifetime);
127
128 /**
129 * Get the precursors list
130 * \param destination the destination
131 * \return the precursors list
132 */
134
135 /**
136 * Delete all the proactive paths
137 */
138 void DeleteProactivePath();
139 /**
140 * Delete all the proactive paths from a given root
141 * \param root the address of the root
142 */
144 /**
145 * Delete the reactive paths toward a destination
146 * \param destination the destination
147 */
148 void DeleteReactivePath(Mac48Address destination);
149 ///@}
150
151 /// \name Lookup
152 ///@{
153 /**
154 * Lookup path to destination
155 * \param destination the destination
156 * \return The lookup result
157 */
159 /**
160 * Return all reactive paths, including expired
161 * \param destination the destination
162 * \return The lookup result
163 */
165 /**
166 * Find proactive path to tree root. Note that calling this method has side effect of deleting
167 * expired proactive path
168 * \return The lookup result
169 */
171 /**
172 * Return all proactive paths, including expired
173 * \return The lookup result
174 */
176 ///@}
177
178 /**
179 * When peer link with a given MAC-address fails - it returns list of unreachable destination
180 * addresses
181 * \param peerAddress the peer address
182 * \returns the list of unreachable destinations
183 */
184 std::vector<HwmpProtocol::FailedDestination> GetUnreachableDestinations(
185 Mac48Address peerAddress);
186
187 private:
188 /// Route found in reactive mode
190 {
191 Mac48Address address; ///< address
192 uint32_t interface; ///< interface
193 Time whenExpire; ///< expire time
194 };
195
196 /// Route found in reactive mode
198 {
199 Mac48Address retransmitter; ///< transmitter
200 uint32_t interface; ///< interface
201 uint32_t metric; ///< metric
202 Time whenExpire; ///< expire time
203 uint32_t seqnum; ///< sequence number
204 std::vector<Precursor> precursors; ///< precursors
205 };
206
207 /// Route found in proactive mode
209 {
211 Mac48Address retransmitter; ///< retransmitter
212 uint32_t interface; ///< interface
213 uint32_t metric; ///< metric
214 Time whenExpire; ///< expire time
215 uint32_t seqnum; ///< sequence number
216 std::vector<Precursor> precursors; ///< precursors
217 };
218
219 /// List of routes
220 std::map<Mac48Address, ReactiveRoute> m_routes;
221 /// Path to proactive tree root MP
223};
224} // namespace dot11s
225} // namespace ns3
226#endif
an EUI-48 address
static Mac48Address GetBroadcast()
A base class which provides memory management and object aggregation.
Definition object.h:78
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Routing table for HWMP – 802.11s routing protocol.
Definition hwmp-rtable.h:29
void DeleteReactivePath(Mac48Address destination)
Delete the reactive paths toward a destination.
void DoDispose() override
Destructor implementation.
static const uint32_t INTERFACE_ANY
Means all interfaces.
Definition hwmp-rtable.h:32
static const uint32_t MAX_METRIC
Maximum (the best?) path metric.
Definition hwmp-rtable.h:34
LookupResult LookupReactive(Mac48Address destination)
Lookup path to destination.
LookupResult LookupReactiveExpired(Mac48Address destination)
Return all reactive paths, including expired.
static TypeId GetTypeId()
Get the type ID.
std::map< Mac48Address, ReactiveRoute > m_routes
List of routes.
PrecursorList GetPrecursors(Mac48Address destination)
Get the precursors list.
void DeleteProactivePath()
Delete all the proactive paths.
LookupResult LookupProactiveExpired()
Return all proactive paths, including expired.
std::vector< std::pair< uint32_t, Mac48Address > > PrecursorList
Path precursor = {MAC, interface ID}.
Definition hwmp-rtable.h:71
std::vector< HwmpProtocol::FailedDestination > GetUnreachableDestinations(Mac48Address peerAddress)
When peer link with a given MAC-address fails - it returns list of unreachable destination addresses.
ProactiveRoute m_root
Path to proactive tree root MP.
LookupResult LookupProactive()
Find proactive path to tree root.
void AddPrecursor(Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress, Time lifetime)
Add a precursor.
void AddProactivePath(uint32_t metric, Mac48Address root, Mac48Address retransmitter, uint32_t interface, Time lifetime, uint32_t seqnum)
Add a proactive path.
void AddReactivePath(Mac48Address destination, Mac48Address retransmitter, uint32_t interface, uint32_t metric, Time lifetime, uint32_t seqnum)
Add a reactive path.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
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:38
LookupResult(Mac48Address r=Mac48Address::GetBroadcast(), uint32_t i=INTERFACE_ANY, uint32_t m=MAX_METRIC, uint32_t s=0, Time l=Seconds(0.0))
Lookup result function.
bool operator==(const LookupResult &o) const
Compare route lookup results, used by tests.
uint32_t seqnum
sequence number
Definition hwmp-rtable.h:42
Mac48Address retransmitter
retransmitter
Definition hwmp-rtable.h:39
Route found in reactive mode.
Route found in proactive mode.
std::vector< Precursor > precursors
precursors
Mac48Address retransmitter
retransmitter
Route found in reactive mode.
Mac48Address retransmitter
transmitter
std::vector< Precursor > precursors
precursors