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 << "HE Operation=[Default PE Duration: " << +m_defaultPeDuration
37 << ", TWT Required: " << +m_twtRequired
38 << ", TXOP Duration RTS Threshold: " << m_txopDurRtsThresh
39 << ", VHT Operation Information Present: " << +m_vhOpPresent
40 << ", Co-Hosted BSS: " << +m_coHostedBss << ", ER SU Disable: " << +m_erSuDisable
41 << ", 6 GHz Operation Information Present: " << m_6GHzOpPresent << "]";
42}
43
44uint16_t
49
50void
52{
53 uint16_t twoBytes = m_defaultPeDuration | (m_twtRequired << 3) | (m_txopDurRtsThresh << 4) |
54 (m_vhOpPresent << 14) | (m_coHostedBss << 15);
55 uint8_t oneByte = m_erSuDisable | ((m_6GHzOpPresent ? 1 : 0) << 1);
56 start.WriteHtolsbU16(twoBytes);
57 start.WriteU8(oneByte);
58}
59
60uint16_t
62{
63 Buffer::Iterator tmp = start;
64 uint16_t twoBytes = start.ReadLsbtohU16();
65 uint8_t oneByte = start.ReadU8();
66 m_defaultPeDuration = twoBytes & 0x07;
67 m_twtRequired = (twoBytes >> 3) & 0x01;
68 m_txopDurRtsThresh = (twoBytes >> 4) & 0x03ff;
69 m_vhOpPresent = (twoBytes >> 14) & 0x01;
70 m_coHostedBss = (twoBytes >> 15) & 0x01;
71 m_erSuDisable = oneByte & 0x01;
72 m_6GHzOpPresent = ((oneByte >> 1) & 0x01) == 1;
73 return start.GetDistanceFrom(tmp);
74}
75
76void
77HeOperation::BssColorInfo::Print(std::ostream& os) const
78{
79 os << "BSS Color: " << +m_bssColor << " Partial BSS Color: " << +m_partialBssColor
80 << " BSS Color Disabled: " << +m_bssColorDisabled;
81}
82
83uint16_t
88
89void
91{
92 uint8_t oneByte = m_bssColor | (m_partialBssColor << 6) | (m_bssColorDisabled << 7);
93 start.WriteU8(oneByte);
94}
95
96uint16_t
98{
99 Buffer::Iterator tmp = start;
100 uint8_t oneByte = start.ReadU8();
101 m_bssColor = oneByte & 0x3f;
102 m_partialBssColor = (oneByte >> 6) & 0x01;
103 m_bssColorDisabled = (oneByte >> 7) & 0x01;
104 return start.GetDistanceFrom(tmp);
105}
106
107void
108HeOperation::OpInfo6GHz::Print(std::ostream& os) const
109{
110 os << "Primary channel: " << +m_primCh << " Channel Width: " << +m_chWid
111 << " Duplicate Beacon: " << +m_dupBeacon << " Regulatory Info: " << +m_regInfo
112 << " Channel center frequency segment 0: " << +m_chCntrFreqSeg0
113 << " Channel center frequency segment 1: " << +m_chCntrFreqSeg1
114 << " Minimum Rate: " << +m_minRate;
115}
116
117uint16_t
119{
120 return 5;
121}
122
123void
125{
126 start.WriteU8(m_primCh);
127 uint8_t control = m_chWid | (m_dupBeacon << 2) | (m_regInfo << 3);
128 start.WriteU8(control);
129 start.WriteU8(m_chCntrFreqSeg0);
130 start.WriteU8(m_chCntrFreqSeg1);
131 start.WriteU8(m_minRate);
132}
133
134uint16_t
136{
137 Buffer::Iterator i = start;
138 m_primCh = i.ReadU8();
139 uint8_t control = i.ReadU8();
140 m_chWid = control & 0x03;
141 m_dupBeacon = (control >> 2) & 0x01;
142 m_regInfo = (control >> 3) & 0x07;
143 m_chCntrFreqSeg0 = i.ReadU8();
144 m_chCntrFreqSeg1 = i.ReadU8();
145 m_minRate = i.ReadU8();
146 return i.GetDistanceFrom(start);
147}
148
149void
150HeOperation::SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
151{
152 NS_ASSERT((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
153
154 // IEEE 802.11ax-2021 9.4.2.248.4 Supported HE-MCS And NSS Set field
155 uint8_t val = 0x03; // not supported
156 if (maxHeMcs == 11) // MCS 0 - 11
157 {
158 val = 0x02;
159 }
160 else if (maxHeMcs >= 9) // MCS 0 - 9
161 {
162 val = 0x01;
163 }
164 else // MCS 0 - 7
165 {
166 val = 0x00;
167 }
168
169 // clear bits for that nss
170 const uint16_t mask = ~(0x03 << ((nss - 1) * 2));
171 m_basicHeMcsAndNssSet &= mask;
172
173 // update bits for that nss
174 m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
175}
176
177void
178HeOperation::Print(std::ostream& os) const
179{
180 os << "HE Operation=[HE Operation Parameters|";
182 os << "][BSS Color|";
184 os << "][Basic HE-MCS And NSS Set: " << m_basicHeMcsAndNssSet << "]";
185 if (m_6GHzOpInfo)
186 {
187 os << "[6 GHz Operation Info|";
188 m_6GHzOpInfo->Print(os);
189 os << "]";
190 }
191}
192
193uint16_t
195{
196 uint16_t ret = 1 /* Element ID Ext */ + m_heOpParams.GetSerializedSize() +
197 m_bssColorInfo.GetSerializedSize() + 2 /* Basic HE-MCS And NSS Set */;
198 if (m_6GHzOpInfo)
199 {
200 ret += m_6GHzOpInfo->GetSerializedSize();
201 }
202 return ret;
203}
204
205void
207{
208 m_heOpParams.Serialize(start);
210 start.WriteHtolsbU16(m_basicHeMcsAndNssSet);
211 if (m_6GHzOpInfo)
212 {
213 m_6GHzOpInfo->Serialize(start);
214 }
215 // todo: VHT Operation Information (variable)
216}
217
218uint16_t
220{
221 Buffer::Iterator i = start;
226 {
227 OpInfo6GHz opInfo6GHz;
228 opInfo6GHz.Deserialize(i);
229 m_6GHzOpInfo = opInfo6GHz;
230 }
231
232 // todo: VHT Operation Information (variable)
233 return i.GetDistanceFrom(start);
234}
235
236} // 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