A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
22namespace 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{
49}
50
51uint16_t
53{
54 return 7;
55}
56
57void
59{
60 m_bssColor = ctrl & 0x3f;
61 m_defaultPEDuration = (ctrl >> 6) & 0x07;
62 m_twtRequired = (ctrl >> 9) & 0x01;
63 m_heDurationBasedRtsThreshold = (ctrl >> 10) & 0x03ff;
64 m_partialBssColor = (ctrl >> 20) & 0x01;
65 m_maxBssidIndicator = (ctrl >> 21) & 0xff;
66 m_txBssidIndicator = (ctrl >> 29) & 0x01;
67 m_bssColorDisabled = (ctrl >> 30) & 0x01;
68 m_dualBeacon = (ctrl >> 31) & 0x01;
69}
70
73{
74 uint32_t val = 0;
75 val |= m_bssColor & 0x3f;
76 val |= (m_defaultPEDuration & 0x07) << 6;
77 val |= (m_twtRequired & 0x01) << 9;
78 val |= (m_heDurationBasedRtsThreshold & 0x03ff) << 10;
79 val |= (m_partialBssColor & 0x01) << 20;
80 val |= (m_maxBssidIndicator & 0xff) << 21;
81 val |= (m_txBssidIndicator & 0x01) << 29;
82 val |= (m_bssColorDisabled & 0x01) << 30;
83 val |= (m_dualBeacon & 0x01) << 31;
84 return val;
85}
86
87void
88HeOperation::SetMaxHeMcsPerNss(uint8_t nss, uint8_t maxHeMcs)
89{
90 NS_ASSERT((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
91
92 // IEEE 802.11ax-2021 9.4.2.248.4 Supported HE-MCS And NSS Set field
93 uint8_t val = 0x03; // not supported
94 if (maxHeMcs > 9) // MCS 0 - 11
95 {
96 val = 0x02;
97 }
98 else if (maxHeMcs > 7) // MCS 0 - 9
99 {
100 val = 0x01;
101 }
102 else if (maxHeMcs == 7) // MCS 0 - 7
103 {
104 val = 0x01;
105 }
106
107 // clear bits for that nss
108 const uint16_t mask = ~(0x03 << ((nss - 1) * 2));
109 m_basicHeMcsAndNssSet &= mask;
110
111 // update bits for that nss
112 m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
113}
114
115uint16_t
117{
119}
120
121void
123{
124 NS_ABORT_UNLESS(bssColor < 64); // 6 bits
125 m_bssColor = bssColor;
127}
128
129uint8_t
131{
132 return m_bssColor;
133}
134
135void
137{
138 // write the corresponding value for each bit
139 start.WriteHtolsbU32(GetHeOperationParameters());
140 start.WriteU16(GetBasicHeMcsAndNssSet());
141 // todo: VHT Operation Information (variable)
142}
143
144uint16_t
146{
147 Buffer::Iterator i = start;
148 uint32_t heOperationParameters = i.ReadLsbtohU32();
150 SetHeOperationParameters(heOperationParameters);
151 // todo: VHT Operation Information (variable)
152 return length;
153}
154
155std::ostream&
156operator<<(std::ostream& os, const HeOperation& HeOperation)
157{
159 return os;
160}
161
162} // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint16_t ReadU16()
Definition: buffer.h:1035
uint32_t ReadLsbtohU32()
Definition: buffer.cc:1079
The HE Operation Information Element.
Definition: he-operation.h:36
void SetBssColor(uint8_t bssColor)
Set the BSS color.
uint8_t m_dualBeacon
Dual Beacon.
Definition: he-operation.h:96
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:88
uint8_t m_partialBssColor
partial BSS color
Definition: he-operation.h:92
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:93
uint8_t GetBssColor() const
Get the BSS color.
uint8_t m_twtRequired
TWT required.
Definition: he-operation.h:90
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:52
uint8_t m_txBssidIndicator
TX BSSID indicator.
Definition: he-operation.h:94
uint8_t m_bssColor
BSS color.
Definition: he-operation.h:88
void SetHeOperationParameters(uint32_t ctrl)
Set the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:58
uint8_t m_defaultPEDuration
default PE duration
Definition: he-operation.h:89
uint16_t m_basicHeMcsAndNssSet
basic HE MCS NSS set
Definition: he-operation.h:99
uint16_t m_heDurationBasedRtsThreshold
HE duration based RTS threshold.
Definition: he-operation.h:91
uint8_t m_bssColorDisabled
BSS color disabled.
Definition: he-operation.h:95
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:72
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.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
#define IE_EXTENSION
#define IE_EXT_HE_OPERATION