A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
vht-capabilities.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Ghada Badawy <gbadawy@rim.com>
7 * Sébastien Deronne <sebastien.deronne@gmail.com>
8 */
9
10#include "vht-capabilities.h"
11
12namespace ns3
13{
14
16 : m_maxMpduLength(0),
17 m_supportedChannelWidthSet(0),
18 m_rxLdpc(0),
19 m_shortGuardIntervalFor80Mhz(0),
20 m_shortGuardIntervalFor160Mhz(0),
21 m_txStbc(0),
22 m_rxStbc(0),
23 m_suBeamformerCapable(0),
24 m_suBeamformeeCapable(0),
25 m_beamformeeStsCapable(0),
26 m_numberOfSoundingDimensions(0),
27 m_muBeamformerCapable(0),
28 m_muBeamformeeCapable(0),
29 m_vhtTxopPs(0),
30 m_htcVhtCapable(0),
31 m_maxAmpduLengthExponent(0),
32 m_vhtLinkAdaptationCapable(0),
33 m_rxAntennaPatternConsistency(0),
34 m_txAntennaPatternConsistency(0),
35 m_rxHighestSupportedLongGuardIntervalDataRate(0),
36 m_txHighestSupportedLongGuardIntervalDataRate(0)
37{
38 m_rxMcsMap.resize(8, 0);
39 m_txMcsMap.resize(8, 0);
40 for (uint8_t i = 0; i < 8;
41 i++) // set to 3 by default, i.e. #spatial streams not supported. 0 means supported up to
42 // MCS 7, not what we want to imply at this stage.
43 {
44 m_rxMcsMap[i] = 3;
45 m_txMcsMap[i] = 3;
46 }
47}
48
54
55void
56VhtCapabilities::Print(std::ostream& os) const
57{
58 os << "VHT Capabilities=[Supported Channel Width Set: " << +m_supportedChannelWidthSet
59 << ", SGI 80 MHz: " << +m_shortGuardIntervalFor80Mhz
60 << ", SGI 160 MHz: " << +m_shortGuardIntervalFor160Mhz
61 << ", Max MPDU Length: " << m_maxMpduLength << "]";
62}
63
64uint16_t
66{
67 return 12;
68}
69
70void
72{
73 // write the corresponding value for each bit
74 start.WriteHtolsbU32(GetVhtCapabilitiesInfo());
75 start.WriteHtolsbU64(GetSupportedMcsAndNssSet());
76}
77
78uint16_t
80{
81 Buffer::Iterator i = start;
82 uint32_t vhtinfo = i.ReadLsbtohU32();
83 uint64_t mcsset = i.ReadLsbtohU64();
86 return length;
87}
88
89void
91{
92 m_maxMpduLength = ctrl & 0x03;
93 m_supportedChannelWidthSet = (ctrl >> 2) & 0x03;
94 m_rxLdpc = (ctrl >> 4) & 0x01;
95 m_shortGuardIntervalFor80Mhz = (ctrl >> 5) & 0x01;
96 m_shortGuardIntervalFor160Mhz = (ctrl >> 6) & 0x01;
97 m_txStbc = (ctrl >> 7) & 0x01;
98 m_rxStbc = (ctrl >> 8) & 0x07;
99 m_suBeamformerCapable = (ctrl >> 11) & 0x01;
100 m_suBeamformeeCapable = (ctrl >> 12) & 0x01;
101 m_beamformeeStsCapable = (ctrl >> 13) & 0x07;
102 m_numberOfSoundingDimensions = (ctrl >> 16) & 0x07;
103 m_muBeamformerCapable = (ctrl >> 19) & 0x01;
104 m_muBeamformeeCapable = (ctrl >> 20) & 0x01;
105 m_vhtTxopPs = (ctrl >> 21) & 0x01;
106 m_htcVhtCapable = (ctrl >> 22) & 0x01;
107 m_maxAmpduLengthExponent = (ctrl >> 23) & 0x07;
108 m_vhtLinkAdaptationCapable = (ctrl >> 26) & 0x03;
109 m_rxAntennaPatternConsistency = (ctrl >> 28) & 0x01;
110 m_txAntennaPatternConsistency = (ctrl >> 29) & 0x01;
111}
112
115{
116 uint32_t val = 0;
117 val |= m_maxMpduLength & 0x03;
118 val |= (m_supportedChannelWidthSet & 0x03) << 2;
119 val |= (m_rxLdpc & 0x01) << 4;
120 val |= (m_shortGuardIntervalFor80Mhz & 0x01) << 5;
121 val |= (m_shortGuardIntervalFor160Mhz & 0x01) << 6;
122 val |= (m_txStbc & 0x01) << 7;
123 val |= (m_rxStbc & 0x07) << 8;
124 val |= (m_suBeamformerCapable & 0x01) << 11;
125 val |= (m_suBeamformeeCapable & 0x01) << 12;
126 val |= (m_beamformeeStsCapable & 0x07) << 13;
127 val |= (m_numberOfSoundingDimensions & 0x07) << 16;
128 val |= (m_muBeamformerCapable & 0x01) << 19;
129 val |= (m_muBeamformeeCapable & 0x01) << 20;
130 val |= (m_vhtTxopPs & 0x01) << 21;
131 val |= (m_htcVhtCapable & 0x01) << 22;
132 val |= (m_maxAmpduLengthExponent & 0x07) << 23;
133 val |= (m_vhtLinkAdaptationCapable & 0x03) << 26;
134 val |= (m_rxAntennaPatternConsistency & 0x01) << 28;
135 val |= (m_txAntennaPatternConsistency & 0x01) << 29;
136 return val;
137}
138
139void
141{
142 uint16_t n;
143 for (uint8_t i = 0; i < 8; i++)
144 {
145 n = i * 2;
146 m_rxMcsMap[i] = (ctrl >> n) & 0x03;
147 }
148 m_rxHighestSupportedLongGuardIntervalDataRate = (ctrl >> 16) & 0x1fff;
149 for (uint8_t i = 0; i < 8; i++)
150 {
151 n = (i * 2) + 32;
152 m_txMcsMap[i] = (ctrl >> n) & 0x03;
153 }
154 m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
155}
156
157uint64_t
159{
160 uint64_t val = 0;
161 uint16_t n;
162 for (uint8_t i = 0; i < 8; i++)
163 {
164 n = i * 2;
165 val |= (static_cast<uint64_t>(m_rxMcsMap[i]) & 0x03) << n;
166 }
167 val |= (static_cast<uint64_t>(m_rxHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 16;
168 for (uint8_t i = 0; i < 8; i++)
169 {
170 n = (i * 2) + 32;
171 val |= (static_cast<uint64_t>(m_txMcsMap[i]) & 0x03) << n;
172 }
173 val |= (static_cast<uint64_t>(m_txHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 48;
174 return val;
175}
176
177void
179{
180 NS_ABORT_MSG_IF(length != 3895 && length != 7991 && length != 11454,
181 "Invalid MPDU Max Length value");
182 if (length == 11454)
183 {
184 m_maxMpduLength = 2;
185 }
186 else if (length == 7991)
187 {
188 m_maxMpduLength = 1;
189 }
190 else
191 {
192 m_maxMpduLength = 0;
193 }
194}
195
196void
198{
199 m_supportedChannelWidthSet = channelWidthSet;
200}
201
202void
204{
205 m_rxLdpc = rxLdpc;
206}
207
208void
210{
211 m_shortGuardIntervalFor80Mhz = shortGuardInterval;
212}
213
214void
216{
217 m_shortGuardIntervalFor160Mhz = shortGuardInterval;
218}
219
220void
222{
223 m_rxStbc = rxStbc;
224}
225
226void
228{
229 m_txStbc = txStbc;
230}
231
232void
234{
235 for (uint8_t i = 0; i <= 7; i++)
236 {
237 if ((1UL << (13 + i)) - 1 == maxampdulength)
238 {
240 return;
241 }
242 }
243 NS_ABORT_MSG("Invalid A-MPDU Max Length value");
244}
245
246void
247VhtCapabilities::SetRxMcsMap(uint8_t mcs, uint8_t nss)
248{
249 // MCS index should be at least 7 and should not exceed 9
250 NS_ASSERT(mcs >= 7 && mcs <= 9);
251 m_rxMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
252}
253
254void
255VhtCapabilities::SetTxMcsMap(uint8_t mcs, uint8_t nss)
256{
257 // MCS index should be at least 7 and should not exceed 9
258 NS_ASSERT(mcs >= 7 && mcs <= 9);
259 m_txMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
260}
261
262bool
264{
265 NS_ASSERT(mcs >= 0 && mcs <= 9);
266 if (mcs <= 7)
267 {
268 return true;
269 }
270 if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
271 {
272 return true;
273 }
274 if (mcs == 9 && m_txMcsMap[0] == 2)
275 {
276 return true;
277 }
278 return false;
279}
280
281bool
283{
284 NS_ASSERT(mcs >= 0 && mcs <= 9);
285 if (mcs <= 7)
286 {
287 return true;
288 }
289 if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
290 {
291 return true;
292 }
293 if (mcs == 9 && m_rxMcsMap[0] == 2)
294 {
295 return true;
296 }
297 return false;
298}
299
300void
305
306void
311
312uint16_t
314{
315 if (m_maxMpduLength == 0)
316 {
317 return 3895;
318 }
319 if (m_maxMpduLength == 1)
320 {
321 return 7991;
322 }
323 if (m_maxMpduLength == 2)
324 {
325 return 11454;
326 }
327 NS_ABORT_MSG("The value 3 is reserved");
328}
329
330uint8_t
335
336uint8_t
338{
339 return m_rxLdpc;
340}
341
342uint8_t
344{
345 return m_rxStbc;
346}
347
348uint8_t
350{
351 return m_txStbc;
352}
353
356{
357 return (1UL << (13 + m_maxAmpduLengthExponent)) - 1;
358}
359
360bool
361VhtCapabilities::IsSupportedMcs(uint8_t mcs, uint8_t nss) const
362{
363 // The MCS index starts at 0 and NSS starts at 1
364 if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
365 {
366 return true;
367 }
368 if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
369 {
370 return true;
371 }
372 if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
373 {
374 return true;
375 }
376 return false;
377}
378
379uint16_t
384
385} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
uint64_t ReadLsbtohU64()
Definition buffer.cc:1083
uint32_t ReadLsbtohU32()
Definition buffer.cc:1065
uint8_t m_htcVhtCapable
HTC VHT capable.
void SetRxHighestSupportedLgiDataRate(uint16_t supportedDatarate)
Set the receive highest supported LGI data rate.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void SetVhtCapabilitiesInfo(uint32_t ctrl)
Set the VHT Capabilities Info field in the VHT Capabilities information element.
bool IsSupportedMcs(uint8_t mcs, uint8_t nss) const
Get the is MCS supported.
void SetSupportedChannelWidthSet(uint8_t channelWidthSet)
Set the supported channel width set.
void SetMaxMpduLength(uint16_t length)
Set the maximum MPDU length.
uint32_t GetMaxAmpduLength() const
Return the maximum A-MPDU length.
uint8_t m_shortGuardIntervalFor80Mhz
short guard interval for 80 MHz
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
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)
uint8_t m_vhtLinkAdaptationCapable
VHT link adaptation capable.
void SetRxLdpc(uint8_t rxLdpc)
Set the receive LDPC.
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
void SetTxStbc(uint8_t txStbc)
Set the transmit STBC.
uint8_t GetRxStbc() const
Get the receive STBC.
uint8_t m_muBeamformerCapable
MU beamformer capable.
bool IsSupportedTxMcs(uint8_t mcs) const
Returns true if transmit MCS is supported.
void SetTxMcsMap(uint8_t mcs, uint8_t nss)
uint8_t m_muBeamformeeCapable
MU beamformee capable.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
uint8_t m_vhtTxopPs
VHT TXOP PS.
void SetShortGuardIntervalFor80Mhz(uint8_t shortGuardInterval)
Set the short guard interval 80 MHz.
uint8_t m_txStbc
transmit STBC
std::vector< uint8_t > m_txMcsMap
transmit MCS map
bool IsSupportedRxMcs(uint8_t mcs) const
Returns true if receive MCS is supported.
uint8_t m_suBeamformerCapable
SU beamformer capable.
uint8_t m_rxStbc
receive STBC
uint8_t m_maxMpduLength
maximum MPDU length
uint16_t GetMaxMpduLength() const
Get the maximum MPDU length.
uint16_t m_txHighestSupportedLongGuardIntervalDataRate
transmit highest supported long guard interval data rate
uint8_t GetTxStbc() const
Get the transmit STBC.
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
uint16_t m_rxHighestSupportedLongGuardIntervalDataRate
receive highest supported long guard interval data rate
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint8_t m_supportedChannelWidthSet
supported channel width set
uint8_t m_shortGuardIntervalFor160Mhz
short guard interval for 160 MHz
std::vector< uint8_t > m_rxMcsMap
receive MCS map
uint8_t m_suBeamformeeCapable
SU beamformee capable.
uint8_t m_beamformeeStsCapable
beamformee STS capable
uint64_t GetSupportedMcsAndNssSet() const
Return the MCS and NSS field in the VHT Capabilities information element.
void SetTxHighestSupportedLgiDataRate(uint16_t supportedDatarate)
Set the transmit highest supported LGI data rate.
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilities Info field in the VHT Capabilities information element.
uint8_t m_rxAntennaPatternConsistency
receive antenna pattern consistency
uint8_t m_rxLdpc
receive LDPC
void SetShortGuardIntervalFor160Mhz(uint8_t shortGuardInterval)
Set the short guard interval 160 MHz.
uint8_t m_txAntennaPatternConsistency
transmit antenna pattern consistency
void SetMaxAmpduLength(uint32_t maxAmpduLength)
Set the maximum AMPDU length.
uint8_t m_numberOfSoundingDimensions
number of sounding dimensions
void SetSupportedMcsAndNssSet(uint64_t ctrl)
Set the MCS and NSS field in the VHT Capabilities information element.
void SetRxMcsMap(uint8_t mcs, uint8_t nss)
uint8_t m_maxAmpduLengthExponent
maximum A-MPDU length exponent
uint8_t GetRxLdpc() const
Get the receive LDPC.
void SetRxStbc(uint8_t rxStbc)
Set the receive STBC.
#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
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition abort.h:97
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.
#define IE_VHT_CAPABILITIES