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
30
33{
34 if (this != &other)
35 {
39 m_6GHzOpInfo = other.m_6GHzOpInfo.ToOptional();
40 }
41 return *this;
42}
43
46{
47 return IE_EXTENSION;
48}
49
55
56void
58{
59 os << "HE Operation=[Default PE Duration: " << +m_defaultPeDuration
60 << ", TWT Required: " << +m_twtRequired
61 << ", TXOP Duration RTS Threshold: " << m_txopDurRtsThresh
62 << ", VHT Operation Information Present: " << +m_vhOpPresent
63 << ", Co-Hosted BSS: " << +m_coHostedBss << ", ER SU Disable: " << +m_erSuDisable
64 << ", 6 GHz Operation Information Present: " << m_6GHzOpPresent << "]";
65}
66
67uint16_t
72
73void
75{
76 uint16_t twoBytes = m_defaultPeDuration | (m_twtRequired << 3) | (m_txopDurRtsThresh << 4) |
77 (m_vhOpPresent << 14) | (m_coHostedBss << 15);
78 uint8_t oneByte = m_erSuDisable | ((m_6GHzOpPresent ? 1 : 0) << 1);
79 start.WriteU16(twoBytes);
80 start.WriteU8(oneByte);
81}
82
83uint16_t
85{
86 Buffer::Iterator tmp = start;
87 uint16_t twoBytes = start.ReadU16();
88 uint8_t oneByte = start.ReadU8();
89 m_defaultPeDuration = twoBytes & 0x07;
90 m_twtRequired = (twoBytes >> 3) & 0x01;
91 m_txopDurRtsThresh = (twoBytes >> 4) & 0x03ff;
92 m_vhOpPresent = (twoBytes >> 14) & 0x01;
93 m_coHostedBss = (twoBytes >> 15) & 0x01;
94 m_erSuDisable = oneByte & 0x01;
95 m_6GHzOpPresent = ((oneByte >> 1) & 0x01) == 1;
96 return start.GetDistanceFrom(tmp);
97}
98
99void
100HeOperation::BssColorInfo::Print(std::ostream& os) const
101{
102 os << "BSS Color: " << +m_bssColor << " Partial BSS Color: " << +m_partialBssColor
103 << " BSS Color Disabled: " << +m_bssColorDisabled;
104}
105
106uint16_t
108{
109 return 1;
110}
111
112void
114{
115 uint8_t oneByte = m_bssColor | (m_partialBssColor << 6) | (m_bssColorDisabled << 7);
116 start.WriteU8(oneByte);
117}
118
119uint16_t
121{
122 Buffer::Iterator tmp = start;
123 uint8_t oneByte = start.ReadU8();
124 m_bssColor = oneByte & 0x3f;
125 m_partialBssColor = (oneByte >> 6) & 0x01;
126 m_bssColorDisabled = (oneByte >> 7) & 0x01;
127 return start.GetDistanceFrom(tmp);
128}
129
130void
131HeOperation::OpInfo6GHz::Print(std::ostream& os) const
132{
133 os << "Primary channel: " << +m_primCh << " Channel Width: " << +m_chWid
134 << " Duplicate Beacon: " << +m_dupBeacon << " Regulatory Info: " << +m_regInfo
135 << " Channel center frequency segment 0: " << +m_chCntrFreqSeg0
136 << " Channel center frequency segment 1: " << +m_chCntrFreqSeg1
137 << " Minimum Rate: " << +m_minRate;
138}
139
140uint16_t
142{
143 return 5;
144}
145
146void
148{
149 start.WriteU8(m_primCh);
150 uint8_t control = m_chWid | (m_dupBeacon << 2) | (m_regInfo << 3);
151 start.WriteU8(control);
152 start.WriteU8(m_chCntrFreqSeg0);
153 start.WriteU8(m_chCntrFreqSeg1);
154 start.WriteU8(m_minRate);
155}
156
157uint16_t
159{
160 Buffer::Iterator i = start;
161 m_primCh = i.ReadU8();
162 uint8_t control = i.ReadU8();
163 m_chWid = control & 0x03;
164 m_dupBeacon = (control >> 2) & 0x01;
165 m_regInfo = (control >> 3) & 0x07;
168 m_minRate = i.ReadU8();
169 return i.GetDistanceFrom(start);
170}
171
172void
173HeOperation::SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
174{
175 NS_ASSERT((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
176
177 // IEEE 802.11ax-2021 9.4.2.248.4 Supported HE-MCS And NSS Set field
178 uint8_t val = 0x03; // not supported
179 if (maxHeMcs == 11) // MCS 0 - 11
180 {
181 val = 0x02;
182 }
183 else if (maxHeMcs >= 9) // MCS 0 - 9
184 {
185 val = 0x01;
186 }
187 else // MCS 0 - 7
188 {
189 val = 0x00;
190 }
191
192 // clear bits for that nss
193 const uint16_t mask = ~(0x03 << ((nss - 1) * 2));
194 m_basicHeMcsAndNssSet &= mask;
195
196 // update bits for that nss
197 m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
198}
199
200void
201HeOperation::Print(std::ostream& os) const
202{
203 os << "HE Operation=[HE Operation Parameters|";
204 m_heOpParams.Print(os);
205 os << "][BSS Color|";
206 m_bssColorInfo.Print(os);
207 os << "][Basic HE-MCS And NSS Set: " << m_basicHeMcsAndNssSet << "]";
208 if (m_6GHzOpInfo)
209 {
210 os << "[6 GHz Operation Info|";
211 m_6GHzOpInfo->Print(os);
212 os << "]";
213 }
214}
215
216uint16_t
218{
219 uint16_t ret = 1 /* Element ID Ext */ + m_heOpParams.GetSerializedSize() +
220 m_bssColorInfo.GetSerializedSize() + 2 /* Basic HE-MCS And NSS Set */;
221 if (m_6GHzOpInfo)
222 {
223 ret += m_6GHzOpInfo->GetSerializedSize();
224 }
225 return ret;
226}
227
228void
230{
231 m_heOpParams.Serialize(start);
232 m_bssColorInfo.Serialize(start);
233 start.WriteU16(m_basicHeMcsAndNssSet);
234 if (m_6GHzOpInfo)
235 {
236 m_6GHzOpInfo->Serialize(start);
237 }
238 // todo: VHT Operation Information (variable)
239}
240
241uint16_t
243{
244 Buffer::Iterator i = start;
245 m_heOpParams.Deserialize(i);
246 m_bssColorInfo.Deserialize(i);
248 if (m_heOpParams.m_6GHzOpPresent)
249 {
250 OpInfo6GHz opInfo6GHz;
251 opInfo6GHz.Deserialize(i);
252 m_6GHzOpInfo = opInfo6GHz;
253 }
254
255 // todo: VHT Operation Information (variable)
256 return i.GetDistanceFrom(start);
257}
258
259} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:109
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:767
uint16_t ReadU16()
Definition buffer.h:1098
The HE Operation Information Element.
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.
HeOperation & operator=(const HeOperation &other)
Copy assignment operator.
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.
Information element, as defined in 802.11-2007 standard.
#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.
uint8_t m_bssColorDisabled
BSS Color Disabled.
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.
uint8_t m_partialBssColor
Partial BSS Color.
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
uint8_t m_chCntrFreqSeg0
Channel center frequency segment 0.
void Print(std::ostream &os) const
Print the content of the 6 GHz Operation Information field.
uint8_t m_chWid
Channel Width.
uint16_t GetSerializedSize() const
uint8_t m_chCntrFreqSeg1
Channel center frequency segment 1.
uint8_t m_minRate
Minimum Rate.
uint16_t Deserialize(Buffer::Iterator &start)
Deserialize the 6 GHz Operation Information field.
uint8_t m_regInfo
Regulatory Info.
uint8_t m_dupBeacon
Duplicate Beacon.
void Serialize(Buffer::Iterator &start) const
Serialize the 6 GHz Operation Information field.
uint8_t m_primCh
Primary Channel.
#define IE_EXTENSION
#define IE_EXT_HE_OPERATION