A Discrete-Event Network Simulator
API
edca-parameter-set.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Sébastien Deronne
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
18  */
19 
20 #include "edca-parameter-set.h"
21 
22 #include <cmath>
23 
24 namespace ns3
25 {
26 
28  : m_qosInfo(0),
29  m_reserved(0),
30  m_acBE(0),
31  m_acBK(0),
32  m_acVI(0),
33  m_acVO(0)
34 {
35 }
36 
39 {
40  return IE_EDCA_PARAMETER_SET;
41 }
42 
43 void
45 {
46  m_qosInfo = qosInfo;
47 }
48 
49 void
51 {
52  m_acBE |= (aifsn & 0x0f);
53 }
54 
55 void
57 {
58  m_acBE |= (aci & 0x03) << 5;
59 }
60 
61 void
63 {
64  auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
65  m_acBE |= (ECWmin & 0x0f) << 8;
66 }
67 
68 void
70 {
71  auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
72  m_acBE |= (ECWmax & 0x0f) << 12;
73 }
74 
75 void
77 {
78  m_acBE |= txop << 16;
79 }
80 
81 void
83 {
84  m_acBK |= (aifsn & 0x0f);
85 }
86 
87 void
89 {
90  m_acBK |= (aci & 0x03) << 5;
91 }
92 
93 void
95 {
96  auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
97  m_acBK |= (ECWmin & 0x0f) << 8;
98 }
99 
100 void
102 {
103  auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
104  m_acBK |= (ECWmax & 0x0f) << 12;
105 }
106 
107 void
109 {
110  m_acBK |= txop << 16;
111 }
112 
113 void
115 {
116  m_acVI |= (aifsn & 0x0f);
117 }
118 
119 void
121 {
122  m_acVI |= (aci & 0x03) << 5;
123 }
124 
125 void
127 {
128  auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
129  m_acVI |= (ECWmin & 0x0f) << 8;
130 }
131 
132 void
134 {
135  auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
136  m_acVI |= (ECWmax & 0x0f) << 12;
137 }
138 
139 void
141 {
142  m_acVI |= txop << 16;
143 }
144 
145 void
147 {
148  m_acVO |= (aifsn & 0x0f);
149 }
150 
151 void
153 {
154  m_acVO |= (aci & 0x03) << 5;
155 }
156 
157 void
159 {
160  auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
161  m_acVO |= (ECWmin & 0x0f) << 8;
162 }
163 
164 void
166 {
167  auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
168  m_acVO |= (ECWmax & 0x0f) << 12;
169 }
170 
171 void
173 {
174  m_acVO |= txop << 16;
175 }
176 
177 uint8_t
179 {
180  return m_qosInfo;
181 }
182 
183 uint8_t
185 {
186  return (m_acBE & 0x0f);
187 }
188 
189 uint32_t
191 {
192  uint8_t ECWmin = ((m_acBE >> 8) & 0x0f);
193  return static_cast<uint32_t>(exp2(ECWmin) - 1);
194 }
195 
196 uint32_t
198 {
199  uint8_t ECWmax = ((m_acBE >> 12) & 0x0f);
200  return static_cast<uint32_t>(exp2(ECWmax) - 1);
201 }
202 
203 uint16_t
205 {
206  return (m_acBE >> 16);
207 }
208 
209 uint8_t
211 {
212  return (m_acBK & 0x0f);
213 }
214 
215 uint32_t
217 {
218  uint8_t ECWmin = ((m_acBK >> 8) & 0x0f);
219  return static_cast<uint32_t>(exp2(ECWmin) - 1);
220 }
221 
222 uint32_t
224 {
225  uint8_t ECWmax = ((m_acBK >> 12) & 0x0f);
226  return static_cast<uint32_t>(exp2(ECWmax) - 1);
227 }
228 
229 uint16_t
231 {
232  return (m_acBK >> 16);
233 }
234 
235 uint8_t
237 {
238  return (m_acVI & 0x0f);
239 }
240 
241 uint32_t
243 {
244  uint8_t ECWmin = ((m_acVI >> 8) & 0x0f);
245  return static_cast<uint32_t>(exp2(ECWmin) - 1);
246 }
247 
248 uint32_t
250 {
251  uint8_t ECWmax = ((m_acVI >> 12) & 0x0f);
252  return static_cast<uint32_t>(exp2(ECWmax) - 1);
253 }
254 
255 uint16_t
257 {
258  return (m_acVI >> 16);
259 }
260 
261 uint8_t
263 {
264  return (m_acVO & 0x0f);
265 }
266 
267 uint32_t
269 {
270  uint8_t ECWmin = ((m_acVO >> 8) & 0x0f);
271  return static_cast<uint32_t>(exp2(ECWmin) - 1);
272 }
273 
274 uint32_t
276 {
277  uint8_t ECWmax = ((m_acVO >> 12) & 0x0f);
278  return static_cast<uint32_t>(exp2(ECWmax) - 1);
279 }
280 
281 uint16_t
283 {
284  return (m_acVO >> 16);
285 }
286 
287 uint16_t
289 {
290  return 18;
291 }
292 
293 void
295 {
296  start.WriteU8(GetQosInfo());
297  start.WriteU8(m_reserved);
298  start.WriteU32(m_acBE);
299  start.WriteU32(m_acBK);
300  start.WriteU32(m_acVI);
301  start.WriteU32(m_acVO);
302 }
303 
304 uint16_t
306 {
308  m_qosInfo = i.ReadU8();
309  m_reserved = i.ReadU8();
310  m_acBE = i.ReadU32();
311  m_acBK = i.ReadU32();
312  m_acVI = i.ReadU32();
313  m_acVO = i.ReadU32();
314  return length;
315 }
316 
317 } // namespace ns3
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
uint32_t ReadU32()
Definition: buffer.cc:966
void SetViTxopLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t GetBeAifsn() const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetViTxopLimit() const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
void SerializeInformationField(Buffer::Iterator start) const override
Serialize information (i.e., the body of the IE, not including the Element ID and length octets)
uint16_t GetBkTxopLimit() const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
uint16_t GetVoTxopLimit() const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
uint8_t GetViAifsn() const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t m_reserved
reserved
uint16_t GetBeTxopLimit() const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBeCWmax() const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
uint32_t GetBeCWmin() const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
uint32_t GetVoCWmax() const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
void SetVoCWmax(uint32_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
void SetViCWmin(uint32_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
void SetVoTxopLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
uint8_t GetQosInfo() const
Return the QoS Info field in the EdcaParameterSet information element.
uint8_t GetVoAifsn() const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the EdcaParameterSet information element.
void SetBkCWmin(uint32_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
uint32_t GetVoCWmin() const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
void SetViCWmax(uint32_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
void SetBeTxopLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
void SetBeCWmax(uint32_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
void SetBkCWmax(uint32_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
void SetBkTxopLimit(uint16_t txop)
Set the AC_BK TXOP Limit field in the EdcaParameterSet information element.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t m_qosInfo
QOS info.
uint8_t GetBkAifsn() const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
void SetBeCWmin(uint32_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
uint32_t GetBkCWmin() const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
uint32_t GetViCWmin() const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
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)
uint32_t GetViCWmax() const
Return the AC_VI CWmax field in the EdcaParameterSet 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...
WifiInformationElementId ElementId() const override
Get the wifi information element ID.
uint32_t GetBkCWmax() const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
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_EDCA_PARAMETER_SET