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 * 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: Ghada Badawy <gbadawy@rim.com>
18 * Sébastien Deronne <sebastien.deronne@gmail.com>
19 */
20
21#include "vht-capabilities.h"
22
23namespace ns3
24{
25
27 : m_maxMpduLength(0),
28 m_supportedChannelWidthSet(0),
29 m_rxLdpc(0),
30 m_shortGuardIntervalFor80Mhz(0),
31 m_shortGuardIntervalFor160Mhz(0),
32 m_txStbc(0),
33 m_rxStbc(0),
34 m_suBeamformerCapable(0),
35 m_suBeamformeeCapable(0),
36 m_beamformeeStsCapable(0),
37 m_numberOfSoundingDimensions(0),
38 m_muBeamformerCapable(0),
39 m_muBeamformeeCapable(0),
40 m_vhtTxopPs(0),
41 m_htcVhtCapable(0),
42 m_maxAmpduLengthExponent(0),
43 m_vhtLinkAdaptationCapable(0),
44 m_rxAntennaPatternConsistency(0),
45 m_txAntennaPatternConsistency(0),
46 m_rxHighestSupportedLongGuardIntervalDataRate(0),
47 m_txHighestSupportedLongGuardIntervalDataRate(0)
48{
49 m_rxMcsMap.resize(8, 0);
50 m_txMcsMap.resize(8, 0);
51 for (uint8_t i = 0; i < 8;
52 i++) // set to 3 by default, i.e. #spatial streams not supported. 0 means supported up to
53 // MCS 7, not what we want to imply at this stage.
54 {
55 m_rxMcsMap[i] = 3;
56 m_txMcsMap[i] = 3;
57 }
58}
59
62{
64}
65
66void
67VhtCapabilities::Print(std::ostream& os) const
68{
69 os << "VHT Capabilities=" << GetVhtCapabilitiesInfo() << "|" << GetSupportedMcsAndNssSet();
70}
71
72uint16_t
74{
75 return 12;
76}
77
78void
80{
81 // write the corresponding value for each bit
82 start.WriteHtolsbU32(GetVhtCapabilitiesInfo());
83 start.WriteHtolsbU64(GetSupportedMcsAndNssSet());
84}
85
86uint16_t
88{
89 Buffer::Iterator i = start;
90 uint32_t vhtinfo = i.ReadLsbtohU32();
91 uint64_t mcsset = i.ReadLsbtohU64();
94 return length;
95}
96
97void
99{
100 m_maxMpduLength = ctrl & 0x03;
101 m_supportedChannelWidthSet = (ctrl >> 2) & 0x03;
102 m_rxLdpc = (ctrl >> 4) & 0x01;
103 m_shortGuardIntervalFor80Mhz = (ctrl >> 5) & 0x01;
104 m_shortGuardIntervalFor160Mhz = (ctrl >> 6) & 0x01;
105 m_txStbc = (ctrl >> 7) & 0x01;
106 m_rxStbc = (ctrl >> 8) & 0x07;
107 m_suBeamformerCapable = (ctrl >> 11) & 0x01;
108 m_suBeamformeeCapable = (ctrl >> 12) & 0x01;
109 m_beamformeeStsCapable = (ctrl >> 13) & 0x07;
110 m_numberOfSoundingDimensions = (ctrl >> 16) & 0x07;
111 m_muBeamformerCapable = (ctrl >> 19) & 0x01;
112 m_muBeamformeeCapable = (ctrl >> 20) & 0x01;
113 m_vhtTxopPs = (ctrl >> 21) & 0x01;
114 m_htcVhtCapable = (ctrl >> 22) & 0x01;
115 m_maxAmpduLengthExponent = (ctrl >> 23) & 0x07;
116 m_vhtLinkAdaptationCapable = (ctrl >> 26) & 0x03;
117 m_rxAntennaPatternConsistency = (ctrl >> 28) & 0x01;
118 m_txAntennaPatternConsistency = (ctrl >> 29) & 0x01;
119}
120
123{
124 uint32_t val = 0;
125 val |= m_maxMpduLength & 0x03;
126 val |= (m_supportedChannelWidthSet & 0x03) << 2;
127 val |= (m_rxLdpc & 0x01) << 4;
128 val |= (m_shortGuardIntervalFor80Mhz & 0x01) << 5;
129 val |= (m_shortGuardIntervalFor160Mhz & 0x01) << 6;
130 val |= (m_txStbc & 0x01) << 7;
131 val |= (m_rxStbc & 0x07) << 8;
132 val |= (m_suBeamformerCapable & 0x01) << 11;
133 val |= (m_suBeamformeeCapable & 0x01) << 12;
134 val |= (m_beamformeeStsCapable & 0x07) << 13;
135 val |= (m_numberOfSoundingDimensions & 0x07) << 16;
136 val |= (m_muBeamformerCapable & 0x01) << 19;
137 val |= (m_muBeamformeeCapable & 0x01) << 20;
138 val |= (m_vhtTxopPs & 0x01) << 21;
139 val |= (m_htcVhtCapable & 0x01) << 22;
140 val |= (m_maxAmpduLengthExponent & 0x07) << 23;
141 val |= (m_vhtLinkAdaptationCapable & 0x03) << 26;
142 val |= (m_rxAntennaPatternConsistency & 0x01) << 28;
143 val |= (m_txAntennaPatternConsistency & 0x01) << 29;
144 return val;
145}
146
147void
149{
150 uint16_t n;
151 for (uint8_t i = 0; i < 8; i++)
152 {
153 n = i * 2;
154 m_rxMcsMap[i] = (ctrl >> n) & 0x03;
155 }
156 m_rxHighestSupportedLongGuardIntervalDataRate = (ctrl >> 16) & 0x1fff;
157 for (uint8_t i = 0; i < 8; i++)
158 {
159 n = (i * 2) + 32;
160 m_txMcsMap[i] = (ctrl >> n) & 0x03;
161 }
162 m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
163}
164
165uint64_t
167{
168 uint64_t val = 0;
169 uint16_t n;
170 for (uint8_t i = 0; i < 8; i++)
171 {
172 n = i * 2;
173 val |= (static_cast<uint64_t>(m_rxMcsMap[i]) & 0x03) << n;
174 }
175 val |= (static_cast<uint64_t>(m_rxHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 16;
176 for (uint8_t i = 0; i < 8; i++)
177 {
178 n = (i * 2) + 32;
179 val |= (static_cast<uint64_t>(m_txMcsMap[i]) & 0x03) << n;
180 }
181 val |= (static_cast<uint64_t>(m_txHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 48;
182 return val;
183}
184
185void
187{
188 NS_ABORT_MSG_IF(length != 3895 && length != 7991 && length != 11454,
189 "Invalid MPDU Max Length value");
190 if (length == 11454)
191 {
192 m_maxMpduLength = 2;
193 }
194 else if (length == 7991)
195 {
196 m_maxMpduLength = 1;
197 }
198 else
199 {
200 m_maxMpduLength = 0;
201 }
202}
203
204void
206{
207 m_supportedChannelWidthSet = channelWidthSet;
208}
209
210void
212{
213 m_rxLdpc = rxLdpc;
214}
215
216void
218{
219 m_shortGuardIntervalFor80Mhz = shortGuardInterval;
220}
221
222void
224{
225 m_shortGuardIntervalFor160Mhz = shortGuardInterval;
226}
227
228void
230{
231 m_rxStbc = rxStbc;
232}
233
234void
236{
237 m_txStbc = txStbc;
238}
239
240void
242{
243 for (uint8_t i = 0; i <= 7; i++)
244 {
245 if ((1UL << (13 + i)) - 1 == maxampdulength)
246 {
248 return;
249 }
250 }
251 NS_ABORT_MSG("Invalid A-MPDU Max Length value");
252}
253
254void
255VhtCapabilities::SetRxMcsMap(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_rxMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
260}
261
262void
263VhtCapabilities::SetTxMcsMap(uint8_t mcs, uint8_t nss)
264{
265 // MCS index should be at least 7 and should not exceed 9
266 NS_ASSERT(mcs >= 7 && mcs <= 9);
267 m_txMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
268}
269
270bool
272{
273 NS_ASSERT(mcs >= 0 && mcs <= 9);
274 if (mcs <= 7)
275 {
276 return true;
277 }
278 if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
279 {
280 return true;
281 }
282 if (mcs == 9 && m_txMcsMap[0] == 2)
283 {
284 return true;
285 }
286 return false;
287}
288
289bool
291{
292 NS_ASSERT(mcs >= 0 && mcs <= 9);
293 if (mcs <= 7)
294 {
295 return true;
296 }
297 if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
298 {
299 return true;
300 }
301 if (mcs == 9 && m_rxMcsMap[0] == 2)
302 {
303 return true;
304 }
305 return false;
306}
307
308void
310{
312}
313
314void
316{
318}
319
320uint16_t
322{
323 if (m_maxMpduLength == 0)
324 {
325 return 3895;
326 }
327 if (m_maxMpduLength == 1)
328 {
329 return 7991;
330 }
331 if (m_maxMpduLength == 2)
332 {
333 return 11454;
334 }
335 NS_ABORT_MSG("The value 3 is reserved");
336}
337
338uint8_t
340{
342}
343
344uint8_t
346{
347 return m_rxLdpc;
348}
349
350uint8_t
352{
353 return m_rxStbc;
354}
355
356uint8_t
358{
359 return m_txStbc;
360}
361
364{
365 return (1UL << (13 + m_maxAmpduLengthExponent)) - 1;
366}
367
368bool
369VhtCapabilities::IsSupportedMcs(uint8_t mcs, uint8_t nss) const
370{
371 // The MCS index starts at 0 and NSS starts at 1
372 if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
373 {
374 return true;
375 }
376 if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
377 {
378 return true;
379 }
380 if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
381 {
382 return true;
383 }
384 return false;
385}
386
387uint16_t
389{
391}
392
393} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint64_t ReadLsbtohU64()
Definition: buffer.cc:1094
uint32_t ReadLsbtohU32()
Definition: buffer.cc:1076
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:66
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:49
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
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