A Discrete-Event Network Simulator
API
he-operation.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 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 "he-operation.h"
22 
23 namespace ns3 {
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 (0),
36  m_heSupported (0)
37 {
38 }
39 
42 {
43  return IE_HE_OPERATION;
44 }
45 
46 void
47 HeOperation::SetHeSupported (uint8_t hesupported)
48 {
49  m_heSupported = hesupported;
50 }
51 
52 uint8_t
54 {
55  //we should not be here if he is not supported
57  return 10;
58 }
59 
60 void
62 {
63  m_bssColor = ctrl & 0x3f;
64  m_defaultPEDuration = (ctrl >> 6) & 0x07;
65  m_twtRequired = (ctrl >> 9) & 0x01;
66  m_heDurationBasedRtsThreshold = (ctrl >> 10) & 0x03ff;
67  m_partialBssColor = (ctrl >> 20) & 0x01;
68  m_maxBssidIndicator = (ctrl >> 21) & 0xff;
69  m_txBssidIndicator = (ctrl >> 29) & 0x01;
70  m_bssColorDisabled = (ctrl >> 30) & 0x01;
71  m_dualBeacon = (ctrl >> 31) & 0x01;
72 }
73 
74 uint32_t
76 {
77  uint32_t val = 0;
78  val |= m_bssColor & 0x3f;
79  val |= (m_defaultPEDuration & 0x07) << 6;
80  val |= (m_twtRequired & 0x01) << 9;
81  val |= (m_heDurationBasedRtsThreshold & 0x03ff) << 10;
82  val |= (m_partialBssColor & 0x01) << 20;
83  val |= (m_maxBssidIndicator & 0xff) << 21;
84  val |= (m_txBssidIndicator & 0x01) << 29;
85  val |= (m_bssColorDisabled & 0x01) << 30;
86  val |= (m_dualBeacon & 0x01) << 31;
87  return val;
88 }
89 
90 void
91 HeOperation::SetMaxHeMcsPerNss (uint8_t nss, uint8_t maxHeMcs)
92 {
93  NS_ASSERT ((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
94  m_basicHeMcsAndNssSet |= (((maxHeMcs - 7) & 0x07) << ((nss - 1) * 3));
95 }
96 
97 uint32_t
99 {
100  return m_basicHeMcsAndNssSet;
101 }
102 
105 {
106  if (m_heSupported < 1)
107  {
108  return i;
109  }
111 }
112 
113 uint16_t
115 {
116  if (m_heSupported < 1)
117  {
118  return 0;
119  }
121 }
122 
123 void
125 {
126  if (m_heSupported == 1)
127  {
128  //write the corresponding value for each bit
129  start.WriteHtolsbU32 (GetHeOperationParameters ());
130  uint32_t mcsset = GetBasicHeMcsAndNssSet ();
131  start.WriteU16 (mcsset & 0xffff);
132  start.WriteU8 ((mcsset >> 16) & 0xff);
133  start.WriteU16 (0); //todo: VHT Operation Information
134  start.WriteU8 (0); //todo: VHT Operation Information
135  }
136 }
137 
138 uint8_t
140 {
142  uint32_t heOperationParameters = i.ReadLsbtohU32 ();
143  uint16_t mcsset_1 = i.ReadU16 ();
144  uint8_t mcsset_2 = i.ReadU8 ();
145  i.ReadU16 (); //todo: VHT Operation Information
146  i.ReadU8 (); //todo: VHT Operation Information
147  SetHeOperationParameters (heOperationParameters);
148  m_basicHeMcsAndNssSet |= mcsset_1 & 0xffff;
149  m_basicHeMcsAndNssSet |= (mcsset_2 & 0xff) << 16;
150  return length;
151 }
152 
161 std::ostream &
162 operator << (std::ostream &os, const HeOperation &HeOperation)
163 {
164  os << HeOperation.GetHeOperationParameters () << "|"
166  return os;
167 }
168 
169 } //namespace ns3
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t GetInformationFieldSize() const
Return the information field size.
Definition: he-operation.cc:53
void SetHeSupported(uint8_t hesupported)
Set the HE supported information element.
Definition: he-operation.cc:47
uint16_t GetSerializedSize() const
Return the serialized size of this HE Operations IE.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
uint8_t m_txBssidIndicator
TX BSSID indicator.
Definition: he-operation.h:129
uint8_t m_heSupported
This is used to decide whether this element should be added to the frame or not.
Definition: he-operation.h:139
def start()
Definition: core.py:1844
#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
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if the STA is a HE STA...
uint32_t GetBasicHeMcsAndNssSet(void) const
Return the Basic HE-MCS And Nss field in the HE Operation information element.
Definition: he-operation.cc:98
uint8_t m_maxBssidIndicator
max BSSID indicator
Definition: he-operation.h:128
uint32_t m_basicHeMcsAndNssSet
basic HE MCS NSS set
Definition: he-operation.h:134
uint8_t m_twtRequired
TWT required.
Definition: he-operation.h:125
iterator in a Buffer instance
Definition: buffer.h:98
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:91
#define IE_HE_OPERATION
WifiInformationElementId ElementId() const
Return the element ID.
Definition: he-operation.cc:41
uint32_t GetHeOperationParameters(void) const
Return the HE Operation Parameters field in the HE Operation information element. ...
Definition: he-operation.cc:75
void SetHeOperationParameters(uint32_t ctrl)
Set the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:61
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize the information field.
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_dualBeacon
Dual Beacon.
Definition: he-operation.h:131
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
uint8_t m_bssColorDisabled
BSS color disabled.
Definition: he-operation.h:130
uint8_t m_defaultPEDuration
default PE duration
Definition: he-operation.h:124
uint8_t ReadU8(void)
Definition: buffer.h:1021
void SerializeInformationField(Buffer::Iterator start) const
Serialize the information field.
uint8_t m_bssColor
BSS color.
Definition: he-operation.h:123
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
The HE Operation Information ElementThis class knows how to serialise and deserialise the HE Operatio...
Definition: he-operation.h:37
uint8_t m_partialBssColor
partial BSS color
Definition: he-operation.h:127
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1076
uint16_t m_heDurationBasedRtsThreshold
HE duration based RTS threshold.
Definition: he-operation.h:126