A Discrete-Event Network Simulator
API
ht-operation.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016 S├ębastien Deronne
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 * Author: S├ębastien Deronne <sebastien.deronne@gmail.com>
19 */
20
21#include "ht-operation.h"
22
23namespace ns3 {
24
26 : m_primaryChannel (0),
27 m_secondaryChannelOffset (0),
28 m_staChannelWidth (0),
29 m_rifsMode (0),
30 m_reservedInformationSubset1 (0),
31 m_htProtection (0),
32 m_nonGfHtStasPresent (1),
33 m_reservedInformationSubset2_1 (0),
34 m_obssNonHtStasPresent (0),
35 m_reservedInformationSubset2_2 (0),
36 m_reservedInformationSubset3_1 (0),
37 m_dualBeacon (0),
38 m_dualCtsProtection (0),
39 m_stbcBeacon (0),
40 m_lSigTxopProtectionFullSupport (0),
41 m_pcoActive (0),
42 m_pcoPhase (0),
43 m_reservedInformationSubset3_2 (0),
44 m_reservedMcsSet1 (0),
45 m_rxHighestSupportedDataRate (0),
46 m_reservedMcsSet2 (0),
47 m_txMcsSetDefined (0),
48 m_txRxMcsSetUnequal (0),
49 m_txMaxNSpatialStreams (0),
50 m_txUnequalModulation (0),
51 m_reservedMcsSet3 (0)
52{
53 for (uint8_t k = 0; k < MAX_SUPPORTED_MCS; k++)
54 {
55 m_rxMcsBitmask[k] = 0;
56 }
57}
58
61{
62 return IE_HT_OPERATION;
63}
64
65uint16_t
67{
68 return 22;
69}
70
71void
73{
74 m_primaryChannel = ctrl;
75}
76
77void
78HtOperation::SetSecondaryChannelOffset (uint8_t secondaryChannelOffset)
79{
80 m_secondaryChannelOffset = secondaryChannelOffset;
81}
82
83void
84HtOperation::SetStaChannelWidth (uint8_t staChannelWidth)
85{
86 m_staChannelWidth = staChannelWidth;
87}
88
89void
90HtOperation::SetRifsMode (uint8_t rifsMode)
91{
92 m_rifsMode = rifsMode;
93}
94
95void
96HtOperation::SetHtProtection (uint8_t htProtection)
97{
98 m_htProtection = htProtection;
99}
100
101void
102HtOperation::SetNonGfHtStasPresent (uint8_t nonGfHtStasPresent)
103{
104 m_nonGfHtStasPresent = nonGfHtStasPresent;
105}
106
107void
108HtOperation::SetObssNonHtStasPresent (uint8_t obssNonHtStasPresent)
109{
110 m_obssNonHtStasPresent = obssNonHtStasPresent;
111}
112
113void
114HtOperation::SetDualBeacon (uint8_t dualBeacon)
115{
116 m_dualBeacon = dualBeacon;
117}
118
119void
120HtOperation::SetDualCtsProtection (uint8_t dualCtsProtection)
121{
122 m_dualCtsProtection = dualCtsProtection;
123}
124
125void
126HtOperation::SetStbcBeacon (uint8_t stbcBeacon)
127{
128 m_stbcBeacon = stbcBeacon;
129}
130
131void
132HtOperation::SetLSigTxopProtectionFullSupport (uint8_t lSigTxopProtectionFullSupport)
133{
134 m_lSigTxopProtectionFullSupport = lSigTxopProtectionFullSupport;
135}
136
137void
138HtOperation::SetPcoActive (uint8_t pcoActive)
139{
140 m_pcoActive = pcoActive;
141}
142
143void
144HtOperation::SetPhase (uint8_t pcoPhase)
145{
146 m_pcoPhase = pcoPhase;
147}
148
149void
151{
152 m_rxMcsBitmask[index] = 1;
153}
154
155void
157{
158 m_rxHighestSupportedDataRate = maxSupportedRate;
159}
160
161void
162HtOperation::SetTxMcsSetDefined (uint8_t txMcsSetDefined)
163{
164 m_txMcsSetDefined = txMcsSetDefined;
165}
166
167void
168HtOperation::SetTxRxMcsSetUnequal (uint8_t txRxMcsSetUnequal)
169{
170 m_txRxMcsSetUnequal = txRxMcsSetUnequal;
171}
172
173void
174HtOperation::SetTxMaxNSpatialStreams (uint8_t maxTxSpatialStreams)
175{
176 m_txMaxNSpatialStreams = maxTxSpatialStreams - 1; //0 for 1 SS, 1 for 2 SSs, etc
177}
178
179void
180HtOperation::SetTxUnequalModulation (uint8_t txUnequalModulation)
181{
182 m_txUnequalModulation = txUnequalModulation;
183}
184
185uint8_t
187{
188 return m_primaryChannel;
189}
190
191uint8_t
193{
195}
196
197uint8_t
199{
200 return m_staChannelWidth;
201}
202
203uint8_t
205{
206 return m_rifsMode;
207}
208
209uint8_t
211{
212 return m_htProtection;
213}
214
215uint8_t
217{
219}
220
221uint8_t
223{
225}
226
227uint8_t
229{
230 return m_dualBeacon;
231}
232
233uint8_t
235{
236 return m_dualCtsProtection;
237}
238
239uint8_t
241{
242 return m_stbcBeacon;
243}
244
245uint8_t
247{
249}
250
251uint8_t
253{
254 return m_pcoActive;
255}
256
257uint8_t
259{
260 return m_pcoPhase;
261}
262
263bool
265{
266 if (m_rxMcsBitmask[mcs] == 1)
267 {
268 return true;
269 }
270 return false;
271}
272
273uint16_t
275{
277}
278
279uint8_t
281{
282 return m_txMcsSetDefined;
283}
284
285uint8_t
287{
288 return m_txRxMcsSetUnequal;
289}
290
291uint8_t
293{
295}
296
297uint8_t
299{
301}
302
303uint8_t
305{
306 uint8_t val = 0;
307 val |= m_secondaryChannelOffset & 0x03;
308 val |= (m_staChannelWidth & 0x01) << 2;
309 val |= (m_rifsMode & 0x01) << 3;
310 val |= (m_reservedInformationSubset1 & 0x0f) << 4;
311 return val;
312}
313
314void
316{
317 m_secondaryChannelOffset = ctrl & 0x03;
318 m_staChannelWidth = (ctrl >> 2) & 0x01;
319 m_rifsMode = (ctrl >> 3) & 0x01;
320 m_reservedInformationSubset1 = (ctrl >> 4) & 0x0f;
321}
322
323uint16_t
325{
326 uint16_t val = 0;
327 val |= m_htProtection & 0x03;
328 val |= (m_nonGfHtStasPresent & 0x01) << 2;
329 val |= (m_reservedInformationSubset2_1 & 0x01) << 3;
330 val |= (m_obssNonHtStasPresent & 0x01) << 4;
331 val |= (m_reservedInformationSubset2_2 & 0x07ff) << 5;
332 return val;
333}
334
335void
337{
338 m_htProtection = ctrl & 0x03;
339 m_nonGfHtStasPresent = (ctrl >> 2) & 0x01;
340 m_reservedInformationSubset2_1 = (ctrl >> 3) & 0x01;
341 m_obssNonHtStasPresent = (ctrl >> 4) & 0x01;
342 m_reservedInformationSubset2_2 = static_cast<uint8_t> ((ctrl >> 5) & 0x07ff);
343}
344
345uint16_t
347{
348 uint16_t val = 0;
349 val |= m_reservedInformationSubset3_1 & 0x3f;
350 val |= (m_dualBeacon & 0x01) << 6;
351 val |= (m_dualCtsProtection & 0x01) << 7;
352 val |= (m_stbcBeacon & 0x01) << 8;
353 val |= (m_lSigTxopProtectionFullSupport & 0x01) << 9;
354 val |= (m_pcoActive & 0x01) << 10;
355 val |= (m_pcoPhase & 0x01) << 11;
356 val |= (m_reservedInformationSubset3_2 & 0x0f) << 12;
357 return val;
358}
359
360void
362{
363 m_reservedInformationSubset3_1 = ctrl & 0x3f;
364 m_dualBeacon = (ctrl >> 6) & 0x01;
365 m_dualCtsProtection = (ctrl >> 7) & 0x01;
366 m_stbcBeacon = (ctrl >> 8) & 0x01;
367 m_lSigTxopProtectionFullSupport = (ctrl >> 9) & 0x01;
368 m_pcoActive = (ctrl >> 10) & 0x01;
369 m_pcoPhase = (ctrl >> 11) & 0x01;
370 m_reservedInformationSubset3_2 = (ctrl >> 12) & 0x0f;
371}
372
373void
374HtOperation::SetBasicMcsSet (uint64_t ctrl1, uint64_t ctrl2)
375{
376 for (uint64_t i = 0; i < 77; i++)
377 {
378 if (i < 64)
379 {
380 m_rxMcsBitmask[i] = (ctrl1 >> i) & 0x01;
381 }
382 else
383 {
384 m_rxMcsBitmask[i] = (ctrl2 >> (i - 64)) & 0x01;
385 }
386 }
387 m_reservedMcsSet1 = (ctrl2 >> 13) & 0x07;
388 m_rxHighestSupportedDataRate = (ctrl2 >> 16) & 0x03ff;
389 m_reservedMcsSet2 = (ctrl2 >> 26) & 0x3f;
390 m_txMcsSetDefined = (ctrl2 >> 32) & 0x01;
391 m_txRxMcsSetUnequal = (ctrl2 >> 33) & 0x01;
392 m_txMaxNSpatialStreams = (ctrl2 >> 34) & 0x03;
393 m_txUnequalModulation = (ctrl2 >> 36) & 0x01;
394 m_reservedMcsSet3 = (ctrl2 >> 37) & 0x07ffffff;
395}
396
397uint64_t
399{
400 uint64_t val = 0;
401 for (uint64_t i = 63; i > 0; i--)
402 {
403 val = (val << 1) | (m_rxMcsBitmask[i] & 0x01);
404 }
405 val = (val << 1) | (m_rxMcsBitmask[0] & 0x01);
406 return val;
407}
408
409uint64_t
411{
412 uint64_t val = 0;
413 val = val | (m_reservedMcsSet3 & 0x07ffffff);
414 val = (val << 1) | (m_txUnequalModulation & 0x01);
415 val = (val << 2) | (m_txMaxNSpatialStreams & 0x03);
416 val = (val << 1) | (m_txRxMcsSetUnequal & 0x01);
417 val = (val << 1) | (m_txMcsSetDefined & 0x01);
418 val = (val << 6) | (m_reservedMcsSet2 & 0x3f);
419 val = (val << 10) | (m_rxHighestSupportedDataRate & 0x3ff);
420 val = (val << 3) | (m_reservedMcsSet1 & 0x07);
421
422 for (uint64_t i = 13; i > 0; i--)
423 {
424 val = (val << 1) | ( m_rxMcsBitmask[i + 63] & 0x01);
425 }
426 return val;
427}
428
429void
431{
432 //write the corresponding value for each bit
433 start.WriteU8 (GetPrimaryChannel ());
434 start.WriteU8 (GetInformationSubset1 ());
435 start.WriteU16 (GetInformationSubset2 ());
436 start.WriteU16 (GetInformationSubset3 ());
437 start.WriteHtolsbU64 (GetBasicMcsSet1 ());
438 start.WriteHtolsbU64 (GetBasicMcsSet2 ());
439}
440
441uint16_t
443 uint16_t length)
444{
446 uint8_t primarychannel = i.ReadU8 ();
447 uint8_t informationsubset1 = i.ReadU8 ();
448 uint16_t informationsubset2 = i.ReadU16 ();
449 uint16_t informationsubset3 = i.ReadU16 ();
450 uint64_t mcsset1 = i.ReadLsbtohU64 ();
451 uint64_t mcsset2 = i.ReadLsbtohU64 ();
452 SetPrimaryChannel (primarychannel);
453 SetInformationSubset1 (informationsubset1);
454 SetInformationSubset2 (informationsubset2);
455 SetInformationSubset3 (informationsubset3);
456 SetBasicMcsSet (mcsset1, mcsset2);
457 return length;
458}
459
460std::ostream &
461operator << (std::ostream &os, const HtOperation &htOperation)
462{
463 os << bool (htOperation.GetPrimaryChannel ())
464 << "|" << +htOperation.GetSecondaryChannelOffset ()
465 << "|" << bool (htOperation.GetStaChannelWidth ())
466 << "|" << bool (htOperation.GetRifsMode ())
467 << "|" << +htOperation.GetHtProtection ()
468 << "|" << bool (htOperation.GetNonGfHtStasPresent ())
469 << "|" << bool (htOperation.GetObssNonHtStasPresent ())
470 << "|" << bool (htOperation.GetDualBeacon ())
471 << "|" << bool (htOperation.GetDualCtsProtection ())
472 << "|" << bool (htOperation.GetStbcBeacon ())
473 << "|" << bool (htOperation.GetLSigTxopProtectionFullSupport ())
474 << "|" << bool (htOperation.GetPcoActive ())
475 << "|" << bool (htOperation.GetPhase ())
476 << "|" << htOperation.GetRxHighestSupportedDataRate ()
477 << "|" << bool (htOperation.GetTxMcsSetDefined ())
478 << "|" << bool (htOperation.GetTxRxMcsSetUnequal ())
479 << "|" << +htOperation.GetTxMaxNSpatialStreams ()
480 << "|" << bool (htOperation.GetTxUnequalModulation ()) << "|";
481 for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
482 {
483 os << htOperation.IsSupportedMcs (i) << " ";
484 }
485 return os;
486}
487
488} //namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint64_t ReadLsbtohU64(void)
Definition: buffer.cc:1094
The HT Operation Information Element.
Definition: ht-operation.h:51
void SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
Set the OBSS non HT STAs present.
uint8_t m_reservedInformationSubset1
reserved information subset 1
Definition: ht-operation.h:366
void SetRifsMode(uint8_t rifsMode)
Set the RIFS mode.
Definition: ht-operation.cc:90
uint8_t m_obssNonHtStasPresent
OBSS NON HT STAs present.
Definition: ht-operation.h:372
void SetBasicMcsSet(uint64_t ctrl1, uint64_t ctrl2)
Set the Basic MCS Set field in the HT Operation information element.
void SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
Set the secondary channel offset.
Definition: ht-operation.cc:78
uint8_t m_reservedInformationSubset3_1
reserved information subset 3-1
Definition: ht-operation.h:376
uint8_t m_stbcBeacon
STBC beacon.
Definition: ht-operation.h:379
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)
uint64_t GetBasicMcsSet1(void) const
Return the first 64 bytes of the Basic MCS Set field in the HT Operation information element.
void SetInformationSubset2(uint16_t ctrl)
Set the Information Subset 2 field in the HT Operation information element.
uint8_t GetTxMaxNSpatialStreams(void) const
Return transmit maximum number spatial streams.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Definition: ht-operation.cc:66
uint8_t m_reservedInformationSubset3_2
reserved information subset 3-2
Definition: ht-operation.h:383
void SetPcoActive(uint8_t pcoActive)
Set the PCO active.
void SetTxUnequalModulation(uint8_t txUnequalModulation)
Set the transmit unequal modulation.
uint8_t m_rifsMode
RIFS mode.
Definition: ht-operation.h:365
uint8_t m_secondaryChannelOffset
secondary channel offset
Definition: ht-operation.h:363
uint8_t m_rxMcsBitmask[MAX_SUPPORTED_MCS]
receive MCS bitmask
Definition: ht-operation.h:394
uint16_t m_rxHighestSupportedDataRate
receive highest supported data rate
Definition: ht-operation.h:387
void SetInformationSubset3(uint16_t ctrl)
Set the Information Subset 3 field in the HT Operation information element.
uint64_t GetBasicMcsSet2(void) const
Return the last 64 bytes of the Basic MCS Set field in the HT Operation information element.
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
Definition: ht-operation.cc:96
uint8_t GetLSigTxopProtectionFullSupport(void) const
Return LSIG TXOP protection full support.
uint8_t GetTxRxMcsSetUnequal(void) const
Return transmit / receive MCS set unequal.
uint8_t m_staChannelWidth
STA channel width.
Definition: ht-operation.h:364
uint8_t GetNonGfHtStasPresent(void) const
Return the non GF HT STAs present.
uint8_t GetStbcBeacon(void) const
Return STBC beacon.
void SetTxMaxNSpatialStreams(uint8_t maxTxSpatialStreams)
Set the transmit maximum number spatial streams.
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint8_t m_txUnequalModulation
transmit unequal modulation
Definition: ht-operation.h:392
uint8_t GetPhase(void) const
Return phase.
void SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
Set the transmit / receive MCS set unequal.
uint8_t m_reservedMcsSet1
reserved MCS set 1
Definition: ht-operation.h:386
uint8_t GetDualBeacon(void) const
Return dual beacon.
uint8_t m_txMaxNSpatialStreams
transmit maximum number spatial streams
Definition: ht-operation.h:391
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
Definition: ht-operation.cc:60
uint16_t GetInformationSubset3(void) const
Return the Information Subset 3 field in the HT Operation information element.
uint8_t m_reservedInformationSubset2_1
reserved information subset 2-1
Definition: ht-operation.h:371
uint8_t GetTxUnequalModulation(void) const
Return transmit unequal modulation.
void SetDualBeacon(uint8_t dualBeacon)
Set the dual beacon.
uint8_t GetDualCtsProtection(void) const
Return dual CTS protection.
uint8_t m_dualBeacon
dual beacon
Definition: ht-operation.h:377
uint8_t m_txMcsSetDefined
transmit MCS set defined
Definition: ht-operation.h:389
void SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
Set the non GF HT STAs present.
uint8_t GetSecondaryChannelOffset(void) const
Return the secondary channel offset.
uint8_t m_dualCtsProtection
dual CTS protection
Definition: ht-operation.h:378
uint8_t m_lSigTxopProtectionFullSupport
L-SIG TXOP protection full support.
Definition: ht-operation.h:380
uint8_t GetPcoActive(void) const
Return PCO active.
uint8_t GetTxMcsSetDefined(void) const
Return transmit MCS set defined.
void SetTxMcsSetDefined(uint8_t txMcsSetDefined)
Set the transmit MCS set defined.
uint8_t m_reservedInformationSubset2_2
reserved information subset 2-2
Definition: ht-operation.h:373
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
uint8_t m_reservedMcsSet2
reserved MCS set2
Definition: ht-operation.h:388
uint8_t GetObssNonHtStasPresent(void) const
Return the OBSS non HT STAs present.
void SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
Set the LSIG TXOP protection full support.
void SetStaChannelWidth(uint8_t staChannelWidth)
Set the STA channel width.
Definition: ht-operation.cc:84
uint8_t GetRifsMode(void) const
Return the RIFS mode.
void SetInformationSubset1(uint8_t ctrl)
Set the Information Subset 1 field in the HT Operation information element.
void SetRxHighestSupportedDataRate(uint16_t maxSupportedRate)
Set the receive highest supported data rate.
uint8_t m_pcoActive
PCO active.
Definition: ht-operation.h:381
uint8_t GetPrimaryChannel(void) const
Return the Primary Channel field in the HT Operation information element.
uint8_t GetHtProtection(void) const
Return the HT protection.
void SetRxMcsBitmask(uint8_t index)
Set the receive MCS bitmask.
uint16_t GetRxHighestSupportedDataRate(void) const
Return receive highest supported data rate.
uint32_t m_reservedMcsSet3
reserved MCS set 3
Definition: ht-operation.h:393
uint8_t GetInformationSubset1(void) const
Return the Information Subset 1 field in the HT Operation information element.
void SetPrimaryChannel(uint8_t ctrl)
Set the Primary Channel field in the HT Operation information element.
Definition: ht-operation.cc:72
void SetDualCtsProtection(uint8_t dualCtsProtection)
Set the dual CTS protection.
uint16_t GetInformationSubset2(void) const
Return the Information Subset 2 field in the HT Operation information element.
uint8_t m_htProtection
HT protection.
Definition: ht-operation.h:369
void SetPhase(uint8_t pcoPhase)
Set the PCO phase.
bool IsSupportedMcs(uint8_t mcs) const
Return MCS is supported.
uint8_t m_txRxMcsSetUnequal
transmit / receive MCS set unequal
Definition: ht-operation.h:390
uint8_t m_pcoPhase
PCO phase.
Definition: ht-operation.h:382
uint8_t m_primaryChannel
primary channel
Definition: ht-operation.h:360
void SetStbcBeacon(uint8_t stbcBeacon)
Set the STBC beacon.
uint8_t m_nonGfHtStasPresent
non GF HT STAs present
Definition: ht-operation.h:370
#define MAX_SUPPORTED_MCS
This defines the maximum number of supported MCSs that a STA is allowed to have.
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:1852
#define IE_HT_OPERATION