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 "ns3/assert.h"
23 #include "ns3/log.h"
24 #include <cmath>
25 
26 namespace ns3 {
27 
28 NS_LOG_COMPONENT_DEFINE ("EdcaParameterSet");
29 
31  : m_qosInfo (0),
32  m_reserved (0),
33  m_acBE (0),
34  m_acBK (0),
35  m_acVI (0),
36  m_acVO (0),
37  m_qosSupported (0)
38 {
39 }
40 
43 {
44  return IE_EDCA_PARAMETER_SET;
45 }
46 
47 void
48 EdcaParameterSet::SetQosSupported (uint8_t qosSupported)
49 {
50  m_qosSupported = qosSupported;
51 }
52 
53 void
55 {
56  m_qosInfo = qosInfo;
57 }
58 
59 void
61 {
62  m_acBE |= (aifsn & 0x0f);
63 }
64 
65 void
67 {
68  m_acBE |= (acm & 0x01) << 4;
69 }
70 
71 void
73 {
74  m_acBE |= (aci & 0x03) << 5;
75 }
76 
77 void
79 {
80  uint8_t ECWmin = log2 (cwMin + 1);
81  m_acBE |= (ECWmin & 0x0f) << 8;
82 }
83 
84 void
86 {
87  uint8_t ECWmax = log2 (cwMax + 1);
88  m_acBE |= (ECWmax & 0x0f) << 12;
89 }
90 
91 void
93 {
94  m_acBE |= txop << 16;
95 }
96 
97 void
99 {
100  m_acBK |= (aifsn & 0x0f);
101 }
102 
103 void
105 {
106  m_acBK |= (acm & 0x01) << 4;
107 }
108 
109 void
111 {
112  m_acBK |= (aci & 0x03) << 5;
113 }
114 
115 void
117 {
118  uint8_t ECWmin = log2 (cwMin + 1);
119  m_acBK |= (ECWmin & 0x0f) << 8;
120 }
121 
122 void
124 {
125  uint8_t ECWmax = log2 (cwMax + 1);
126  m_acBK |= (ECWmax & 0x0f) << 12;
127 }
128 
129 void
131 {
132  m_acBK |= txop << 16;
133 }
134 
135 void
137 {
138  m_acVI |= (aifsn & 0x0f);
139 }
140 
141 void
143 {
144  m_acVI |= (acm & 0x01) << 4;
145 }
146 
147 void
149 {
150  m_acVI |= (aci & 0x03) << 5;
151 }
152 
153 void
155 {
156  uint8_t ECWmin = log2 (cwMin + 1);
157  m_acVI |= (ECWmin & 0x0f) << 8;
158 }
159 
160 void
162 {
163  uint8_t ECWmax = log2 (cwMax + 1);
164  m_acVI |= (ECWmax & 0x0f) << 12;
165 }
166 
167 void
169 {
170  m_acVI |= txop << 16;
171 }
172 
173 void
175 {
176  m_acVO |= (aifsn & 0x0f);
177 }
178 
179 void
181 {
182  m_acVO |= (acm & 0x01) << 4;
183 }
184 
185 void
187 {
188  m_acVO |= (aci & 0x03) << 5;
189 }
190 
191 void
193 {
194  uint8_t ECWmin = log2 (cwMin + 1);
195  m_acVO |= (ECWmin & 0x0f) << 8;
196 }
197 
198 void
200 {
201  uint8_t ECWmax = log2 (cwMax + 1);
202  m_acVO |= (ECWmax & 0x0f) << 12;
203 }
204 
205 void
207 {
208  m_acVO |= txop << 16;
209 }
210 
211 uint8_t
213 {
214  return m_qosInfo;
215 }
216 
217 uint8_t
219 {
220  return (m_acBE & 0x0f);
221 }
222 
223 uint8_t
225 {
226  return ((m_acBE >> 4) & 0x01);
227 }
228 
229 uint8_t
231 {
232  return ((m_acBE >> 5) & 0x03);
233 }
234 
235 uint8_t
237 {
238  uint8_t ECWmin = ((m_acBE >> 8) & 0x0f);
239  return (exp2 (ECWmin) - 1);
240 }
241 
242 uint8_t
244 {
245  uint8_t ECWmax = ((m_acBE >> 12) & 0x0f);
246  return (exp2 (ECWmax) - 1);
247 }
248 
249 uint16_t
251 {
252  return (m_acBE >> 16);
253 }
254 
255 uint8_t
257 {
258  return (m_acBK & 0x0f);
259 }
260 
261 uint8_t
263 {
264  return ((m_acBK >> 4) & 0x01);
265 }
266 
267 uint8_t
269 {
270  return ((m_acBK >> 5) & 0x03);
271 }
272 
273 uint8_t
275 {
276  uint8_t ECWmin = ((m_acBK >> 8) & 0x0f);
277  return (exp2 (ECWmin) - 1);
278 }
279 
280 uint8_t
282 {
283  uint8_t ECWmax = ((m_acBK >> 12) & 0x0f);
284  return (exp2 (ECWmax) - 1);
285 }
286 
287 uint16_t
289 {
290  return (m_acBK >> 16);
291 }
292 
293 uint8_t
295 {
296  return (m_acVI & 0x0f);
297 }
298 
299 uint8_t
301 {
302  return ((m_acVI >> 4) & 0x01);
303 }
304 
305 uint8_t
307 {
308  return ((m_acVI >> 5) & 0x03);
309 }
310 
311 uint8_t
313 {
314  uint8_t ECWmin = ((m_acVI >> 8) & 0x0f);
315  return (exp2 (ECWmin) - 1);
316 }
317 
318 uint8_t
320 {
321  uint8_t ECWmax = ((m_acVI >> 12) & 0x0f);
322  return (exp2 (ECWmax) - 1);
323 }
324 
325 uint16_t
327 {
328  return (m_acVI >> 16);
329 }
330 
331 uint8_t
333 {
334  return (m_acVO & 0x0f);
335 }
336 
337 uint8_t
339 {
340  return ((m_acVO >> 4) & 0x01);
341 }
342 
343 uint8_t
345 {
346  return ((m_acVO >> 5) & 0x03);
347 }
348 
349 uint8_t
351 {
352  uint8_t ECWmin = ((m_acVO >> 8) & 0x0f);
353  return (exp2 (ECWmin) - 1);
354 }
355 
356 uint8_t
358 {
359  uint8_t ECWmax = ((m_acVO >> 12) & 0x0f);
360  return (exp2 (ECWmax) - 1);
361 }
362 
363 uint16_t
365 {
366  return (m_acVO >> 16);
367 }
368 
369 uint8_t
371 {
373  return 18;
374 }
375 
378 {
379  if (m_qosSupported < 1)
380  {
381  return i;
382  }
384 }
385 
386 uint16_t
388 {
389  if (m_qosSupported < 1)
390  {
391  return 0;
392  }
394 }
395 
396 void
398 {
399  if (m_qosSupported == 1)
400  {
401  start.WriteU8 (m_qosInfo);
402  start.WriteU8 (m_reserved);
403  start.WriteU32 (m_acBE);
404  start.WriteU32 (m_acBK);
405  start.WriteU32 (m_acVI);
406  start.WriteU32 (m_acVO);
407  }
408 }
409 
410 uint8_t
412 {
414  m_qosInfo = i.ReadU8 ();
415  m_reserved = i.ReadU8 ();
416  m_acBE = i.ReadU32 ();
417  m_acBK = i.ReadU32 ();
418  m_acVI = i.ReadU32 ();
419  m_acVO = i.ReadU32 ();
420  return length;
421 }
422 
424 
425 std::ostream & operator << (std::ostream &os, const EdcaParameterSet &edcaParameterSet)
426 {
427  return os;
428 }
429 
430 std::istream &operator >> (std::istream &is, EdcaParameterSet &edcaParameterSet)
431 {
432  return is;
433 }
434 
435 } //namespace ns3
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:972
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)
uint8_t GetVoAcm(void) const
void SetBkCWmin(uint8_t cwMin)
Set the AC_BK CWmin field in the EdcaParameterSet information element.
void SetBeAcm(uint8_t acm)
Set the AC_BE ACM field in the EdcaParameterSet information element.
WifiInformationElementId ElementId() const
Own unique Element ID.
#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:1482
uint8_t GetViCWmax(void) const
uint8_t GetVoAifsn(void) const
#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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
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
uint8_t GetVoCWmin(void) const
uint8_t GetBkAci(void) const
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
uint8_t GetViCWmin(void) const
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.
void SetBeTXOPLimit(uint16_t txop)
Set the AC_BE TXOP Limit field in the EdcaParameterSet information element.
uint16_t GetBkTXOPLimit(void) const
uint8_t GetBeCWmin(void) const
void SetViAci(uint8_t aci)
Set the AC_VI ACI field in the EdcaParameterSet information element.
void SerializeInformationField(Buffer::Iterator start) const
Serialize information (i.e., the body of the IE, not including the Element ID and length octets) ...
uint16_t GetVoTXOPLimit(void) const
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
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 (i.e., the body of the IE, not including the Element ID and length octets) ...
uint8_t GetBkAcm(void) const
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
The EDCA Parameter SetThis class knows how to serialise and deserialise the EDCA Parameter Set...
uint8_t GetBkCWmax(void) const
uint8_t GetBeAcm(void) const
void SetBkAifsn(uint8_t aifsn)
Set the AC_BK AIFSN field in the EdcaParameterSet information element.
uint8_t GetBkCWmin(void) const
uint8_t GetQosInfo(void) const
uint16_t GetViTXOPLimit(void) const
uint8_t GetViAifsn(void) const
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
Length of serialized information (i.e., the length of the body of the IE, not including the Element I...
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:868
void SetViTXOPLimit(uint16_t txop)
Set the AC_VI TXOP Limit field in the EdcaParameterSet information element.
uint8_t GetViAci(void) const
void SetVoCWmin(uint8_t cwMin)
Set the AC_VO CWmin field in the EdcaParameterSet information element.
uint8_t GetBeAifsn(void) const
uint8_t ReadU8(void)
Definition: buffer.h:1020
uint8_t GetBkAifsn(void) const
uint8_t GetViAcm(void) const
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
void SetBkCWmax(uint8_t cwMax)
Set the AC_BK CWmax field in the EdcaParameterSet information element.
void WriteU32(uint32_t data)
Definition: buffer.cc:878
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.