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 * 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 * Authors: Sébastien Deronne <sebastien.deronne@gmail.com>
18 * Stefano Avallone <stavallo@unina.it>
19 */
20
21#include "he-operation.h"
22
23namespace ns3
24{
25
27 : m_basicHeMcsAndNssSet(0xffff),
28 m_6GHzOpInfo(m_heOpParams.m_6GHzOpPresent)
29{
30}
31
34{
35 return IE_EXTENSION;
36}
37
40{
42}
43
44void
46{
47 os << "Default PE Duration: " << +m_defaultPeDuration << " TWT Required: " << +m_twtRequired
48 << " TXOP Duration RTS Threshold: " << m_txopDurRtsThresh
49 << " VHT Operation Information Present: " << +m_vhOpPresent
50 << " Co-Hosted BSS: " << +m_coHostedBss << " ER SU Disable: " << +m_erSuDisable
51 << " 6 GHz Operation Information Present: " << m_6GHzOpPresent;
52}
53
54uint16_t
56{
57 return 3;
58}
59
60void
62{
63 uint16_t twoBytes = m_defaultPeDuration | (m_twtRequired << 3) | (m_txopDurRtsThresh << 4) |
64 (m_vhOpPresent << 14) | (m_coHostedBss << 15);
65 uint8_t oneByte = m_erSuDisable | ((m_6GHzOpPresent ? 1 : 0) << 1);
66 start.WriteHtolsbU16(twoBytes);
67 start.WriteU8(oneByte);
68}
69
70uint16_t
72{
73 Buffer::Iterator tmp = start;
74 uint16_t twoBytes = start.ReadLsbtohU16();
75 uint8_t oneByte = start.ReadU8();
76 m_defaultPeDuration = twoBytes & 0x07;
77 m_twtRequired = (twoBytes >> 3) & 0x01;
78 m_txopDurRtsThresh = (twoBytes >> 4) & 0x03ff;
79 m_vhOpPresent = (twoBytes >> 14) & 0x01;
80 m_coHostedBss = (twoBytes >> 15) & 0x01;
81 m_erSuDisable = oneByte & 0x01;
82 m_6GHzOpPresent = ((oneByte >> 1) & 0x01) == 1;
83 return start.GetDistanceFrom(tmp);
84}
85
86void
87HeOperation::BssColorInfo::Print(std::ostream& os) const
88{
89 os << "BSS Color: " << +m_bssColor << " Partial BSS Color: " << +m_partialBssColor
90 << " BSS Color Disabled: " << +m_bssColorDisabled;
91}
92
93uint16_t
95{
96 return 1;
97}
98
99void
101{
102 uint8_t oneByte = m_bssColor | (m_partialBssColor << 6) | (m_bssColorDisabled << 7);
103 start.WriteU8(oneByte);
104}
105
106uint16_t
108{
109 Buffer::Iterator tmp = start;
110 uint8_t oneByte = start.ReadU8();
111 m_bssColor = oneByte & 0x3f;
112 m_partialBssColor = (oneByte >> 6) & 0x01;
113 m_bssColorDisabled = (oneByte >> 7) & 0x01;
114 return start.GetDistanceFrom(tmp);
115}
116
117void
118HeOperation::OpInfo6GHz::Print(std::ostream& os) const
119{
120 os << "Primary channel: " << +m_primCh << " Channel Width: " << +m_chWid
121 << " Duplicate Beacon: " << +m_dupBeacon << " Regulatory Info: " << +m_regInfo
122 << " Channel center frequency segment 0: " << +m_chCntrFreqSeg0
123 << " Channel center frequency segment 1: " << +m_chCntrFreqSeg1
124 << " Minimum Rate: " << +m_minRate;
125}
126
127uint16_t
129{
130 return 5;
131}
132
133void
135{
136 start.WriteU8(m_primCh);
137 uint8_t control = m_chWid | (m_dupBeacon << 2) | (m_regInfo << 3);
138 start.WriteU8(control);
139 start.WriteU8(m_chCntrFreqSeg0);
140 start.WriteU8(m_chCntrFreqSeg1);
141 start.WriteU8(m_minRate);
142}
143
144uint16_t
146{
147 Buffer::Iterator i = start;
148 m_primCh = i.ReadU8();
149 uint8_t control = i.ReadU8();
150 m_chWid = control & 0x03;
151 m_dupBeacon = (control >> 2) & 0x01;
152 m_regInfo = (control >> 3) & 0x07;
153 m_chCntrFreqSeg0 = i.ReadU8();
154 m_chCntrFreqSeg1 = i.ReadU8();
155 m_minRate = i.ReadU8();
156 return i.GetDistanceFrom(start);
157}
158
159void
160HeOperation::SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
161{
162 NS_ASSERT((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
163
164 // IEEE 802.11ax-2021 9.4.2.248.4 Supported HE-MCS And NSS Set field
165 uint8_t val = 0x03; // not supported
166 if (maxHeMcs == 11) // MCS 0 - 11
167 {
168 val = 0x02;
169 }
170 else if (maxHeMcs >= 9) // MCS 0 - 9
171 {
172 val = 0x01;
173 }
174 else // MCS 0 - 7
175 {
176 val = 0x00;
177 }
178
179 // clear bits for that nss
180 const uint16_t mask = ~(0x03 << ((nss - 1) * 2));
181 m_basicHeMcsAndNssSet &= mask;
182
183 // update bits for that nss
184 m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
185}
186
187void
188HeOperation::Print(std::ostream& os) const
189{
190 os << "HE Operation=[HE Operation Parameters|";
192 os << "][BSS Color|";
194 os << "][Basic HE-MCS And NSS Set: " << m_basicHeMcsAndNssSet << "]";
195 if (m_6GHzOpInfo)
196 {
197 os << "[6 GHz Operation Info|";
198 m_6GHzOpInfo->Print(os);
199 os << "]";
200 }
201}
202
203uint16_t
205{
206 uint16_t ret = 1 /* Element ID Ext */ + m_heOpParams.GetSerializedSize() +
207 m_bssColorInfo.GetSerializedSize() + 2 /* Basic HE-MCS And NSS Set */;
208 if (m_6GHzOpInfo)
209 {
210 ret += m_6GHzOpInfo->GetSerializedSize();
211 }
212 return ret;
213}
214
215void
217{
218 m_heOpParams.Serialize(start);
220 start.WriteHtolsbU16(m_basicHeMcsAndNssSet);
221 if (m_6GHzOpInfo)
222 {
223 m_6GHzOpInfo->Serialize(start);
224 }
225 // todo: VHT Operation Information (variable)
226}
227
228uint16_t
230{
231 Buffer::Iterator i = start;
236 {
237 OpInfo6GHz opInfo6GHz;
238 opInfo6GHz.Deserialize(i);
239 m_6GHzOpInfo = opInfo6GHz;
240 }
241
242 // todo: VHT Operation Information (variable)
243 return i.GetDistanceFrom(start);
244}
245
246} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
uint16_t ReadLsbtohU16()
Definition: buffer.cc:1064
uint32_t GetDistanceFrom(const Iterator &o) const
Definition: buffer.cc:780
OptFieldWithPresenceInd< OpInfo6GHz > m_6GHzOpInfo
6 GHz Operation Information field
Definition: he-operation.h:175
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.
Definition: he-operation.cc:39
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)
Definition: he-operation.h:174
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
Definition: he-operation.cc:33
HeOperationParams m_heOpParams
HE Operation Parameters field.
Definition: he-operation.h:172
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.
Definition: he-operation.h:173
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
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.
Definition: he-operation.cc:87
uint16_t Deserialize(Buffer::Iterator &start)
Deserialize the BSS Color Information field.
uint16_t GetSerializedSize() const
Definition: he-operation.cc:94
uint8_t m_erSuDisable
ER SU Disable.
Definition: he-operation.h:55
void Print(std::ostream &os) const
Print the content of the HE Operation Parameters field.
Definition: he-operation.cc:45
void Serialize(Buffer::Iterator &start) const
Serialize the HE Operation Parameters field.
Definition: he-operation.cc:61
uint8_t m_vhOpPresent
VHT Operation Information Present (value 1 unsupported)
Definition: he-operation.h:53
bool m_6GHzOpPresent
6 GHz Operation Information Present (do not set, it is set by the OptFieldWithPresenceInd)
Definition: he-operation.h:56
uint8_t m_coHostedBss
Co-Hosted BSS (value 1 unsupported)
Definition: he-operation.h:54
uint16_t Deserialize(Buffer::Iterator &start)
Deserialize the HE Operation Parameters field.
Definition: he-operation.cc:71
uint8_t m_defaultPeDuration
Default PE Duration.
Definition: he-operation.h:50
uint8_t m_twtRequired
TWT Required.
Definition: he-operation.h:51
uint16_t m_txopDurRtsThresh
TXOP Duration RTS Threshold.
Definition: he-operation.h:52
6 GHz Operation Information field
Definition: he-operation.h:124
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