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
NS_ASSERT
#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
ns3::HeOperation::GetHeOperationParameters
uint32_t GetHeOperationParameters(void) const
Return the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:81
ns3::HeOperation::Serialize
Buffer::Iterator Serialize(Buffer::Iterator start) const override
Serialize entire IE including Element ID and length fields.
Definition: he-operation.cc:137
ns3::HeOperation::GetBasicHeMcsAndNssSet
uint16_t GetBasicHeMcsAndNssSet(void) const
Return the Basic HE-MCS And Nss field in the HE Operation information element.
Definition: he-operation.cc:117
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::HeOperation::SerializeInformationField
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
Definition: he-operation.cc:157
ns3::HeOperation::m_bssColor
uint8_t m_bssColor
BSS color.
Definition: he-operation.h:101
ns3::HeOperation::GetInformationFieldSize
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: he-operation.cc:59
ns3::HeOperation::m_defaultPEDuration
uint8_t m_defaultPEDuration
default PE duration
Definition: he-operation.h:102
ns3::HeOperation::m_heDurationBasedRtsThreshold
uint16_t m_heDurationBasedRtsThreshold
HE duration based RTS threshold.
Definition: he-operation.h:104
ns3::HeOperation::GetSerializedSize
uint16_t GetSerializedSize() const override
Get the size of the serialized IE including Element ID and length fields.
Definition: he-operation.cc:147
ns3::HeOperation::SetBssColor
void SetBssColor(uint8_t bssColor)
Set the BSS color.
Definition: he-operation.cc:123
ns3::WifiInformationElementId
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
Definition: wifi-information-element.h:40
ns3::WifiInformationElement::GetSerializedSize
virtual uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
Definition: wifi-information-element.cc:35
ns3::HeOperation::m_heSupported
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
ns3::HeOperation::SetHeOperationParameters
void SetHeOperationParameters(uint32_t ctrl)
Set the HE Operation Parameters field in the HE Operation information element.
Definition: he-operation.cc:67
visualizer.core.start
def start()
Definition: core.py:1855
ns3::HeOperation::ElementId
WifiInformationElementId ElementId() const override
Definition: he-operation.cc:41
ns3::WifiInformationElement::Serialize
virtual Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
Definition: wifi-information-element.cc:47
ns3::HeOperation::SetMaxHeMcsPerNss
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
ns3::HeOperation::m_basicHeMcsAndNssSet
uint16_t m_basicHeMcsAndNssSet
basic HE MCS NSS set
Definition: he-operation.h:112
NS_ABORT_UNLESS
#define NS_ABORT_UNLESS(cond)
Abnormal program termination if a condition is false.
Definition: abort.h:128
ns3::Buffer::Iterator::ReadLsbtohU32
uint32_t ReadLsbtohU32(void)
Definition: buffer.cc:1077
IE_EXTENSION
#define IE_EXTENSION
Definition: wifi-information-element.h:189
ns3::HeOperation
The HE Operation Information Element.
Definition: he-operation.h:36
ns3::HeOperation::GetBssColor
uint8_t GetBssColor(void) const
Get the BSS color.
Definition: he-operation.cc:131
ns3::Buffer::Iterator::ReadU16
uint16_t ReadU16(void)
Definition: buffer.h:1029
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition: buffer.h:99
ns3::HeOperation::m_partialBssColor
uint8_t m_partialBssColor
partial BSS color
Definition: he-operation.h:105
ns3::HeOperation::m_txBssidIndicator
uint8_t m_txBssidIndicator
TX BSSID indicator.
Definition: he-operation.h:107
ns3::HeOperation::HeOperation
HeOperation()
Definition: he-operation.cc:25
ns3::HeOperation::DeserializeInformationField
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)
Definition: he-operation.cc:169
ns3::HeOperation::m_dualBeacon
uint8_t m_dualBeacon
Dual Beacon.
Definition: he-operation.h:109
ns3::HeOperation::m_twtRequired
uint8_t m_twtRequired
TWT required.
Definition: he-operation.h:103
IE_EXT_HE_OPERATION
#define IE_EXT_HE_OPERATION
Definition: wifi-information-element.h:192
ns3::HeOperation::m_bssColorDisabled
uint8_t m_bssColorDisabled
BSS color disabled.
Definition: he-operation.h:108
ns3::HeOperation::SetHeSupported
void SetHeSupported(uint8_t heSupported)
Set the HE supported information element.
Definition: he-operation.cc:53
ns3::HeOperation::m_maxBssidIndicator
uint8_t m_maxBssidIndicator
max BSSID indicator
Definition: he-operation.h:106
ns3::HeOperation::ElementIdExt
WifiInformationElementId ElementIdExt() const override
Definition: he-operation.cc:47
he-operation.h
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:137