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_EXTENSION;
44 }
45 
48 {
49  return IE_EXT_HE_OPERATION;
50 }
51 
52 void
53 HeOperation::SetHeSupported (uint8_t heSupported)
54 {
55  m_heSupported = heSupported;
56 }
57 
58 uint8_t
60 {
61  //we should not be here if he is not supported
63  return 7;
64 }
65 
66 void
68 {
69  m_bssColor = ctrl & 0x3f;
70  m_defaultPEDuration = (ctrl >> 6) & 0x07;
71  m_twtRequired = (ctrl >> 9) & 0x01;
72  m_heDurationBasedRtsThreshold = (ctrl >> 10) & 0x03ff;
73  m_partialBssColor = (ctrl >> 20) & 0x01;
74  m_maxBssidIndicator = (ctrl >> 21) & 0xff;
75  m_txBssidIndicator = (ctrl >> 29) & 0x01;
76  m_bssColorDisabled = (ctrl >> 30) & 0x01;
77  m_dualBeacon = (ctrl >> 31) & 0x01;
78 }
79 
80 uint32_t
82 {
83  uint32_t val = 0;
84  val |= m_bssColor & 0x3f;
85  val |= (m_defaultPEDuration & 0x07) << 6;
86  val |= (m_twtRequired & 0x01) << 9;
87  val |= (m_heDurationBasedRtsThreshold & 0x03ff) << 10;
88  val |= (m_partialBssColor & 0x01) << 20;
89  val |= (m_maxBssidIndicator & 0xff) << 21;
90  val |= (m_txBssidIndicator & 0x01) << 29;
91  val |= (m_bssColorDisabled & 0x01) << 30;
92  val |= (m_dualBeacon & 0x01) << 31;
93  return val;
94 }
95 
96 void
97 HeOperation::SetMaxHeMcsPerNss (uint8_t nss, uint8_t maxHeMcs)
98 {
99  NS_ASSERT ((maxHeMcs >= 7 && maxHeMcs <= 11) && (nss >= 1 && nss <= 8));
100  uint8_t val = 3; //3 means not supported
101  if (maxHeMcs > 9) //MCS 0 - 11
102  {
103  val = 2;
104  }
105  else if (maxHeMcs > 7) //MCS 0 - 9
106  {
107  val = 1;
108  }
109  else if (maxHeMcs == 7) //MCS 0 - 7
110  {
111  val = 0;
112  }
113  m_basicHeMcsAndNssSet |= ((val & 0x03) << ((nss - 1) * 2));
114 }
115 
116 uint16_t
118 {
119  return m_basicHeMcsAndNssSet;
120 }
121 
122 void
123 HeOperation::SetBssColor (uint8_t bssColor)
124 {
125  NS_ABORT_UNLESS (bssColor < 64); // 6 bits
126  m_bssColor = bssColor;
127  m_bssColorDisabled = 0;
128 }
129 
130 uint8_t
132 {
133  return m_bssColor;
134 }
135 
138 {
139  if (m_heSupported < 1)
140  {
141  return i;
142  }
144 }
145 
146 uint16_t
148 {
149  if (m_heSupported < 1)
150  {
151  return 0;
152  }
154 }
155 
156 void
158 {
159  if (m_heSupported == 1)
160  {
161  //write the corresponding value for each bit
162  start.WriteHtolsbU32 (GetHeOperationParameters ());
163  start.WriteU16 (GetBasicHeMcsAndNssSet ());
164  //todo: VHT Operation Information (variable)
165  }
166 }
167 
168 uint8_t
170 {
172  uint32_t heOperationParameters = i.ReadLsbtohU32 ();
174  SetHeOperationParameters (heOperationParameters);
175  //todo: VHT Operation Information (variable)
176  return length;
177 }
178 
179 std::ostream &
180 operator << (std::ostream &os, const HeOperation &HeOperation)
181 {
182  os << HeOperation.GetHeOperationParameters () << "|"
184  return os;
185 }
186 
187 } //namespace ns3
uint16_t ReadU16(void)
Definition: buffer.h:1029
uint8_t GetInformationFieldSize() const
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
Definition: he-operation.cc:59
uint16_t GetSerializedSize() const
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:107
uint8_t m_heSupported
This is used to decide whether this element should be added to the frame or not.
Definition: he-operation.h:117
def start()
Definition: core.py:1855
#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
void SetHeSupported(uint8_t heSupported)
Set the HE supported information element.
Definition: he-operation.cc:53
uint8_t m_maxBssidIndicator
max BSSID indicator
Definition: he-operation.h:106
uint8_t m_twtRequired
TWT required.
Definition: he-operation.h:103
iterator in a Buffer instance
Definition: buffer.h:98
#define NS_ABORT_UNLESS(cond)
Abnormal program termination if a condition is false.
Definition: abort.h:128
uint16_t GetBasicHeMcsAndNssSet(void) const
Return the Basic HE-MCS And Nss field in the HE Operation information element.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137
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:97
uint16_t m_basicHeMcsAndNssSet
basic HE MCS NSS set
Definition: he-operation.h:112
#define IE_EXT_HE_OPERATION
WifiInformationElementId ElementId() const
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:81
void SetHeOperationParameters(uint32_t ctrl)
Set the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:67
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t m_dualBeacon
Dual Beacon.
Definition: he-operation.h:109
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:108
WifiInformationElementId ElementIdExt() const
Definition: he-operation.cc:47
uint8_t m_defaultPEDuration
default PE duration
Definition: he-operation.h:102
void SetBssColor(uint8_t bssColor)
Set the BSS color.
#define IE_EXTENSION
void SerializeInformationField(Buffer::Iterator start) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
uint8_t GetBssColor(void) const
Get the BSS color.
uint8_t m_bssColor
BSS color.
Definition: he-operation.h:101
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:35
uint8_t m_partialBssColor
partial BSS color
Definition: he-operation.h:105
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1076
uint16_t m_heDurationBasedRtsThreshold
HE duration based RTS threshold.
Definition: he-operation.h:104