A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ht-operation.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2016 Sébastien Deronne
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#include "ht-operation.h"
10
11namespace ns3
12{
13
15 : m_primaryChannel(0),
16 m_secondaryChannelOffset(0),
17 m_staChannelWidth(0),
18 m_rifsMode(0),
19 m_reservedInformationSubset1(0),
20 m_htProtection(0),
21 m_nonGfHtStasPresent(1),
22 m_reservedInformationSubset2_1(0),
23 m_obssNonHtStasPresent(0),
24 m_reservedInformationSubset2_2(0),
25 m_reservedInformationSubset3_1(0),
26 m_dualBeacon(0),
27 m_dualCtsProtection(0),
28 m_stbcBeacon(0),
29 m_lSigTxopProtectionFullSupport(0),
30 m_pcoActive(0),
31 m_pcoPhase(0),
32 m_reservedInformationSubset3_2(0),
33 m_reservedMcsSet1(0),
34 m_rxHighestSupportedDataRate(0),
35 m_reservedMcsSet2(0),
36 m_txMcsSetDefined(0),
37 m_txRxMcsSetUnequal(0),
38 m_txMaxNSpatialStreams(0),
39 m_txUnequalModulation(0),
40 m_reservedMcsSet3(0)
41{
42 for (uint8_t k = 0; k < MAX_SUPPORTED_MCS; k++)
43 {
44 m_rxMcsBitmask[k] = 0;
45 }
46}
47
50{
51 return IE_HT_OPERATION;
52}
53
54void
55HtOperation::Print(std::ostream& os) const
56{
57 os << "HT Operation=[Primary Channel: " << +m_primaryChannel
58 << ", Secondary Channel Offset: " << +m_secondaryChannelOffset
59 << ", STA Channel Width: " << +m_staChannelWidth << ", HT Protection: " << +m_htProtection
60 << ", OBSS NON HT STAs Present: " << +m_obssNonHtStasPresent
61 << ", L-SIG TXOP Protection Full Support: " << +m_lSigTxopProtectionFullSupport
62 << ", RX Highest Supported Data Rate: " << m_rxHighestSupportedDataRate << ", MCS Set: {";
63 for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
64 {
65 if (IsSupportedMcs(i))
66 {
67 os << +i << " ";
68 }
69 }
70 os << "}]";
71}
72
73uint16_t
75{
76 return 22;
77}
78
79void
81{
82 m_primaryChannel = ctrl;
83}
84
85void
86HtOperation::SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
87{
88 m_secondaryChannelOffset = secondaryChannelOffset;
89}
90
91void
92HtOperation::SetStaChannelWidth(uint8_t staChannelWidth)
93{
94 m_staChannelWidth = staChannelWidth;
95}
96
97void
98HtOperation::SetRifsMode(uint8_t rifsMode)
99{
100 m_rifsMode = rifsMode;
101}
102
103void
104HtOperation::SetHtProtection(uint8_t htProtection)
105{
106 m_htProtection = htProtection;
107}
108
109void
110HtOperation::SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
111{
112 m_nonGfHtStasPresent = nonGfHtStasPresent;
113}
114
115void
116HtOperation::SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
117{
118 m_obssNonHtStasPresent = obssNonHtStasPresent;
119}
120
121void
122HtOperation::SetDualBeacon(uint8_t dualBeacon)
123{
124 m_dualBeacon = dualBeacon;
125}
126
127void
128HtOperation::SetDualCtsProtection(uint8_t dualCtsProtection)
129{
130 m_dualCtsProtection = dualCtsProtection;
131}
132
133void
134HtOperation::SetStbcBeacon(uint8_t stbcBeacon)
135{
136 m_stbcBeacon = stbcBeacon;
137}
138
139void
140HtOperation::SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
141{
142 m_lSigTxopProtectionFullSupport = lSigTxopProtectionFullSupport;
143}
144
145void
147{
148 m_pcoActive = pcoActive;
149}
150
151void
152HtOperation::SetPhase(uint8_t pcoPhase)
153{
154 m_pcoPhase = pcoPhase;
155}
156
157void
159{
160 m_rxMcsBitmask[index] = 1;
161}
162
163void
165{
166 m_rxHighestSupportedDataRate = maxSupportedRate;
167}
168
169void
170HtOperation::SetTxMcsSetDefined(uint8_t txMcsSetDefined)
171{
172 m_txMcsSetDefined = txMcsSetDefined;
173}
174
175void
176HtOperation::SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
177{
178 m_txRxMcsSetUnequal = txRxMcsSetUnequal;
179}
180
181void
182HtOperation::SetTxMaxNSpatialStreams(uint8_t maxTxSpatialStreams)
183{
184 m_txMaxNSpatialStreams = maxTxSpatialStreams - 1; // 0 for 1 SS, 1 for 2 SSs, etc
185}
186
187void
188HtOperation::SetTxUnequalModulation(uint8_t txUnequalModulation)
189{
190 m_txUnequalModulation = txUnequalModulation;
191}
192
193uint8_t
198
199uint8_t
204
205uint8_t
210
211uint8_t
213{
214 return m_rifsMode;
215}
216
217uint8_t
219{
220 return m_htProtection;
221}
222
223uint8_t
228
229uint8_t
234
235uint8_t
237{
238 return m_dualBeacon;
239}
240
241uint8_t
246
247uint8_t
249{
250 return m_stbcBeacon;
251}
252
253uint8_t
258
259uint8_t
261{
262 return m_pcoActive;
263}
264
265uint8_t
267{
268 return m_pcoPhase;
269}
270
271bool
273{
274 return m_rxMcsBitmask[mcs] == 1;
275}
276
277uint16_t
282
283uint8_t
288
289uint8_t
294
295uint8_t
300
301uint8_t
306
307uint8_t
309{
310 uint8_t val = 0;
311 val |= m_secondaryChannelOffset & 0x03;
312 val |= (m_staChannelWidth & 0x01) << 2;
313 val |= (m_rifsMode & 0x01) << 3;
314 val |= (m_reservedInformationSubset1 & 0x0f) << 4;
315 return val;
316}
317
318void
320{
321 m_secondaryChannelOffset = ctrl & 0x03;
322 m_staChannelWidth = (ctrl >> 2) & 0x01;
323 m_rifsMode = (ctrl >> 3) & 0x01;
324 m_reservedInformationSubset1 = (ctrl >> 4) & 0x0f;
325}
326
327uint16_t
329{
330 uint16_t val = 0;
331 val |= m_htProtection & 0x03;
332 val |= (m_nonGfHtStasPresent & 0x01) << 2;
333 val |= (m_reservedInformationSubset2_1 & 0x01) << 3;
334 val |= (m_obssNonHtStasPresent & 0x01) << 4;
335 val |= (m_reservedInformationSubset2_2 & 0x07ff) << 5;
336 return val;
337}
338
339void
341{
342 m_htProtection = ctrl & 0x03;
343 m_nonGfHtStasPresent = (ctrl >> 2) & 0x01;
344 m_reservedInformationSubset2_1 = (ctrl >> 3) & 0x01;
345 m_obssNonHtStasPresent = (ctrl >> 4) & 0x01;
346 m_reservedInformationSubset2_2 = static_cast<uint8_t>((ctrl >> 5) & 0x07ff);
347}
348
349uint16_t
351{
352 uint16_t val = 0;
353 val |= m_reservedInformationSubset3_1 & 0x3f;
354 val |= (m_dualBeacon & 0x01) << 6;
355 val |= (m_dualCtsProtection & 0x01) << 7;
356 val |= (m_stbcBeacon & 0x01) << 8;
357 val |= (m_lSigTxopProtectionFullSupport & 0x01) << 9;
358 val |= (m_pcoActive & 0x01) << 10;
359 val |= (m_pcoPhase & 0x01) << 11;
360 val |= (m_reservedInformationSubset3_2 & 0x0f) << 12;
361 return val;
362}
363
364void
366{
367 m_reservedInformationSubset3_1 = ctrl & 0x3f;
368 m_dualBeacon = (ctrl >> 6) & 0x01;
369 m_dualCtsProtection = (ctrl >> 7) & 0x01;
370 m_stbcBeacon = (ctrl >> 8) & 0x01;
371 m_lSigTxopProtectionFullSupport = (ctrl >> 9) & 0x01;
372 m_pcoActive = (ctrl >> 10) & 0x01;
373 m_pcoPhase = (ctrl >> 11) & 0x01;
374 m_reservedInformationSubset3_2 = (ctrl >> 12) & 0x0f;
375}
376
377void
378HtOperation::SetBasicMcsSet(uint64_t ctrl1, uint64_t ctrl2)
379{
380 for (uint64_t i = 0; i < 77; i++)
381 {
382 if (i < 64)
383 {
384 m_rxMcsBitmask[i] = (ctrl1 >> i) & 0x01;
385 }
386 else
387 {
388 m_rxMcsBitmask[i] = (ctrl2 >> (i - 64)) & 0x01;
389 }
390 }
391 m_reservedMcsSet1 = (ctrl2 >> 13) & 0x07;
392 m_rxHighestSupportedDataRate = (ctrl2 >> 16) & 0x03ff;
393 m_reservedMcsSet2 = (ctrl2 >> 26) & 0x3f;
394 m_txMcsSetDefined = (ctrl2 >> 32) & 0x01;
395 m_txRxMcsSetUnequal = (ctrl2 >> 33) & 0x01;
396 m_txMaxNSpatialStreams = (ctrl2 >> 34) & 0x03;
397 m_txUnequalModulation = (ctrl2 >> 36) & 0x01;
398 m_reservedMcsSet3 = (ctrl2 >> 37) & 0x07ffffff;
399}
400
401uint64_t
403{
404 uint64_t val = 0;
405 for (uint64_t i = 63; i > 0; i--)
406 {
407 val = (val << 1) | (m_rxMcsBitmask[i] & 0x01);
408 }
409 val = (val << 1) | (m_rxMcsBitmask[0] & 0x01);
410 return val;
411}
412
413uint64_t
415{
416 uint64_t val = 0;
417 val = val | (m_reservedMcsSet3 & 0x07ffffff);
418 val = (val << 1) | (m_txUnequalModulation & 0x01);
419 val = (val << 2) | (m_txMaxNSpatialStreams & 0x03);
420 val = (val << 1) | (m_txRxMcsSetUnequal & 0x01);
421 val = (val << 1) | (m_txMcsSetDefined & 0x01);
422 val = (val << 6) | (m_reservedMcsSet2 & 0x3f);
423 val = (val << 10) | (m_rxHighestSupportedDataRate & 0x3ff);
424 val = (val << 3) | (m_reservedMcsSet1 & 0x07);
425
426 for (uint64_t i = 13; i > 0; i--)
427 {
428 val = (val << 1) | (m_rxMcsBitmask[i + 63] & 0x01);
429 }
430 return val;
431}
432
433void
435{
436 // write the corresponding value for each bit
437 start.WriteU8(GetPrimaryChannel());
438 start.WriteU8(GetInformationSubset1());
439 start.WriteU16(GetInformationSubset2());
440 start.WriteU16(GetInformationSubset3());
441 start.WriteHtolsbU64(GetBasicMcsSet1());
442 start.WriteHtolsbU64(GetBasicMcsSet2());
443}
444
445uint16_t
447{
448 Buffer::Iterator i = start;
449 uint8_t primarychannel = i.ReadU8();
450 uint8_t informationsubset1 = i.ReadU8();
451 uint16_t informationsubset2 = i.ReadU16();
452 uint16_t informationsubset3 = i.ReadU16();
453 uint64_t mcsset1 = i.ReadLsbtohU64();
454 uint64_t mcsset2 = i.ReadLsbtohU64();
455 SetPrimaryChannel(primarychannel);
456 SetInformationSubset1(informationsubset1);
457 SetInformationSubset2(informationsubset2);
458 SetInformationSubset3(informationsubset3);
459 SetBasicMcsSet(mcsset1, mcsset2);
460 return length;
461}
462
463} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
uint64_t ReadLsbtohU64()
Definition buffer.cc:1083
uint16_t ReadU16()
Definition buffer.h:1024
uint8_t GetTxRxMcsSetUnequal() const
Return transmit / receive MCS set unequal.
void SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
Set the OBSS non HT STAs present.
uint8_t m_reservedInformationSubset1
reserved information subset 1
uint8_t GetDualBeacon() const
Return dual beacon.
void SetRifsMode(uint8_t rifsMode)
Set the RIFS mode.
uint8_t GetRifsMode() const
Return the RIFS mode.
uint8_t m_obssNonHtStasPresent
OBSS NON HT STAs present.
void SetBasicMcsSet(uint64_t ctrl1, uint64_t ctrl2)
Set the Basic MCS Set field in the HT Operation information element.
uint8_t GetLSigTxopProtectionFullSupport() const
Return LSIG TXOP protection full support.
void SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
Set the secondary channel offset.
uint8_t GetInformationSubset1() const
Return the Information Subset 1 field in the HT Operation information element.
uint8_t m_reservedInformationSubset3_1
reserved information subset 3-1
uint8_t m_stbcBeacon
STBC beacon.
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)
void SetInformationSubset2(uint16_t ctrl)
Set the Information Subset 2 field in the HT Operation information element.
uint64_t GetBasicMcsSet1() const
Return the first 64 bytes of the Basic MCS Set field in the HT Operation information element.
uint16_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
uint8_t m_reservedInformationSubset3_2
reserved information subset 3-2
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.
uint8_t m_secondaryChannelOffset
secondary channel offset
uint8_t m_rxMcsBitmask[MAX_SUPPORTED_MCS]
receive MCS bitmask
uint16_t m_rxHighestSupportedDataRate
receive highest supported data rate
void SetInformationSubset3(uint16_t ctrl)
Set the Information Subset 3 field in the HT Operation information element.
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
uint8_t GetTxMcsSetDefined() const
Return transmit MCS set defined.
uint8_t m_staChannelWidth
STA channel width.
uint8_t GetPrimaryChannel() const
Return the Primary Channel field in the HT Operation information element.
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
uint16_t GetRxHighestSupportedDataRate() const
Return receive highest supported data rate.
void SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
Set the transmit / receive MCS set unequal.
uint8_t m_reservedMcsSet1
reserved MCS set 1
uint8_t m_txMaxNSpatialStreams
transmit maximum number spatial streams
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint8_t GetPcoActive() const
Return PCO active.
uint16_t GetInformationSubset3() const
Return the Information Subset 3 field in the HT Operation information element.
uint8_t GetStbcBeacon() const
Return STBC beacon.
void Print(std::ostream &os) const override
Generate human-readable form of IE.
uint8_t m_reservedInformationSubset2_1
reserved information subset 2-1
void SetDualBeacon(uint8_t dualBeacon)
Set the dual beacon.
uint8_t m_dualBeacon
dual beacon
uint8_t m_txMcsSetDefined
transmit MCS set defined
void SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
Set the non GF HT STAs present.
uint64_t GetBasicMcsSet2() const
Return the last 64 bytes of the Basic MCS Set field in the HT Operation information element.
uint8_t m_dualCtsProtection
dual CTS protection
uint8_t m_lSigTxopProtectionFullSupport
L-SIG TXOP protection full support.
void SetTxMcsSetDefined(uint8_t txMcsSetDefined)
Set the transmit MCS set defined.
uint8_t GetHtProtection() const
Return the HT protection.
uint8_t m_reservedInformationSubset2_2
reserved information subset 2-2
uint8_t GetDualCtsProtection() const
Return dual CTS protection.
uint8_t m_reservedMcsSet2
reserved MCS set2
uint8_t GetStaChannelWidth() const
Return the STA channel width.
void SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
Set the LSIG TXOP protection full support.
void SetStaChannelWidth(uint8_t staChannelWidth)
Set the STA channel width.
uint8_t GetSecondaryChannelOffset() const
Return the secondary channel offset.
void SetInformationSubset1(uint8_t ctrl)
Set the Information Subset 1 field in the HT Operation information element.
uint16_t GetInformationSubset2() const
Return the Information Subset 2 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.
uint8_t GetTxUnequalModulation() const
Return transmit unequal modulation.
void SetRxMcsBitmask(uint8_t index)
Set the receive MCS bitmask.
uint32_t m_reservedMcsSet3
reserved MCS set 3
void SetPrimaryChannel(uint8_t ctrl)
Set the Primary Channel field in the HT Operation information element.
uint8_t GetObssNonHtStasPresent() const
Return the OBSS non HT STAs present.
void SetDualCtsProtection(uint8_t dualCtsProtection)
Set the dual CTS protection.
uint8_t m_htProtection
HT protection.
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
uint8_t GetTxMaxNSpatialStreams() const
Return transmit maximum number spatial streams.
uint8_t GetPhase() const
Return phase.
uint8_t GetNonGfHtStasPresent() const
Return the non GF HT STAs present.
uint8_t m_pcoPhase
PCO phase.
uint8_t m_primaryChannel
primary channel
void SetStbcBeacon(uint8_t stbcBeacon)
Set the STBC beacon.
uint8_t m_nonGfHtStasPresent
non GF HT STAs present
#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.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
#define IE_HT_OPERATION