A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
multi-link-element.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 MULTI_LINK_ELEMENT_H
10#define MULTI_LINK_ELEMENT_H
11
14
15#include "ns3/nstime.h"
16#include "ns3/wifi-information-element.h"
17#include "ns3/wifi-mac-header.h"
18
19#include <memory>
20#include <optional>
21#include <variant>
22
23namespace ns3
24{
25
26class MgtAssocRequestHeader;
27class MgtReassocRequestHeader;
28class MgtAssocResponseHeader;
29class MgtProbeResponseHeader;
30
31/// variant holding a reference to a (Re)Association Request
32using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
33 std::reference_wrapper<MgtReassocRequestHeader>>;
34
35/**
36 * @brief The Multi-Link element
37 * @ingroup wifi
38 *
39 * The 802.11be Multi-Link element (see Sec.9.4.2.312 of 802.11be D5.0)
40 *
41 * TODO:
42 * - Add support for variants other than the Basic and Probe Request.
43 */
45{
46 public:
47 /**
48 * @ingroup wifi
49 * Multi-Link element variants
50 *
51 * Note that Multi-Link element variants can be added to this enum only when
52 * the corresponding CommonInfo variant is implemented. This is because the
53 * index of m_commonInfo, which is a std::variant, is casted to this enum and
54 * the index of the "unset" variant must correspond to UNSET.
55 */
56 enum Variant : uint8_t
57 {
60 // RECONFIGURATION_VARIANT,
61 // TDLS_VARIANT,
62 // PRIORITY_ACCESS_VARIANT,
63 UNSET
64 };
65
66 /**
67 * @ingroup wifi
68 * SubElement IDs
69 */
70 enum SubElementId : uint8_t
71 {
73 };
74
75 /// Typedef for structure holding a reference to the containing frame
76 using ContainingFrame = std::variant<std::monostate,
77 std::reference_wrapper<const MgtAssocRequestHeader>,
78 std::reference_wrapper<const MgtReassocRequestHeader>,
79 std::reference_wrapper<const MgtAssocResponseHeader>,
80 std::reference_wrapper<const MgtProbeResponseHeader>>;
81
82 /**
83 * Construct a Multi-Link Element with no variant set.
84 *
85 * @param frame the management frame containing this Multi-Link Element
86 */
88 /**
89 * Constructor
90 *
91 * @param variant the Multi-Link element variant (cannot be UNSET)
92 * @param frame the management frame containing this Multi-Link Element
93 */
94 MultiLinkElement(Variant variant, ContainingFrame frame = {});
95
96 WifiInformationElementId ElementId() const override;
98 uint16_t GetInformationFieldSize() const override;
99 void SerializeInformationField(Buffer::Iterator start) const override;
100 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
101
102 /**
103 * Get the Multi-Link element variant
104 *
105 * @return the Multi-Link element variant
106 */
107 Variant GetVariant() const;
108
109 /// @return a reference to the Common Info field (the MLE variant must be Basic)
110 CommonInfoBasicMle& GetCommonInfoBasic();
111
112 /// @return a const reference to the Common Info field (the MLE variant must be Basic)
113 const CommonInfoBasicMle& GetCommonInfoBasic() const;
114
115 /**
116 * Set the MLD MAC Address subfield in the Common Info field. Make sure that
117 * this is a Basic Multi-Link Element.
118 *
119 * @param address the MLD MAC address
120 */
121 void SetMldMacAddress(Mac48Address address);
122
123 /**
124 * Return the MLD MAC Address subfield in the Common Info field. Make sure that
125 * this is a Basic Multi-Link Element.
126 *
127 * @return the MLD MAC Address subfield in the Common Info field.
128 */
129 Mac48Address GetMldMacAddress() const;
130
131 /**
132 * Set the Link ID Info subfield in the Common Info field. Make sure that
133 * this is a Basic Multi-Link Element.
134 *
135 * @param linkIdInfo the link ID information
136 */
137 void SetLinkIdInfo(uint8_t linkIdInfo);
138 /**
139 * Return true if the Link ID Info subfield in the Common Info field is present
140 * and false otherwise. Make sure that this is a Basic Multi-Link Element.
141 *
142 * @return true if the Link ID Info subfield in the Common Info field is present
143 * and false otherwise
144 */
145 bool HasLinkIdInfo() const;
146 /**
147 * Return the Link ID Info subfield in the Common Info field. Make sure that
148 * this is a Basic Multi-Link Element and the Link ID Info subfield is present.
149 *
150 * @return the Link ID Info subfield in the Common Info field
151 */
152 uint8_t GetLinkIdInfo() const;
153
154 /**
155 * Set the BSS Parameters Change Count subfield in the Common Info field. Make sure that
156 * this is a Basic Multi-Link Element.
157 *
158 * @param count the BSS Parameters Change Count
159 */
160 void SetBssParamsChangeCount(uint8_t count);
161 /**
162 * Return true if the BSS Parameters Change Count subfield in the Common Info field is present
163 * and false otherwise. Make sure that this is a Basic Multi-Link Element.
164 *
165 * @return true if the BSS Parameters Change Count subfield in the Common Info field is present
166 * and false otherwise
167 */
168 bool HasBssParamsChangeCount() const;
169 /**
170 * Return the BSS Parameters Change Count subfield in the Common Info field. Make sure that
171 * this is a Basic Multi-Link Element and the BSS Parameters Change Count subfield is present.
172 *
173 * @return the BSS Parameters Change Count subfield in the Common Info field
174 */
175 uint8_t GetBssParamsChangeCount() const;
176
177 /**
178 * Set the EMLSR Support subfield of the EML Capabilities subfield in the Common Info field
179 * to 1 if EMLSR mode is supported and set it to 0 otherwise. Make sure that this is a Basic
180 * Multi-Link Element.
181 *
182 * @param supported whether EMLSR mode is supported
183 */
184 void SetEmlsrSupported(bool supported);
185 /**
186 * Set the EMLSR Padding Delay subfield of the EML Capabilities subfield in the
187 * Common Info field. Make sure that this is a Basic Multi-Link Element.
188 *
189 * @param delay the EMLSR Padding delay (0us, 32us, 64us, 128us or 256us)
190 */
191 void SetEmlsrPaddingDelay(Time delay);
192 /**
193 * Set the EMLSR Transition Delay subfield of the EML Capabilities subfield in the
194 * Common Info field. Make sure that this is a Basic Multi-Link Element.
195 *
196 * @param delay the EMLSR Transition delay (0us, 16us, 32us, 64us, 128us or 256us)
197 */
198 void SetEmlsrTransitionDelay(Time delay);
199 /**
200 * Set the Transition Timeout subfield of the EML Capabilities subfield in the
201 * Common Info field. Make sure that this is a Basic Multi-Link Element.
202 *
203 * @param timeout the Transition Timeout (0us or 2^n us, with n=7..16)
204 */
205 void SetTransitionTimeout(Time timeout);
206 /**
207 * Return true if the EML Capabilities subfield in the Common Info field is present
208 * and false otherwise. Make sure that this is a Basic Multi-Link Element.
209 *
210 * @return whether the EML Capabilities subfield in the Common Info field is present
211 */
212 bool HasEmlCapabilities() const;
213 /**
214 * Return true if the EMLSR Support subfield of the EML Capabilities subfield in the
215 * Common Info field is set to 1 and false otherwise. Make sure that this is a Basic
216 * Multi-Link Element and the EML Capabilities subfield is present.
217 *
218 * @return whether the EMLSR Support subfield is set to 1
219 */
220 bool IsEmlsrSupported() const;
221 /**
222 * Get the EMLSR Padding Delay subfield of the EML Capabilities subfield in the
223 * Common Info field. Make sure that this is a Basic Multi-Link Element and the
224 * EML Capabilities subfield is present.
225 *
226 * @return the EMLSR Padding Delay
227 */
228 Time GetEmlsrPaddingDelay() const;
229 /**
230 * Get the EMLSR Transition Delay subfield of the EML Capabilities subfield in the
231 * Common Info field. Make sure that this is a Basic Multi-Link Element and the
232 * EML Capabilities subfield is present.
233 *
234 * @return the EMLSR Transition Delay
235 */
236 Time GetEmlsrTransitionDelay() const;
237 /**
238 * Get the Transition Timeout subfield of the EML Capabilities subfield in the
239 * Common Info field. Make sure that this is a Basic Multi-Link Element and the
240 * EML Capabilities subfield is present.
241 *
242 * @return the Transition Timeout
243 */
244 Time GetTransitionTimeout() const;
245
246 /**
247 * Set the AP MLD ID subfield of Common Info field. Valid variants are Basic and Probe Request.
248 *
249 * @param id AP MLD ID
250 */
251 void SetApMldId(uint8_t id);
252
253 /**
254 * Get the AP MLD ID subfield of Common Info field (if present). Valid variants are Basic and
255 * Probe Request.
256 *
257 * @return the AP MLD ID
258 */
259 std::optional<uint8_t> GetApMldId() const;
260
261 mutable ContainingFrame m_containingFrame; //!< reference to the mgt frame containing this MLE
262
263 /**
264 * @ingroup wifi
265 * Per-STA Profile Subelement of Multi-Link element.
266 * See Sec. 9.4.2.312.2.3 of 802.11be D1.5
267 *
268 * The frame body of the management frame included in the Per-STA Profile field
269 * is stored as a (unique) pointer to the Header base class, because we cannot
270 * include mgt-headers.h here (otherwise, we would create a circular dependency).
271 *
272 * TODO:
273 * - complete the implementation of STA Control and STA Info subfields
274 */
276 {
277 public:
278 /**
279 * Constructor
280 *
281 * @param variant the Multi-Link element variant
282 */
284
285 /**
286 * Copy constructor performing a deep copy of the object
287 *
288 * @param perStaProfile the object to copy
289 */
291
292 /**
293 * Copy assignment operator performing a deep copy of the object
294 *
295 * @param perStaProfile the object to copy-assign
296 * @return a reference to this object
297 */
299
300 /**
301 * Use default move assignment operator
302 *
303 * @param perStaProfile the object to move-assign
304 * @return a reference to this object
305 */
307
308 WifiInformationElementId ElementId() const override;
309
310 /**
311 * Set the Link ID subfield in the STA Control field
312 *
313 * @param linkId the Link ID value
314 */
315 void SetLinkId(uint8_t linkId);
316 /**
317 * Get the Link ID subfield in the STA Control field
318 *
319 * @return the Link ID subfield in the STA Control field
320 */
321 uint8_t GetLinkId() const;
322
323 /**
324 * Set the Complete Profile flag in the STA Control field
325 */
326 void SetCompleteProfile();
327 /**
328 * @return whether the Complete Profile flag in the STA Control field is set
329 */
330 bool IsCompleteProfileSet() const;
331
332 /**
333 * Set the STA MAC Address subfield in the STA Info field
334 *
335 * @param address the MAC address to set
336 */
337 void SetStaMacAddress(Mac48Address address);
338 /**
339 * Return true if the STA MAC Address subfield in the STA Info field is present
340 *
341 * @return true if the STA MAC Address subfield in the STA Info field is present
342 */
343 bool HasStaMacAddress() const;
344 /**
345 * Get the STA MAC Address subfield in the STA Info field, if present
346 *
347 * @return the STA MAC Address subfield in the STA Info field, if present
348 */
350
351 /**
352 * Set the BSS Parameters Change Count subfield in the STA Info field.
353 *
354 * @param count BSS Parameters Change Count
355 */
356 void SetBssParamsChgCnt(uint8_t count);
357
358 /// @return whether the BSS Parameters Change Count subfield in STA Info field is present
359 bool HasBssParamsChgCnt() const;
360
361 /**
362 * Get BSS Parameters Change Count subfield in the STA Info field.
363 *
364 * @return count value
365 */
366 uint8_t GetBssParamsChgCnt() const;
367
368 /**
369 * Include the given (Re)Association Request frame body in the STA Profile field
370 * of this Per-STA Profile subelement
371 *
372 * @param assoc the given (Re)Association Request frame body
373 */
374 void SetAssocRequest(
375 const std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>& assoc);
376 /** @copydoc SetAssocRequest */
377 void SetAssocRequest(std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>&& assoc);
378 /**
379 * Return true if an Association Request frame body is included in the
380 * STA Profile field of this Per-STA Profile subelement
381 *
382 * @return true if an Association Request frame body is included
383 */
384 bool HasAssocRequest() const;
385 /**
386 * Return true if a Reassociation Request frame body is included in the
387 * STA Profile field of this Per-STA Profile subelement
388 *
389 * @return true if a Reassociation Request frame body is included
390 */
391 bool HasReassocRequest() const;
392 /**
393 * Get the (Re)Association Request frame body included in the STA Profile
394 * field of this Per-STA Profile subelement
395 *
396 * @return the (Re)Association Request frame body
397 */
399
400 /**
401 * Include the given (Re)Association Response frame body in the STA Profile field
402 * of this Per-STA Profile subelement
403 *
404 * @param assoc the given (Re)Association Response frame body
405 */
406 void SetAssocResponse(const MgtAssocResponseHeader& assoc);
407 /** @copydoc SetAssocResponse */
409 /**
410 * Return true if a (Re)Association Response frame body is included in the
411 * STA Profile field of this Per-STA Profile subelement
412 *
413 * @return true if a (Re)Association Response frame body is included
414 */
415 bool HasAssocResponse() const;
416 /**
417 * Get the (Re)Association Response frame body included in the STA Profile
418 * field of this Per-STA Profile subelement
419 *
420 * @return the (Re)Association Response frame body
421 */
423
424 /**
425 * Include the given Probe Response frame body in the STA Profile field
426 * of this Per-STA Profile subelement
427 *
428 * @param probeResp the given Probe Response frame body
429 */
430 void SetProbeResponse(const MgtProbeResponseHeader& probeResp);
431
432 /// @copydoc SetProbeResponse
434
435 /**
436 * Return true if a Probe Response frame body is included in the
437 * STA Profile field of this Per-STA Profile subelement
438 *
439 * @return true if a Probe Response frame body is included
440 */
441 bool HasProbeResponse() const;
442
443 /**
444 * Get the Probe Response frame body included in the STA Profile
445 * field of this Per-STA Profile subelement
446 *
447 * @return the Probe Response frame body
448 */
450
451 /**
452 * Get the size in bytes of the serialized STA Info Length subfield of
453 * the STA Info field
454 *
455 * @return the size in bytes of the serialized STA Info Length subfield
456 */
457 uint8_t GetStaInfoLength() const;
458
459 mutable ContainingFrame
460 m_containingFrame; //!< the mgt frame containing this Per-STA Profile
461
462 private:
463 uint16_t GetInformationFieldSize() const override;
464 void SerializeInformationField(Buffer::Iterator start) const override;
465 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
466
467 /**
468 * Deserialize information of Per-STA Profile Subelement in Probe Request Multi-link
469 * Element.
470 *
471 * @param start an iterator which points to where the information should be written
472 * @param length the expected number of octets to read
473 * @return the number of octets read
474 */
475 uint16_t DeserProbeReqMlePerSta(ns3::Buffer::Iterator start, uint16_t length);
476
477 Variant m_variant; //!< Multi-Link element variant
478 uint16_t m_staControl; //!< STA Control field
479 Mac48Address m_staMacAddress; //!< STA MAC address
480 std::optional<uint8_t> m_bssParamsChgCnt; //!< BSS Params Change Count (Basic MLE)
481 std::variant<std::monostate,
482 std::unique_ptr<MgtAssocRequestHeader>,
483 std::unique_ptr<MgtReassocRequestHeader>,
484 std::unique_ptr<MgtAssocResponseHeader>,
485 std::unique_ptr<MgtProbeResponseHeader>>
486 m_staProfile; /**< STA Profile field, containing the frame body of a frame of the
487 same type as the frame containing the Multi-Link Element */
488 };
489
490 /**
491 * Add a Per-STA Profile Subelement in the Link Info field
492 */
494 /**
495 * Return the number of Per-STA Profile Subelement in the Link Info field
496 *
497 * @return the number of Per-STA Profile Subelement in the Link Info field
498 */
499 std::size_t GetNPerStaProfileSubelements() const;
500 /**
501 * Get a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
502 *
503 * @param i the index of the Per-STA Profile Subelement in the Link Info field
504 * @return a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
505 */
507 /**
508 * Get a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
509 *
510 * @param i the index of the Per-STA Profile Subelement in the Link Info field
511 * @return a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
512 */
513 const PerStaProfileSubelement& GetPerStaProfile(std::size_t i) const;
514
515 private:
516 /**
517 * Set the variant of this Multi-Link Element
518 *
519 * @param variant the variant of this Multi-Link Element
520 */
521 void SetVariant(Variant variant);
522
523 /// Typedef for structure holding a Common Info field
524 using CommonInfo = std::variant<CommonInfoBasicMle,
526 // TODO Add other variants
527 std::monostate /* UNSET variant*/>;
528
529 CommonInfo m_commonInfo; //!< Common Info field
530
531 /*
532 * Link Info field
533 */
534 std::vector<PerStaProfileSubelement>
535 m_perStaProfileSubelements; //!< Per-STA Profile Subelements
536};
537
538} // namespace ns3
539
540#endif /* MULTI_LINK_ELEMENT_H */
iterator in a Buffer instance
Definition buffer.h:89
an EUI-48 address
Implement the header for management frames of type association and reassociation response.
Implement the header for management frames of type probe response.
Information element, as defined in 802.11-2007 standard.
Variant
Multi-Link element variants.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::variant< std::reference_wrapper< MgtAssocRequestHeader >, std::reference_wrapper< MgtReassocRequestHeader > > AssocReqRefVariant
variant holding a reference to a (Re)Association Request
Definition ap-wifi-mac.h:45
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
ns3::Time timeout
Common Info field of the Basic Multi-Link element.
Common Info field of Multi-link Element Probe Request variant.