A Discrete-Event Network Simulator
API
he-operation.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Sébastien Deronne
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
18  */
19 
20 #include "he-operation.h"
21 
22 namespace ns3
23 {
24 
26  : m_bssColor(0),
27  m_defaultPEDuration(0),
28  m_twtRequired(0),
29  m_heDurationBasedRtsThreshold(0),
30  m_partialBssColor(0),
31  m_maxBssidIndicator(0),
32  m_txBssidIndicator(0),
33  m_bssColorDisabled(0),
34  m_dualBeacon(0),
35  m_basicHeMcsAndNssSet(0xfffc)
36 {
37 }
38 
41 {
42  return IE_EXTENSION;
43 }
44 
47 {
48  return IE_EXT_HE_OPERATION;
49 }
50 
51 void
52 HeOperation::Print(std::ostream& os) const
53 {
54  os << "HE Operation=" << GetHeOperationParameters() << "|" << GetBasicHeMcsAndNssSet();
55 }
56 
57 uint16_t
59 {
60  return 7;
61 }
62 
63 void
65 {
66  m_bssColor = ctrl & 0x3f;
67  m_defaultPEDuration = (ctrl >> 6) & 0x07;
68  m_twtRequired = (ctrl >> 9) & 0x01;
69  m_heDurationBasedRtsThreshold = (ctrl >> 10) & 0x03ff;
70  m_partialBssColor = (ctrl >> 20) & 0x01;
71  m_maxBssidIndicator = (ctrl >> 21) & 0xff;
72  m_txBssidIndicator = (ctrl >> 29) & 0x01;
73  m_bssColorDisabled = (ctrl >> 30) & 0x01;
74  m_dualBeacon = (ctrl >> 31) & 0x01;
75 }
76 
77 uint32_t
79 {
80  uint32_t val = 0;
81  val |= m_bssColor & 0x3f;
82  val |= (m_defaultPEDuration & 0x07) << 6;
83  val |= (m_twtRequired & 0x01) << 9;
84  val |= (m_heDurationBasedRtsThreshold & 0x03ff) << 10;
85  val |= (m_partialBssColor & 0x01) << 20;
86  val |= (m_maxBssidIndicator & 0xff) << 21;
87  val |= (m_txBssidIndicator & 0x01) << 29;
88  val |= (m_bssColorDisabled & 0x01) << 30;
89  val |= (m_dualBeacon & 0x01) << 31;
90  return val;
91 }
92 
93 void
94 HeOperation::SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
95 {
96  NS_ASSERT((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
97 
98  // IEEE 802.11ax-2021 9.4.2.248.4 Supported HE-MCS And NSS Set field
99  uint8_t val = 0x03; // not supported
100  if (maxHeMcs > 9) // MCS 0 - 11
101  {
102  val = 0x02;
103  }
104  else if (maxHeMcs > 7) // MCS 0 - 9
105  {
106  val = 0x01;
107  }
108  else if (maxHeMcs == 7) // MCS 0 - 7
109  {
110  val = 0x01;
111  }
112 
113  // clear bits for that nss
114  const uint16_t mask = ~(0x03 << ((nss - 1) * 2));
115  m_basicHeMcsAndNssSet &= mask;
116 
117  // update bits for that nss
118  m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
119 }
120 
121 uint16_t
123 {
124  return m_basicHeMcsAndNssSet;
125 }
126 
127 void
128 HeOperation::SetBssColor(uint8_t bssColor)
129 {
130  NS_ABORT_UNLESS(bssColor < 64); // 6 bits
131  m_bssColor = bssColor;
132  m_bssColorDisabled = 0;
133 }
134 
135 uint8_t
137 {
138  return m_bssColor;
139 }
140 
141 void
143 {
144  // write the corresponding value for each bit
145  start.WriteHtolsbU32(GetHeOperationParameters());
146  start.WriteU16(GetBasicHeMcsAndNssSet());
147  // todo: VHT Operation Information (variable)
148 }
149 
150 uint16_t
152 {
154  uint32_t heOperationParameters = i.ReadLsbtohU32();
156  SetHeOperationParameters(heOperationParameters);
157  // todo: VHT Operation Information (variable)
158  return length;
159 }
160 
161 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint16_t ReadU16()
Definition: buffer.h:1035
uint32_t ReadLsbtohU32()
Definition: buffer.cc:1076
void Print(std::ostream &os) const override
Generate human-readable form of IE.
Definition: he-operation.cc:52
void SetBssColor(uint8_t bssColor)
Set the BSS color.
uint8_t m_dualBeacon
Dual Beacon.
Definition: he-operation.h:97
void SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
Set the Basic HE-MCS and NSS field in the HE Operation information element by specifying the tuple (n...
Definition: he-operation.cc:94
uint8_t m_partialBssColor
partial BSS color
Definition: he-operation.h:93
WifiInformationElementId ElementIdExt() const override
Get the wifi information element ID extension.
Definition: he-operation.cc:46
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)
uint8_t m_maxBssidIndicator
max BSSID indicator
Definition: he-operation.h:94
uint8_t GetBssColor() const
Get the BSS color.
uint8_t m_twtRequired
TWT required.
Definition: he-operation.h:91
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: he-operation.cc:58
uint8_t m_txBssidIndicator
TX BSSID indicator.
Definition: he-operation.h:95
uint8_t m_bssColor
BSS color.
Definition: he-operation.h:89
void SetHeOperationParameters(uint32_t ctrl)
Set the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:64
uint8_t m_defaultPEDuration
default PE duration
Definition: he-operation.h:90
uint16_t m_basicHeMcsAndNssSet
basic HE MCS NSS set
Definition: he-operation.h:100
uint16_t m_heDurationBasedRtsThreshold
HE duration based RTS threshold.
Definition: he-operation.h:92
uint8_t m_bssColorDisabled
BSS color disabled.
Definition: he-operation.h:96
uint16_t GetBasicHeMcsAndNssSet() const
Return the Basic HE-MCS And Nss field in the HE Operation information element.
uint32_t GetHeOperationParameters() const
Return the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:78
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
Definition: he-operation.cc:40
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
#define NS_ABORT_UNLESS(cond)
Abnormal program termination if a condition is false.
Definition: abort.h:129
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
#define IE_EXTENSION
#define IE_EXT_HE_OPERATION