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 m_htSupported (0)
53{
54 for (uint8_t k = 0; k < MAX_SUPPORTED_MCS; k++)
55 {
56 m_rxMcsBitmask[k] = 0;
57 }
58}
59
62{
63 return IE_HT_OPERATION;
64}
65
66void
67HtOperation::SetHtSupported (uint8_t htSupported)
68{
69 m_htSupported = htSupported;
70}
71
72uint8_t
74{
75 //we should not be here if HT is not supported
77 return 22;
78}
79
80void
82{
83 m_primaryChannel = ctrl;
84}
85
86void
87HtOperation::SetSecondaryChannelOffset (uint8_t secondaryChannelOffset)
88{
89 m_secondaryChannelOffset = secondaryChannelOffset;
90}
91
92void
93HtOperation::SetStaChannelWidth (uint8_t staChannelWidth)
94{
95 m_staChannelWidth = staChannelWidth;
96}
97
98void
99HtOperation::SetRifsMode (uint8_t rifsMode)
100{
101 m_rifsMode = rifsMode;
102}
103
104void
105HtOperation::SetHtProtection (uint8_t htProtection)
106{
107 m_htProtection = htProtection;
108}
109
110void
111HtOperation::SetNonGfHtStasPresent (uint8_t nonGfHtStasPresent)
112{
113 m_nonGfHtStasPresent = nonGfHtStasPresent;
114}
115
116void
117HtOperation::SetObssNonHtStasPresent (uint8_t obssNonHtStasPresent)
118{
119 m_obssNonHtStasPresent = obssNonHtStasPresent;
120}
121
122void
123HtOperation::SetDualBeacon (uint8_t dualBeacon)
124{
125 m_dualBeacon = dualBeacon;
126}
127
128void
129HtOperation::SetDualCtsProtection (uint8_t dualCtsProtection)
130{
131 m_dualCtsProtection = dualCtsProtection;
132}
133
134void
135HtOperation::SetStbcBeacon (uint8_t stbcBeacon)
136{
137 m_stbcBeacon = stbcBeacon;
138}
139
140void
141HtOperation::SetLSigTxopProtectionFullSupport (uint8_t lSigTxopProtectionFullSupport)
142{
143 m_lSigTxopProtectionFullSupport = lSigTxopProtectionFullSupport;
144}
145
146void
147HtOperation::SetPcoActive (uint8_t pcoActive)
148{
149 m_pcoActive = pcoActive;
150}
151
152void
153HtOperation::SetPhase (uint8_t pcoPhase)
154{
155 m_pcoPhase = pcoPhase;
156}
157
158void
160{
161 m_rxMcsBitmask[index] = 1;
162}
163
164void
166{
167 m_rxHighestSupportedDataRate = maxSupportedRate;
168}
169
170void
171HtOperation::SetTxMcsSetDefined (uint8_t txMcsSetDefined)
172{
173 m_txMcsSetDefined = txMcsSetDefined;
174}
175
176void
177HtOperation::SetTxRxMcsSetUnequal (uint8_t txRxMcsSetUnequal)
178{
179 m_txRxMcsSetUnequal = txRxMcsSetUnequal;
180}
181
182void
183HtOperation::SetTxMaxNSpatialStreams (uint8_t maxTxSpatialStreams)
184{
185 m_txMaxNSpatialStreams = maxTxSpatialStreams - 1; //0 for 1 SS, 1 for 2 SSs, etc
186}
187
188void
189HtOperation::SetTxUnequalModulation (uint8_t txUnequalModulation)
190{
191 m_txUnequalModulation = txUnequalModulation;
192}
193
194uint8_t
196{
197 return m_primaryChannel;
198}
199
200uint8_t
202{
204}
205
206uint8_t
208{
209 return m_staChannelWidth;
210}
211
212uint8_t
214{
215 return m_rifsMode;
216}
217
218uint8_t
220{
221 return m_htProtection;
222}
223
224uint8_t
226{
228}
229
230uint8_t
232{
234}
235
236uint8_t
238{
239 return m_dualBeacon;
240}
241
242uint8_t
244{
245 return m_dualCtsProtection;
246}
247
248uint8_t
250{
251 return m_stbcBeacon;
252}
253
254uint8_t
256{
258}
259
260uint8_t
262{
263 return m_pcoActive;
264}
265
266uint8_t
268{
269 return m_pcoPhase;
270}
271
272bool
274{
275 if (m_rxMcsBitmask[mcs] == 1)
276 {
277 return true;
278 }
279 return false;
280}
281
282uint16_t
284{
286}
287
288uint8_t
290{
291 return m_txMcsSetDefined;
292}
293
294uint8_t
296{
297 return m_txRxMcsSetUnequal;
298}
299
300uint8_t
302{
304}
305
306uint8_t
308{
310}
311
314{
315 if (m_htSupported < 1)
316 {
317 return i;
318 }
320}
321
322uint16_t
324{
325 if (m_htSupported < 1)
326 {
327 return 0;
328 }
330}
331
332uint8_t
334{
335 uint8_t val = 0;
336 val |= m_secondaryChannelOffset & 0x03;
337 val |= (m_staChannelWidth & 0x01) << 2;
338 val |= (m_rifsMode & 0x01) << 3;
339 val |= (m_reservedInformationSubset1 & 0x0f) << 4;
340 return val;
341}
342
343void
345{
346 m_secondaryChannelOffset = ctrl & 0x03;
347 m_staChannelWidth = (ctrl >> 2) & 0x01;
348 m_rifsMode = (ctrl >> 3) & 0x01;
349 m_reservedInformationSubset1 = (ctrl >> 4) & 0x0f;
350}
351
352uint16_t
354{
355 uint16_t val = 0;
356 val |= m_htProtection & 0x03;
357 val |= (m_nonGfHtStasPresent & 0x01) << 2;
358 val |= (m_reservedInformationSubset2_1 & 0x01) << 3;
359 val |= (m_obssNonHtStasPresent & 0x01) << 4;
360 val |= (m_reservedInformationSubset2_2 & 0x07ff) << 5;
361 return val;
362}
363
364void
366{
367 m_htProtection = ctrl & 0x03;
368 m_nonGfHtStasPresent = (ctrl >> 2) & 0x01;
369 m_reservedInformationSubset2_1 = (ctrl >> 3) & 0x01;
370 m_obssNonHtStasPresent = (ctrl >> 4) & 0x01;
371 m_reservedInformationSubset2_2 = static_cast<uint8_t> ((ctrl >> 5) & 0x07ff);
372}
373
374uint16_t
376{
377 uint16_t val = 0;
378 val |= m_reservedInformationSubset3_1 & 0x3f;
379 val |= (m_dualBeacon & 0x01) << 6;
380 val |= (m_dualCtsProtection & 0x01) << 7;
381 val |= (m_stbcBeacon & 0x01) << 8;
382 val |= (m_lSigTxopProtectionFullSupport & 0x01) << 9;
383 val |= (m_pcoActive & 0x01) << 10;
384 val |= (m_pcoPhase & 0x01) << 11;
385 val |= (m_reservedInformationSubset3_2 & 0x0f) << 12;
386 return val;
387}
388
389void
391{
392 m_reservedInformationSubset3_1 = ctrl & 0x3f;
393 m_dualBeacon = (ctrl >> 6) & 0x01;
394 m_dualCtsProtection = (ctrl >> 7) & 0x01;
395 m_stbcBeacon = (ctrl >> 8) & 0x01;
396 m_lSigTxopProtectionFullSupport = (ctrl >> 9) & 0x01;
397 m_pcoActive = (ctrl >> 10) & 0x01;
398 m_pcoPhase = (ctrl >> 11) & 0x01;
399 m_reservedInformationSubset3_2 = (ctrl >> 12) & 0x0f;
400}
401
402void
403HtOperation::SetBasicMcsSet (uint64_t ctrl1, uint64_t ctrl2)
404{
405 for (uint64_t i = 0; i < 77; i++)
406 {
407 if (i < 64)
408 {
409 m_rxMcsBitmask[i] = (ctrl1 >> i) & 0x01;
410 }
411 else
412 {
413 m_rxMcsBitmask[i] = (ctrl2 >> (i - 64)) & 0x01;
414 }
415 }
416 m_reservedMcsSet1 = (ctrl2 >> 13) & 0x07;
417 m_rxHighestSupportedDataRate = (ctrl2 >> 16) & 0x03ff;
418 m_reservedMcsSet2 = (ctrl2 >> 26) & 0x3f;
419 m_txMcsSetDefined = (ctrl2 >> 32) & 0x01;
420 m_txRxMcsSetUnequal = (ctrl2 >> 33) & 0x01;
421 m_txMaxNSpatialStreams = (ctrl2 >> 34) & 0x03;
422 m_txUnequalModulation = (ctrl2 >> 36) & 0x01;
423 m_reservedMcsSet3 = (ctrl2 >> 37) & 0x07ffffff;
424}
425
426uint64_t
428{
429 uint64_t val = 0;
430 for (uint64_t i = 63; i > 0; i--)
431 {
432 val = (val << 1) | (m_rxMcsBitmask[i] & 0x01);
433 }
434 val = (val << 1) | (m_rxMcsBitmask[0] & 0x01);
435 return val;
436}
437
438uint64_t
440{
441 uint64_t val = 0;
442 val = val | (m_reservedMcsSet3 & 0x07ffffff);
443 val = (val << 1) | (m_txUnequalModulation & 0x01);
444 val = (val << 2) | (m_txMaxNSpatialStreams & 0x03);
445 val = (val << 1) | (m_txRxMcsSetUnequal & 0x01);
446 val = (val << 1) | (m_txMcsSetDefined & 0x01);
447 val = (val << 6) | (m_reservedMcsSet2 & 0x3f);
448 val = (val << 10) | (m_rxHighestSupportedDataRate & 0x3ff);
449 val = (val << 3) | (m_reservedMcsSet1 & 0x07);
450
451 for (uint64_t i = 13; i > 0; i--)
452 {
453 val = (val << 1) | ( m_rxMcsBitmask[i + 63] & 0x01);
454 }
455 return val;
456}
457
458void
460{
461 if (m_htSupported == 1)
462 {
463 //write the corresponding value for each bit
464 start.WriteU8 (GetPrimaryChannel ());
465 start.WriteU8 (GetInformationSubset1 ());
466 start.WriteU16 (GetInformationSubset2 ());
467 start.WriteU16 (GetInformationSubset3 ());
468 start.WriteHtolsbU64 (GetBasicMcsSet1 ());
469 start.WriteHtolsbU64 (GetBasicMcsSet2 ());
470 }
471}
472
473uint8_t
475 uint8_t length)
476{
478 uint8_t primarychannel = i.ReadU8 ();
479 uint8_t informationsubset1 = i.ReadU8 ();
480 uint16_t informationsubset2 = i.ReadU16 ();
481 uint16_t informationsubset3 = i.ReadU16 ();
482 uint64_t mcsset1 = i.ReadLsbtohU64 ();
483 uint64_t mcsset2 = i.ReadLsbtohU64 ();
484 SetPrimaryChannel (primarychannel);
485 SetInformationSubset1 (informationsubset1);
486 SetInformationSubset2 (informationsubset2);
487 SetInformationSubset3 (informationsubset3);
488 SetBasicMcsSet (mcsset1, mcsset2);
489 return length;
490}
491
492std::ostream &
493operator << (std::ostream &os, const HtOperation &htOperation)
494{
495 os << bool (htOperation.GetPrimaryChannel ())
496 << "|" << +htOperation.GetSecondaryChannelOffset ()
497 << "|" << bool (htOperation.GetStaChannelWidth ())
498 << "|" << bool (htOperation.GetRifsMode ())
499 << "|" << +htOperation.GetHtProtection ()
500 << "|" << bool (htOperation.GetNonGfHtStasPresent ())
501 << "|" << bool (htOperation.GetObssNonHtStasPresent ())
502 << "|" << bool (htOperation.GetDualBeacon ())
503 << "|" << bool (htOperation.GetDualCtsProtection ())
504 << "|" << bool (htOperation.GetStbcBeacon ())
505 << "|" << bool (htOperation.GetLSigTxopProtectionFullSupport ())
506 << "|" << bool (htOperation.GetPcoActive ())
507 << "|" << bool (htOperation.GetPhase ())
508 << "|" << htOperation.GetRxHighestSupportedDataRate ()
509 << "|" << bool (htOperation.GetTxMcsSetDefined ())
510 << "|" << bool (htOperation.GetTxRxMcsSetUnequal ())
511 << "|" << +htOperation.GetTxMaxNSpatialStreams ()
512 << "|" << bool (htOperation.GetTxUnequalModulation ()) << "|";
513 for (uint8_t i = 0; i < MAX_SUPPORTED_MCS; i++)
514 {
515 os << htOperation.IsSupportedMcs (i) << " ";
516 }
517 return os;
518}
519
520} //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:378
Buffer::Iterator Serialize(Buffer::Iterator start) const override
Serialize entire IE including Element ID and length fields.
void SetRifsMode(uint8_t rifsMode)
Set the RIFS mode.
Definition: ht-operation.cc:99
uint8_t m_obssNonHtStasPresent
OBSS NON HT STAs present.
Definition: ht-operation.h:384
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:87
uint8_t m_htSupported
This is used to decide whether this element should be added to the frame or not.
Definition: ht-operation.h:409
uint8_t m_reservedInformationSubset3_1
reserved information subset 3-1
Definition: ht-operation.h:388
uint8_t m_stbcBeacon
STBC beacon.
Definition: ht-operation.h:391
uint64_t GetBasicMcsSet1(void) const
Return the first 64 bytes of the Basic MCS Set field in the HT Operation information element.
uint16_t GetSerializedSize() const override
Get the size of the serialized IE including Element ID and length fields.
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.
uint8_t m_reservedInformationSubset3_2
reserved information subset 3-2
Definition: ht-operation.h:395
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:377
uint8_t m_secondaryChannelOffset
secondary channel offset
Definition: ht-operation.h:375
uint8_t m_rxMcsBitmask[MAX_SUPPORTED_MCS]
receive MCS bitmask
Definition: ht-operation.h:406
uint16_t m_rxHighestSupportedDataRate
receive highest supported data rate
Definition: ht-operation.h:399
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.
uint8_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:73
void SetHtProtection(uint8_t htProtection)
Set the HT protection.
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length) override
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets)
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:376
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:404
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:398
uint8_t GetDualBeacon(void) const
Return dual beacon.
uint8_t m_txMaxNSpatialStreams
transmit maximum number spatial streams
Definition: ht-operation.h:403
WifiInformationElementId ElementId() const override
Definition: ht-operation.cc:61
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:383
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:389
uint8_t m_txMcsSetDefined
transmit MCS set defined
Definition: ht-operation.h:401
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:390
uint8_t m_lSigTxopProtectionFullSupport
L-SIG TXOP protection full support.
Definition: ht-operation.h:392
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:385
uint8_t GetStaChannelWidth(void) const
Return the STA channel width.
uint8_t m_reservedMcsSet2
reserved MCS set2
Definition: ht-operation.h:400
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:93
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:393
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:405
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:81
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:381
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:402
void SetHtSupported(uint8_t htSupported)
Set the HT Supported.
Definition: ht-operation.cc:67
uint8_t m_pcoPhase
PCO phase.
Definition: ht-operation.h:394
uint8_t m_primaryChannel
primary channel
Definition: ht-operation.h:372
void SetStbcBeacon(uint8_t stbcBeacon)
Set the STBC beacon.
uint8_t m_nonGfHtStasPresent
non GF HT STAs present
Definition: ht-operation.h:382
virtual uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
virtual Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
#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:1853
#define IE_HT_OPERATION