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 vht 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  uint32_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  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 |= (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 
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
259 VhtCapabilities::SetRxMcsMap (uint8_t mcs, uint8_t nss)
260 {
261  //MCS index should be at least 7 and should not exceed 9
262  NS_ASSERT (mcs >= 7 && mcs <= 9);
263  m_rxMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
264 }
265 
266 void
267 VhtCapabilities::SetTxMcsMap (uint8_t mcs, uint8_t nss)
268 {
269  //MCS index should be at least 7 and should not exceed 9
270  NS_ASSERT (mcs >= 7 && mcs <= 9);
271  m_txMcsMap[nss - 1] = mcs - 7; //1 = MCS 8; 2 = MCS 9
272 }
273 
274 bool
276 {
277  NS_ASSERT (mcs >= 0 && mcs <= 9);
278  if (mcs <= 7)
279  {
280  return true;
281  }
282  if (mcs == 8 && (m_txMcsMap[0] == 1 || m_txMcsMap[0] == 2))
283  {
284  return true;
285  }
286  if (mcs == 9 && m_txMcsMap[0] == 2)
287  {
288  return true;
289  }
290  return false;
291 }
292 
293 bool
295 {
296  NS_ASSERT (mcs >= 0 && mcs <= 9);
297  if (mcs <= 7)
298  {
299  return true;
300  }
301  if (mcs == 8 && (m_rxMcsMap[0] == 1 || m_rxMcsMap[0] == 2))
302  {
303  return true;
304  }
305  if (mcs == 9 && m_rxMcsMap[0] == 2)
306  {
307  return true;
308  }
309  return false;
310 }
311 
312 void
314 {
316 }
317 
318 void
320 {
322 }
323 
324 uint8_t
326 {
328 }
329 
330 uint8_t
332 {
333  return m_rxLdpc;
334 }
335 
336 uint8_t
338 {
339  return m_rxStbc;
340 }
341 
342 uint8_t
344 {
345  return m_txStbc;
346 }
347 
348 bool
349 VhtCapabilities::IsSupportedMcs (uint8_t mcs, uint8_t nss) const
350 {
351  //The MCS index starts at 0 and NSS starts at 1
352  if (mcs <= 7 && m_rxMcsMap[nss - 1] < 3)
353  {
354  return true;
355  }
356  if (mcs == 8 && m_rxMcsMap[nss - 1] > 0 && m_rxMcsMap[nss - 1] < 3)
357  {
358  return true;
359  }
360  if (mcs == 9 && m_rxMcsMap[nss - 1] == 2)
361  {
362  return true;
363  }
364  return false;
365 }
366 
367 uint16_t
369 {
371 }
372 
381 std::ostream &
383 {
384  os << VhtCapabilities.GetVhtCapabilitiesInfo () << "|" << VhtCapabilities.GetSupportedMcsAndNssSet ();
385 
386  return os;
387 }
388 
389 } //namespace ns3
uint8_t m_numberOfSoundingDimensions
number of sounding dimensions
uint32_t GetVhtCapabilitiesInfo() const
Return the VHT Capabilities Info field in the VHT Capabilities information element.
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
uint8_t GetSupportedChannelWidthSet() const
Get the supported channel width set.
uint8_t m_rxLdpc
receive LDPC
uint8_t m_muBeamformeeCapable
MU beam formee capable.
void SetMaxMpduLength(uint8_t length)
Set the maximum MPDU length.
def start()
Definition: core.py:1806
#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
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.
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.
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
void SetRxMcsMap(uint8_t mcs, uint8_t nss)
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.
uint16_t GetSerializedSize() const
Get the serialized size.
uint8_t m_vhtTxopPs
VHT TXOP PS.
uint8_t m_supportedChannelWidthSet
supported channel width set
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.
uint64_t ReadLsbtohU64(void)
Definition: buffer.cc:1096
uint16_t GetRxHighestSupportedLgiDataRate() const
Get the receive highest supported LGI data rate.
uint8_t m_maxMpduLength
maximum MPDU length
void SerializeInformationField(Buffer::Iterator start) const
Serialize the information field.
uint8_t m_rxStbc
receive STBC
void SetTxMcsMap(uint8_t mcs, uint8_t nss)
void SetTxStbc(uint8_t txstbc)
Set the transmit STBC.
void SetVhtCapabilitiesInfo(uint32_t ctrl)
Set the VHT Capabilities 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.