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 
24 namespace 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 {
40  return IE_EDCA_PARAMETER_SET;
41 }
42 
43 void
44 EdcaParameterSet::SetQosSupported (uint8_t qosSupported)
45 {
46  m_qosSupported = qosSupported;
47 }
48 
49 uint8_t
51 {
52  return ((m_acBE != 0) || (m_acBK != 0) || (m_acVI != 0) || (m_acVO != 0));
53 }
54 
55 void
57 {
58  m_qosInfo = qosInfo;
59 }
60 
61 void
63 {
64  m_acBE |= (aifsn & 0x0f);
65 }
66 
67 void
69 {
70  m_acBE |= (aci & 0x03) << 5;
71 }
72 
73 void
75 {
76  uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
77  m_acBE |= (ECWmin & 0x0f) << 8;
78 }
79 
80 void
82 {
83  uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
84  m_acBE |= (ECWmax & 0x0f) << 12;
85 }
86 
87 void
89 {
90  m_acBE |= txop << 16;
91 }
92 
93 void
95 {
96  m_acBK |= (aifsn & 0x0f);
97 }
98 
99 void
101 {
102  m_acBK |= (aci & 0x03) << 5;
103 }
104 
105 void
107 {
108  uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
109  m_acBK |= (ECWmin & 0x0f) << 8;
110 }
111 
112 void
114 {
115  uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
116  m_acBK |= (ECWmax & 0x0f) << 12;
117 }
118 
119 void
121 {
122  m_acBK |= txop << 16;
123 }
124 
125 void
127 {
128  m_acVI |= (aifsn & 0x0f);
129 }
130 
131 void
133 {
134  m_acVI |= (aci & 0x03) << 5;
135 }
136 
137 void
139 {
140  uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
141  m_acVI |= (ECWmin & 0x0f) << 8;
142 }
143 
144 void
146 {
147  uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
148  m_acVI |= (ECWmax & 0x0f) << 12;
149 }
150 
151 void
153 {
154  m_acVI |= txop << 16;
155 }
156 
157 void
159 {
160  m_acVO |= (aifsn & 0x0f);
161 }
162 
163 void
165 {
166  m_acVO |= (aci & 0x03) << 5;
167 }
168 
169 void
171 {
172  uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1));
173  m_acVO |= (ECWmin & 0x0f) << 8;
174 }
175 
176 void
178 {
179  uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1));
180  m_acVO |= (ECWmax & 0x0f) << 12;
181 }
182 
183 void
185 {
186  m_acVO |= txop << 16;
187 }
188 
189 uint8_t
191 {
192  return m_qosInfo;
193 }
194 
195 uint8_t
197 {
198  return (m_acBE & 0x0f);
199 }
200 
201 uint32_t
203 {
204  uint8_t ECWmin = ((m_acBE >> 8) & 0x0f);
205  return static_cast<uint32_t> (exp2 (ECWmin) - 1);
206 }
207 
208 uint32_t
210 {
211  uint8_t ECWmax = ((m_acBE >> 12) & 0x0f);
212  return static_cast<uint32_t> (exp2 (ECWmax) - 1);
213 }
214 
215 uint16_t
217 {
218  return (m_acBE >> 16);
219 }
220 
221 uint8_t
223 {
224  return (m_acBK & 0x0f);
225 }
226 
227 uint32_t
229 {
230  uint8_t ECWmin = ((m_acBK >> 8) & 0x0f);
231  return static_cast<uint32_t> (exp2 (ECWmin) - 1);
232 }
233 
234 uint32_t
236 {
237  uint8_t ECWmax = ((m_acBK >> 12) & 0x0f);
238  return static_cast<uint32_t> (exp2 (ECWmax) - 1);
239 }
240 
241 uint16_t
243 {
244  return (m_acBK >> 16);
245 }
246 
247 uint8_t
249 {
250  return (m_acVI & 0x0f);
251 }
252 
253 uint32_t
255 {
256  uint8_t ECWmin = ((m_acVI >> 8) & 0x0f);
257  return static_cast<uint32_t> (exp2 (ECWmin) - 1);
258 }
259 
260 uint32_t
262 {
263  uint8_t ECWmax = ((m_acVI >> 12) & 0x0f);
264  return static_cast<uint32_t> (exp2 (ECWmax) - 1);
265 }
266 
267 uint16_t
269 {
270  return (m_acVI >> 16);
271 }
272 
273 uint8_t
275 {
276  return (m_acVO & 0x0f);
277 }
278 
279 uint32_t
281 {
282  uint8_t ECWmin = ((m_acVO >> 8) & 0x0f);
283  return static_cast<uint32_t> (exp2 (ECWmin) - 1);
284 }
285 
286 uint32_t
288 {
289  uint8_t ECWmax = ((m_acVO >> 12) & 0x0f);
290  return static_cast<uint32_t> (exp2 (ECWmax) - 1);
291 }
292 
293 uint16_t
295 {
296  return (m_acVO >> 16);
297 }
298 
299 uint8_t
301 {
303  return 18;
304 }
305 
308 {
309  if (!m_qosSupported)
310  {
311  return i;
312  }
314 }
315 
316 uint16_t
318 {
319  if (!m_qosSupported)
320  {
321  return 0;
322  }
324 }
325 
326 void
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 
340 uint8_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
uint8_t m_reserved
reserved
uint32_t ReadU32(void)
Definition: buffer.cc:972
#define IE_EDCA_PARAMETER_SET
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
void SetViCWmin(uint32_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
uint8_t m_qosInfo
QOS info.
uint16_t GetVoTxopLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetInformationFieldSize() const
Get information field size function.
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
def start()
Definition: core.py:1844
#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
void SetQosInfo(uint8_t qosInfo)
Set the QoS Info 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.
void SetVoAifsn(uint8_t aifsn)
Set the AC_VO AIFSN field in the EdcaParameterSet information element.
uint32_t GetBeCWmin(void) const
Return the AC_BE CWmin field in the EdcaParameterSet information element.
void SetVoCWmin(uint32_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
uint16_t GetViTxopLimit(void) const
Return the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint32_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
iterator in a Buffer instance
Definition: buffer.h:98
WifiInformationElementId ElementId() const
Element ID function.
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
Buffer::Iterator Serialize(Buffer::Iterator start) const
This information element is a bit special in that it is only included if the STA is a QoS STA...
void SetVoCWmax(uint32_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
void SetBeCWmin(uint32_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t GetQosInfo(void) const
Return the QoS Info field in the EdcaParameterSet information element.
void SetViTxopLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint16_t GetSerializedSize() const
Return the serialized size of this EDCA Parameter Set.
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize information field function.
uint32_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
uint8_t GetBeAifsn(void) const
Return the AC_BE AIFSN field in the EdcaParameterSet information element.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
uint32_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
uint16_t GetBkTxopLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN 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.
uint16_t GetBeTxopLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
void SetBkCWmin(uint32_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
void SetVoTxopLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint32_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
uint32_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
uint32_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
void SetBeCWmax(uint32_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
void SerializeInformationField(Buffer::Iterator start) const
Serialize information field function.
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
void SetBeTxopLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetViAifsn(void) const
Return the AC_VI AIFSN field in the EdcaParameterSet information element.
uint8_t IsQosSupported(void) const
Is QOS supported function.
void SetViCWmax(uint32_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.