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 serialise and deserialise the Reduced Neighbor Report element.
28 */
30{
31 public:
32 /**
33 * MLD Parameters subfield
34 */
36 {
37 uint8_t mldId; //!< MLD ID
38 uint8_t linkId; //!< Link ID
39 uint8_t bssParamsChangeCount; //!< BSS Parameters Change Count
40 };
41
42 /**
43 * TBTT Information field
44 */
46 {
47 uint8_t neighborApTbttOffset{0}; //!< Neighbor AP TBTT Offset
48 Mac48Address bssid; //!< BSSID (optional)
49 uint32_t shortSsid{0}; //!< Short SSID (optional)
50 uint8_t bssParameters{0}; //!< BSS parameters (optional)
51 uint8_t psd20MHz{0}; //!< 20 MHz PSD (optional)
52 MldParameters mldParameters{0, 0, 0}; //!< MLD Parameters (optional)
53 };
54
55 /**
56 * TBTT Information Header subfield
57 */
59 {
60 uint8_t type : 2; //!< TBTT Information Field Type (2 bits)
61 uint8_t filtered : 1; //!< Filtered Neighbor AP (1 bit)
62 uint8_t reserved : 1; //!< Reserved (1 bit)
63 uint8_t tbttInfoCount : 4; //!< TBTT Information Count (4 bits)
64 uint8_t tbttInfoLength; //!< TBTT Information Length (8 bits)
65 };
66
67 /**
68 * Neighbor AP information field
69 */
71 {
72 mutable TbttInformationHeader tbttInfoHdr{0, 0, 0, 0, 0}; //!< TBTT Information header
73 uint8_t operatingClass{0}; //!< Operating class
74 uint8_t channelNumber{0}; //!< Primary channel number
75 std::vector<TbttInformation> tbttInformationSet; //!< One or more TBTT Information fields
76
77 bool hasBssid{false}; //!< whether BSSID is present in all TBTT Information fields
78 bool hasShortSsid{false}; //!< whether Short SSID is present in all TBTT Information fields
80 false}; //!< whether BSS parameters is present in all TBTT Information fields
81 bool has20MHzPsd{false}; //!< whether 20 MHz PSD is present in all TBTT Information fields
83 false}; //!< whether MLD Parameters is present in all TBTT Information fields
84 };
85
87
88 // Implementations of pure virtual methods of WifiInformationElement
89 WifiInformationElementId ElementId() const override;
90 uint16_t GetInformationFieldSize() const override;
91 void SerializeInformationField(Buffer::Iterator start) const override;
92 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
93
94 /**
95 * Get the number of Neighbor AP Information fields
96 *
97 * \return the number of Neighbor AP Information fields
98 */
99 std::size_t GetNNbrApInfoFields() const;
100 /**
101 * Add a Neighbor AP Information field
102 */
103 void AddNbrApInfoField();
104
105 /**
106 * Set the Operating Class and the Channel Number fields of the given
107 * Neighbor AP Information field based on the given operating channel.
108 *
109 * \param nbrApInfoId identifier of the given Neighbor AP Information field
110 * \param channel the PHY operating channel
111 */
112 void SetOperatingChannel(std::size_t nbrApInfoId, const WifiPhyOperatingChannel& channel);
113 /**
114 * Get the operating channel coded into the Operating Class and the Channel Number
115 * fields of the given Neighbor AP Information field.
116 *
117 * \param nbrApInfoId identifier of the given Neighbor AP Information field
118 * \return the PHY operating channel
119 */
120 WifiPhyOperatingChannel GetOperatingChannel(std::size_t nbrApInfoId) const;
121
122 /**
123 * Get the number of TBTT Information fields included in the TBTT Information Set
124 * field of the given Neighbor AP Information field
125 *
126 * \param nbrApInfoId identifier of the given Neighbor AP Information field
127 * \return the number of TBTT Information fields
128 */
129 std::size_t GetNTbttInformationFields(std::size_t nbrApInfoId) const;
130 /**
131 * Add a TBTT Information fields to the TBTT Information Set field
132 * of the given Neighbor AP Information field
133 *
134 * \param nbrApInfoId identifier of the given Neighbor AP Information field
135 */
136 void AddTbttInformationField(std::size_t nbrApInfoId);
137
138 /**
139 * Set the BSSID field of the <i>i</i>-th TBTT Information field of the given
140 * Neighbor AP Information field
141 *
142 * \param nbrApInfoId identifier of the given Neighbor AP Information field
143 * \param index the index of the given TBTT Information field
144 * \param bssid the BSSID value
145 */
146 void SetBssid(std::size_t nbrApInfoId, std::size_t index, Mac48Address bssid);
147 /**
148 * Return true if the BSSID field is present in all the TBTT Information fields
149 * of the given Neighbor AP Information field.
150 *
151 * \param nbrApInfoId identifier of the given Neighbor AP Information field
152 * \return true if the BSSID field is present
153 */
154 bool HasBssid(std::size_t nbrApInfoId) const;
155 /**
156 * Get the BSSID field (must be present) in the <i>i</i>-th TBTT Information field
157 * of the given Neighbor AP Information field.
158 *
159 * \param nbrApInfoId identifier of the given Neighbor AP Information field
160 * \param index the index of the given TBTT Information field
161 * \return the BSSID field
162 */
163 Mac48Address GetBssid(std::size_t nbrApInfoId, std::size_t index) const;
164
165 /**
166 * Set the Short SSID field of the <i>i</i>-th TBTT Information field of the given
167 * Neighbor AP Information field
168 *
169 * \param nbrApInfoId identifier of the given Neighbor AP Information field
170 * \param index the index of the given TBTT Information field
171 * \param shortSsid the short SSID value
172 */
173 void SetShortSsid(std::size_t nbrApInfoId, std::size_t index, uint32_t shortSsid);
174 /**
175 * Return true if the Short SSID field is present in all the TBTT Information fields
176 * of the given Neighbor AP Information field.
177 *
178 * \param nbrApInfoId identifier of the given Neighbor AP Information field
179 * \return true if the Short SSID field is present
180 */
181 bool HasShortSsid(std::size_t nbrApInfoId) const;
182 /**
183 * Get the Short SSID field (must be present) in the <i>i</i>-th TBTT Information field
184 * of the given Neighbor AP Information field.
185 *
186 * \param nbrApInfoId identifier of the given Neighbor AP Information field
187 * \param index the index of the given TBTT Information field
188 * \return the Short SSID field
189 */
190 uint32_t GetShortSsid(std::size_t nbrApInfoId, std::size_t index) const;
191
192 /**
193 * Set the BSS Parameters field of the <i>i</i>-th TBTT Information field of the given
194 * Neighbor AP Information field
195 *
196 * \param nbrApInfoId identifier of the given Neighbor AP Information field
197 * \param index the index of the given TBTT Information field
198 * \param bssParameters the BSS Parameters value
199 */
200 void SetBssParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t bssParameters);
201 /**
202 * Return true if the BSS Parameters field is present in all the TBTT Information fields
203 * of the given Neighbor AP Information field.
204 *
205 * \param nbrApInfoId identifier of the given Neighbor AP Information field
206 * \return true if the BSS Parameters field is present
207 */
208 bool HasBssParameters(std::size_t nbrApInfoId) const;
209 /**
210 * Get the BSS Parameters field (must be present) in the <i>i</i>-th TBTT Information field
211 * of the given Neighbor AP Information field.
212 *
213 * \param nbrApInfoId identifier of the given Neighbor AP Information field
214 * \param index the index of the given TBTT Information field
215 * \return the BSS Parameters field
216 */
217 uint8_t GetBssParameters(std::size_t nbrApInfoId, std::size_t index) const;
218
219 /**
220 * Set the 20 MHz PSD field of the <i>i</i>-th TBTT Information field of the given
221 * Neighbor AP Information field
222 *
223 * \param nbrApInfoId identifier of the given Neighbor AP Information field
224 * \param index the index of the given TBTT Information field
225 * \param psd20MHz the 20 MHz PSD value
226 */
227 void SetPsd20MHz(std::size_t nbrApInfoId, std::size_t index, uint8_t psd20MHz);
228 /**
229 * Return true if the 20 MHz PSD field is present in all the TBTT Information fields
230 * of the given Neighbor AP Information field.
231 *
232 * \param nbrApInfoId identifier of the given Neighbor AP Information field
233 * \return true if the 20 MHz PSD field is present
234 */
235 bool HasPsd20MHz(std::size_t nbrApInfoId) const;
236 /**
237 * Get the 20 MHz PSD field (must be present) in the <i>i</i>-th TBTT Information field
238 * of the given Neighbor AP Information field.
239 *
240 * \param nbrApInfoId identifier of the given Neighbor AP Information field
241 * \param index the index of the given TBTT Information field
242 * \return the 20 MHz PSD field
243 */
244 uint8_t GetPsd20MHz(std::size_t nbrApInfoId, std::size_t index) const;
245
246 /**
247 * Set the MLD Parameters subfield of the <i>i</i>-th TBTT Information field of the given
248 * Neighbor AP Information field
249 *
250 * \param nbrApInfoId identifier of the given Neighbor AP Information field
251 * \param index the index of the given TBTT Information field
252 * \param mldId the MLD ID value
253 * \param linkId the Link ID value
254 * \param changeSequence the Change Sequence value
255 */
256 void SetMldParameters(std::size_t nbrApInfoId,
257 std::size_t index,
258 uint8_t mldId,
259 uint8_t linkId,
260 uint8_t changeSequence);
261 /**
262 * Return true if the MLD Parameters subfield is present in all the TBTT Information fields
263 * of the given Neighbor AP Information field.
264 *
265 * \param nbrApInfoId identifier of the given Neighbor AP Information field
266 * \return true if the MLD Parameters subfield is present
267 */
268 bool HasMldParameters(std::size_t nbrApInfoId) const;
269 /**
270 * Get the MLD ID value in the MLD Parameters subfield (must be present) in the
271 * <i>i</i>-th TBTT Information field of the given Neighbor AP Information field.
272 *
273 * \param nbrApInfoId identifier of the given Neighbor AP Information field
274 * \param index the index of the given TBTT Information field
275 * \return the MLD ID value
276 */
277 uint8_t GetMldId(std::size_t nbrApInfoId, std::size_t index) const;
278 /**
279 * Get the Link ID value in the MLD Parameters subfield (must be present) in the
280 * <i>i</i>-th TBTT Information field of the given Neighbor AP Information field.
281 *
282 * \param nbrApInfoId identifier of the given Neighbor AP Information field
283 * \param index the index of the given TBTT Information field
284 * \return the Link ID value
285 */
286 uint8_t GetLinkId(std::size_t nbrApInfoId, std::size_t index) const;
287
288 private:
289 /**
290 * Set the TBTT Information Count field of the given Neighbor AP Information field
291 * based on the size of the tbttInformationSet field.
292 *
293 * This method is marked as const because it needs to be called within the
294 * SerializeInformationField method. In fact, only when serializing this object
295 * we can set the TBTT Information Count field based on the number of TBTT Information
296 * fields included in the given Neighbor AP Information field.
297 *
298 * \param nbrApInfoId identifier of the given Neighbor AP Information field
299 */
300 void WriteTbttInformationCount(std::size_t nbrApInfoId) const;
301 /**
302 * Get the TBTT Information Count field of the given Neighbor AP Information field.
303 *
304 * \param nbrApInfoId identifier of the given Neighbor AP Information field
305 * \return the TBTT Information Count
306 */
307 uint8_t ReadTbttInformationCount(std::size_t nbrApInfoId) const;
308
309 /**
310 * Set the TBTT Information Length field of the given Neighbor AP Information field
311 * based on the xxxPresent flags of the NeighborApInformation struct
312 *
313 * This method is marked as const because it needs to be called within the
314 * SerializeInformationField method. In fact, only when serializing this object
315 * we can set the TBTT Information Length field based on the TBTT Information
316 * field contents.
317 *
318 * \param nbrApInfoId identifier of the given Neighbor AP Information field
319 */
320 void WriteTbttInformationLength(std::size_t nbrApInfoId) const;
321 /**
322 * Use the TBTT Information Length field of the given Neighbor AP Information field
323 * to set the xxxPresent flags of the NeighborApInformation struct
324 *
325 * \param nbrApInfoId identifier of the given Neighbor AP Information field
326 */
327 void ReadTbttInformationLength(std::size_t nbrApInfoId);
328
329 std::vector<NeighborApInformation>
330 m_nbrApInfoFields; //!< one or more Neighbor AP Information fields
331};
332
333} // namespace ns3
334
335#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 SetMldParameters(std::size_t nbrApInfoId, std::size_t index, uint8_t mldId, uint8_t linkId, uint8_t changeSequence)
Set the MLD Parameters subfield of the i-th TBTT Information field of the given Neighbor AP Informati...
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...
uint8_t GetLinkId(std::size_t nbrApInfoId, std::size_t index) const
Get the Link ID value in the MLD Parameters subfield (must be present) in the i-th TBTT Information f...
uint8_t GetMldId(std::size_t nbrApInfoId, std::size_t index) const
Get the MLD ID value in the MLD Parameters subfield (must be present) in the i-th TBTT Information fi...
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.
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 ...
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 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)