A Discrete-Event Network Simulator
API
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  * 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: Stefano Avallone <stavallo@unina.it>
18  */
19 
20 #ifndef MULTI_LINK_ELEMENT_H
21 #define MULTI_LINK_ELEMENT_H
22 
23 #include "ns3/nstime.h"
24 #include "ns3/wifi-information-element.h"
25 #include "ns3/wifi-mac-header.h"
26 
27 #include <memory>
28 #include <optional>
29 #include <variant>
30 
31 namespace ns3
32 {
33 
34 class MgtAssocRequestHeader;
35 class MgtReassocRequestHeader;
36 class MgtAssocResponseHeader;
37 
39 using AssocReqRefVariant = std::variant<std::reference_wrapper<MgtAssocRequestHeader>,
40  std::reference_wrapper<MgtReassocRequestHeader>>;
41 
47 {
52  {
55  uint8_t mediumSyncMaxNTxops : 4;
56  };
57 
62  {
63  uint8_t emlsrSupport : 1;
64  uint8_t emlsrPaddingDelay : 3;
65  uint8_t emlsrTransitionDelay : 3;
66  uint8_t emlmrSupport : 1;
67  uint8_t emlmrDelay : 3;
68  uint8_t transitionTimeout : 4;
69  };
70 
75  {
76  uint8_t maxNSimultaneousLinks : 4;
77  uint8_t srsSupport : 1;
79  uint8_t freqSepForStrApMld : 5;
80  uint8_t aarSupport : 1;
81  };
82 
87  std::optional<uint8_t> m_linkIdInfo;
88  std::optional<uint8_t> m_bssParamsChangeCount;
89  std::optional<MediumSyncDelayInfo>
91  std::optional<EmlCapabilities> m_emlCapabilities;
92  std::optional<MldCapabilities> m_mldCapabilities;
93 
99  uint16_t GetPresenceBitmap() const;
105  uint8_t GetSize() const;
111  void Serialize(Buffer::Iterator& start) const;
120  uint8_t Deserialize(Buffer::Iterator start, uint16_t presence);
121 
126  static uint8_t EncodeEmlsrPaddingDelay(Time delay);
131  static Time DecodeEmlsrPaddingDelay(uint8_t value);
132 
137  static uint8_t EncodeEmlsrTransitionDelay(Time delay);
142  static Time DecodeEmlsrTransitionDelay(uint8_t value);
143 
150  void SetMediumSyncDelayTimer(Time delay);
157  void SetMediumSyncOfdmEdThreshold(int8_t threshold);
166  void SetMediumSyncMaxNTxops(uint8_t nTxops);
181  int8_t GetMediumSyncOfdmEdThreshold() const;
190  std::optional<uint8_t> GetMediumSyncMaxNTxops() const;
191 };
192 
205 {
206  public:
216  enum Variant : uint8_t
217  {
219  // PROBE_REQUEST_VARIANT,
220  // RECONFIGURATION_VARIANT,
221  // TDLS_VARIANT,
222  // PRIORITY_ACCESS_VARIANT,
223  UNSET
224  };
225 
230  enum SubElementId : uint8_t
231  {
233  };
234 
236  using ContainingFrame = std::variant<std::monostate,
237  std::reference_wrapper<const MgtAssocRequestHeader>,
238  std::reference_wrapper<const MgtReassocRequestHeader>,
239  std::reference_wrapper<const MgtAssocResponseHeader>>;
240 
246  MultiLinkElement(ContainingFrame frame = {});
253  MultiLinkElement(Variant variant, ContainingFrame frame = {});
254 
255  WifiInformationElementId ElementId() const override;
256  WifiInformationElementId ElementIdExt() const override;
257  uint16_t GetInformationFieldSize() const override;
258  void SerializeInformationField(Buffer::Iterator start) const override;
259  uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
260 
266  Variant GetVariant() const;
267 
269  CommonInfoBasicMle& GetCommonInfoBasic();
270 
272  const CommonInfoBasicMle& GetCommonInfoBasic() const;
273 
280  void SetMldMacAddress(Mac48Address address);
281 
288  Mac48Address GetMldMacAddress() const;
289 
296  void SetLinkIdInfo(uint8_t linkIdInfo);
304  bool HasLinkIdInfo() const;
311  uint8_t GetLinkIdInfo() const;
312 
319  void SetBssParamsChangeCount(uint8_t count);
327  bool HasBssParamsChangeCount() const;
334  uint8_t GetBssParamsChangeCount() const;
335 
343  void SetEmlsrSupported(bool supported);
350  void SetEmlsrPaddingDelay(Time delay);
357  void SetEmlsrTransitionDelay(Time delay);
371  bool HasEmlCapabilities() const;
379  bool IsEmlsrSupported() const;
387  Time GetEmlsrPaddingDelay() const;
403  Time GetTransitionTimeout() const;
404 
406 
420  {
421  public:
428 
434  PerStaProfileSubelement(const PerStaProfileSubelement& perStaProfile);
449 
450  WifiInformationElementId ElementId() const override;
451 
457  void SetLinkId(uint8_t linkId);
463  uint8_t GetLinkId() const;
464 
468  void SetCompleteProfile();
472  bool IsCompleteProfileSet() const;
473 
485  bool HasStaMacAddress() const;
492 
499  void SetAssocRequest(
500  const std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>& assoc);
502  void SetAssocRequest(std::variant<MgtAssocRequestHeader, MgtReassocRequestHeader>&& assoc);
509  bool HasAssocRequest() const;
516  bool HasReassocRequest() const;
524 
531  void SetAssocResponse(const MgtAssocResponseHeader& assoc);
540  bool HasAssocResponse() const;
548 
555  uint8_t GetStaInfoLength() const;
556 
557  mutable ContainingFrame
559 
560  private:
561  uint16_t GetInformationFieldSize() const override;
562  void SerializeInformationField(Buffer::Iterator start) const override;
563  uint16_t DeserializeInformationField(Buffer::Iterator start, uint16_t length) override;
564 
566  uint16_t m_staControl;
568  std::variant<std::monostate,
569  std::unique_ptr<MgtAssocRequestHeader>,
570  std::unique_ptr<MgtReassocRequestHeader>,
571  std::unique_ptr<MgtAssocResponseHeader>>
574  };
575 
585  std::size_t GetNPerStaProfileSubelements() const;
599  const PerStaProfileSubelement& GetPerStaProfile(std::size_t i) const;
600 
601  private:
607  void SetVariant(Variant variant);
608 
610  using CommonInfo = std::variant<CommonInfoBasicMle,
611  // TODO Add other variants
612  std::monostate /* UNSET variant*/>;
613 
615 
616  /*
617  * Link Info field
618  */
619  std::vector<PerStaProfileSubelement>
621 };
622 
623 } // namespace ns3
624 
625 #endif /* MULTI_LINK_ELEMENT_H */
iterator in a Buffer instance
Definition: buffer.h:100
an EUI-48 address
Definition: mac48-address.h:46
Implement the header for management frames of type association and reassociation response.
Definition: mgt-headers.h:334
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Information element, as defined in 802.11-2007 standard.
Variant
Multi-Link element variants.
address
Definition: first.py:47
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:839
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:55
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
ns3::Time timeout
uint8_t emlsrPaddingDelay
EMLSR Padding Delay.
uint8_t emlsrTransitionDelay
EMLSR Transition Delay.
uint8_t transitionTimeout
Transition Timeout.
Medium Synchronization Delay Information subfield.
uint8_t mediumSyncOfdmEdThreshold
Medium Synchronization OFDM ED Threshold.
uint8_t mediumSyncDuration
Medium Synchronization Duration.
uint8_t mediumSyncMaxNTxops
Medium Synchronization MAximum Number of TXOPs.
uint8_t freqSepForStrApMld
Frequency Separation For STR/AP MLD Type Indication.
uint8_t maxNSimultaneousLinks
Max number of simultaneous links.
uint8_t tidToLinkMappingSupport
TID-To-Link Mapping Negotiation Supported.
Common Info field of the Basic Multi-Link element.
uint16_t GetPresenceBitmap() const
Get the Presence Bitmap subfield of the Common Info field.
uint8_t GetSize() const
Get the size of the serialized Common Info field.
static uint8_t EncodeEmlsrTransitionDelay(Time delay)
static Time DecodeEmlsrTransitionDelay(uint8_t value)
std::optional< EmlCapabilities > m_emlCapabilities
EML Capabilities.
uint8_t Deserialize(Buffer::Iterator start, uint16_t presence)
Deserialize the Common Info field.
std::optional< uint8_t > GetMediumSyncMaxNTxops() const
Get the maximum number of TXOPs a non-AP STA is allowed to attempt to initiate while the MediumSyncDe...
int8_t GetMediumSyncOfdmEdThreshold() const
Get the Medium Synchronization OFDM ED Threshold in dBm.
std::optional< MldCapabilities > m_mldCapabilities
MLD Capabilities.
void SetMediumSyncOfdmEdThreshold(int8_t threshold)
Set the Medium Synchronization OFDM ED Threshold subfield of the Medium Synchronization Delay Informa...
static Time DecodeEmlsrPaddingDelay(uint8_t value)
void Serialize(Buffer::Iterator &start) const
Serialize the Common Info field.
std::optional< MediumSyncDelayInfo > m_mediumSyncDelayInfo
Medium Synchronization Delay Information.
void SetMediumSyncDelayTimer(Time delay)
Set the Medium Synchronization Duration subfield of the Medium Synchronization Delay Information in t...
Time GetMediumSyncDelayTimer() const
Get the Medium Synchronization Duration subfield of the Medium Synchronization Delay Information in t...
Mac48Address m_mldMacAddress
Subfields.
std::optional< uint8_t > m_bssParamsChangeCount
BSS Parameters Change Count.
void SetMediumSyncMaxNTxops(uint8_t nTxops)
Set the Medium Synchronization Maximum Number of TXOPs subfield of the Medium Synchronization Delay I...
std::optional< uint8_t > m_linkIdInfo
Link ID Info.
static uint8_t EncodeEmlsrPaddingDelay(Time delay)