A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-information-element.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010 Dean Armstrong
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: Dean Armstrong <deanarm@gmail.com>
18 */
19
20#ifndef WIFI_INFORMATION_ELEMENT_H
21#define WIFI_INFORMATION_ELEMENT_H
22
23#include "ns3/header.h"
24
25#include <optional>
26
27namespace ns3
28{
29
30/// Size in bytes of the Element ID Extension field (IEEE 802.11-2020 9.4.2.1 General)
31constexpr uint8_t WIFI_IE_ELEMENT_ID_EXT_SIZE = 1;
32
33/**
34 * This type is used to represent an Information Element ID. An
35 * enumeration would be tidier, but doesn't provide for the
36 * inheritance that is currently preferable to cleanly support
37 * pre-standard modules such as mesh. Maybe there is a nice way of
38 * doing this with a class.
39 *
40 * Until such time as a better way of implementing this is dreamt up
41 * and applied, developers will need to be careful to avoid
42 * duplication of IE IDs in the defines below (and in files which
43 * declare "subclasses" of WifiInformationElement). Sorry.
44 */
46
47/**
48 * Here we have definition of all Information Element IDs in IEEE
49 * 802.11-2007. See the comments for WifiInformationElementId - this could
50 * probably be done in a considerably tidier manner.
51 */
52#define IE_SSID ((WifiInformationElementId)0)
53#define IE_SUPPORTED_RATES ((WifiInformationElementId)1)
54#define IE_FH_PARAMETER_SET ((WifiInformationElementId)2)
55#define IE_DSSS_PARAMETER_SET ((WifiInformationElementId)3)
56#define IE_CF_PARAMETER_SET ((WifiInformationElementId)4)
57#define IE_TIM ((WifiInformationElementId)5)
58#define IE_IBSS_PARAMETER_SET ((WifiInformationElementId)6)
59#define IE_COUNTRY ((WifiInformationElementId)7)
60#define IE_HOPPING_PATTERN_PARAMETERS ((WifiInformationElementId)8)
61#define IE_HOPPING_PATTERN_TABLE ((WifiInformationElementId)9)
62#define IE_REQUEST ((WifiInformationElementId)10)
63#define IE_BSS_LOAD ((WifiInformationElementId)11)
64#define IE_EDCA_PARAMETER_SET ((WifiInformationElementId)12)
65#define IE_TSPEC ((WifiInformationElementId)13)
66#define IE_TCLAS ((WifiInformationElementId)14)
67#define IE_SCHEDULE ((WifiInformationElementId)15)
68#define IE_CHALLENGE_TEXT ((WifiInformationElementId)16)
69// 17 to 31 are reserved
70#define IE_POWER_CONSTRAINT ((WifiInformationElementId)32)
71#define IE_POWER_CAPABILITY ((WifiInformationElementId)33)
72#define IE_TPC_REQUEST ((WifiInformationElementId)34)
73#define IE_TPC_REPORT ((WifiInformationElementId)35)
74#define IE_SUPPORTED_CHANNELS ((WifiInformationElementId)36)
75#define IE_CHANNEL_SWITCH_ANNOUNCEMENT ((WifiInformationElementId)37)
76#define IE_MEASUREMENT_REQUEST ((WifiInformationElementId)38)
77#define IE_MEASUREMENT_REPORT ((WifiInformationElementId)39)
78#define IE_QUIET ((WifiInformationElementId)40)
79#define IE_IBSS_DFS ((WifiInformationElementId)41)
80#define IE_ERP_INFORMATION ((WifiInformationElementId)42)
81#define IE_TS_DELAY ((WifiInformationElementId)43)
82#define IE_TCLAS_PROCESSING ((WifiInformationElementId)44)
83#define IE_HT_CAPABILITIES ((WifiInformationElementId)45)
84#define IE_QOS_CAPABILITY ((WifiInformationElementId)46)
85// 47 is reserved
86#define IE_RSN ((WifiInformationElementId)48)
87// 49 is reserved
88#define IE_EXTENDED_SUPPORTED_RATES ((WifiInformationElementId)50)
89#define IE_AP_CHANNEL_REPORT ((WifiInformationElementId)51)
90#define IE_NEIGHBOR_REPORT ((WifiInformationElementId)52)
91#define IE_RCPI ((WifiInformationElementId)53)
92#define IE_MOBILITY_DOMAIN ((WifiInformationElementId)54)
93#define IE_FAST_BSS_TRANSITION ((WifiInformationElementId)55)
94#define IE_TIMEOUT_INTERVAL ((WifiInformationElementId)56)
95#define IE_RIC_DATA ((WifiInformationElementId)57)
96#define IE_DSE_REGISTERED_LOCATION ((WifiInformationElementId)58)
97#define IE_SUPPORTED_OPERATING_CLASSES ((WifiInformationElementId)59)
98#define IE_EXTENDED_CHANNEL_SWITCH_ANNOUNCEMENT ((WifiInformationElementId)60)
99#define IE_HT_OPERATION ((WifiInformationElementId)61)
100#define IE_SECONDARY_CHANNEL_OFFSET ((WifiInformationElementId)62)
101#define IE_BSS_AVERAGE_ACCESS_DELAY ((WifiInformationElementId)63)
102#define IE_ANTENNA ((WifiInformationElementId)64)
103#define IE_RSNI ((WifiInformationElementId)65)
104#define IE_MEASUREMENT_PILOT_TRANSMISSION ((WifiInformationElementId)66)
105#define IE_BSS_AVAILABLE_ADMISSION_CAPACITY ((WifiInformationElementId)67)
106#define IE_BSS_AC_ACCESS_DELAY ((WifiInformationElementId)68)
107#define IE_TIME_ADVERTISEMENT ((WifiInformationElementId)69)
108#define IE_RM_ENABLED_CAPACITIES ((WifiInformationElementId)70)
109#define IE_MULTIPLE_BSSID ((WifiInformationElementId)71)
110#define IE_20_40_BSS_COEXISTENCE ((WifiInformationElementId)72)
111#define IE_20_40_BSS_INTOLERANT_CHANNEL_REPORT ((WifiInformationElementId)73)
112#define IE_OVERLAPPING_BSS_SCAN_PARAMETERS ((WifiInformationElementId)74)
113#define IE_RIC_DESCRIPTOR ((WifiInformationElementId)75)
114#define IE_MANAGEMENT_MIC ((WifiInformationElementId)76)
115// 77 is reserved
116#define IE_EVENT_REQUEST ((WifiInformationElementId)78)
117#define IE_EVENT_REPORT ((WifiInformationElementId)79)
118#define IE_DIAGNOSTIC_REQUEST ((WifiInformationElementId)80)
119#define IE_DIAGNOSTIC_REPORT ((WifiInformationElementId)81)
120#define IE_LOCATION_PARAMETERS ((WifiInformationElementId)82)
121#define IE_NONTRANSMITTED_BSSID_CAPABILITY ((WifiInformationElementId)83)
122#define IE_SSID_LIST ((WifiInformationElementId)84)
123#define IE_MULTIPLE_BSSID_INDEX ((WifiInformationElementId)85)
124#define IE_FMS_DESCRIPTOR ((WifiInformationElementId)86)
125#define IE_FMS_REQUEST ((WifiInformationElementId)87)
126#define IE_FMS_RESPONSE ((WifiInformationElementId)88)
127#define IE_QOS_TRAFFIC_CAPABILITY ((WifiInformationElementId)89)
128#define IE_BSS_MAX_IDLE_PERIOD ((WifiInformationElementId)90)
129#define IE_TFS_REQUEST ((WifiInformationElementId)91)
130#define IE_TFS_RESPONSE ((WifiInformationElementId)92)
131#define IE_WNM_SLEEP_MODE ((WifiInformationElementId)93)
132#define IE_TIM_BROADCAST_REQUEST ((WifiInformationElementId)94)
133#define IE_TIM_BROADCAST_RESPONSE ((WifiInformationElementId)95)
134#define IE_COLLOCATED_INTERFERENCE_REPORT ((WifiInformationElementId)96)
135#define IE_CHANNEL_USAGE ((WifiInformationElementId)97)
136#define IE_TIME_ZONE ((WifiInformationElementId)98)
137#define IE_DMS_REQUEST ((WifiInformationElementId)99)
138#define IE_DMS_RESPONSE ((WifiInformationElementId)100)
139#define IE_LINK_IDENTIFIER ((WifiInformationElementId)101)
140#define IE_WAKEUP_SCHEDULE ((WifiInformationElementId)102)
141// 103 is reserved
142#define IE_CHANNEL_SWITCH_TIMING ((WifiInformationElementId)104)
143#define IE_PTI_CONTROL ((WifiInformationElementId)105)
144#define IE_TPU_BUFFER_STATUS ((WifiInformationElementId)106)
145#define IE_INTERWORKING ((WifiInformationElementId)107)
146#define IE_ADVERTISEMENT_PROTOCOL ((WifiInformationElementId)108)
147#define IE_EXPEDITED_BANDWIDTH_REQUEST ((WifiInformationElementId)109)
148#define IE_QOS_MAP_SET ((WifiInformationElementId)110)
149#define IE_ROAMING_CONSORTIUM ((WifiInformationElementId)111)
150#define IE_EMERGENCY_ALART_IDENTIFIER ((WifiInformationElementId)112)
151#define IE_MESH_CONFIGURATION ((WifiInformationElementId)113)
152#define IE_MESH_ID ((WifiInformationElementId)114)
153#define IE_MESH_LINK_METRIC_REPORT ((WifiInformationElementId)115)
154#define IE_CONGESTION_NOTIFICATION ((WifiInformationElementId)116)
155#define IE_MESH_PEERING_MANAGEMENT ((WifiInformationElementId)117)
156#define IE_MESH_CHANNEL_SWITCH_PARAMETERS ((WifiInformationElementId)118)
157#define IE_MESH_AWAKE_WINDOW ((WifiInformationElementId)119)
158#define IE_BEACON_TIMING ((WifiInformationElementId)120)
159#define IE_MCCAOP_SETUP_REQUEST ((WifiInformationElementId)121)
160#define IE_MCCAOP_SETUP_REPLY ((WifiInformationElementId)122)
161#define IE_MCCAOP_ADVERTISEMENT ((WifiInformationElementId)123)
162#define IE_MCCAOP_TEARDOWN ((WifiInformationElementId)124)
163#define IE_GANN ((WifiInformationElementId)125)
164#define IE_RANN ((WifiInformationElementId)126)
165// 67 to 126 are reserved
166#define IE_EXTENDED_CAPABILITIES ((WifiInformationElementId)127)
167// 128 to 129 are reserved
168#define IE_PREQ ((WifiInformationElementId)130)
169#define IE_PREP ((WifiInformationElementId)131)
170#define IE_PERR ((WifiInformationElementId)132)
171// 133 to 136 are reserved
172#define IE_PROXY_UPDATE ((WifiInformationElementId)137)
173#define IE_PROXY_UPDATE_CONFIRMATION ((WifiInformationElementId)138)
174#define IE_AUTHENTICATED_MESH_PEERING_EXCHANGE ((WifiInformationElementId)139)
175#define IE_MIC ((WifiInformationElementId)140)
176#define IE_DESTINATION_URI ((WifiInformationElementId)141)
177#define IE_UAPSD_COEXISTENCE ((WifiInformationElementId)142)
178#define IE_DMG_WAKEUP_SCHEDULE ((WifiInformationElementId)143)
179#define IE_EXTENDED_SCHEDULE ((WifiInformationElementId)144)
180#define IE_STA_AVAILABILITY ((WifiInformationElementId)145)
181#define IE_DMG_TSPEC ((WifiInformationElementId)146)
182#define IE_NEXT_DMG_ATI ((WifiInformationElementId)147)
183#define IE_DMG_CAPABILITIES ((WifiInformationElementId)148)
184// 149 to 150 are reserved
185#define IE_DMG_OPERATION ((WifiInformationElementId)151)
186#define IE_DMG_BSS_PARAMETER_CHANGE ((WifiInformationElementId)152)
187#define IE_DMG_BEAM_REFINEMENT ((WifiInformationElementId)153)
188#define IE_CHANNEL_MEASUREMENT_FEEDBACK ((WifiInformationElementId)154)
189// 155 to 156 are reserved
190#define IE_AWAKE_WINDOW ((WifiInformationElementId)157)
191#define IE_MULTI_BAND ((WifiInformationElementId)158)
192#define IE_ADDBA_EXTENSION ((WifiInformationElementId)159)
193#define IE_NEXT_PCP_LIST ((WifiInformationElementId)160)
194#define IE_PCP_HANDOVER ((WifiInformationElementId)161)
195#define IE_DMG_LINK_MARGIN ((WifiInformationElementId)162)
196#define IE_SWITCHING_STREAM ((WifiInformationElementId)163)
197#define IE_SESSION_TRANSITION ((WifiInformationElementId)164)
198#define IE_DYNAMIC_TONE_PAIRING_REPORT ((WifiInformationElementId)165)
199#define IE_CLUSTER_REPORT ((WifiInformationElementId)166)
200#define IE_RELAY_CAPABILITIES ((WifiInformationElementId)167)
201#define IE_RELAY_TRANSFER_PARAMETER_SET ((WifiInformationElementId)168)
202#define IE_BEAMLINK_MAINTENANCE ((WifiInformationElementId)169)
203// 170 to 171 are reserved
204#define IE_DMG_LINK_ADAPTATION_ACKNOWLEDGMENT ((WifiInformationElementId)172)
205// 173 is reserved
206#define IE_MCCAOP_ADVERTISEMENT_OVERVIEW ((WifiInformationElementId)174)
207#define IE_QUIET_PERIOD_REQUEST ((WifiInformationElementId)175)
208// 176 is reserved
209#define IE_QUIET_PERIOD_RESPONSE ((WifiInformationElementId)177)
210// 178 to 181 are reserved
211#define IE_ECPAC_POLICY ((WifiInformationElementId)182)
212// 183 to 190 are reserved
213#define IE_VHT_CAPABILITIES ((WifiInformationElementId)191)
214#define IE_VHT_OPERATION ((WifiInformationElementId)192)
215#define IE_EXTENDED_BSS_LOAD ((WifiInformationElementId)193)
216#define IE_WIDE_BANDWIDTH_CHANNEL_SWITCH ((WifiInformationElementId)194)
217#define IE_VHT_TRANSMIT_POWER_ENVELOPE ((WifiInformationElementId)195)
218#define IE_CHANNEL_SWITCH_WRAPPER ((WifiInformationElementId)196)
219#define IE_AID ((WifiInformationElementId)197)
220#define IE_QUIET_CHANNEL ((WifiInformationElementId)198)
221#define IE_OPERATING_MODE_NOTIFICATION ((WifiInformationElementId)199)
222#define IE_UPSIM ((WifiInformationElementId)200)
223#define IE_REDUCED_NEIGHBOR_REPORT ((WifiInformationElementId)201)
224// TODO Add 202 to 220. See Table 9-92 of 802.11-2020
225#define IE_VENDOR_SPECIFIC ((WifiInformationElementId)221)
226// TODO Add 222 to 241. See Table 9-92 of 802.11-2020
227#define IE_FRAGMENT ((WifiInformationElementId)242)
228// 243 to 254 are reserved
229#define IE_EXTENSION ((WifiInformationElementId)255)
230
231#define IE_EXT_HE_CAPABILITIES ((WifiInformationElementId)35)
232#define IE_EXT_HE_OPERATION ((WifiInformationElementId)36)
233#define IE_EXT_UORA_PARAMETER_SET ((WifiInformationElementId)37)
234#define IE_EXT_MU_EDCA_PARAMETER_SET ((WifiInformationElementId)38)
235
236#define IE_EXT_NON_INHERITANCE ((WifiInformationElementId)56)
237
238#define IE_EXT_EHT_OPERATION ((WifiInformationElementId)106)
239#define IE_EXT_MULTI_LINK_ELEMENT ((WifiInformationElementId)107)
240#define IE_EXT_EHT_CAPABILITIES ((WifiInformationElementId)108)
241#define IE_EXT_TID_TO_LINK_MAPPING_ELEMENT ((WifiInformationElementId)109)
242
243/**
244 * \brief Information element, as defined in 802.11-2007 standard
245 * \ingroup wifi
246 *
247 * The IEEE 802.11 standard includes the notion of Information
248 * Elements, which are encodings of management information to be
249 * communicated between STAs in the payload of various frames of type
250 * Management. Information Elements (IEs) have a common format, each
251 * starting with a single octet - the Element ID, which indicates the
252 * specific type of IE (a type to represent the options here is
253 * defined as WifiInformationElementId). The next octet is a length field and
254 * encodes the number of octets in the third and final field, which is
255 * the IE Information field.
256 *
257 * The class ns3::WifiInformationElement provides a base for classes
258 * which represent specific Information Elements. This class defines
259 * pure virtual methods for serialisation
260 * (ns3::WifiInformationElement::SerializeInformationField) and
261 * deserialisation
262 * (ns3::WifiInformationElement::DeserializeInformationField) of IEs, from
263 * or to data members or other objects that simulation objects use to
264 * maintain the relevant state.
265 *
266 * This class also provides an implementation of the equality
267 * operator, which operates by comparing the serialised versions of
268 * the two WifiInformationElement objects concerned.
269 *
270 * Elements are defined to have a common general format consisting of
271 * a 1 octet Element ID field, a 1 octet length field, and a
272 * variable-length element-specific information field. Each element is
273 * assigned a unique Element ID as defined in this standard. The
274 * Length field specifies the number of octets in the Information
275 * field.
276 *
277 * Fragmentation of an Information Element is handled transparently by the base
278 * class. Subclasses can simply serialize/deserialize their data into/from a
279 * single large buffer. It is the base class that takes care of splitting
280 * serialized data into multiple fragments (when serializing) or reconstructing
281 * data from multiple fragments when deserializing.
282 *
283 * This class is pure virtual and acts as base for classes which know
284 * how to serialize specific IEs.
285 */
286class WifiInformationElement : public SimpleRefCount<WifiInformationElement>
287{
288 public:
289 virtual ~WifiInformationElement();
290 /**
291 * Serialize entire IE including Element ID and length fields. Handle
292 * fragmentation of the IE if needed.
293 *
294 * \param i an iterator which points to where the IE should be written.
295 *
296 * \return an iterator
297 */
299 /**
300 * Deserialize entire IE (which may possibly be fragmented into multiple
301 * elements), which must be present. The iterator passed in must be pointing
302 * at the Element ID (i.e., the very first octet) of the correct type of
303 * information element, otherwise this method will generate a fatal error.
304 *
305 * \param i an iterator which points to where the IE should be read.
306 *
307 * \return an iterator
308 */
310 /**
311 * Deserialize entire IE (which may possibly be fragmented into multiple
312 * elements) if it is present. The iterator passed in
313 * must be pointing at the Element ID of an information element. If
314 * the Element ID is not the one that the given class is interested
315 * in then it will return the same iterator.
316 *
317 * \param i an iterator which points to where the IE should be read.
318 *
319 * \return an iterator
320 */
322 /**
323 * Get the size of the serialized IE including Element ID and
324 * length fields (for every element this IE is possibly fragmented into).
325 *
326 * \return the size of the serialized IE in bytes
327 */
328 uint16_t GetSerializedSize() const;
329
330 // Each subclass must implement these pure virtual functions:
331 /**
332 * Get the wifi information element ID
333 * \returns the wifi information element ID
334 */
336
337 /**
338 * Get the wifi information element ID extension
339 * \returns the wifi information element ID extension
340 */
342
343 // In addition, a subclass may optionally override the following...
344 /**
345 * Generate human-readable form of IE
346 *
347 * \param os output stream
348 */
349 virtual void Print(std::ostream& os) const;
350 /**
351 * Compare two IEs for equality by ID & Length, and then through
352 * memcmp of serialised version
353 *
354 * \param a another information element to compare with
355 *
356 * \return true if the two IEs are equal,
357 * false otherwise
358 */
359 virtual bool operator==(const WifiInformationElement& a) const;
360
361 private:
362 /**
363 * Serialize an IE that needs to be fragmented.
364 *
365 * \param i an iterator which points to where the IE should be written.
366 * \param size the size of the body of the IE
367 * \return an iterator pointing to past the IE that was serialized
368 */
370 /**
371 * Deserialize the Information field of an IE. Also handle the case in which
372 * the IE is fragmented.
373 *
374 * \param i an iterator which points to where the Information field should be read.
375 * \param length the expected number of bytes to read
376 * \return an iterator pointing to past the IE that was deserialized
377 */
379 /**
380 * Length of serialized information (i.e., the length of the body
381 * of the IE, not including the Element ID and length octets. This
382 * is the value that will appear in the second octet of the entire
383 * IE - the length field - if the IE is not fragmented)
384 *
385 * \return the length of serialized information
386 */
387 virtual uint16_t GetInformationFieldSize() const = 0;
388 /**
389 * Serialize information (i.e., the body of the IE, not including
390 * the Element ID and length octets)
391 *
392 * \param start an iterator which points to where the information should
393 * be written.
394 */
395 virtual void SerializeInformationField(Buffer::Iterator start) const = 0;
396 /**
397 * Deserialize information (i.e., the body of the IE, not including
398 * the Element ID and length octets)
399 *
400 * \param start an iterator which points to where the information should be written.
401 * \param length the expected number of bytes to read
402 *
403 * \return the number of bytes read
404 */
405 virtual uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) = 0;
406};
407
408/**
409 * \brief Stream insertion operator.
410 *
411 * \param os the output stream
412 * \param element the Information Element
413 * \returns a reference to the stream
414 */
415std::ostream& operator<<(std::ostream& os, const WifiInformationElement& element);
416
417} // namespace ns3
418
419#endif /* WIFI_INFORMATION_ELEMENT_H */
iterator in a Buffer instance
Definition: buffer.h:100
A template-based reference counting class.
Information element, as defined in 802.11-2007 standard.
virtual WifiInformationElementId ElementId() const =0
Get the wifi information element ID.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields (for every element this IE i...
Buffer::Iterator Deserialize(Buffer::Iterator i)
Deserialize entire IE (which may possibly be fragmented into multiple elements), which must be presen...
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
virtual uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length)=0
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i)
Deserialize entire IE (which may possibly be fragmented into multiple elements) if it is present.
Buffer::Iterator SerializeFragments(Buffer::Iterator i, uint16_t size) const
Serialize an IE that needs to be fragmented.
virtual void Print(std::ostream &os) const
Generate human-readable form of IE.
virtual void SerializeInformationField(Buffer::Iterator start) const =0
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
virtual uint16_t GetInformationFieldSize() const =0
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
virtual WifiInformationElementId ElementIdExt() const
Get the wifi information element ID extension.
Buffer::Iterator DoDeserialize(Buffer::Iterator i, uint16_t length)
Deserialize the Information field of an IE.
virtual bool operator==(const WifiInformationElement &a) const
Compare two IEs for equality by ID & Length, and then through memcmp of serialised version.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:159
constexpr uint8_t WIFI_IE_ELEMENT_ID_EXT_SIZE
Size in bytes of the Element ID Extension field (IEEE 802.11-2020 9.4.2.1 General)
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.