A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
24namespace 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{
41}
42
43void
45{
46 m_qosInfo = qosInfo;
47}
48
49void
51{
52 m_acBE |= (aifsn & 0x0f);
53}
54
55void
57{
58 m_acBE |= (aci & 0x03) << 5;
59}
60
61void
63{
64 auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
65 m_acBE |= (ECWmin & 0x0f) << 8;
66}
67
68void
70{
71 auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
72 m_acBE |= (ECWmax & 0x0f) << 12;
73}
74
75void
77{
78 m_acBE |= txop << 16;
79}
80
81void
83{
84 m_acBK |= (aifsn & 0x0f);
85}
86
87void
89{
90 m_acBK |= (aci & 0x03) << 5;
91}
92
93void
95{
96 auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
97 m_acBK |= (ECWmin & 0x0f) << 8;
98}
99
100void
102{
103 auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
104 m_acBK |= (ECWmax & 0x0f) << 12;
105}
106
107void
109{
110 m_acBK |= txop << 16;
111}
112
113void
115{
116 m_acVI |= (aifsn & 0x0f);
117}
118
119void
121{
122 m_acVI |= (aci & 0x03) << 5;
123}
124
125void
127{
128 auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
129 m_acVI |= (ECWmin & 0x0f) << 8;
130}
131
132void
134{
135 auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
136 m_acVI |= (ECWmax & 0x0f) << 12;
137}
138
139void
141{
142 m_acVI |= txop << 16;
143}
144
145void
147{
148 m_acVO |= (aifsn & 0x0f);
149}
150
151void
153{
154 m_acVO |= (aci & 0x03) << 5;
155}
156
157void
159{
160 auto ECWmin = static_cast<uint8_t>(log2(cwMin + 1));
161 m_acVO |= (ECWmin & 0x0f) << 8;
162}
163
164void
166{
167 auto ECWmax = static_cast<uint8_t>(log2(cwMax + 1));
168 m_acVO |= (ECWmax & 0x0f) << 12;
169}
170
171void
173{
174 m_acVO |= txop << 16;
175}
176
177uint8_t
179{
180 return m_qosInfo;
181}
182
183uint8_t
185{
186 return (m_acBE & 0x0f);
187}
188
191{
192 uint8_t ECWmin = ((m_acBE >> 8) & 0x0f);
193 return static_cast<uint32_t>(exp2(ECWmin) - 1);
194}
195
198{
199 uint8_t ECWmax = ((m_acBE >> 12) & 0x0f);
200 return static_cast<uint32_t>(exp2(ECWmax) - 1);
201}
202
203uint16_t
205{
206 return (m_acBE >> 16);
207}
208
209uint8_t
211{
212 return (m_acBK & 0x0f);
213}
214
217{
218 uint8_t ECWmin = ((m_acBK >> 8) & 0x0f);
219 return static_cast<uint32_t>(exp2(ECWmin) - 1);
220}
221
224{
225 uint8_t ECWmax = ((m_acBK >> 12) & 0x0f);
226 return static_cast<uint32_t>(exp2(ECWmax) - 1);
227}
228
229uint16_t
231{
232 return (m_acBK >> 16);
233}
234
235uint8_t
237{
238 return (m_acVI & 0x0f);
239}
240
243{
244 uint8_t ECWmin = ((m_acVI >> 8) & 0x0f);
245 return static_cast<uint32_t>(exp2(ECWmin) - 1);
246}
247
250{
251 uint8_t ECWmax = ((m_acVI >> 12) & 0x0f);
252 return static_cast<uint32_t>(exp2(ECWmax) - 1);
253}
254
255uint16_t
257{
258 return (m_acVI >> 16);
259}
260
261uint8_t
263{
264 return (m_acVO & 0x0f);
265}
266
269{
270 uint8_t ECWmin = ((m_acVO >> 8) & 0x0f);
271 return static_cast<uint32_t>(exp2(ECWmin) - 1);
272}
273
276{
277 uint8_t ECWmax = ((m_acVO >> 12) & 0x0f);
278 return static_cast<uint32_t>(exp2(ECWmax) - 1);
279}
280
281uint16_t
283{
284 return (m_acVO >> 16);
285}
286
287uint16_t
289{
290 return 18;
291}
292
293void
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
304uint16_t
306{
307 Buffer::Iterator i = start;
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