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=" << bool(GetPrimaryChannel()) << "|" << +GetSecondaryChannelOffset() << "|"
58 << bool(GetStaChannelWidth()) << "|" << bool(GetRifsMode()) << "|" << +GetHtProtection()
59 << "|" << bool(GetNonGfHtStasPresent()) << "|" << bool(GetObssNonHtStasPresent()) << "|"
60 << bool(GetDualBeacon()) << "|" << bool(GetDualCtsProtection()) << "|"
61 << bool(GetStbcBeacon()) << "|" << bool(GetLSigTxopProtectionFullSupport()) << "|"
62 << bool(GetPcoActive()) << "|" << bool(GetPhase()) << "|" << GetRxHighestSupportedDataRate()
63 << "|" << bool(GetTxMcsSetDefined()) << "|" << bool(GetTxRxMcsSetUnequal()) << "|"
64 << +GetTxMaxNSpatialStreams() << "|" << bool(GetTxUnequalModulation()) << "|";
65 for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
66 {
67 os << IsSupportedMcs(i) << " ";
68 }
69}
70
71uint16_t
73{
74 return 22;
75}
76
77void
79{
80 m_primaryChannel = ctrl;
81}
82
83void
84HtOperation::SetSecondaryChannelOffset(uint8_t secondaryChannelOffset)
85{
86 m_secondaryChannelOffset = secondaryChannelOffset;
87}
88
89void
90HtOperation::SetStaChannelWidth(uint8_t staChannelWidth)
91{
92 m_staChannelWidth = staChannelWidth;
93}
94
95void
96HtOperation::SetRifsMode(uint8_t rifsMode)
97{
98 m_rifsMode = rifsMode;
99}
100
101void
102HtOperation::SetHtProtection(uint8_t htProtection)
103{
104 m_htProtection = htProtection;
105}
106
107void
108HtOperation::SetNonGfHtStasPresent(uint8_t nonGfHtStasPresent)
109{
110 m_nonGfHtStasPresent = nonGfHtStasPresent;
111}
112
113void
114HtOperation::SetObssNonHtStasPresent(uint8_t obssNonHtStasPresent)
115{
116 m_obssNonHtStasPresent = obssNonHtStasPresent;
117}
118
119void
120HtOperation::SetDualBeacon(uint8_t dualBeacon)
121{
122 m_dualBeacon = dualBeacon;
123}
124
125void
126HtOperation::SetDualCtsProtection(uint8_t dualCtsProtection)
127{
128 m_dualCtsProtection = dualCtsProtection;
129}
130
131void
132HtOperation::SetStbcBeacon(uint8_t stbcBeacon)
133{
134 m_stbcBeacon = stbcBeacon;
135}
136
137void
138HtOperation::SetLSigTxopProtectionFullSupport(uint8_t lSigTxopProtectionFullSupport)
139{
140 m_lSigTxopProtectionFullSupport = lSigTxopProtectionFullSupport;
141}
142
143void
145{
146 m_pcoActive = pcoActive;
147}
148
149void
150HtOperation::SetPhase(uint8_t pcoPhase)
151{
152 m_pcoPhase = pcoPhase;
153}
154
155void
157{
158 m_rxMcsBitmask[index] = 1;
159}
160
161void
163{
164 m_rxHighestSupportedDataRate = maxSupportedRate;
165}
166
167void
168HtOperation::SetTxMcsSetDefined(uint8_t txMcsSetDefined)
169{
170 m_txMcsSetDefined = txMcsSetDefined;
171}
172
173void
174HtOperation::SetTxRxMcsSetUnequal(uint8_t txRxMcsSetUnequal)
175{
176 m_txRxMcsSetUnequal = txRxMcsSetUnequal;
177}
178
179void
180HtOperation::SetTxMaxNSpatialStreams(uint8_t maxTxSpatialStreams)
181{
182 m_txMaxNSpatialStreams = maxTxSpatialStreams - 1; // 0 for 1 SS, 1 for 2 SSs, etc
183}
184
185void
186HtOperation::SetTxUnequalModulation(uint8_t txUnequalModulation)
187{
188 m_txUnequalModulation = txUnequalModulation;
189}
190
191uint8_t
196
197uint8_t
202
203uint8_t
208
209uint8_t
211{
212 return m_rifsMode;
213}
214
215uint8_t
217{
218 return m_htProtection;
219}
220
221uint8_t
226
227uint8_t
232
233uint8_t
235{
236 return m_dualBeacon;
237}
238
239uint8_t
244
245uint8_t
247{
248 return m_stbcBeacon;
249}
250
251uint8_t
256
257uint8_t
259{
260 return m_pcoActive;
261}
262
263uint8_t
265{
266 return m_pcoPhase;
267}
268
269bool
271{
272 return m_rxMcsBitmask[mcs] == 1;
273}
274
275uint16_t
280
281uint8_t
286
287uint8_t
292
293uint8_t
298
299uint8_t
304
305uint8_t
307{
308 uint8_t val = 0;
309 val |= m_secondaryChannelOffset & 0x03;
310 val |= (m_staChannelWidth & 0x01) << 2;
311 val |= (m_rifsMode & 0x01) << 3;
312 val |= (m_reservedInformationSubset1 & 0x0f) << 4;
313 return val;
314}
315
316void
318{
319 m_secondaryChannelOffset = ctrl & 0x03;
320 m_staChannelWidth = (ctrl >> 2) & 0x01;
321 m_rifsMode = (ctrl >> 3) & 0x01;
322 m_reservedInformationSubset1 = (ctrl >> 4) & 0x0f;
323}
324
325uint16_t
327{
328 uint16_t val = 0;
329 val |= m_htProtection & 0x03;
330 val |= (m_nonGfHtStasPresent & 0x01) << 2;
331 val |= (m_reservedInformationSubset2_1 & 0x01) << 3;
332 val |= (m_obssNonHtStasPresent & 0x01) << 4;
333 val |= (m_reservedInformationSubset2_2 & 0x07ff) << 5;
334 return val;
335}
336
337void
339{
340 m_htProtection = ctrl & 0x03;
341 m_nonGfHtStasPresent = (ctrl >> 2) & 0x01;
342 m_reservedInformationSubset2_1 = (ctrl >> 3) & 0x01;
343 m_obssNonHtStasPresent = (ctrl >> 4) & 0x01;
344 m_reservedInformationSubset2_2 = static_cast<uint8_t>((ctrl >> 5) & 0x07ff);
345}
346
347uint16_t
349{
350 uint16_t val = 0;
351 val |= m_reservedInformationSubset3_1 & 0x3f;
352 val |= (m_dualBeacon & 0x01) << 6;
353 val |= (m_dualCtsProtection & 0x01) << 7;
354 val |= (m_stbcBeacon & 0x01) << 8;
355 val |= (m_lSigTxopProtectionFullSupport & 0x01) << 9;
356 val |= (m_pcoActive & 0x01) << 10;
357 val |= (m_pcoPhase & 0x01) << 11;
358 val |= (m_reservedInformationSubset3_2 & 0x0f) << 12;
359 return val;
360}
361
362void
364{
365 m_reservedInformationSubset3_1 = ctrl & 0x3f;
366 m_dualBeacon = (ctrl >> 6) & 0x01;
367 m_dualCtsProtection = (ctrl >> 7) & 0x01;
368 m_stbcBeacon = (ctrl >> 8) & 0x01;
369 m_lSigTxopProtectionFullSupport = (ctrl >> 9) & 0x01;
370 m_pcoActive = (ctrl >> 10) & 0x01;
371 m_pcoPhase = (ctrl >> 11) & 0x01;
372 m_reservedInformationSubset3_2 = (ctrl >> 12) & 0x0f;
373}
374
375void
376HtOperation::SetBasicMcsSet(uint64_t ctrl1, uint64_t ctrl2)
377{
378 for (uint64_t i = 0; i < 77; i++)
379 {
380 if (i < 64)
381 {
382 m_rxMcsBitmask[i] = (ctrl1 >> i) & 0x01;
383 }
384 else
385 {
386 m_rxMcsBitmask[i] = (ctrl2 >> (i - 64)) & 0x01;
387 }
388 }
389 m_reservedMcsSet1 = (ctrl2 >> 13) & 0x07;
390 m_rxHighestSupportedDataRate = (ctrl2 >> 16) & 0x03ff;
391 m_reservedMcsSet2 = (ctrl2 >> 26) & 0x3f;
392 m_txMcsSetDefined = (ctrl2 >> 32) & 0x01;
393 m_txRxMcsSetUnequal = (ctrl2 >> 33) & 0x01;
394 m_txMaxNSpatialStreams = (ctrl2 >> 34) & 0x03;
395 m_txUnequalModulation = (ctrl2 >> 36) & 0x01;
396 m_reservedMcsSet3 = (ctrl2 >> 37) & 0x07ffffff;
397}
398
399uint64_t
401{
402 uint64_t val = 0;
403 for (uint64_t i = 63; i > 0; i--)
404 {
405 val = (val << 1) | (m_rxMcsBitmask[i] & 0x01);
406 }
407 val = (val << 1) | (m_rxMcsBitmask[0] & 0x01);
408 return val;
409}
410
411uint64_t
413{
414 uint64_t val = 0;
415 val = val | (m_reservedMcsSet3 & 0x07ffffff);
416 val = (val << 1) | (m_txUnequalModulation & 0x01);
417 val = (val << 2) | (m_txMaxNSpatialStreams & 0x03);
418 val = (val << 1) | (m_txRxMcsSetUnequal & 0x01);
419 val = (val << 1) | (m_txMcsSetDefined & 0x01);
420 val = (val << 6) | (m_reservedMcsSet2 & 0x3f);
421 val = (val << 10) | (m_rxHighestSupportedDataRate & 0x3ff);
422 val = (val << 3) | (m_reservedMcsSet1 & 0x07);
423
424 for (uint64_t i = 13; i > 0; i--)
425 {
426 val = (val << 1) | (m_rxMcsBitmask[i + 63] & 0x01);
427 }
428 return val;
429}
430
431void
433{
434 // write the corresponding value for each bit
435 start.WriteU8(GetPrimaryChannel());
436 start.WriteU8(GetInformationSubset1());
437 start.WriteU16(GetInformationSubset2());
438 start.WriteU16(GetInformationSubset3());
439 start.WriteHtolsbU64(GetBasicMcsSet1());
440 start.WriteHtolsbU64(GetBasicMcsSet2());
441}
442
443uint16_t
445{
446 Buffer::Iterator i = start;
447 uint8_t primarychannel = i.ReadU8();
448 uint8_t informationsubset1 = i.ReadU8();
449 uint16_t informationsubset2 = i.ReadU16();
450 uint16_t informationsubset3 = i.ReadU16();
451 uint64_t mcsset1 = i.ReadLsbtohU64();
452 uint64_t mcsset2 = i.ReadLsbtohU64();
453 SetPrimaryChannel(primarychannel);
454 SetInformationSubset1(informationsubset1);
455 SetInformationSubset2(informationsubset2);
456 SetInformationSubset3(informationsubset3);
457 SetBasicMcsSet(mcsset1, mcsset2);
458 return length;
459}
460
461} // 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