A Discrete-Event Network Simulator
API
edca-parameter-set.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016 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 "edca-parameter-set.h"
22#include <cmath>
23
24namespace ns3 {
25
27 : m_qosInfo (0),
28 m_reserved (0),
29 m_acBE (0),
30 m_acBK (0),
31 m_acVI (0),
32 m_acVO (0),
33 m_qosSupported (0)
34{
35}
36
39{
41}
42
43void
45{
46 m_qosSupported = qosSupported;
47}
48
49uint8_t
51{
52 return ((m_acBE != 0) || (m_acBK != 0) || (m_acVI != 0) || (m_acVO != 0));
53}
54
55void
57{
58 m_qosInfo = qosInfo;
59}
60
61void
63{
64 m_acBE |= (aifsn & 0x0f);
65}
66
67void
69{
70 m_acBE |= (aci & 0x03) << 5;
71}
72
73void
75{
76 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
77 m_acBE |= (ECWmin & 0x0f) << 8;
78}
79
80void
82{
83 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
84 m_acBE |= (ECWmax & 0x0f) << 12;
85}
86
87void
89{
90 m_acBE |= txop << 16;
91}
92
93void
95{
96 m_acBK |= (aifsn & 0x0f);
97}
98
99void
101{
102 m_acBK |= (aci & 0x03) << 5;
103}
104
105void
107{
108 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
109 m_acBK |= (ECWmin & 0x0f) << 8;
110}
111
112void
114{
115 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
116 m_acBK |= (ECWmax & 0x0f) << 12;
117}
118
119void
121{
122 m_acBK |= txop << 16;
123}
124
125void
127{
128 m_acVI |= (aifsn & 0x0f);
129}
130
131void
133{
134 m_acVI |= (aci & 0x03) << 5;
135}
136
137void
139{
140 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
141 m_acVI |= (ECWmin & 0x0f) << 8;
142}
143
144void
146{
147 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
148 m_acVI |= (ECWmax & 0x0f) << 12;
149}
150
151void
153{
154 m_acVI |= txop << 16;
155}
156
157void
159{
160 m_acVO |= (aifsn & 0x0f);
161}
162
163void
165{
166 m_acVO |= (aci & 0x03) << 5;
167}
168
169void
171{
172 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
173 m_acVO |= (ECWmin & 0x0f) << 8;
174}
175
176void
178{
179 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
180 m_acVO |= (ECWmax & 0x0f) << 12;
181}
182
183void
185{
186 m_acVO |= txop << 16;
187}
188
189uint8_t
191{
192 return m_qosInfo;
193}
194
195uint8_t
197{
198 return (m_acBE & 0x0f);
199}
200
203{
204 uint8_t ECWmin = ((m_acBE >> 8) & 0x0f);
205 return static_cast<uint32_t> (exp2 (ECWmin) - 1);
206}
207
210{
211 uint8_t ECWmax = ((m_acBE >> 12) & 0x0f);
212 return static_cast<uint32_t> (exp2 (ECWmax) - 1);
213}
214
215uint16_t
217{
218 return (m_acBE >> 16);
219}
220
221uint8_t
223{
224 return (m_acBK & 0x0f);
225}
226
229{
230 uint8_t ECWmin = ((m_acBK >> 8) & 0x0f);
231 return static_cast<uint32_t> (exp2 (ECWmin) - 1);
232}
233
236{
237 uint8_t ECWmax = ((m_acBK >> 12) & 0x0f);
238 return static_cast<uint32_t> (exp2 (ECWmax) - 1);
239}
240
241uint16_t
243{
244 return (m_acBK >> 16);
245}
246
247uint8_t
249{
250 return (m_acVI & 0x0f);
251}
252
255{
256 uint8_t ECWmin = ((m_acVI >> 8) & 0x0f);
257 return static_cast<uint32_t> (exp2 (ECWmin) - 1);
258}
259
262{
263 uint8_t ECWmax = ((m_acVI >> 12) & 0x0f);
264 return static_cast<uint32_t> (exp2 (ECWmax) - 1);
265}
266
267uint16_t
269{
270 return (m_acVI >> 16);
271}
272
273uint8_t
275{
276 return (m_acVO & 0x0f);
277}
278
281{
282 uint8_t ECWmin = ((m_acVO >> 8) & 0x0f);
283 return static_cast<uint32_t> (exp2 (ECWmin) - 1);
284}
285
288{
289 uint8_t ECWmax = ((m_acVO >> 12) & 0x0f);
290 return static_cast<uint32_t> (exp2 (ECWmax) - 1);
291}
292
293uint16_t
295{
296 return (m_acVO >> 16);
297}
298
299uint8_t
301{
303 return 18;
304}
305
308{
309 if (!m_qosSupported)
310 {
311 return i;
312 }
314}
315
316uint16_t
318{
319 if (!m_qosSupported)
320 {
321 return 0;
322 }
324}
325
326void
328{
329 if (m_qosSupported)
330 {
331 start.WriteU8 (GetQosInfo ());
332 start.WriteU8 (m_reserved);
333 start.WriteU32 (m_acBE);
334 start.WriteU32 (m_acBK);
335 start.WriteU32 (m_acVI);
336 start.WriteU32 (m_acVO);
337 }
338}
339
340uint8_t
342{
344 m_qosInfo = i.ReadU8 ();
345 m_reserved = i.ReadU8 ();
346 m_acBE = i.ReadU32 ();
347 m_acBK = i.ReadU32 ();
348 m_acVI = i.ReadU32 ();
349 m_acVO = i.ReadU32 ();
350 return length;
351}
352
353} //namespace ns3
iterator in a Buffer instance
Definition: buffer.h:99
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t ReadU32(void)
Definition: buffer.cc:973
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.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE 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)
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
uint8_t m_reserved
reserved
uint8_t GetQosInfo(void) const
Return the QoS Info field in the EdcaParameterSet information element.
uint8_t GetInformationFieldSize() const override
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
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 GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info field in the EdcaParameterSet information element.
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
void SetBkCWmin(uint32_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
bool m_qosSupported
This is used to decide whether this element should be added to the frame or not.
Buffer::Iterator Serialize(Buffer::Iterator start) const override
Serialize entire IE including Element ID and length fields.
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.
uint8_t IsQosSupported(void) const
Is QOS supported function.
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.
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax 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.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
uint8_t m_qosInfo
QOS info.
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
void SetBeCWmin(uint32_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
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)
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
WifiInformationElementId ElementId() const override
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetSerializedSize() const override
Get the size of the serialized IE including Element ID and length fields.
virtual uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
virtual Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
#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
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.
def start()
Definition: core.py:1853
#define IE_EDCA_PARAMETER_SET