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 #include "ns3/assert.h"
24 #include "ns3/log.h"
25 
26 NS_LOG_COMPONENT_DEFINE ("VhtCapabilities");
27 
28 namespace ns3 {
29 
31  : m_maxMpduLength (0),
32  m_supportedChannelWidthSet (0),
33  m_rxLdpc (0),
34  m_shortGuardIntervalFor80Mhz (0),
35  m_shortGuardIntervalFor160Mhz (0),
36  m_txStbc (0),
37  m_rxStbc (0),
38  m_suBeamformerCapable (0),
39  m_suBeamformeeCapable (0),
40  m_beamformeeStsCapable (0),
41  m_numberOfSoundingDimensions (0),
42  m_muBeamformerCapable (0),
43  m_muBeamformeeCapable (0),
44  m_vhtTxopPs (0),
45  m_htcVhtCapable (0),
46  m_maxAmpduLengthExponent (0),
47  m_vhtLinkAdaptationCapable (0),
48  m_rxAntennaPatternConsistency (0),
49  m_txAntennaPatternConsistency (0),
50  m_rxHighestSupportedLongGuardIntervalDataRate (0),
51  m_txHighestSupportedLongGuardIntervalDataRate (0),
52  m_vhtSupported (0)
53 {
54  m_rxMcsMap.resize (8,0);
55  m_txMcsMap.resize (8,0);
56 }
57 
60 {
61  return IE_VHT_CAPABILITIES;
62 }
63 
64 void
65 VhtCapabilities::SetVhtSupported (uint8_t vhtsupported)
66 {
67  m_vhtSupported = vhtsupported;
68 }
69 
70 uint8_t
72 {
73  //we should not be here if ht is not supported
75  return 12;
76 }
77 
80 {
81  if (m_vhtSupported < 1)
82  {
83  return i;
84  }
86 }
87 
88 uint16_t
90 {
91  if (m_vhtSupported < 1)
92  {
93  return 0;
94  }
96 }
97 
98 void
100 {
101  if (m_vhtSupported == 1)
102  {
103  //write the corresponding value for each bit
106  }
107 }
108 
109 uint8_t
111  uint8_t length)
112 {
114  uint16_t vhtinfo = i.ReadLsbtohU32 ();
115  uint64_t mcsset = i.ReadLsbtohU64 ();
116  SetVhtCapabilitiesInfo (vhtinfo);
117  SetSupportedMcsAndNssSet (mcsset);
118  return length;
119 }
120 
121 void
123 {
124  m_maxMpduLength = ctrl & 0x03;
125  m_supportedChannelWidthSet = (ctrl >> 2) & 0x03;
126  m_rxLdpc = (ctrl >> 4) & 0x01;
127  m_shortGuardIntervalFor80Mhz = (ctrl >> 5) & 0x01;
128  m_shortGuardIntervalFor160Mhz = (ctrl >> 6) & 0x01;
129  m_txStbc = (ctrl >> 7) & 0x01;
130  m_rxStbc = (ctrl >> 8) & 0x07;
131  m_suBeamformerCapable = (ctrl >> 11) & 0x01;
132  m_suBeamformeeCapable = (ctrl >> 12) & 0x01;
133  m_beamformeeStsCapable = (ctrl >> 13) & 0x07;
134  m_numberOfSoundingDimensions = (ctrl >> 16) & 0x07;
135  m_muBeamformerCapable = (ctrl >> 19) & 0x01;
136  m_muBeamformeeCapable = (ctrl >> 20) & 0x01;
137  m_vhtTxopPs = (ctrl >> 21) & 0x01;
138  m_htcVhtCapable = (ctrl >> 22) & 0x01;
139  m_maxAmpduLengthExponent = (ctrl >> 23) & 0x07;
140  m_vhtLinkAdaptationCapable = (ctrl >> 26) & 0x03;
141  m_rxAntennaPatternConsistency = (ctrl >> 28) & 0x01;
142  m_txAntennaPatternConsistency = (ctrl >> 29) & 0x01;
143 }
144 
145 uint32_t
147 {
148  uint32_t val = 0;
149  val |= m_maxMpduLength & 0x03;
150  val |= (m_supportedChannelWidthSet & 0x03) << 2;
151  val |= (m_rxLdpc & 0x01) << 4;
152  val |= (m_shortGuardIntervalFor80Mhz & 0x01) << 5;
153  val |= (m_shortGuardIntervalFor160Mhz & 0x01) << 6;
154  val |= (m_txStbc & 0x01) << 7;
155  val |= (m_rxStbc & 0x07) << 8;
156  val |= (m_suBeamformerCapable & 0x01) << 11;
157  val |= (m_suBeamformeeCapable & 0x01) << 12;
158  val |= (m_beamformeeStsCapable & 0x07) << 13;
159  val |= (m_numberOfSoundingDimensions & 0x07) << 16;
160  val |= (m_muBeamformerCapable & 0x01) << 19;
161  val |= (m_muBeamformeeCapable & 0x01) << 20;
162  val |= (m_vhtTxopPs & 0x01) << 21;
163  val |= (m_htcVhtCapable & 0x01) << 22;
164  val |= (m_maxAmpduLengthExponent & 0x07) << 23;
165  val |= (m_vhtLinkAdaptationCapable & 0x03) << 26;
166  val |= (m_rxAntennaPatternConsistency & 0x01) << 28;
167  val |= (m_txAntennaPatternConsistency & 0x01) << 29;
168  return val;
169 }
170 
171 void
173 {
174  uint16_t n;
175  for (uint8_t i = 0; i < 8; i++)
176  {
177  n = i * 2;
178  m_rxMcsMap[i] = (ctrl >> n) & 0x03;
179  }
180  m_rxHighestSupportedLongGuardIntervalDataRate = (ctrl >> 16) & 0x1fff;
181  for (uint8_t i = 0; i < 8; i++)
182  {
183  uint16_t n = (i * 2) + 32;
184  m_txMcsMap[i] = (ctrl >> n) & 0x03;
185  }
186  m_txHighestSupportedLongGuardIntervalDataRate = (ctrl >> 48) & 0x1fff;
187 }
188 
189 uint64_t
191 {
192  uint64_t val = 0;
193  uint16_t n;
194  for (uint8_t i = 0; i < 8; i++)
195  {
196  n = i * 2;
197  val |= ((uint64_t)m_rxMcsMap[i] & 0x03) << n;
198  }
199  val |= ((uint64_t)m_rxHighestSupportedLongGuardIntervalDataRate & 0x1fff) << 16;
200  for (uint8_t i = 0; i < 8; i++)
201  {
202  n = (i * 2) + 32;
203  val |= ((uint64_t)m_txMcsMap[i] & 0x03) << n;
204  }
205  val |= ((uint64_t)m_txHighestSupportedLongGuardIntervalDataRate & 0x1fff) << 48;
206  return val;
207 }
208 
209 void
211 {
212  m_maxMpduLength = length;
213 }
214 
215 void
217 {
218  m_supportedChannelWidthSet = channelwidthset;
219 }
220 
221 void
223 {
224  m_rxLdpc = rxldpc;
225 }
226 
227 void
229 {
230  m_shortGuardIntervalFor80Mhz = shortguardinterval;
231 }
232 
233 void
235 {
236  m_shortGuardIntervalFor160Mhz = shortguardinterval;
237 }
238 
239 void
241 {
242  m_rxStbc = rxstbc;
243 }
244 
245 void
247 {
248  m_txStbc = txstbc;
249 }
250 
251 void
253 {
254  m_maxAmpduLengthExponent = exponent;
255 }
256 
257 void
259 {
260  //Set each element in the map accoriding to the 2 bits representing it page 98 in the 11ac standard
261  uint8_t n;
262  for (uint8_t i = 0; i < 8; i++)
263  {
264  n = i * 2;
265  m_rxMcsMap[i] = (map >> n) & 0x03;
266  }
267 }
268 
269 void
270 VhtCapabilities::SetRxMcsMap (uint8_t mcs, uint8_t nss)
271 {
272  //MCS index should be at least 7 and should not exceed 9
273  NS_ASSERT (mcs >= 7 && mcs <= 9);
274  m_rxMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
275 }
276 
277 void
279 {
280  //Set each element in the map accoriding to the 2 bits representing it page 98 in the 11ac standard
281  uint8_t n;
282  for (uint8_t i = 0; i < 8; i++)
283  {
284  n = i * 2;
285  m_txMcsMap[i] = (map >> n) & 0x03;
286  }
287 }
288 
289 void
290 VhtCapabilities::SetTxMcsMap (uint8_t mcs, uint8_t nss)
291 {
292  //MCS index should be at least 7 and should not exceed 9
293  NS_ASSERT (mcs >= 7 && mcs <= 9);
294  m_txMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
295 }
296 
297 bool
299 {
300  NS_ASSERT (mcs >= 0 && mcs <= 9);
301  if (mcs <= 7)
302  {
303  return true;
304  }
305  if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
306  {
307  return true;
308  }
309  if (mcs == 9 && m_txMcsMap[0] == 2)
310  {
311  return true;
312  }
313  return false;
314 }
315 
316 bool
318 {
319  NS_ASSERT (mcs >= 0 && mcs <= 9);
320  if (mcs <= 7)
321  {
322  return true;
323  }
324  if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
325  {
326  return true;
327  }
328  if (mcs == 9 && m_rxMcsMap[0] == 2)
329  {
330  return true;
331  }
332  return false;
333 }
334 
335 void
337 {
339 }
340 
341 void
343 {
345 }
346 
347 uint8_t
349 {
350  return m_maxMpduLength;
351 }
352 
353 uint8_t
355 {
357 }
358 
359 uint8_t
361 {
362  return m_rxLdpc;
363 }
364 
365 uint8_t
367 {
369 }
370 
371 uint8_t
373 {
375 }
376 
377 uint8_t
379 {
380  return m_rxStbc;
381 }
382 
383 uint8_t
385 {
386  return m_txStbc;
387 }
388 
389 uint8_t
391 {
393 }
394 
395 bool
396 VhtCapabilities::IsSupportedMcs (uint8_t mcs, uint8_t nss) const
397 {
398  //The MCS index starts at 0 and NSS starts at 1
399  if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
400  {
401  return true;
402  }
403  if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
404  {
405  return true;
406  }
407  if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
408  {
409  return true;
410  }
411  return false;
412 }
413 
414 uint16_t
416 {
417  uint16_t val = 0;
418  uint8_t n;
419  for (uint8_t i = 0; i < 8; i++)
420  {
421  n = i * 2;
422  val |= (m_rxMcsMap[i] & 0x03) << n;
423  }
424  return val;
425 }
426 
427 uint16_t
429 {
430  uint16_t val = 0;
431  uint8_t n;
432  for (uint8_t i = 0; i < 8; i++)
433  {
434  n = i * 2;
435  val |= (m_txMcsMap[i] & 0x03) << n;
436  }
437  return val;
438 }
439 
440 uint16_t
442 {
444 }
445 
446 uint16_t
448 {
450 }
451 
453 
454 std::ostream &
456 {
457  os << VhtCapabilities.GetVhtCapabilitiesInfo () << "|" << VhtCapabilities.GetSupportedMcsAndNssSet ();
458 
459  return os;
460 }
461 
462 std::istream &operator >> (std::istream &is,VhtCapabilities &VhtCapabilities)
463 {
464  uint32_t c1;
465  uint64_t c2;
466  is >> c1 >> c2;
467  VhtCapabilities.SetVhtCapabilitiesInfo (c1);
468  VhtCapabilities.SetSupportedMcsAndNssSet (c2);
469 
470  return is;
471 }
472 
473 } //namespace ns3
uint8_t m_numberOfSoundingDimensions
uint32_t GetVhtCapabilitiesInfo() const
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
void SetShortGuardIntervalFor80Mhz(uint8_t shortguardinterval)
bool IsSupportedTxMcs(uint8_t mcs) const
uint8_t m_shortGuardIntervalFor160Mhz
uint16_t GetTxMcsMap() const
uint16_t GetTxHighestSupportedLgiDataRate() const
uint8_t GetSupportedChannelWidthSet() const
void SetTxMcsMap(uint16_t map)
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
void SetMaxMpduLength(uint8_t length)
def start()
Definition: core.py:1482
#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_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
uint16_t m_rxHighestSupportedLongGuardIntervalDataRate
uint8_t GetMaxMpduLength() const
uint8_t GetShortGuardIntervalFor160Mhz() const
void SetVhtSupported(uint8_t vhtsupported)
#define IE_VHT_CAPABILITIES
void SetRxLdpc(uint8_t rxldpc)
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
void SetSupportedMcsAndNssSet(uint64_t ctrl)
Set the MCS and NSS field in the VHT Capabilities information element.
uint8_t GetRxStbc() const
std::vector< uint8_t > m_rxMcsMap
void SetShortGuardIntervalFor160Mhz(uint8_t shortguardinterval)
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
std::vector< uint8_t > m_txMcsMap
The IEEE 802.11ac VHT Capabilities.
uint8_t m_rxAntennaPatternConsistency
void SetTxHighestSupportedLgiDataRate(uint16_t supporteddatarate)
uint16_t GetRxMcsMap() const
void SetSupportedChannelWidthSet(uint8_t channelwidthset)
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
uint8_t m_txAntennaPatternConsistency
uint8_t m_shortGuardIntervalFor80Mhz
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
void SetRxStbc(uint8_t rxstbc)
uint8_t GetMaxAmpduLengthExponent() const
uint8_t GetShortGuardIntervalFor80Mhz() const
Buffer::Iterator Serialize(Buffer::Iterator start) const
uint16_t m_txHighestSupportedLongGuardIntervalDataRate
void SetRxHighestSupportedLgiDataRate(uint16_t supporteddatarate)
void SetRxMcsMap(uint16_t map)
uint16_t GetSerializedSize() const
void WriteHtolsbU64(uint64_t data)
Definition: buffer.cc:926
uint64_t GetSupportedMcsAndNssSet() const
bool IsSupportedRxMcs(uint8_t mcs) const
bool IsSupportedMcs(uint8_t mcs, uint8_t Nss) const
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
WifiInformationElementId ElementId() const
Own unique Element ID.
uint8_t GetTxStbc() const
uint8_t GetRxLdpc() const
uint16_t m_supportedChannelWidthSet
uint64_t ReadLsbtohU64(void)
Definition: buffer.cc:1093
uint16_t GetRxHighestSupportedLgiDataRate() const
void SerializeInformationField(Buffer::Iterator start) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
void SetTxStbc(uint8_t txstbc)
void SetVhtCapabilitiesInfo(uint32_t ctrl)
Set the VHT Capabilties Info field in the VHT Capabilities information element.
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1076
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
void WriteHtolsbU32(uint32_t data)
Definition: buffer.cc:917
void SetMaxAmpduLengthExponent(uint8_t exponent)