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 |= (acm & 0x01) << 4;
71 }
72 
73 void
75 {
76  m_acBE |= (aci & 0x03) << 5;
77 }
78 
79 void
81 {
82  uint8_t ECWmin = log2 (cwMin + 1);
83  m_acBE |= (ECWmin & 0x0f) << 8;
84 }
85 
86 void
88 {
89  uint8_t ECWmax = log2 (cwMax + 1);
90  m_acBE |= (ECWmax & 0x0f) << 12;
91 }
92 
93 void
95 {
96  m_acBE |= txop << 16;
97 }
98 
99 void
101 {
102  m_acBK |= (aifsn & 0x0f);
103 }
104 
105 void
107 {
108  m_acBK |= (acm & 0x01) << 4;
109 }
110 
111 void
113 {
114  m_acBK |= (aci & 0x03) << 5;
115 }
116 
117 void
119 {
120  uint8_t ECWmin = log2 (cwMin + 1);
121  m_acBK |= (ECWmin & 0x0f) << 8;
122 }
123 
124 void
126 {
127  uint8_t ECWmax = log2 (cwMax + 1);
128  m_acBK |= (ECWmax & 0x0f) << 12;
129 }
130 
131 void
133 {
134  m_acBK |= txop << 16;
135 }
136 
137 void
139 {
140  m_acVI |= (aifsn & 0x0f);
141 }
142 
143 void
145 {
146  m_acVI |= (acm & 0x01) << 4;
147 }
148 
149 void
151 {
152  m_acVI |= (aci & 0x03) << 5;
153 }
154 
155 void
157 {
158  uint8_t ECWmin = log2 (cwMin + 1);
159  m_acVI |= (ECWmin & 0x0f) << 8;
160 }
161 
162 void
164 {
165  uint8_t ECWmax = log2 (cwMax + 1);
166  m_acVI |= (ECWmax & 0x0f) << 12;
167 }
168 
169 void
171 {
172  m_acVI |= txop << 16;
173 }
174 
175 void
177 {
178  m_acVO |= (aifsn & 0x0f);
179 }
180 
181 void
183 {
184  m_acVO |= (acm & 0x01) << 4;
185 }
186 
187 void
189 {
190  m_acVO |= (aci & 0x03) << 5;
191 }
192 
193 void
195 {
196  uint8_t ECWmin = log2 (cwMin + 1);
197  m_acVO |= (ECWmin & 0x0f) << 8;
198 }
199 
200 void
202 {
203  uint8_t ECWmax = log2 (cwMax + 1);
204  m_acVO |= (ECWmax & 0x0f) << 12;
205 }
206 
207 void
209 {
210  m_acVO |= txop << 16;
211 }
212 
213 uint8_t
215 {
216  return m_qosInfo;
217 }
218 
219 uint8_t
221 {
222  return (m_acBE & 0x0f);
223 }
224 
225 uint8_t
227 {
228  return ((m_acBE >> 4) & 0x01);
229 }
230 
231 uint8_t
233 {
234  return ((m_acBE >> 5) & 0x03);
235 }
236 
237 uint8_t
239 {
240  uint8_t ECWmin = ((m_acBE >> 8) & 0x0f);
241  return (exp2 (ECWmin) - 1);
242 }
243 
244 uint8_t
246 {
247  uint8_t ECWmax = ((m_acBE >> 12) & 0x0f);
248  return (exp2 (ECWmax) - 1);
249 }
250 
251 uint16_t
253 {
254  return (m_acBE >> 16);
255 }
256 
257 uint8_t
259 {
260  return (m_acBK & 0x0f);
261 }
262 
263 uint8_t
265 {
266  return ((m_acBK >> 4) & 0x01);
267 }
268 
269 uint8_t
271 {
272  return ((m_acBK >> 5) & 0x03);
273 }
274 
275 uint8_t
277 {
278  uint8_t ECWmin = ((m_acBK >> 8) & 0x0f);
279  return (exp2 (ECWmin) - 1);
280 }
281 
282 uint8_t
284 {
285  uint8_t ECWmax = ((m_acBK >> 12) & 0x0f);
286  return (exp2 (ECWmax) - 1);
287 }
288 
289 uint16_t
291 {
292  return (m_acBK >> 16);
293 }
294 
295 uint8_t
297 {
298  return (m_acVI & 0x0f);
299 }
300 
301 uint8_t
303 {
304  return ((m_acVI >> 4) & 0x01);
305 }
306 
307 uint8_t
309 {
310  return ((m_acVI >> 5) & 0x03);
311 }
312 
313 uint8_t
315 {
316  uint8_t ECWmin = ((m_acVI >> 8) & 0x0f);
317  return (exp2 (ECWmin) - 1);
318 }
319 
320 uint8_t
322 {
323  uint8_t ECWmax = ((m_acVI >> 12) & 0x0f);
324  return (exp2 (ECWmax) - 1);
325 }
326 
327 uint16_t
329 {
330  return (m_acVI >> 16);
331 }
332 
333 uint8_t
335 {
336  return (m_acVO & 0x0f);
337 }
338 
339 uint8_t
341 {
342  return ((m_acVO >> 4) & 0x01);
343 }
344 
345 uint8_t
347 {
348  return ((m_acVO >> 5) & 0x03);
349 }
350 
351 uint8_t
353 {
354  uint8_t ECWmin = ((m_acVO >> 8) & 0x0f);
355  return (exp2 (ECWmin) - 1);
356 }
357 
358 uint8_t
360 {
361  uint8_t ECWmax = ((m_acVO >> 12) & 0x0f);
362  return (exp2 (ECWmax) - 1);
363 }
364 
365 uint16_t
367 {
368  return (m_acVO >> 16);
369 }
370 
371 uint8_t
373 {
375  return 18;
376 }
377 
380 {
381  if (m_qosSupported < 1)
382  {
383  return i;
384  }
386 }
387 
388 uint16_t
390 {
391  if (m_qosSupported < 1)
392  {
393  return 0;
394  }
396 }
397 
398 void
400 {
401  if (m_qosSupported == 1)
402  {
403  start.WriteU8 (m_qosInfo);
404  start.WriteU8 (m_reserved);
405  start.WriteU32 (m_acBE);
406  start.WriteU32 (m_acBK);
407  start.WriteU32 (m_acVI);
408  start.WriteU32 (m_acVO);
409  }
410 }
411 
412 uint8_t
414 {
416  m_qosInfo = i.ReadU8 ();
417  m_reserved = i.ReadU8 ();
418  m_acBE = i.ReadU32 ();
419  m_acBK = i.ReadU32 ();
420  m_acVI = i.ReadU32 ();
421  m_acVO = i.ReadU32 ();
422  return length;
423 }
424 
427 
436 std::ostream & operator << (std::ostream &os, const EdcaParameterSet &edcaParameterSet)
437 {
438  return os;
439 }
440 
449 std::istream &operator >> (std::istream &is, EdcaParameterSet &edcaParameterSet)
450 {
451  return is;
452 }
453 
454 } //namespace ns3
uint8_t m_reserved
reserved
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
Definition: angles.cc:48
uint32_t ReadU32(void)
Definition: buffer.cc:975
void SetViAcm(uint8_t acm)
Set the AC_VI ACM field in the EdcaParameterSet information element.
#define IE_EDCA_PARAMETER_SET
void SetQosSupported(uint8_t qosSupported)
Set QOS supported function.
uint8_t GetVoAcm(void) const
Return the AC_VO ACM field in the EdcaParameterSet information element.
void SetBkCWmin(uint8_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
uint8_t m_qosInfo
QOS info.
void SetBeAcm(uint8_t acm)
Set the AC_BE ACM field in the EdcaParameterSet information element.
WifiInformationElementId ElementId() const
Element ID function.
#define ATTRIBUTE_HELPER_CPP(type)
Define the attribute value, accessor and checkers for class type.
void SetVoAci(uint8_t aci)
Set the AC_VO ACI field in the EdcaParameterSet information element.
def start()
Definition: core.py:1790
uint8_t GetViCWmax(void) const
Return the AC_VI CWmax field in the EdcaParameterSet information element.
uint8_t GetVoAifsn(void) const
Return the AC_VO AIFSN field in the EdcaParameterSet information element.
#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.
void SetVoTXOPLimit(uint16_t txop)
Set the AC_VO TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetBeAci(void) const
Return the AC_BE ACI field in the EdcaParameterSet information element.
uint8_t GetVoCWmin(void) const
Return the AC_VO CWmin field in the EdcaParameterSet information element.
uint8_t GetBkAci(void) const
Return the AC_BK ACI field in the EdcaParameterSet information element.
uint16_t GetSerializedSize() const
Get the size of the serialized IE including Element ID and length fields.
iterator in a Buffer instance
Definition: buffer.h:98
uint16_t GetBeTXOPLimit(void) const
Return the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetViCWmin(void) const
Return the AC_VI CWmin field in the EdcaParameterSet information element.
void SetViAifsn(uint8_t aifsn)
Set the AC_VI AIFSN field in the EdcaParameterSet information element.
uint16_t GetSerializedSize() const
Return the serialized size of this EDCA Parameter Set.
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.
uint16_t GetBkTXOPLimit(void) const
Return the AC_BK TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetBeCWmin(void) const
Return 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.
void SerializeInformationField(Buffer::Iterator start) const
Serialize information field function.
uint16_t GetVoTXOPLimit(void) const
Return the AC_VO TXOP Limit field in the EdcaParameterSet information element.
void SetBeCWmax(uint8_t cwMax)
Set the AC_BE CWmax field in the EdcaParameterSet information element.
void SetBeCWmin(uint8_t cwMin)
Set the AC_BE CWmin field in the EdcaParameterSet information element.
uint8_t GetVoCWmax(void) const
Return the AC_VO CWmax field in the EdcaParameterSet information element.
void SetViCWmin(uint8_t cwMin)
Set the AC_VI CWmin field in the EdcaParameterSet information element.
uint8_t DeserializeInformationField(Buffer::Iterator start, uint8_t length)
Deserialize information field function.
uint8_t GetBkAcm(void) const
Return the AC_BK ACM 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...
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t GetBeCWmax(void) const
Return the AC_BE CWmax field in the EdcaParameterSet information element.
The EDCA Parameter SetThis class knows how to serialise and deserialise the EDCA Parameter Set...
uint8_t GetBkCWmax(void) const
Return the AC_BK CWmax field in the EdcaParameterSet information element.
uint8_t GetBeAcm(void) const
Return the AC_BE ACM field in the EdcaParameterSet information element.
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t GetBkCWmin(void) const
Return the AC_BK CWmin field in the EdcaParameterSet information element.
uint8_t GetQosInfo(void) const
Return the QoS Info field in the EdcaParameterSet information element.
uint16_t GetViTXOPLimit(void) const
Return the AC_VI 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 SetBkTXOPLimit(uint16_t txop)
Set the AC_BK TXOP Limit field in the EdcaParameterSet information element.
void SetBeAci(uint8_t aci)
Set the AC_BE ACI field in the EdcaParameterSet information element.
uint8_t GetInformationFieldSize() const
Get information field size function.
void SetBkAci(uint8_t aci)
Set the AC_BK ACI field in the EdcaParameterSet information element.
void SetVoAcm(uint8_t acm)
Set the AC_VO ACM field in the EdcaParameterSet information element.
void WriteU8(uint8_t data)
Definition: buffer.h:869
void SetViTXOPLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetViAci(void) const
Return the AC_VI ACI field in the EdcaParameterSet information element.
void SetVoCWmin(uint8_t cwMin)
Set 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.
uint8_t ReadU8(void)
Definition: buffer.h:1021
uint8_t GetBkAifsn(void) const
Return the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t GetViAcm(void) const
Return the AC_VI ACM field in the EdcaParameterSet information element.
uint8_t WifiInformationElementId
This type is used to represent an Information Element ID.
void SetVoCWmax(uint8_t cwMax)
Set the AC_VO CWmax field in the EdcaParameterSet information element.
uint8_t GetVoAci(void) const
Return the AC_VO ACI field in the EdcaParameterSet information element.
void SetBkCWmax(uint8_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
void WriteU32(uint32_t data)
Definition: buffer.cc:881
void SetBeAifsn(uint8_t aifsn)
Set the AC_BE AIFSN field in the EdcaParameterSet information element.
void SetViCWmax(uint8_t cwMax)
Set the AC_VI CWmax field in the EdcaParameterSet information element.
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
void SetBkAcm(uint8_t acm)
Set the AC_BK ACM field in the EdcaParameterSet information element.