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=" << GetVhtCapabilitiesInfo() << "|" << GetSupportedMcsAndNssSet();
59}
60
61uint16_t
63{
64 return 12;
65}
66
67void
69{
70 // write the corresponding value for each bit
71 start.WriteHtolsbU32(GetVhtCapabilitiesInfo());
72 start.WriteHtolsbU64(GetSupportedMcsAndNssSet());
73}
74
75uint16_t
77{
78 Buffer::Iterator i = start;
79 uint32_t vhtinfo = i.ReadLsbtohU32();
80 uint64_t mcsset = i.ReadLsbtohU64();
83 return length;
84}
85
86void
88{
89 m_maxMpduLength = ctrl & 0x03;
90 m_supportedChannelWidthSet = (ctrl >> 2) & 0x03;
91 m_rxLdpc = (ctrl >> 4) & 0x01;
92 m_shortGuardIntervalFor80Mhz = (ctrl >> 5) & 0x01;
93 m_shortGuardIntervalFor160Mhz = (ctrl >> 6) & 0x01;
94 m_txStbc = (ctrl >> 7) & 0x01;
95 m_rxStbc = (ctrl >> 8) & 0x07;
96 m_suBeamformerCapable = (ctrl >> 11) & 0x01;
97 m_suBeamformeeCapable = (ctrl >> 12) & 0x01;
98 m_beamformeeStsCapable = (ctrl >> 13) & 0x07;
99 m_numberOfSoundingDimensions = (ctrl >> 16) & 0x07;
100 m_muBeamformerCapable = (ctrl >> 19) & 0x01;
101 m_muBeamformeeCapable = (ctrl >> 20) & 0x01;
102 m_vhtTxopPs = (ctrl >> 21) & 0x01;
103 m_htcVhtCapable = (ctrl >> 22) & 0x01;
104 m_maxAmpduLengthExponent = (ctrl >> 23) & 0x07;
105 m_vhtLinkAdaptationCapable = (ctrl >> 26) & 0x03;
106 m_rxAntennaPatternConsistency = (ctrl >> 28) & 0x01;
107 m_txAntennaPatternConsistency = (ctrl >> 29) & 0x01;
108}
109
112{
113 uint32_t val = 0;
114 val |= m_maxMpduLength & 0x03;
115 val |= (m_supportedChannelWidthSet & 0x03) << 2;
116 val |= (m_rxLdpc & 0x01) << 4;
117 val |= (m_shortGuardIntervalFor80Mhz & 0x01) << 5;
118 val |= (m_shortGuardIntervalFor160Mhz & 0x01) << 6;
119 val |= (m_txStbc & 0x01) << 7;
120 val |= (m_rxStbc & 0x07) << 8;
121 val |= (m_suBeamformerCapable & 0x01) << 11;
122 val |= (m_suBeamformeeCapable & 0x01) << 12;
123 val |= (m_beamformeeStsCapable & 0x07) << 13;
124 val |= (m_numberOfSoundingDimensions & 0x07) << 16;
125 val |= (m_muBeamformerCapable & 0x01) << 19;
126 val |= (m_muBeamformeeCapable & 0x01) << 20;
127 val |= (m_vhtTxopPs & 0x01) << 21;
128 val |= (m_htcVhtCapable & 0x01) << 22;
129 val |= (m_maxAmpduLengthExponent & 0x07) << 23;
130 val |= (m_vhtLinkAdaptationCapable & 0x03) << 26;
131 val |= (m_rxAntennaPatternConsistency & 0x01) << 28;
132 val |= (m_txAntennaPatternConsistency & 0x01) << 29;
133 return val;
134}
135
136void
138{
139 uint16_t n;
140 for (uint8_t i = 0; i < 8; i++)
141 {
142 n = i * 2;
143 m_rxMcsMap[i] = (ctrl >> n) & 0x03;
144 }
145 m_rxHighestSupportedLongGuardIntervalDataRate = (ctrl >> 16) & 0x1fff;
146 for (uint8_t i = 0; i < 8; i++)
147 {
148 n = (i * 2) + 32;
149 m_txMcsMap[i] = (ctrl >> n) & 0x03;
150 }
151 m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
152}
153
154uint64_t
156{
157 uint64_t val = 0;
158 uint16_t n;
159 for (uint8_t i = 0; i < 8; i++)
160 {
161 n = i * 2;
162 val |= (static_cast<uint64_t>(m_rxMcsMap[i]) & 0x03) << n;
163 }
164 val |= (static_cast<uint64_t>(m_rxHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 16;
165 for (uint8_t i = 0; i < 8; i++)
166 {
167 n = (i * 2) + 32;
168 val |= (static_cast<uint64_t>(m_txMcsMap[i]) & 0x03) << n;
169 }
170 val |= (static_cast<uint64_t>(m_txHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 48;
171 return val;
172}
173
174void
176{
177 NS_ABORT_MSG_IF(length != 3895 && length != 7991 && length != 11454,
178 "Invalid MPDU Max Length value");
179 if (length == 11454)
180 {
181 m_maxMpduLength = 2;
182 }
183 else if (length == 7991)
184 {
185 m_maxMpduLength = 1;
186 }
187 else
188 {
189 m_maxMpduLength = 0;
190 }
191}
192
193void
195{
196 m_supportedChannelWidthSet = channelWidthSet;
197}
198
199void
201{
202 m_rxLdpc = rxLdpc;
203}
204
205void
207{
208 m_shortGuardIntervalFor80Mhz = shortGuardInterval;
209}
210
211void
213{
214 m_shortGuardIntervalFor160Mhz = shortGuardInterval;
215}
216
217void
219{
220 m_rxStbc = rxStbc;
221}
222
223void
225{
226 m_txStbc = txStbc;
227}
228
229void
231{
232 for (uint8_t i = 0; i <= 7; i++)
233 {
234 if ((1UL << (13 + i)) - 1 == maxampdulength)
235 {
237 return;
238 }
239 }
240 NS_ABORT_MSG("Invalid A-MPDU Max Length value");
241}
242
243void
244VhtCapabilities::SetRxMcsMap(uint8_t mcs, uint8_t nss)
245{
246 // MCS index should be at least 7 and should not exceed 9
247 NS_ASSERT(mcs >= 7 && mcs <= 9);
248 m_rxMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
249}
250
251void
252VhtCapabilities::SetTxMcsMap(uint8_t mcs, uint8_t nss)
253{
254 // MCS index should be at least 7 and should not exceed 9
255 NS_ASSERT(mcs >= 7 && mcs <= 9);
256 m_txMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
257}
258
259bool
261{
262 NS_ASSERT(mcs >= 0 && mcs <= 9);
263 if (mcs <= 7)
264 {
265 return true;
266 }
267 if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
268 {
269 return true;
270 }
271 if (mcs == 9 && m_txMcsMap[0] == 2)
272 {
273 return true;
274 }
275 return false;
276}
277
278bool
280{
281 NS_ASSERT(mcs >= 0 && mcs <= 9);
282 if (mcs <= 7)
283 {
284 return true;
285 }
286 if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
287 {
288 return true;
289 }
290 if (mcs == 9 && m_rxMcsMap[0] == 2)
291 {
292 return true;
293 }
294 return false;
295}
296
297void
302
303void
308
309uint16_t
311{
312 if (m_maxMpduLength == 0)
313 {
314 return 3895;
315 }
316 if (m_maxMpduLength == 1)
317 {
318 return 7991;
319 }
320 if (m_maxMpduLength == 2)
321 {
322 return 11454;
323 }
324 NS_ABORT_MSG("The value 3 is reserved");
325}
326
327uint8_t
332
333uint8_t
335{
336 return m_rxLdpc;
337}
338
339uint8_t
341{
342 return m_rxStbc;
343}
344
345uint8_t
347{
348 return m_txStbc;
349}
350
353{
354 return (1UL << (13 + m_maxAmpduLengthExponent)) - 1;
355}
356
357bool
358VhtCapabilities::IsSupportedMcs(uint8_t mcs, uint8_t nss) const
359{
360 // The MCS index starts at 0 and NSS starts at 1
361 if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
362 {
363 return true;
364 }
365 if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
366 {
367 return true;
368 }
369 if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
370 {
371 return true;
372 }
373 return false;
374}
375
376uint16_t
381
382} // 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