A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
reduced-neighbor-report.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Universita' degli Studi di Napoli Federico II
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Stefano Avallone <stavallo@unina.it>
7 */
8
9#ifndef REDUCED_NEIGHBOR_REPORT_H
10#define REDUCED_NEIGHBOR_REPORT_H
11
13
14#include "ns3/mac48-address.h"
15
16#include <vector>
17
18namespace ns3
19{
20
21class WifiPhyOperatingChannel;
22
23/**
24 * @brief The Reduced Neighbor Report element
25 * @ingroup wifi
26 *
27 * This class knows how to serialize and deserialize the Reduced Neighbor Report element.
28 */
30{
31 public:
32 /**
33 * MLD Parameters subfield
34 */
36 {
37 uint8_t apMldId; //!< AP MLD ID
38 uint8_t linkId : 4; //!< Link ID
39 uint8_t bssParamsChangeCount; //!< BSS Parameters Change Count
40 uint8_t allUpdates : 1; ///< All Updates Included
41 uint8_t disabledLink : 1; ///< Disabled Link Indication
42 };
43
44 /**
45 * TBTT Information field
46 */
48 {
49 uint8_t neighborApTbttOffset{0}; //!< Neighbor AP TBTT Offset
50 Mac48Address bssid; //!< BSSID (optional)
51 uint32_t shortSsid{0}; //!< Short SSID (optional)
52 uint8_t bssParameters{0}; //!< BSS parameters (optional)
53 uint8_t psd20MHz{0}; //!< 20 MHz PSD (optional)
54 MldParameters mldParameters{}; //!< MLD Parameters (optional)
55 };
56
57 /**
58 * TBTT Information Header subfield
59 */
61 {
62 uint8_t type : 2; //!< TBTT Information Field Type (2 bits)
63 uint8_t filtered : 1; //!< Filtered Neighbor AP (1 bit)
64 uint8_t reserved : 1; //!< Reserved (1 bit)
65 uint8_t tbttInfoCount : 4; //!< TBTT Information Count (4 bits)
66 uint8_t tbttInfoLength; //!< TBTT Information Length (8 bits)
67 };
68
69 /**
70 * Neighbor AP information field
71 */
73 {
74 mutable TbttInformationHeader tbttInfoHdr{0, 0, 0, 0, 0}; //!< TBTT Information header
75 uint8_t operatingClass{0}; //!< Operating class
76 uint8_t channelNumber{0}; //!< Primary channel number
77 std::vector<TbttInformation> tbttInformationSet; //!< One or more TBTT Information fields
78
79 bool hasBssid{false}; //!< whether BSSID is present in all TBTT Information fields
80 bool hasShortSsid{false}; //!< whether Short SSID is present in all TBTT Information fields
82 false}; //!< whether BSS parameters is present in all TBTT Information fields
83 bool has20MHzPsd{false}; //!< whether 20 MHz PSD is present in all TBTT Information fields
85 false}; //!< whether MLD Parameters is present in all TBTT Information fields
86 };
87
89
90 // Implementations of pure virtual methods of WifiInformationElement
91 WifiInformationElementId ElementId() const override;
92 uint16_t GetInformationFieldSize() const override;
93 void SerializeInformationField(Buffer::Iterator start) const override;
94 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
95 void Print(std::ostream& os) const override;
96
97 /**
98 * Get the number of Neighbor AP Information fields
99 *
100 * @return the number of Neighbor AP Information fields
101 */
102 std::size_t GetNNbrApInfoFields() const;
103 /**
104 * Add a Neighbor AP Information field
105 */
106 void AddNbrApInfoField();
107
108 /**
109 * Set the Operating Class and the Channel Number fields of the given
110 * Neighbor AP Information field based on the given operating channel.
111 *
112 * @param nbrApInfoId identifier of the given Neighbor AP Information field
113 * @param channel the PHY operating channel
114 */
115 void SetOperatingChannel(std::size_t nbrApInfoId, const WifiPhyOperatingChannel& channel);
116 /**
117 * Get the operating channel coded into the Operating Class and the Channel Number
118 * fields of the given Neighbor AP Information field.
119 *
120 * @param nbrApInfoId identifier of the given Neighbor AP Information field
121 * @return the PHY operating channel
122 */
123 WifiPhyOperatingChannel GetOperatingChannel(std::size_t nbrApInfoId) const;
124
125 /**
126 * Get the number of TBTT Information fields included in the TBTT Information Set
127 * field of the given Neighbor AP Information field
128 *
129 * @param nbrApInfoId identifier of the given Neighbor AP Information field
130 * @return the number of TBTT Information fields
131 */
132 std::size_t GetNTbttInformationFields(std::size_t nbrApInfoId) const;
133 /**
134 * Add a TBTT Information fields to the TBTT Information Set field
135 * of the given Neighbor AP Information field
136 *
137 * @param nbrApInfoId identifier of the given Neighbor AP Information field
138 */
139 void AddTbttInformationField(std::size_t nbrApInfoId);
140
141 /**
142 * Set the BSSID field of the <i>i</i>-th TBTT Information field of the given
143 * Neighbor AP Information field
144 *
145 * @param nbrApInfoId identifier of the given Neighbor AP Information field
146 * @param index the index of the given TBTT Information field
147 * @param bssid the BSSID value
148 */
149 void SetBssid(std::size_t nbrApInfoId, std::size_t index, Mac48Address bssid);
150 /**
151 * Return true if the BSSID field is present in all the TBTT Information fields
152 * of the given Neighbor AP Information field.
153 *
154 * @param nbrApInfoId identifier of the given Neighbor AP Information field
155 * @return true if the BSSID field is present
156 */
157 bool HasBssid(std::size_t nbrApInfoId) const;
158 /**
159 * Get the BSSID field (must be present) in the <i>i</i>-th TBTT Information field
160 * of the given Neighbor AP Information field.
161 *
162 * @param nbrApInfoId identifier of the given Neighbor AP Information field
163 * @param index the index of the given TBTT Information field
164 * @return the BSSID field
165 */
166 Mac48Address GetBssid(std::size_t nbrApInfoId, std::size_t index) const;
167
168 /**
169 * Set the Short SSID field of the <i>i</i>-th TBTT Information field of the given
170 * Neighbor AP Information field
171 *
172 * @param nbrApInfoId identifier of the given Neighbor AP Information field
173 * @param index the index of the given TBTT Information field
174 * @param shortSsid the short SSID value
175 */
176 void SetShortSsid(std::size_t nbrApInfoId, std::size_t index, uint32_t shortSsid);
177 /**
178 * Return true if the Short SSID field is present in all the TBTT Information fields
179 * of the given Neighbor AP Information field.
180 *
181 * @param nbrApInfoId identifier of the given Neighbor AP Information field
182 * @return true if the Short SSID field is present
183 */
184 bool HasShortSsid(std::size_t nbrApInfoId) const;
185 /**
186 * Get the Short SSID field (must be present) in the <i>i</i>-th TBTT Information field
187 * of the given Neighbor AP Information field.
188 *
189 * @param nbrApInfoId identifier of the given Neighbor AP Information field
190 * @param index the index of the given TBTT Information field
191 * @return the Short SSID field
192 */
193 uint32_t GetShortSsid(std::size_t nbrApInfoId, std::size_t index) const;
194
195 /**
196 * Set the BSS Parameters field of the <i>i</i>-th TBTT Information field of the given
197 * Neighbor AP Information field
198 *
199 * @param nbrApInfoId identifier of the given Neighbor AP Information field
200 * @param index the index of the given TBTT Information field
201 * @param bssParameters the BSS Parameters value
202 */
203 void SetBssParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t bssParameters);
204 /**
205 * Return true if the BSS Parameters field is present in all the TBTT Information fields
206 * of the given Neighbor AP Information field.
207 *
208 * @param nbrApInfoId identifier of the given Neighbor AP Information field
209 * @return true if the BSS Parameters field is present
210 */
211 bool HasBssParameters(std::size_t nbrApInfoId) const;
212 /**
213 * Get the BSS Parameters field (must be present) in the <i>i</i>-th TBTT Information field
214 * of the given Neighbor AP Information field.
215 *
216 * @param nbrApInfoId identifier of the given Neighbor AP Information field
217 * @param index the index of the given TBTT Information field
218 * @return the BSS Parameters field
219 */
220 uint8_t GetBssParameters(std::size_t nbrApInfoId, std::size_t index) const;
221
222 /**
223 * Set the 20 MHz PSD field of the <i>i</i>-th TBTT Information field of the given
224 * Neighbor AP Information field
225 *
226 * @param nbrApInfoId identifier of the given Neighbor AP Information field
227 * @param index the index of the given TBTT Information field
228 * @param psd20MHz the 20 MHz PSD value
229 */
230 void SetPsd20MHz(std::size_t nbrApInfoId, std::size_t index, uint8_t psd20MHz);
231 /**
232 * Return true if the 20 MHz PSD field is present in all the TBTT Information fields
233 * of the given Neighbor AP Information field.
234 *
235 * @param nbrApInfoId identifier of the given Neighbor AP Information field
236 * @return true if the 20 MHz PSD field is present
237 */
238 bool HasPsd20MHz(std::size_t nbrApInfoId) const;
239 /**
240 * Get the 20 MHz PSD field (must be present) in the <i>i</i>-th TBTT Information field
241 * of the given Neighbor AP Information field.
242 *
243 * @param nbrApInfoId identifier of the given Neighbor AP Information field
244 * @param index the index of the given TBTT Information field
245 * @return the 20 MHz PSD field
246 */
247 uint8_t GetPsd20MHz(std::size_t nbrApInfoId, std::size_t index) const;
248
249 /**
250 * Set the MLD Parameters subfield of the <i>i</i>-th TBTT Information field of the given
251 * Neighbor AP Information field
252 *
253 * @param nbrApInfoId identifier of the given Neighbor AP Information field
254 * @param index the index of the given TBTT Information field
255 * @param mldParams the MLD parameters
256 */
257 void SetMldParameters(std::size_t nbrApInfoId,
258 std::size_t index,
259 const MldParameters& mldParams);
260 /**
261 * Return true if the MLD Parameters subfield is present in all the TBTT Information fields
262 * of the given Neighbor AP Information field.
263 *
264 * @param nbrApInfoId identifier of the given Neighbor AP Information field
265 * @return true if the MLD Parameters subfield is present
266 */
267 bool HasMldParameters(std::size_t nbrApInfoId) const;
268 /**
269 * Get the MLD Parameters subfield (must be present) in the <i>i</i>-th TBTT Information field
270 * of the given Neighbor AP Information field.
271 *
272 * @param nbrApInfoId identifier of the given Neighbor AP Information field
273 * @param index the index of the given TBTT Information field
274 * @return the MLD parameters
275 */
276 const MldParameters& GetMldParameters(std::size_t nbrApInfoId, std::size_t index) const;
277
278 private:
279 /**
280 * Set the TBTT Information Count field of the given Neighbor AP Information field
281 * based on the size of the tbttInformationSet field.
282 *
283 * This method is marked as const because it needs to be called within the
284 * SerializeInformationField method. In fact, only when serializing this object
285 * we can set the TBTT Information Count field based on the number of TBTT Information
286 * fields included in the given Neighbor AP Information field.
287 *
288 * @param nbrApInfoId identifier of the given Neighbor AP Information field
289 */
290 void WriteTbttInformationCount(std::size_t nbrApInfoId) const;
291 /**
292 * Get the TBTT Information Count field of the given Neighbor AP Information field.
293 *
294 * @param nbrApInfoId identifier of the given Neighbor AP Information field
295 * @return the TBTT Information Count
296 */
297 uint8_t ReadTbttInformationCount(std::size_t nbrApInfoId) const;
298
299 /**
300 * Set the TBTT Information Length field of the given Neighbor AP Information field
301 * based on the xxxPresent flags of the NeighborApInformation struct
302 *
303 * This method is marked as const because it needs to be called within the
304 * SerializeInformationField method. In fact, only when serializing this object
305 * we can set the TBTT Information Length field based on the TBTT Information
306 * field contents.
307 *
308 * @param nbrApInfoId identifier of the given Neighbor AP Information field
309 */
310 void WriteTbttInformationLength(std::size_t nbrApInfoId) const;
311 /**
312 * Use the TBTT Information Length field of the given Neighbor AP Information field
313 * to set the xxxPresent flags of the NeighborApInformation struct
314 *
315 * @param nbrApInfoId identifier of the given Neighbor AP Information field
316 */
317 void ReadTbttInformationLength(std::size_t nbrApInfoId);
318
319 std::vector<NeighborApInformation>
320 m_nbrApInfoFields; //!< one or more Neighbor AP Information fields
321};
322
323} // namespace ns3
324
325#endif /* REDUCED_NEIGHBOR_REPORT_H */
iterator in a Buffer instance
Definition buffer.h:89
an EUI-48 address
The Reduced Neighbor Report element.
void WriteTbttInformationLength(std::size_t nbrApInfoId) const
Set the TBTT Information Length field of the given Neighbor AP Information field based on the xxxPres...
Mac48Address GetBssid(std::size_t nbrApInfoId, std::size_t index) const
Get the BSSID field (must be present) in the i-th TBTT Information field of the given Neighbor AP Inf...
std::vector< NeighborApInformation > m_nbrApInfoFields
one or more Neighbor AP Information fields
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
bool HasShortSsid(std::size_t nbrApInfoId) const
Return true if the Short SSID field is present in all the TBTT Information fields of the given Neighb...
std::size_t GetNNbrApInfoFields() const
Get the number of Neighbor AP Information fields.
void WriteTbttInformationCount(std::size_t nbrApInfoId) const
Set the TBTT Information Count field of the given Neighbor AP Information field based on the size of ...
bool HasBssid(std::size_t nbrApInfoId) const
Return true if the BSSID field is present in all the TBTT Information fields of the given Neighbor AP...
uint8_t ReadTbttInformationCount(std::size_t nbrApInfoId) const
Get the TBTT Information Count field of the given Neighbor AP Information field.
void SetShortSsid(std::size_t nbrApInfoId, std::size_t index, uint32_t shortSsid)
Set the Short SSID field of the i-th TBTT Information field of the given Neighbor AP Information fiel...
uint32_t GetShortSsid(std::size_t nbrApInfoId, std::size_t index) const
Get the Short SSID field (must be present) in the i-th TBTT Information field of the given Neighbor A...
void SetBssid(std::size_t nbrApInfoId, std::size_t index, Mac48Address bssid)
Set the BSSID field of the i-th TBTT Information field of the given Neighbor AP Information field.
std::size_t GetNTbttInformationFields(std::size_t nbrApInfoId) const
Get the number of TBTT Information fields included in the TBTT Information Set field of the given Nei...
void SetPsd20MHz(std::size_t nbrApInfoId, std::size_t index, uint8_t psd20MHz)
Set the 20 MHz PSD field of the i-th TBTT Information field of the given Neighbor AP Information fiel...
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
const MldParameters & GetMldParameters(std::size_t nbrApInfoId, std::size_t index) const
Get the MLD Parameters subfield (must be present) in the i-th TBTT Information field of the given Nei...
void AddNbrApInfoField()
Add a Neighbor AP Information field.
WifiPhyOperatingChannel GetOperatingChannel(std::size_t nbrApInfoId) const
Get the operating channel coded into the Operating Class and the Channel Number fields of the given N...
void SetBssParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t bssParameters)
Set the BSS Parameters field of the i-th TBTT Information field of the given Neighbor AP Information ...
void SetMldParameters(std::size_t nbrApInfoId, std::size_t index, const MldParameters &mldParams)
Set the MLD Parameters subfield of the i-th TBTT Information field of the given Neighbor AP Informati...
void Print(std::ostream &os) const override
Generate human-readable form of IE.
uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint8_t GetPsd20MHz(std::size_t nbrApInfoId, std::size_t index) const
Get the 20 MHz PSD field (must be present) in the i-th TBTT Information field of the given Neighbor A...
bool HasMldParameters(std::size_t nbrApInfoId) const
Return true if the MLD Parameters subfield is present in all the TBTT Information fields of the given...
void AddTbttInformationField(std::size_t nbrApInfoId)
Add a TBTT Information fields to the TBTT Information Set field of the given Neighbor AP Information ...
void ReadTbttInformationLength(std::size_t nbrApInfoId)
Use the TBTT Information Length field of the given Neighbor AP Information field to set the xxxPresen...
bool HasBssParameters(std::size_t nbrApInfoId) const
Return true if the BSS Parameters field is present in all the TBTT Information fields of the given Ne...
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void SetOperatingChannel(std::size_t nbrApInfoId, const WifiPhyOperatingChannel &channel)
Set the Operating Class and the Channel Number fields of the given Neighbor AP Information field base...
bool HasPsd20MHz(std::size_t nbrApInfoId) const
Return true if the 20 MHz PSD field is present in all the TBTT Information fields of the given Neighb...
uint8_t GetBssParameters(std::size_t nbrApInfoId, std::size_t index) const
Get the BSS Parameters field (must be present) in the i-th TBTT Information field of the given Neighb...
Information element, as defined in 802.11-2007 standard.
Class that keeps track of all information about the current PHY operating channel.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
uint8_t disabledLink
Disabled Link Indication.
uint8_t bssParamsChangeCount
BSS Parameters Change Count.
std::vector< TbttInformation > tbttInformationSet
One or more TBTT Information fields.
bool hasMldParams
whether MLD Parameters is present in all TBTT Information fields
TbttInformationHeader tbttInfoHdr
TBTT Information header.
bool hasShortSsid
whether Short SSID is present in all TBTT Information fields
bool hasBssParams
whether BSS parameters is present in all TBTT Information fields
bool has20MHzPsd
whether 20 MHz PSD is present in all TBTT Information fields
bool hasBssid
whether BSSID is present in all TBTT Information fields
uint8_t tbttInfoLength
TBTT Information Length (8 bits)
uint8_t tbttInfoCount
TBTT Information Count (4 bits)
uint8_t type
TBTT Information Field Type (2 bits)
uint8_t neighborApTbttOffset
Neighbor AP TBTT Offset.
MldParameters mldParameters
MLD Parameters (optional)