A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
he-operation.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Sébastien Deronne
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Sébastien Deronne <sebastien.deronne@gmail.com>
7 * Stefano Avallone <stavallo@unina.it>
8 */
9
10#include "he-operation.h"
11
12namespace ns3
13{
14
16 : m_basicHeMcsAndNssSet(0xffff),
17 m_6GHzOpInfo(m_heOpParams.m_6GHzOpPresent)
18{
19}
20
23{
24 return IE_EXTENSION;
25}
26
32
33void
35{
36 os << "Default PE Duration: " << +m_defaultPeDuration << " TWT Required: " << +m_twtRequired
37 << " TXOP Duration RTS Threshold: " << m_txopDurRtsThresh
38 << " VHT Operation Information Present: " << +m_vhOpPresent
39 << " Co-Hosted BSS: " << +m_coHostedBss << " ER SU Disable: " << +m_erSuDisable
40 << " 6 GHz Operation Information Present: " << m_6GHzOpPresent;
41}
42
43uint16_t
48
49void
51{
52 uint16_t twoBytes = m_defaultPeDuration | (m_twtRequired << 3) | (m_txopDurRtsThresh << 4) |
53 (m_vhOpPresent << 14) | (m_coHostedBss << 15);
54 uint8_t oneByte = m_erSuDisable | ((m_6GHzOpPresent ? 1 : 0) << 1);
55 start.WriteHtolsbU16(twoBytes);
56 start.WriteU8(oneByte);
57}
58
59uint16_t
61{
62 Buffer::Iterator tmp = start;
63 uint16_t twoBytes = start.ReadLsbtohU16();
64 uint8_t oneByte = start.ReadU8();
65 m_defaultPeDuration = twoBytes & 0x07;
66 m_twtRequired = (twoBytes >> 3) & 0x01;
67 m_txopDurRtsThresh = (twoBytes >> 4) & 0x03ff;
68 m_vhOpPresent = (twoBytes >> 14) & 0x01;
69 m_coHostedBss = (twoBytes >> 15) & 0x01;
70 m_erSuDisable = oneByte & 0x01;
71 m_6GHzOpPresent = ((oneByte >> 1) & 0x01) == 1;
72 return start.GetDistanceFrom(tmp);
73}
74
75void
76HeOperation::BssColorInfo::Print(std::ostream& os) const
77{
78 os << "BSS Color: " << +m_bssColor << " Partial BSS Color: " << +m_partialBssColor
79 << " BSS Color Disabled: " << +m_bssColorDisabled;
80}
81
82uint16_t
87
88void
90{
91 uint8_t oneByte = m_bssColor | (m_partialBssColor << 6) | (m_bssColorDisabled << 7);
92 start.WriteU8(oneByte);
93}
94
95uint16_t
97{
98 Buffer::Iterator tmp = start;
99 uint8_t oneByte = start.ReadU8();
100 m_bssColor = oneByte & 0x3f;
101 m_partialBssColor = (oneByte >> 6) & 0x01;
102 m_bssColorDisabled = (oneByte >> 7) & 0x01;
103 return start.GetDistanceFrom(tmp);
104}
105
106void
107HeOperation::OpInfo6GHz::Print(std::ostream& os) const
108{
109 os << "Primary channel: " << +m_primCh << " Channel Width: " << +m_chWid
110 << " Duplicate Beacon: " << +m_dupBeacon << " Regulatory Info: " << +m_regInfo
111 << " Channel center frequency segment 0: " << +m_chCntrFreqSeg0
112 << " Channel center frequency segment 1: " << +m_chCntrFreqSeg1
113 << " Minimum Rate: " << +m_minRate;
114}
115
116uint16_t
118{
119 return 5;
120}
121
122void
124{
125 start.WriteU8(m_primCh);
126 uint8_t control = m_chWid | (m_dupBeacon << 2) | (m_regInfo << 3);
127 start.WriteU8(control);
128 start.WriteU8(m_chCntrFreqSeg0);
129 start.WriteU8(m_chCntrFreqSeg1);
130 start.WriteU8(m_minRate);
131}
132
133uint16_t
135{
136 Buffer::Iterator i = start;
137 m_primCh = i.ReadU8();
138 uint8_t control = i.ReadU8();
139 m_chWid = control & 0x03;
140 m_dupBeacon = (control >> 2) & 0x01;
141 m_regInfo = (control >> 3) & 0x07;
142 m_chCntrFreqSeg0 = i.ReadU8();
143 m_chCntrFreqSeg1 = i.ReadU8();
144 m_minRate = i.ReadU8();
145 return i.GetDistanceFrom(start);
146}
147
148void
149HeOperation::SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
150{
151 NS_ASSERT((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
152
153 // IEEE 802.11ax-2021 9.4.2.248.4 Supported HE-MCS And NSS Set field
154 uint8_t val = 0x03; // not supported
155 if (maxHeMcs == 11) // MCS 0 - 11
156 {
157 val = 0x02;
158 }
159 else if (maxHeMcs >= 9) // MCS 0 - 9
160 {
161 val = 0x01;
162 }
163 else // MCS 0 - 7
164 {
165 val = 0x00;
166 }
167
168 // clear bits for that nss
169 const uint16_t mask = ~(0x03 << ((nss - 1) * 2));
170 m_basicHeMcsAndNssSet &= mask;
171
172 // update bits for that nss
173 m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
174}
175
176void
177HeOperation::Print(std::ostream& os) const
178{
179 os << "HE Operation=[HE Operation Parameters|";
181 os << "][BSS Color|";
183 os << "][Basic HE-MCS And NSS Set: " << m_basicHeMcsAndNssSet << "]";
184 if (m_6GHzOpInfo)
185 {
186 os << "[6 GHz Operation Info|";
187 m_6GHzOpInfo->Print(os);
188 os << "]";
189 }
190}
191
192uint16_t
194{
195 uint16_t ret = 1 /* Element ID Ext */ + m_heOpParams.GetSerializedSize() +
196 m_bssColorInfo.GetSerializedSize() + 2 /* Basic HE-MCS And NSS Set */;
197 if (m_6GHzOpInfo)
198 {
199 ret += m_6GHzOpInfo->GetSerializedSize();
200 }
201 return ret;
202}
203
204void
206{
207 m_heOpParams.Serialize(start);
209 start.WriteHtolsbU16(m_basicHeMcsAndNssSet);
210 if (m_6GHzOpInfo)
211 {
212 m_6GHzOpInfo->Serialize(start);
213 }
214 // todo: VHT Operation Information (variable)
215}
216
217uint16_t
219{
220 Buffer::Iterator i = start;
225 {
226 OpInfo6GHz opInfo6GHz;
227 opInfo6GHz.Deserialize(i);
228 m_6GHzOpInfo = opInfo6GHz;
229 }
230
231 // todo: VHT Operation Information (variable)
232 return i.GetDistanceFrom(start);
233}
234
235} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
uint16_t ReadLsbtohU16()
Definition buffer.cc:1053
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
OptFieldWithPresenceInd< OpInfo6GHz > m_6GHzOpInfo
6 GHz Operation Information field
void Print(std::ostream &os) const override
Generate human-readable form of IE.
void SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
Set the Basic HE-MCS and NSS field in the HE Operation information element by specifying the pair (ns...
WifiInformationElementId ElementIdExt() const override
Get the wifi information element ID extension.
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)
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
uint16_t m_basicHeMcsAndNssSet
Basic HE-MCS And NSS set (use setter to set value)
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
HeOperationParams m_heOpParams
HE Operation Parameters field.
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
BssColorInfo m_bssColorInfo
BSS Color Information field.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
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.
void Serialize(Buffer::Iterator &start) const
Serialize the BSS Color Information field.
void Print(std::ostream &os) const
Print the content of the BSS Color Information field.
uint16_t Deserialize(Buffer::Iterator &start)
Deserialize the BSS Color Information field.
uint16_t GetSerializedSize() const
uint8_t m_erSuDisable
ER SU Disable.
void Print(std::ostream &os) const
Print the content of the HE Operation Parameters field.
void Serialize(Buffer::Iterator &start) const
Serialize the HE Operation Parameters field.
uint8_t m_vhOpPresent
VHT Operation Information Present (value 1 unsupported)
bool m_6GHzOpPresent
6 GHz Operation Information Present (do not set, it is set by the OptFieldWithPresenceInd)
uint8_t m_coHostedBss
Co-Hosted BSS (value 1 unsupported)
uint16_t Deserialize(Buffer::Iterator &start)
Deserialize the HE Operation Parameters field.
uint8_t m_defaultPeDuration
Default PE Duration.
uint8_t m_twtRequired
TWT Required.
uint16_t m_txopDurRtsThresh
TXOP Duration RTS Threshold.
6 GHz Operation Information field
void Print(std::ostream &os) const
Print the content of the 6 GHz Operation Information field.
uint16_t GetSerializedSize() const
uint16_t Deserialize(Buffer::Iterator &start)
Deserialize the 6 GHz Operation Information field.
void Serialize(Buffer::Iterator &start) const
Serialize the 6 GHz Operation Information field.
#define IE_EXTENSION
#define IE_EXT_HE_OPERATION