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 
24 namespace 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 {
62  return IE_VHT_CAPABILITIES;
63 }
64 
65 void
66 VhtCapabilities::SetVhtSupported (uint8_t vhtsupported)
67 {
68  m_vhtSupported = vhtsupported;
69 }
70 
71 uint8_t
73 {
74  //we should not be here if ht is not supported
76  return 12;
77 }
78 
81 {
82  if (m_vhtSupported < 1)
83  {
84  return i;
85  }
87 }
88 
89 uint16_t
91 {
92  if (m_vhtSupported < 1)
93  {
94  return 0;
95  }
97 }
98 
99 void
101 {
102  if (m_vhtSupported == 1)
103  {
104  //write the corresponding value for each bit
107  }
108 }
109 
110 uint8_t
112  uint8_t length)
113 {
115  uint16_t vhtinfo = i.ReadLsbtohU32 ();
116  uint64_t mcsset = i.ReadLsbtohU64 ();
117  SetVhtCapabilitiesInfo (vhtinfo);
118  SetSupportedMcsAndNssSet (mcsset);
119  return length;
120 }
121 
122 void
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 
146 uint32_t
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 
172 void
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  uint16_t n = (i * 2) + 32;
185  m_txMcsMap[i] = (ctrl >> n) & 0x03;
186  }
187  m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
188 }
189 
190 uint64_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 |= ((uint64_t)m_rxMcsMap[i] & 0x03) << n;
199  }
200  val |= ((uint64_t)m_rxHighestSupportedLongGuardIntervalDataRate & 0x1fff) << 16;
201  for (uint8_t i = 0; i < 8; i++)
202  {
203  n = (i * 2) + 32;
204  val |= ((uint64_t)m_txMcsMap[i] & 0x03) << n;
205  }
206  val |= ((uint64_t)m_txHighestSupportedLongGuardIntervalDataRate & 0x1fff) << 48;
207  return val;
208 }
209 
210 void
212 {
213  m_maxMpduLength = length;
214 }
215 
216 void
218 {
219  m_supportedChannelWidthSet = channelwidthset;
220 }
221 
222 void
224 {
225  m_rxLdpc = rxldpc;
226 }
227 
228 void
230 {
231  m_shortGuardIntervalFor80Mhz = shortguardinterval;
232 }
233 
234 void
236 {
237  m_shortGuardIntervalFor160Mhz = shortguardinterval;
238 }
239 
240 void
242 {
243  m_rxStbc = rxstbc;
244 }
245 
246 void
248 {
249  m_txStbc = txstbc;
250 }
251 
252 void
254 {
255  m_maxAmpduLengthExponent = exponent;
256 }
257 
258 void
260 {
261  //Set each element in the map accoriding to the 2 bits representing it page 98 in the 11ac standard
262  uint8_t n;
263  for (uint8_t i = 0; i < 8; i++)
264  {
265  n = i * 2;
266  m_rxMcsMap[i] = (map >> n) & 0x03;
267  }
268 }
269 
270 void
271 VhtCapabilities::SetRxMcsMap (uint8_t mcs, uint8_t nss)
272 {
273  //MCS index should be at least 7 and should not exceed 9
274  NS_ASSERT (mcs >= 7 && mcs <= 9);
275  m_rxMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
276 }
277 
278 void
280 {
281  //Set each element in the map accoriding to the 2 bits representing it page 98 in the 11ac standard
282  uint8_t n;
283  for (uint8_t i = 0; i < 8; i++)
284  {
285  n = i * 2;
286  m_txMcsMap[i] = (map >> n) & 0x03;
287  }
288 }
289 
290 void
291 VhtCapabilities::SetTxMcsMap (uint8_t mcs, uint8_t nss)
292 {
293  //MCS index should be at least 7 and should not exceed 9
294  NS_ASSERT (mcs >= 7 && mcs <= 9);
295  m_txMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
296 }
297 
298 bool
300 {
301  NS_ASSERT (mcs >= 0 && mcs <= 9);
302  if (mcs <= 7)
303  {
304  return true;
305  }
306  if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
307  {
308  return true;
309  }
310  if (mcs == 9 && m_txMcsMap[0] == 2)
311  {
312  return true;
313  }
314  return false;
315 }
316 
317 bool
319 {
320  NS_ASSERT (mcs >= 0 && mcs <= 9);
321  if (mcs <= 7)
322  {
323  return true;
324  }
325  if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
326  {
327  return true;
328  }
329  if (mcs == 9 && m_rxMcsMap[0] == 2)
330  {
331  return true;
332  }
333  return false;
334 }
335 
336 void
338 {
340 }
341 
342 void
344 {
346 }
347 
348 uint8_t
350 {
351  return m_maxMpduLength;
352 }
353 
354 uint8_t
356 {
358 }
359 
360 uint8_t
362 {
363  return m_rxLdpc;
364 }
365 
366 uint8_t
368 {
370 }
371 
372 uint8_t
374 {
376 }
377 
378 uint8_t
380 {
381  return m_rxStbc;
382 }
383 
384 uint8_t
386 {
387  return m_txStbc;
388 }
389 
390 uint8_t
392 {
394 }
395 
396 bool
397 VhtCapabilities::IsSupportedMcs (uint8_t mcs, uint8_t nss) const
398 {
399  //The MCS index starts at 0 and NSS starts at 1
400  if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
401  {
402  return true;
403  }
404  if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
405  {
406  return true;
407  }
408  if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
409  {
410  return true;
411  }
412  return false;
413 }
414 
415 uint16_t
417 {
418  uint16_t val = 0;
419  uint8_t n;
420  for (uint8_t i = 0; i < 8; i++)
421  {
422  n = i * 2;
423  val |= (m_rxMcsMap[i] & 0x03) << n;
424  }
425  return val;
426 }
427 
428 uint16_t
430 {
431  uint16_t val = 0;
432  uint8_t n;
433  for (uint8_t i = 0; i < 8; i++)
434  {
435  n = i * 2;
436  val |= (m_txMcsMap[i] & 0x03) << n;
437  }
438  return val;
439 }
440 
441 uint16_t
443 {
445 }
446 
447 uint16_t
449 {
451 }
452 
454 
463 std::ostream &
465 {
466  os << VhtCapabilities.GetVhtCapabilitiesInfo () << "|" << VhtCapabilities.GetSupportedMcsAndNssSet ();
467 
468  return os;
469 }
470 
479 std::istream &operator >> (std::istream &is,VhtCapabilities &VhtCapabilities)
480 {
481  uint32_t c1;
482  uint64_t c2;
483  is >> c1 >> c2;
484  VhtCapabilities.SetVhtCapabilitiesInfo (c1);
485  VhtCapabilities.SetSupportedMcsAndNssSet (c2);
486 
487  return is;
488 }
489 
490 } //namespace ns3
uint8_t m_numberOfSoundingDimensions
number of sounding dimensions
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilties Info field in the VHT Capabilities information element.
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
void SetShortGuardIntervalFor80Mhz(uint8_t shortguardinterval)
Set the short guard interval 80 Mhz.
bool IsSupportedTxMcs(uint8_t mcs) const
Get the is transmit MCS supported.
uint8_t m_shortGuardIntervalFor160Mhz
short guard interval 160 MHz
uint16_t GetTxMcsMap() const
Get the transmit MCS map.
uint16_t GetTxHighestSupportedLgiDataRate() const
Get the transmit highest supported LGI data rate.
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
uint8_t m_rxLdpc
receive LDPC
void SetTxMcsMap(uint16_t map)
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
uint8_t m_muBeamformeeCapable
MU beam formee capable.
void SetMaxMpduLength(uint8_t length)
Set the maximum MPDU length.
def start()
Definition: core.py:1790
#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
uint8_t m_maxAmpduLengthExponent
maximum AMPDU length exponent
uint8_t m_htcVhtCapable
HTC VHT capable.
uint16_t m_rxHighestSupportedLongGuardIntervalDataRate
receive highest supported long guard interval data rate
uint8_t GetMaxMpduLength() const
Get the maximum MPDU length.
uint8_t GetShortGuardIntervalFor160Mhz() const
Get the short guard interval 80 MHz.
void SetVhtSupported(uint8_t vhtsupported)
Set the VHT supported field.
#define IE_VHT_CAPABILITIES
void SetRxLdpc(uint8_t rxldpc)
Set the receive LDPC.
uint8_t m_vhtLinkAdaptationCapable
VHT link adaptation capable.
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize the information field.
void SetSupportedMcsAndNssSet(uint64_t ctrl)
Set the MCS and NSS field in the VHT Capabilities information element.
uint8_t GetRxStbc() const
Get the receive STBC.
std::vector< uint8_t > m_rxMcsMap
receive MCS map
void SetShortGuardIntervalFor160Mhz(uint8_t shortguardinterval)
Set the short guard interval 160 Mhz.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
iterator in a Buffer instance
Definition: buffer.h:98
uint8_t m_txStbc
transmit STBC
std::vector< uint8_t > m_txMcsMap
transmit MCS map
The IEEE 802.11ac VHT Capabilities.
uint8_t m_rxAntennaPatternConsistency
receive antenna pattern consistency
void SetTxHighestSupportedLgiDataRate(uint16_t supporteddatarate)
Set the transmit highest supported LGI data rate.
uint16_t GetRxMcsMap() const
Get the receive MCS map.
void SetSupportedChannelWidthSet(uint8_t channelwidthset)
Set the supported channel width set.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
uint8_t m_txAntennaPatternConsistency
transmit antenna pattern consistency
uint8_t m_shortGuardIntervalFor80Mhz
short guard interval 80 MHz
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t GetInformationFieldSize() const
Return the information field size.
uint8_t m_suBeamformerCapable
SU beam former capable.
void SetRxStbc(uint8_t rxstbc)
Set the receive STBC.
uint8_t GetMaxAmpduLengthExponent() const
Get the maximum AMPDU length exponent.
uint8_t GetShortGuardIntervalFor80Mhz() const
Get the short guard interval 80 MHz.
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if the STA is an VHT STA...
uint8_t m_beamformeeStsCapable
beam formee STS capable
uint16_t m_txHighestSupportedLongGuardIntervalDataRate
transmit highest supported long guard interval data rate
void SetRxHighestSupportedLgiDataRate(uint16_t supporteddatarate)
Set the receive highest supported LGI data rate.
void SetRxMcsMap(uint16_t map)
uint16_t GetSerializedSize() const
Get the serialized size.
uint8_t m_vhtTxopPs
VHT TXOP PS.
void WriteHtolsbU64(uint64_t data)
Definition: buffer.cc:929
uint64_t GetSupportedMcsAndNssSet() const
Return the MCS and NSS field in the VHT Capabilities information element.
uint8_t m_muBeamformerCapable
MU beam former capable.
bool IsSupportedRxMcs(uint8_t mcs) const
Get the is receive MCS supported.
bool IsSupportedMcs(uint8_t mcs, uint8_t Nss) const
Get the is MCS supported.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
uint8_t m_suBeamformeeCapable
SU beam formee capable.
WifiInformationElementId ElementId() const
Return the element ID.
uint8_t GetTxStbc() const
Get the transmit STBC.
uint8_t GetRxLdpc() const
Get the receive LDPC.
uint16_t m_supportedChannelWidthSet
supported channel width set
uint16_t m_maxMpduLength
maximum MPDU length
uint64_t ReadLsbtohU64(void)
Definition: buffer.cc:1096
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
void SerializeInformationField(Buffer::Iterator start) const
Serialize the information field.
uint8_t m_rxStbc
receive STBC
void SetTxStbc(uint8_t txstbc)
Set the transmit STBC.
void SetVhtCapabilitiesInfo(uint32_t ctrl)
Set the VHT Capabilties Info field in the VHT Capabilities information element.
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1079
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
uint8_t m_vhtSupported
This is used to decide if this element should be added to the frame or not.
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:920
void SetMaxAmpduLengthExponent(uint8_t exponent)
Set the maximum AMPDU length exponent.