A Discrete-Event Network Simulator
API
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
66uint16_t
68{
69 return 12;
70}
71
72void
74{
75 // write the corresponding value for each bit
76 start.WriteHtolsbU32(GetVhtCapabilitiesInfo());
77 start.WriteHtolsbU64(GetSupportedMcsAndNssSet());
78}
79
80uint16_t
82{
84 uint32_t vhtinfo = i.ReadLsbtohU32();
85 uint64_t mcsset = i.ReadLsbtohU64();
88 return length;
89}
90
91void
93{
94 m_maxMpduLength = ctrl & 0x03;
95 m_supportedChannelWidthSet = (ctrl >> 2) & 0x03;
96 m_rxLdpc = (ctrl >> 4) & 0x01;
97 m_shortGuardIntervalFor80Mhz = (ctrl >> 5) & 0x01;
98 m_shortGuardIntervalFor160Mhz = (ctrl >> 6) & 0x01;
99 m_txStbc = (ctrl >> 7) & 0x01;
100 m_rxStbc = (ctrl >> 8) & 0x07;
101 m_suBeamformerCapable = (ctrl >> 11) & 0x01;
102 m_suBeamformeeCapable = (ctrl >> 12) & 0x01;
103 m_beamformeeStsCapable = (ctrl >> 13) & 0x07;
104 m_numberOfSoundingDimensions = (ctrl >> 16) & 0x07;
105 m_muBeamformerCapable = (ctrl >> 19) & 0x01;
106 m_muBeamformeeCapable = (ctrl >> 20) & 0x01;
107 m_vhtTxopPs = (ctrl >> 21) & 0x01;
108 m_htcVhtCapable = (ctrl >> 22) & 0x01;
109 m_maxAmpduLengthExponent = (ctrl >> 23) & 0x07;
110 m_vhtLinkAdaptationCapable = (ctrl >> 26) & 0x03;
111 m_rxAntennaPatternConsistency = (ctrl >> 28) & 0x01;
112 m_txAntennaPatternConsistency = (ctrl >> 29) & 0x01;
113}
114
117{
118 uint32_t val = 0;
119 val |= m_maxMpduLength & 0x03;
120 val |= (m_supportedChannelWidthSet & 0x03) << 2;
121 val |= (m_rxLdpc & 0x01) << 4;
122 val |= (m_shortGuardIntervalFor80Mhz & 0x01) << 5;
123 val |= (m_shortGuardIntervalFor160Mhz & 0x01) << 6;
124 val |= (m_txStbc & 0x01) << 7;
125 val |= (m_rxStbc & 0x07) << 8;
126 val |= (m_suBeamformerCapable & 0x01) << 11;
127 val |= (m_suBeamformeeCapable & 0x01) << 12;
128 val |= (m_beamformeeStsCapable & 0x07) << 13;
129 val |= (m_numberOfSoundingDimensions & 0x07) << 16;
130 val |= (m_muBeamformerCapable & 0x01) << 19;
131 val |= (m_muBeamformeeCapable & 0x01) << 20;
132 val |= (m_vhtTxopPs & 0x01) << 21;
133 val |= (m_htcVhtCapable & 0x01) << 22;
134 val |= (m_maxAmpduLengthExponent & 0x07) << 23;
135 val |= (m_vhtLinkAdaptationCapable & 0x03) << 26;
136 val |= (m_rxAntennaPatternConsistency & 0x01) << 28;
137 val |= (m_txAntennaPatternConsistency & 0x01) << 29;
138 return val;
139}
140
141void
143{
144 uint16_t n;
145 for (uint8_t i = 0; i < 8; i++)
146 {
147 n = i * 2;
148 m_rxMcsMap[i] = (ctrl >> n) & 0x03;
149 }
150 m_rxHighestSupportedLongGuardIntervalDataRate = (ctrl >> 16) & 0x1fff;
151 for (uint8_t i = 0; i < 8; i++)
152 {
153 n = (i * 2) + 32;
154 m_txMcsMap[i] = (ctrl >> n) & 0x03;
155 }
156 m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
157}
158
159uint64_t
161{
162 uint64_t val = 0;
163 uint16_t n;
164 for (uint8_t i = 0; i < 8; i++)
165 {
166 n = i * 2;
167 val |= (static_cast<uint64_t>(m_rxMcsMap[i]) & 0x03) << n;
168 }
169 val |= (static_cast<uint64_t>(m_rxHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 16;
170 for (uint8_t i = 0; i < 8; i++)
171 {
172 n = (i * 2) + 32;
173 val |= (static_cast<uint64_t>(m_txMcsMap[i]) & 0x03) << n;
174 }
175 val |= (static_cast<uint64_t>(m_txHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 48;
176 return val;
177}
178
179void
181{
182 NS_ABORT_MSG_IF(length != 3895 && length != 7991 && length != 11454,
183 "Invalid MPDU Max Length value");
184 if (length == 11454)
185 {
186 m_maxMpduLength = 2;
187 }
188 else if (length == 7991)
189 {
190 m_maxMpduLength = 1;
191 }
192 else
193 {
194 m_maxMpduLength = 0;
195 }
196}
197
198void
200{
201 m_supportedChannelWidthSet = channelWidthSet;
202}
203
204void
206{
207 m_rxLdpc = rxLdpc;
208}
209
210void
212{
213 m_shortGuardIntervalFor80Mhz = shortGuardInterval;
214}
215
216void
218{
219 m_shortGuardIntervalFor160Mhz = shortGuardInterval;
220}
221
222void
224{
225 m_rxStbc = rxStbc;
226}
227
228void
230{
231 m_txStbc = txStbc;
232}
233
234void
236{
237 for (uint8_t i = 0; i <= 7; i++)
238 {
239 if ((1UL << (13 + i)) - 1 == maxampdulength)
240 {
242 return;
243 }
244 }
245 NS_ABORT_MSG("Invalid A-MPDU Max Length value");
246}
247
248void
249VhtCapabilities::SetRxMcsMap(uint8_t mcs, uint8_t nss)
250{
251 // MCS index should be at least 7 and should not exceed 9
252 NS_ASSERT(mcs >= 7 && mcs <= 9);
253 m_rxMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
254}
255
256void
257VhtCapabilities::SetTxMcsMap(uint8_t mcs, uint8_t nss)
258{
259 // MCS index should be at least 7 and should not exceed 9
260 NS_ASSERT(mcs >= 7 && mcs <= 9);
261 m_txMcsMap[nss - 1] = mcs - 7; // 1 = MCS 8; 2 = MCS 9
262}
263
264bool
266{
267 NS_ASSERT(mcs >= 0 && mcs <= 9);
268 if (mcs <= 7)
269 {
270 return true;
271 }
272 if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
273 {
274 return true;
275 }
276 if (mcs == 9 && m_txMcsMap[0] == 2)
277 {
278 return true;
279 }
280 return false;
281}
282
283bool
285{
286 NS_ASSERT(mcs >= 0 && mcs <= 9);
287 if (mcs <= 7)
288 {
289 return true;
290 }
291 if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
292 {
293 return true;
294 }
295 if (mcs == 9 && m_rxMcsMap[0] == 2)
296 {
297 return true;
298 }
299 return false;
300}
301
302void
304{
306}
307
308void
310{
312}
313
314uint16_t
316{
317 if (m_maxMpduLength == 0)
318 {
319 return 3895;
320 }
321 if (m_maxMpduLength == 1)
322 {
323 return 7991;
324 }
325 if (m_maxMpduLength == 2)
326 {
327 return 11454;
328 }
329 NS_ABORT_MSG("The value 3 is reserved");
330}
331
332uint8_t
334{
336}
337
338uint8_t
340{
341 return m_rxLdpc;
342}
343
344uint8_t
346{
347 return m_rxStbc;
348}
349
350uint8_t
352{
353 return m_txStbc;
354}
355
358{
359 return (1UL << (13 + m_maxAmpduLengthExponent)) - 1;
360}
361
362bool
363VhtCapabilities::IsSupportedMcs(uint8_t mcs, uint8_t nss) const
364{
365 // The MCS index starts at 0 and NSS starts at 1
366 if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
367 {
368 return true;
369 }
370 if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
371 {
372 return true;
373 }
374 if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
375 {
376 return true;
377 }
378 return false;
379}
380
381uint16_t
383{
385}
386
387std::ostream&
388operator<<(std::ostream& os, const VhtCapabilities& vhtCapabilities)
389{
390 os << vhtCapabilities.GetVhtCapabilitiesInfo() << "|"
391 << vhtCapabilities.GetSupportedMcsAndNssSet();
392
393 return os;
394}
395
396} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint64_t ReadLsbtohU64()
Definition: buffer.cc:1097
uint32_t ReadLsbtohU32()
Definition: buffer.cc:1079
The IEEE 802.11ac VHT Capabilities.
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.
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.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
def start()
Definition: core.py:1861
#define IE_VHT_CAPABILITIES