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
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,
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 void Print(std::ostream& os) const override;
102
103 /**
104 * Get the Multi-Link element variant
105 *
106 * @return the Multi-Link element variant
107 */
108 Variant GetVariant() const;
109
110 /// @return a reference to the Common Info field (the MLE variant must be Basic)
111 CommonInfoBasicMle& GetCommonInfoBasic();
112
113 /// @return a const reference to the Common Info field (the MLE variant must be Basic)
114 const CommonInfoBasicMle& GetCommonInfoBasic() const;
115
116 /**
117 * Set the MLD MAC Address subfield in the Common Info field. Make sure that
118 * this is a Basic Multi-Link Element.
119 *
120 * @param address the MLD MAC address
121 */
122 void SetMldMacAddress(Mac48Address address);
123
124 /**
125 * Return the MLD MAC Address subfield in the Common Info field. Make sure that
126 * this is a Basic Multi-Link Element.
127 *
128 * @return the MLD MAC Address subfield in the Common Info field.
129 */
130 Mac48Address GetMldMacAddress() const;
131
132 /**
133 * Set the Link ID Info subfield in the Common Info field. Make sure that
134 * this is a Basic Multi-Link Element.
135 *
136 * @param linkIdInfo the link ID information
137 */
138 void SetLinkIdInfo(uint8_t linkIdInfo);
139 /**
140 * Return true if the Link ID Info subfield in the Common Info field is present
141 * and false otherwise. Make sure that this is a Basic Multi-Link Element.
142 *
143 * @return true if the Link ID Info subfield in the Common Info field is present
144 * and false otherwise
145 */
146 bool HasLinkIdInfo() const;
147 /**
148 * Return the Link ID Info subfield in the Common Info field. Make sure that
149 * this is a Basic Multi-Link Element and the Link ID Info subfield is present.
150 *
151 * @return the Link ID Info subfield in the Common Info field
152 */
153 uint8_t GetLinkIdInfo() const;
154
155 /**
156 * Set the BSS Parameters Change Count subfield in the Common Info field. Make sure that
157 * this is a Basic Multi-Link Element.
158 *
159 * @param count the BSS Parameters Change Count
160 */
161 void SetBssParamsChangeCount(uint8_t count);
162 /**
163 * Return true if the BSS Parameters Change Count subfield in the Common Info field is present
164 * and false otherwise. Make sure that this is a Basic Multi-Link Element.
165 *
166 * @return true if the BSS Parameters Change Count subfield in the Common Info field is present
167 * and false otherwise
168 */
169 bool HasBssParamsChangeCount() const;
170 /**
171 * Return the BSS Parameters Change Count subfield in the Common Info field. Make sure that
172 * this is a Basic Multi-Link Element and the BSS Parameters Change Count subfield is present.
173 *
174 * @return the BSS Parameters Change Count subfield in the Common Info field
175 */
176 uint8_t GetBssParamsChangeCount() const;
177
178 /**
179 * Set the EMLSR Support subfield of the EML Capabilities subfield in the Common Info field
180 * to 1 if EMLSR mode is supported and set it to 0 otherwise. Make sure that this is a Basic
181 * Multi-Link Element.
182 *
183 * @param supported whether EMLSR mode is supported
184 */
185 void SetEmlsrSupported(bool supported);
186 /**
187 * Set the EMLSR Padding Delay subfield of the EML Capabilities subfield in the
188 * Common Info field. Make sure that this is a Basic Multi-Link Element.
189 *
190 * @param delay the EMLSR Padding delay (0us, 32us, 64us, 128us or 256us)
191 */
192 void SetEmlsrPaddingDelay(Time delay);
193 /**
194 * Set the EMLSR Transition Delay subfield of the EML Capabilities subfield in the
195 * Common Info field. Make sure that this is a Basic Multi-Link Element.
196 *
197 * @param delay the EMLSR Transition delay (0us, 16us, 32us, 64us, 128us or 256us)
198 */
199 void SetEmlsrTransitionDelay(Time delay);
200 /**
201 * Set the Transition Timeout subfield of the EML Capabilities subfield in the
202 * Common Info field. Make sure that this is a Basic Multi-Link Element.
203 *
204 * @param timeout the Transition Timeout (0us or 2^n us, with n=7..16)
205 */
206 void SetTransitionTimeout(Time timeout);
207 /**
208 * Return true if the EML Capabilities subfield in the Common Info field is present
209 * and false otherwise. Make sure that this is a Basic Multi-Link Element.
210 *
211 * @return whether the EML Capabilities subfield in the Common Info field is present
212 */
213 bool HasEmlCapabilities() const;
214 /**
215 * Return true if the EMLSR Support subfield of the EML Capabilities subfield in the
216 * Common Info field is set to 1 and false otherwise. Make sure that this is a Basic
217 * Multi-Link Element and the EML Capabilities subfield is present.
218 *
219 * @return whether the EMLSR Support subfield is set to 1
220 */
221 bool IsEmlsrSupported() const;
222 /**
223 * Get the EMLSR Padding Delay subfield of the EML Capabilities subfield in the
224 * Common Info field. Make sure that this is a Basic Multi-Link Element and the
225 * EML Capabilities subfield is present.
226 *
227 * @return the EMLSR Padding Delay
228 */
229 Time GetEmlsrPaddingDelay() const;
230 /**
231 * Get the EMLSR Transition Delay subfield of the EML Capabilities subfield in the
232 * Common Info field. Make sure that this is a Basic Multi-Link Element and the
233 * EML Capabilities subfield is present.
234 *
235 * @return the EMLSR Transition Delay
236 */
237 Time GetEmlsrTransitionDelay() const;
238 /**
239 * Get the Transition Timeout subfield of the EML Capabilities subfield in the
240 * Common Info field. Make sure that this is a Basic Multi-Link Element and the
241 * EML Capabilities subfield is present.
242 *
243 * @return the Transition Timeout
244 */
245 Time GetTransitionTimeout() const;
246
247 /**
248 * Set the AP MLD ID subfield of Common Info field. Valid variants are Basic and Probe Request.
249 *
250 * @param id AP MLD ID
251 */
252 void SetApMldId(uint8_t id);
253
254 /**
255 * Get the AP MLD ID subfield of Common Info field (if present). Valid variants are Basic and
256 * Probe Request.
257 *
258 * @return the AP MLD ID
259 */
260 std::optional<uint8_t> GetApMldId() const;
261
262 mutable ContainingFrame m_containingFrame; //!< reference to the mgt frame containing this MLE
263
264 /**
265 * @ingroup wifi
266 * Per-STA Profile Subelement of Multi-Link element.
267 * See Sec. 9.4.2.312.2.3 of 802.11be D1.5
268 *
269 * The frame body of the management frame included in the Per-STA Profile field
270 * is stored as a (unique) pointer to the Header base class, because we cannot
271 * include mgt-headers.h here (otherwise, we would create a circular dependency).
272 *
273 * TODO:
274 * - complete the implementation of STA Control and STA Info subfields
275 */
277 {
278 public:
279 /**
280 * Constructor
281 *
282 * @param variant the Multi-Link element variant
283 */
285
286 /**
287 * Copy constructor performing a deep copy of the object
288 *
289 * @param perStaProfile the object to copy
290 */
292
293 /**
294 * Copy assignment operator performing a deep copy of the object
295 *
296 * @param perStaProfile the object to copy-assign
297 * @return a reference to this object
298 */
300
301 /**
302 * Use default move assignment operator
303 *
304 * @param perStaProfile the object to move-assign
305 * @return a reference to this object
306 */
308
309 WifiInformationElementId ElementId() const override;
310 void Print(std::ostream& os) const override;
311
312 /**
313 * Set the Link ID subfield in the STA Control field
314 *
315 * @param linkId the Link ID value
316 */
317 void SetLinkId(uint8_t linkId);
318 /**
319 * Get the Link ID subfield in the STA Control field
320 *
321 * @return the Link ID subfield in the STA Control field
322 */
323 uint8_t GetLinkId() const;
324
325 /**
326 * Set the Complete Profile flag in the STA Control field
327 */
328 void SetCompleteProfile();
329 /**
330 * @return whether the Complete Profile flag in the STA Control field is set
331 */
332 bool IsCompleteProfileSet() const;
333
334 /**
335 * Set the STA MAC Address subfield in the STA Info field
336 *
337 * @param address the MAC address to set
338 */
339 void SetStaMacAddress(Mac48Address address);
340 /**
341 * Return true if the STA MAC Address subfield in the STA Info field is present
342 *
343 * @return true if the STA MAC Address subfield in the STA Info field is present
344 */
345 bool HasStaMacAddress() const;
346 /**
347 * Get the STA MAC Address subfield in the STA Info field, if present
348 *
349 * @return the STA MAC Address subfield in the STA Info field, if present
350 */
352
353 /**
354 * Set the BSS Parameters Change Count subfield in the STA Info field.
355 *
356 * @param count BSS Parameters Change Count
357 */
358 void SetBssParamsChgCnt(uint8_t count);
359
360 /// @return whether the BSS Parameters Change Count subfield in STA Info field is present
361 bool HasBssParamsChgCnt() const;
362
363 /**
364 * Get BSS Parameters Change Count subfield in the STA Info field.
365 *
366 * @return count value
367 */
368 uint8_t GetBssParamsChgCnt() const;
369
370 /**
371 * Include the given (Re)Association Request frame body in the STA Profile field
372 * of this Per-STA Profile subelement
373 *
374 * @param assoc the given (Re)Association Request frame body
375 */
376 void SetAssocRequest(
377 const std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>& assoc);
378 /** @copydoc SetAssocRequest */
379 void SetAssocRequest(std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>&& assoc);
380 /**
381 * Return true if an Association Request frame body is included in the
382 * STA Profile field of this Per-STA Profile subelement
383 *
384 * @return true if an Association Request frame body is included
385 */
386 bool HasAssocRequest() const;
387 /**
388 * Return true if a Reassociation Request frame body is included in the
389 * STA Profile field of this Per-STA Profile subelement
390 *
391 * @return true if a Reassociation Request frame body is included
392 */
393 bool HasReassocRequest() const;
394 /**
395 * Get the (Re)Association Request frame body included in the STA Profile
396 * field of this Per-STA Profile subelement
397 *
398 * @return the (Re)Association Request frame body
399 */
401
402 /**
403 * Include the given (Re)Association Response frame body in the STA Profile field
404 * of this Per-STA Profile subelement
405 *
406 * @param assoc the given (Re)Association Response frame body
407 */
408 void SetAssocResponse(const MgtAssocResponseHeader& assoc);
409 /** @copydoc SetAssocResponse */
411 /**
412 * Return true if a (Re)Association Response frame body is included in the
413 * STA Profile field of this Per-STA Profile subelement
414 *
415 * @return true if a (Re)Association Response frame body is included
416 */
417 bool HasAssocResponse() const;
418 /**
419 * Get the (Re)Association Response frame body included in the STA Profile
420 * field of this Per-STA Profile subelement
421 *
422 * @return the (Re)Association Response frame body
423 */
425
426 /**
427 * Include the given Probe Response frame body in the STA Profile field
428 * of this Per-STA Profile subelement
429 *
430 * @param probeResp the given Probe Response frame body
431 */
432 void SetProbeResponse(const MgtProbeResponseHeader& probeResp);
433
434 /// @copydoc SetProbeResponse
436
437 /**
438 * Return true if a Probe Response frame body is included in the
439 * STA Profile field of this Per-STA Profile subelement
440 *
441 * @return true if a Probe Response frame body is included
442 */
443 bool HasProbeResponse() const;
444
445 /**
446 * Get the Probe Response frame body included in the STA Profile
447 * field of this Per-STA Profile subelement
448 *
449 * @return the Probe Response frame body
450 */
452
453 /**
454 * Get the size in bytes of the serialized STA Info Length subfield of
455 * the STA Info field
456 *
457 * @return the size in bytes of the serialized STA Info Length subfield
458 */
459 uint8_t GetStaInfoLength() const;
460
461 mutable ContainingFrame
462 m_containingFrame; //!< the mgt frame containing this Per-STA Profile
463
464 private:
465 uint16_t GetInformationFieldSize() const override;
466 void SerializeInformationField(Buffer::Iterator start) const override;
467 uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
468
469 /**
470 * Deserialize information of Per-STA Profile Subelement in Probe Request Multi-link
471 * Element.
472 *
473 * @param start an iterator which points to where the information should be written
474 * @param length the expected number of octets to read
475 * @return the number of octets read
476 */
477 uint16_t DeserProbeReqMlePerSta(ns3::Buffer::Iterator start, uint16_t length);
478
479 Variant m_variant; //!< Multi-Link element variant
480 uint16_t m_staControl; //!< STA Control field
481 Mac48Address m_staMacAddress; //!< STA MAC address
482 std::optional<uint8_t> m_bssParamsChgCnt; //!< BSS Params Change Count (Basic MLE)
483 std::variant<std::monostate,
484 std::unique_ptr<MgtAssocRequestHeader>,
485 std::unique_ptr<MgtReassocRequestHeader>,
486 std::unique_ptr<MgtAssocResponseHeader>,
487 std::unique_ptr<MgtProbeResponseHeader>>
488 m_staProfile; /**< STA Profile field, containing the frame body of a frame of the
489 same type as the frame containing the Multi-Link Element */
490 };
491
492 /**
493 * Add a Per-STA Profile Subelement in the Link Info field
494 */
496 /**
497 * Return the number of Per-STA Profile Subelement in the Link Info field
498 *
499 * @return the number of Per-STA Profile Subelement in the Link Info field
500 */
501 std::size_t GetNPerStaProfileSubelements() const;
502 /**
503 * Get a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
504 *
505 * @param i the index of the Per-STA Profile Subelement in the Link Info field
506 * @return a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
507 */
509 /**
510 * Get a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
511 *
512 * @param i the index of the Per-STA Profile Subelement in the Link Info field
513 * @return a reference to the <i>i</i>-th Per-STA Profile Subelement in the Link Info field
514 */
515 const PerStaProfileSubelement& GetPerStaProfile(std::size_t i) const;
516
517 private:
518 /**
519 * Set the variant of this Multi-Link Element
520 *
521 * @param variant the variant of this Multi-Link Element
522 */
523 void SetVariant(Variant variant);
524
525 /// Typedef for structure holding a Common Info field
526 using CommonInfo = std::variant<CommonInfoBasicMle,
528 // TODO Add other variants
529 std::monostate /* UNSET variant*/>;
530
531 CommonInfo m_commonInfo; //!< Common Info field
532
533 /*
534 * Link Info field
535 */
536 std::vector<PerStaProfileSubelement>
537 m_perStaProfileSubelements; //!< Per-STA Profile Subelements
538};
539
540} // namespace ns3
541
542#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 request.
Implement the header for management frames of type association and reassociation response.
Implement the header for management frames of type probe response.
Implement the header for management frames of type reassociation request.
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.