A Discrete-Event Network Simulator
API
vht-capabilities.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2015
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Authors: Ghada Badawy <gbadawy@rim.com>
19 * Sébastien Deronne <sebastien.deronne@gmail.com>
20 */
21
22#include "vht-capabilities.h"
23
24namespace ns3 {
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 m_vhtSupported (0)
49{
50 m_rxMcsMap.resize (8,0);
51 m_txMcsMap.resize (8,0);
52 for (uint8_t i = 0; i < 8; i++) //set to 3 by default, i.e. #spatial streams not supported. 0 means supported up to MCS 7, not what we want to imply at this stage.
53 {
54 m_rxMcsMap[i] = 3;
55 m_txMcsMap[i] = 3;
56 }
57}
58
61{
63}
64
65void
67{
68 m_vhtSupported = vhtSupported;
69}
70
71uint8_t
73{
74 //we should not be here if vht is not supported
76 return 12;
77}
78
81{
82 if (m_vhtSupported < 1)
83 {
84 return i;
85 }
87}
88
89uint16_t
91{
92 if (m_vhtSupported < 1)
93 {
94 return 0;
95 }
97}
98
99void
101{
102 if (m_vhtSupported == 1)
103 {
104 //write the corresponding value for each bit
105 start.WriteHtolsbU32 (GetVhtCapabilitiesInfo ());
106 start.WriteHtolsbU64 (GetSupportedMcsAndNssSet ());
107 }
108}
109
110uint8_t
112 uint8_t length)
113{
115 uint32_t vhtinfo = i.ReadLsbtohU32 ();
116 uint64_t mcsset = i.ReadLsbtohU64 ();
117 SetVhtCapabilitiesInfo (vhtinfo);
119 return length;
120}
121
122void
124{
125 m_maxMpduLength = ctrl & 0x03;
126 m_supportedChannelWidthSet = (ctrl >> 2) & 0x03;
127 m_rxLdpc = (ctrl >> 4) & 0x01;
128 m_shortGuardIntervalFor80Mhz = (ctrl >> 5) & 0x01;
129 m_shortGuardIntervalFor160Mhz = (ctrl >> 6) & 0x01;
130 m_txStbc = (ctrl >> 7) & 0x01;
131 m_rxStbc = (ctrl >> 8) & 0x07;
132 m_suBeamformerCapable = (ctrl >> 11) & 0x01;
133 m_suBeamformeeCapable = (ctrl >> 12) & 0x01;
134 m_beamformeeStsCapable = (ctrl >> 13) & 0x07;
135 m_numberOfSoundingDimensions = (ctrl >> 16) & 0x07;
136 m_muBeamformerCapable = (ctrl >> 19) & 0x01;
137 m_muBeamformeeCapable = (ctrl >> 20) & 0x01;
138 m_vhtTxopPs = (ctrl >> 21) & 0x01;
139 m_htcVhtCapable = (ctrl >> 22) & 0x01;
140 m_maxAmpduLengthExponent = (ctrl >> 23) & 0x07;
141 m_vhtLinkAdaptationCapable = (ctrl >> 26) & 0x03;
142 m_rxAntennaPatternConsistency = (ctrl >> 28) & 0x01;
143 m_txAntennaPatternConsistency = (ctrl >> 29) & 0x01;
144}
145
148{
149 uint32_t val = 0;
150 val |= m_maxMpduLength & 0x03;
151 val |= (m_supportedChannelWidthSet & 0x03) << 2;
152 val |= (m_rxLdpc & 0x01) << 4;
153 val |= (m_shortGuardIntervalFor80Mhz & 0x01) << 5;
154 val |= (m_shortGuardIntervalFor160Mhz & 0x01) << 6;
155 val |= (m_txStbc & 0x01) << 7;
156 val |= (m_rxStbc & 0x07) << 8;
157 val |= (m_suBeamformerCapable & 0x01) << 11;
158 val |= (m_suBeamformeeCapable & 0x01) << 12;
159 val |= (m_beamformeeStsCapable & 0x07) << 13;
160 val |= (m_numberOfSoundingDimensions & 0x07) << 16;
161 val |= (m_muBeamformerCapable & 0x01) << 19;
162 val |= (m_muBeamformeeCapable & 0x01) << 20;
163 val |= (m_vhtTxopPs & 0x01) << 21;
164 val |= (m_htcVhtCapable & 0x01) << 22;
165 val |= (m_maxAmpduLengthExponent & 0x07) << 23;
166 val |= (m_vhtLinkAdaptationCapable & 0x03) << 26;
167 val |= (m_rxAntennaPatternConsistency & 0x01) << 28;
168 val |= (m_txAntennaPatternConsistency & 0x01) << 29;
169 return val;
170}
171
172void
174{
175 uint16_t n;
176 for (uint8_t i = 0; i < 8; i++)
177 {
178 n = i * 2;
179 m_rxMcsMap[i] = (ctrl >> n) & 0x03;
180 }
181 m_rxHighestSupportedLongGuardIntervalDataRate = (ctrl >> 16) & 0x1fff;
182 for (uint8_t i = 0; i < 8; i++)
183 {
184 n = (i * 2) + 32;
185 m_txMcsMap[i] = (ctrl >> n) & 0x03;
186 }
187 m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
188}
189
190uint64_t
192{
193 uint64_t val = 0;
194 uint16_t n;
195 for (uint8_t i = 0; i < 8; i++)
196 {
197 n = i * 2;
198 val |= (static_cast<uint64_t> (m_rxMcsMap[i]) & 0x03) << n;
199 }
200 val |= (static_cast<uint64_t> (m_rxHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 16;
201 for (uint8_t i = 0; i < 8; i++)
202 {
203 n = (i * 2) + 32;
204 val |= (static_cast<uint64_t> (m_txMcsMap[i]) & 0x03) << n;
205 }
206 val |= (static_cast<uint64_t> (m_txHighestSupportedLongGuardIntervalDataRate) & 0x1fff) << 48;
207 return val;
208}
209
210void
212{
213 NS_ABORT_MSG_IF (length != 3895 && length != 7991 && length != 11454,
214 "Invalid MPDU Max Length value");
215 if (length == 11454)
216 {
217 m_maxMpduLength = 2;
218 }
219 else if (length == 7991)
220 {
221 m_maxMpduLength = 1;
222 }
223 else
224 {
225 m_maxMpduLength = 0;
226 }
227}
228
229void
231{
232 m_supportedChannelWidthSet = channelWidthSet;
233}
234
235void
237{
238 m_rxLdpc = rxLdpc;
239}
240
241void
243{
244 m_shortGuardIntervalFor80Mhz = shortGuardInterval;
245}
246
247void
249{
250 m_shortGuardIntervalFor160Mhz = shortGuardInterval;
251}
252
253void
255{
256 m_rxStbc = rxStbc;
257}
258
259void
261{
262 m_txStbc = txStbc;
263}
264
265void
267{
268 for (uint8_t i = 0; i <= 7; i++)
269 {
270 if ((1ul << (13 + i)) - 1 == maxampdulength)
271 {
273 return;
274 }
275 }
276 NS_ABORT_MSG ("Invalid A-MPDU Max Length value");
277}
278
279void
280VhtCapabilities::SetRxMcsMap (uint8_t mcs, uint8_t nss)
281{
282 //MCS index should be at least 7 and should not exceed 9
283 NS_ASSERT (mcs >= 7 && mcs <= 9);
284 m_rxMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
285}
286
287void
288VhtCapabilities::SetTxMcsMap (uint8_t mcs, uint8_t nss)
289{
290 //MCS index should be at least 7 and should not exceed 9
291 NS_ASSERT (mcs >= 7 && mcs <= 9);
292 m_txMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
293}
294
295bool
297{
298 NS_ASSERT (mcs >= 0 && mcs <= 9);
299 if (mcs <= 7)
300 {
301 return true;
302 }
303 if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
304 {
305 return true;
306 }
307 if (mcs == 9 && m_txMcsMap[0] == 2)
308 {
309 return true;
310 }
311 return false;
312}
313
314bool
316{
317 NS_ASSERT (mcs >= 0 && mcs <= 9);
318 if (mcs <= 7)
319 {
320 return true;
321 }
322 if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
323 {
324 return true;
325 }
326 if (mcs == 9 && m_rxMcsMap[0] == 2)
327 {
328 return true;
329 }
330 return false;
331}
332
333void
335{
337}
338
339void
341{
343}
344
345uint16_t
347{
348 if (m_maxMpduLength == 0)
349 {
350 return 3895;
351 }
352 if (m_maxMpduLength == 1)
353 {
354 return 7991;
355 }
356 if (m_maxMpduLength == 2)
357 {
358 return 11454;
359 }
360 NS_ABORT_MSG ("The value 3 is reserved");
361}
362
363uint8_t
365{
367}
368
369uint8_t
371{
372 return m_rxLdpc;
373}
374
375uint8_t
377{
378 return m_rxStbc;
379}
380
381uint8_t
383{
384 return m_txStbc;
385}
386
389{
390 return (1ul << (13 + m_maxAmpduLengthExponent)) - 1;
391}
392
393bool
394VhtCapabilities::IsSupportedMcs (uint8_t mcs, uint8_t nss) const
395{
396 //The MCS index starts at 0 and NSS starts at 1
397 if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
398 {
399 return true;
400 }
401 if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
402 {
403 return true;
404 }
405 if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
406 {
407 return true;
408 }
409 return false;
410}
411
412uint16_t
414{
416}
417
418std::ostream &
419operator << (std::ostream &os, const VhtCapabilities &vhtCapabilities)
420{
421 os << vhtCapabilities.GetVhtCapabilitiesInfo () << "|" << vhtCapabilities.GetSupportedMcsAndNssSet ();
422
423 return os;
424}
425
426} //namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1077
uint64_t ReadLsbtohU64(void)
Definition: buffer.cc:1094
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.
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.
uint8_t m_shortGuardIntervalFor80Mhz
short guard interval for 80 MHz
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
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 GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
uint8_t GetRxStbc() const
Get the receive STBC.
uint8_t m_muBeamformerCapable
MU beamformer capable.
uint32_t GetMaxAmpduLength(void) const
Return the maximum A-MPDU length.
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
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
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 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
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
uint16_t GetMaxMpduLength(void) const
Get the maximum MPDU length.
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_vhtSupported
This is used to decide if this element should be added to the frame or not.
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
uint16_t GetSerializedSize() const override
Get the size of the serialized IE including Element ID and length fields.
void SetSupportedMcsAndNssSet(uint64_t ctrl)
Set the MCS and NSS field in the VHT Capabilities information element.
Buffer::Iterator Serialize(Buffer::Iterator start) const override
Serialize entire IE including Element ID and length fields.
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.
void SetVhtSupported(uint8_t vhtSupported)
Set the VHT supported field.
virtual uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
virtual Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition: abort.h:50
#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:139
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
def start()
Definition: core.py:1853
#define IE_VHT_CAPABILITIES