LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2016 Sébastien Deronne | 3 * Copyright (c) 2016 Sébastien Deronne |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Sébastien Deronne <sebastien.deronne@gmail.com> | 18 * Author: Sébastien Deronne <sebastien.deronne@gmail.com> |
19 */ | 19 */ |
20 | 20 |
21 #include "edca-parameter-set.h" | 21 #include "edca-parameter-set.h" |
22 #include "ns3/unused.h" | |
23 #include <cmath> | 22 #include <cmath> |
24 | 23 |
25 namespace ns3 { | 24 namespace ns3 { |
26 | 25 |
27 EdcaParameterSet::EdcaParameterSet () | 26 EdcaParameterSet::EdcaParameterSet () |
28 : m_qosInfo (0), | 27 : m_qosInfo (0), |
29 m_reserved (0), | 28 m_reserved (0), |
30 m_acBE (0), | 29 m_acBE (0), |
31 m_acBK (0), | 30 m_acBK (0), |
32 m_acVI (0), | 31 m_acVI (0), |
(...skipping 26 matching lines...) Expand all Loading... |
59 m_qosInfo = qosInfo; | 58 m_qosInfo = qosInfo; |
60 } | 59 } |
61 | 60 |
62 void | 61 void |
63 EdcaParameterSet::SetBeAifsn (uint8_t aifsn) | 62 EdcaParameterSet::SetBeAifsn (uint8_t aifsn) |
64 { | 63 { |
65 m_acBE |= (aifsn & 0x0f); | 64 m_acBE |= (aifsn & 0x0f); |
66 } | 65 } |
67 | 66 |
68 void | 67 void |
69 EdcaParameterSet::SetBeAcm (uint8_t acm) | |
70 { | |
71 m_acBE |= (acm & 0x01) << 4; | |
72 } | |
73 | |
74 void | |
75 EdcaParameterSet::SetBeAci (uint8_t aci) | 68 EdcaParameterSet::SetBeAci (uint8_t aci) |
76 { | 69 { |
77 m_acBE |= (aci & 0x03) << 5; | 70 m_acBE |= (aci & 0x03) << 5; |
78 } | 71 } |
79 | 72 |
80 void | 73 void |
81 EdcaParameterSet::SetBeCWmin (uint8_t cwMin) | 74 EdcaParameterSet::SetBeCWmin (uint32_t cwMin) |
82 { | 75 { |
83 uint8_t ECWmin = (uint8_t)log2 (cwMin + 1); | 76 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1)); |
84 m_acBE |= (ECWmin & 0x0f) << 8; | 77 m_acBE |= (ECWmin & 0x0f) << 8; |
85 } | 78 } |
86 | 79 |
87 void | 80 void |
88 EdcaParameterSet::SetBeCWmax (uint8_t cwMax) | 81 EdcaParameterSet::SetBeCWmax (uint32_t cwMax) |
89 { | 82 { |
90 uint8_t ECWmax = (uint8_t)log2 (cwMax + 1); | 83 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1)); |
91 m_acBE |= (ECWmax & 0x0f) << 12; | 84 m_acBE |= (ECWmax & 0x0f) << 12; |
92 } | 85 } |
93 | 86 |
94 void | 87 void |
95 EdcaParameterSet::SetBeTXOPLimit (uint16_t txop) | 88 EdcaParameterSet::SetBeTXOPLimit (uint16_t txop) |
96 { | 89 { |
97 m_acBE |= txop << 16; | 90 m_acBE |= txop << 16; |
98 } | 91 } |
99 | 92 |
100 void | 93 void |
101 EdcaParameterSet::SetBkAifsn (uint8_t aifsn) | 94 EdcaParameterSet::SetBkAifsn (uint8_t aifsn) |
102 { | 95 { |
103 m_acBK |= (aifsn & 0x0f); | 96 m_acBK |= (aifsn & 0x0f); |
104 } | 97 } |
105 | 98 |
106 void | 99 void |
107 EdcaParameterSet::SetBkAcm (uint8_t acm) | |
108 { | |
109 m_acBK |= (acm & 0x01) << 4; | |
110 } | |
111 | |
112 void | |
113 EdcaParameterSet::SetBkAci (uint8_t aci) | 100 EdcaParameterSet::SetBkAci (uint8_t aci) |
114 { | 101 { |
115 m_acBK |= (aci & 0x03) << 5; | 102 m_acBK |= (aci & 0x03) << 5; |
116 } | 103 } |
117 | 104 |
118 void | 105 void |
119 EdcaParameterSet::SetBkCWmin (uint8_t cwMin) | 106 EdcaParameterSet::SetBkCWmin (uint32_t cwMin) |
120 { | 107 { |
121 uint8_t ECWmin = (uint8_t)log2 (cwMin + 1); | 108 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1)); |
122 m_acBK |= (ECWmin & 0x0f) << 8; | 109 m_acBK |= (ECWmin & 0x0f) << 8; |
123 } | 110 } |
124 | 111 |
125 void | 112 void |
126 EdcaParameterSet::SetBkCWmax (uint8_t cwMax) | 113 EdcaParameterSet::SetBkCWmax (uint32_t cwMax) |
127 { | 114 { |
128 uint8_t ECWmax = (uint8_t)log2 (cwMax + 1); | 115 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1)); |
129 m_acBK |= (ECWmax & 0x0f) << 12; | 116 m_acBK |= (ECWmax & 0x0f) << 12; |
130 } | 117 } |
131 | 118 |
132 void | 119 void |
133 EdcaParameterSet::SetBkTXOPLimit (uint16_t txop) | 120 EdcaParameterSet::SetBkTXOPLimit (uint16_t txop) |
134 { | 121 { |
135 m_acBK |= txop << 16; | 122 m_acBK |= txop << 16; |
136 } | 123 } |
137 | 124 |
138 void | 125 void |
139 EdcaParameterSet::SetViAifsn (uint8_t aifsn) | 126 EdcaParameterSet::SetViAifsn (uint8_t aifsn) |
140 { | 127 { |
141 m_acVI |= (aifsn & 0x0f); | 128 m_acVI |= (aifsn & 0x0f); |
142 } | 129 } |
143 | 130 |
144 void | 131 void |
145 EdcaParameterSet::SetViAcm (uint8_t acm) | |
146 { | |
147 m_acVI |= (acm & 0x01) << 4; | |
148 } | |
149 | |
150 void | |
151 EdcaParameterSet::SetViAci (uint8_t aci) | 132 EdcaParameterSet::SetViAci (uint8_t aci) |
152 { | 133 { |
153 m_acVI |= (aci & 0x03) << 5; | 134 m_acVI |= (aci & 0x03) << 5; |
154 } | 135 } |
155 | 136 |
156 void | 137 void |
157 EdcaParameterSet::SetViCWmin (uint8_t cwMin) | 138 EdcaParameterSet::SetViCWmin (uint32_t cwMin) |
158 { | 139 { |
159 uint8_t ECWmin = (uint8_t)log2 (cwMin + 1); | 140 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1)); |
160 m_acVI |= (ECWmin & 0x0f) << 8; | 141 m_acVI |= (ECWmin & 0x0f) << 8; |
161 } | 142 } |
162 | 143 |
163 void | 144 void |
164 EdcaParameterSet::SetViCWmax (uint8_t cwMax) | 145 EdcaParameterSet::SetViCWmax (uint32_t cwMax) |
165 { | 146 { |
166 uint8_t ECWmax = (uint8_t)log2 (cwMax + 1); | 147 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1)); |
167 m_acVI |= (ECWmax & 0x0f) << 12; | 148 m_acVI |= (ECWmax & 0x0f) << 12; |
168 } | 149 } |
169 | 150 |
170 void | 151 void |
171 EdcaParameterSet::SetViTXOPLimit (uint16_t txop) | 152 EdcaParameterSet::SetViTXOPLimit (uint16_t txop) |
172 { | 153 { |
173 m_acVI |= txop << 16; | 154 m_acVI |= txop << 16; |
174 } | 155 } |
175 | 156 |
176 void | 157 void |
177 EdcaParameterSet::SetVoAifsn (uint8_t aifsn) | 158 EdcaParameterSet::SetVoAifsn (uint8_t aifsn) |
178 { | 159 { |
179 m_acVO |= (aifsn & 0x0f); | 160 m_acVO |= (aifsn & 0x0f); |
180 } | 161 } |
181 | 162 |
182 void | 163 void |
183 EdcaParameterSet::SetVoAcm (uint8_t acm) | |
184 { | |
185 m_acVO |= (acm & 0x01) << 4; | |
186 } | |
187 | |
188 void | |
189 EdcaParameterSet::SetVoAci (uint8_t aci) | 164 EdcaParameterSet::SetVoAci (uint8_t aci) |
190 { | 165 { |
191 m_acVO |= (aci & 0x03) << 5; | 166 m_acVO |= (aci & 0x03) << 5; |
192 } | 167 } |
193 | 168 |
194 void | 169 void |
195 EdcaParameterSet::SetVoCWmin (uint8_t cwMin) | 170 EdcaParameterSet::SetVoCWmin (uint32_t cwMin) |
196 { | 171 { |
197 uint8_t ECWmin = (uint8_t)log2 (cwMin + 1); | 172 uint8_t ECWmin = static_cast<uint8_t> (log2 (cwMin + 1)); |
198 m_acVO |= (ECWmin & 0x0f) << 8; | 173 m_acVO |= (ECWmin & 0x0f) << 8; |
199 } | 174 } |
200 | 175 |
201 void | 176 void |
202 EdcaParameterSet::SetVoCWmax (uint8_t cwMax) | 177 EdcaParameterSet::SetVoCWmax (uint32_t cwMax) |
203 { | 178 { |
204 uint8_t ECWmax = (uint8_t)log2 (cwMax + 1); | 179 uint8_t ECWmax = static_cast<uint8_t> (log2 (cwMax + 1)); |
205 m_acVO |= (ECWmax & 0x0f) << 12; | 180 m_acVO |= (ECWmax & 0x0f) << 12; |
206 } | 181 } |
207 | 182 |
208 void | 183 void |
209 EdcaParameterSet::SetVoTXOPLimit (uint16_t txop) | 184 EdcaParameterSet::SetVoTXOPLimit (uint16_t txop) |
210 { | 185 { |
211 m_acVO |= txop << 16; | 186 m_acVO |= txop << 16; |
212 } | 187 } |
213 | 188 |
214 uint8_t | 189 uint8_t |
215 EdcaParameterSet::GetQosInfo (void) const | 190 EdcaParameterSet::GetQosInfo (void) const |
216 { | 191 { |
217 return m_qosInfo; | 192 return m_qosInfo; |
218 } | 193 } |
219 | 194 |
220 uint8_t | 195 uint8_t |
221 EdcaParameterSet::GetBeAifsn (void) const | 196 EdcaParameterSet::GetBeAifsn (void) const |
222 { | 197 { |
223 return (m_acBE & 0x0f); | 198 return (m_acBE & 0x0f); |
224 } | 199 } |
225 | 200 |
226 uint8_t | 201 uint32_t |
227 EdcaParameterSet::GetBeAcm (void) const | |
228 { | |
229 return ((m_acBE >> 4) & 0x01); | |
230 } | |
231 | |
232 uint8_t | |
233 EdcaParameterSet::GetBeAci (void) const | |
234 { | |
235 return ((m_acBE >> 5) & 0x03); | |
236 } | |
237 | |
238 uint8_t | |
239 EdcaParameterSet::GetBeCWmin (void) const | 202 EdcaParameterSet::GetBeCWmin (void) const |
240 { | 203 { |
241 uint8_t ECWmin = ((m_acBE >> 8) & 0x0f); | 204 uint8_t ECWmin = ((m_acBE >> 8) & 0x0f); |
242 return (uint8_t)(exp2 (ECWmin) - 1); | 205 return static_cast<uint32_t> (exp2 (ECWmin) - 1); |
243 } | 206 } |
244 | 207 |
245 uint8_t | 208 uint32_t |
246 EdcaParameterSet::GetBeCWmax (void) const | 209 EdcaParameterSet::GetBeCWmax (void) const |
247 { | 210 { |
248 uint8_t ECWmax = ((m_acBE >> 12) & 0x0f); | 211 uint8_t ECWmax = ((m_acBE >> 12) & 0x0f); |
249 return (uint8_t)(exp2 (ECWmax) - 1); | 212 return static_cast<uint32_t> (exp2 (ECWmax) - 1); |
250 } | 213 } |
251 | 214 |
252 uint16_t | 215 uint16_t |
253 EdcaParameterSet::GetBeTXOPLimit (void) const | 216 EdcaParameterSet::GetBeTXOPLimit (void) const |
254 { | 217 { |
255 return (m_acBE >> 16); | 218 return (m_acBE >> 16); |
256 } | 219 } |
257 | 220 |
258 uint8_t | 221 uint8_t |
259 EdcaParameterSet::GetBkAifsn (void) const | 222 EdcaParameterSet::GetBkAifsn (void) const |
260 { | 223 { |
261 return (m_acBK & 0x0f); | 224 return (m_acBK & 0x0f); |
262 } | 225 } |
263 | 226 |
264 uint8_t | 227 uint32_t |
265 EdcaParameterSet::GetBkAcm (void) const | |
266 { | |
267 return ((m_acBK >> 4) & 0x01); | |
268 } | |
269 | |
270 uint8_t | |
271 EdcaParameterSet::GetBkAci (void) const | |
272 { | |
273 return ((m_acBK >> 5) & 0x03); | |
274 } | |
275 | |
276 uint8_t | |
277 EdcaParameterSet::GetBkCWmin (void) const | 228 EdcaParameterSet::GetBkCWmin (void) const |
278 { | 229 { |
279 uint8_t ECWmin = ((m_acBK >> 8) & 0x0f); | 230 uint8_t ECWmin = ((m_acBK >> 8) & 0x0f); |
280 return (uint8_t)(exp2 (ECWmin) - 1); | 231 return static_cast<uint32_t> (exp2 (ECWmin) - 1); |
281 } | 232 } |
282 | 233 |
283 uint8_t | 234 uint32_t |
284 EdcaParameterSet::GetBkCWmax (void) const | 235 EdcaParameterSet::GetBkCWmax (void) const |
285 { | 236 { |
286 uint8_t ECWmax = ((m_acBK >> 12) & 0x0f); | 237 uint8_t ECWmax = ((m_acBK >> 12) & 0x0f); |
287 return (uint8_t)(exp2 (ECWmax) - 1); | 238 return static_cast<uint32_t> (exp2 (ECWmax) - 1); |
288 } | 239 } |
289 | 240 |
290 uint16_t | 241 uint16_t |
291 EdcaParameterSet::GetBkTXOPLimit (void) const | 242 EdcaParameterSet::GetBkTXOPLimit (void) const |
292 { | 243 { |
293 return (m_acBK >> 16); | 244 return (m_acBK >> 16); |
294 } | 245 } |
295 | 246 |
296 uint8_t | 247 uint8_t |
297 EdcaParameterSet::GetViAifsn (void) const | 248 EdcaParameterSet::GetViAifsn (void) const |
298 { | 249 { |
299 return (m_acVI & 0x0f); | 250 return (m_acVI & 0x0f); |
300 } | 251 } |
301 | 252 |
302 uint8_t | 253 uint32_t |
303 EdcaParameterSet::GetViAcm (void) const | |
304 { | |
305 return ((m_acVI >> 4) & 0x01); | |
306 } | |
307 | |
308 uint8_t | |
309 EdcaParameterSet::GetViAci (void) const | |
310 { | |
311 return ((m_acVI >> 5) & 0x03); | |
312 } | |
313 | |
314 uint8_t | |
315 EdcaParameterSet::GetViCWmin (void) const | 254 EdcaParameterSet::GetViCWmin (void) const |
316 { | 255 { |
317 uint8_t ECWmin = ((m_acVI >> 8) & 0x0f); | 256 uint8_t ECWmin = ((m_acVI >> 8) & 0x0f); |
318 return (uint8_t)(exp2 (ECWmin) - 1); | 257 return static_cast<uint32_t> (exp2 (ECWmin) - 1); |
319 } | 258 } |
320 | 259 |
321 uint8_t | 260 uint32_t |
322 EdcaParameterSet::GetViCWmax (void) const | 261 EdcaParameterSet::GetViCWmax (void) const |
323 { | 262 { |
324 uint8_t ECWmax = ((m_acVI >> 12) & 0x0f); | 263 uint8_t ECWmax = ((m_acVI >> 12) & 0x0f); |
325 return (uint8_t)(exp2 (ECWmax) - 1); | 264 return static_cast<uint32_t> (exp2 (ECWmax) - 1); |
326 } | 265 } |
327 | 266 |
328 uint16_t | 267 uint16_t |
329 EdcaParameterSet::GetViTXOPLimit (void) const | 268 EdcaParameterSet::GetViTXOPLimit (void) const |
330 { | 269 { |
331 return (m_acVI >> 16); | 270 return (m_acVI >> 16); |
332 } | 271 } |
333 | 272 |
334 uint8_t | 273 uint8_t |
335 EdcaParameterSet::GetVoAifsn (void) const | 274 EdcaParameterSet::GetVoAifsn (void) const |
336 { | 275 { |
337 return (m_acVO & 0x0f); | 276 return (m_acVO & 0x0f); |
338 } | 277 } |
339 | 278 |
340 uint8_t | 279 uint32_t |
341 EdcaParameterSet::GetVoAcm (void) const | |
342 { | |
343 return ((m_acVO >> 4) & 0x01); | |
344 } | |
345 | |
346 uint8_t | |
347 EdcaParameterSet::GetVoAci (void) const | |
348 { | |
349 return ((m_acVO >> 5) & 0x03); | |
350 } | |
351 | |
352 uint8_t | |
353 EdcaParameterSet::GetVoCWmin (void) const | 280 EdcaParameterSet::GetVoCWmin (void) const |
354 { | 281 { |
355 uint8_t ECWmin = ((m_acVO >> 8) & 0x0f); | 282 uint8_t ECWmin = ((m_acVO >> 8) & 0x0f); |
356 return (uint8_t)(exp2 (ECWmin) - 1); | 283 return static_cast<uint32_t> (exp2 (ECWmin) - 1); |
357 } | 284 } |
358 | 285 |
359 uint8_t | 286 uint32_t |
360 EdcaParameterSet::GetVoCWmax (void) const | 287 EdcaParameterSet::GetVoCWmax (void) const |
361 { | 288 { |
362 uint8_t ECWmax = ((m_acVO >> 12) & 0x0f); | 289 uint8_t ECWmax = ((m_acVO >> 12) & 0x0f); |
363 return (uint8_t)(exp2 (ECWmax) - 1); | 290 return static_cast<uint32_t> (exp2 (ECWmax) - 1); |
364 } | 291 } |
365 | 292 |
366 uint16_t | 293 uint16_t |
367 EdcaParameterSet::GetVoTXOPLimit (void) const | 294 EdcaParameterSet::GetVoTXOPLimit (void) const |
368 { | 295 { |
369 return (m_acVO >> 16); | 296 return (m_acVO >> 16); |
370 } | 297 } |
371 | 298 |
372 uint8_t | 299 uint8_t |
373 EdcaParameterSet::GetInformationFieldSize () const | 300 EdcaParameterSet::GetInformationFieldSize () const |
(...skipping 20 matching lines...) Expand all Loading... |
394 return 0; | 321 return 0; |
395 } | 322 } |
396 return WifiInformationElement::GetSerializedSize (); | 323 return WifiInformationElement::GetSerializedSize (); |
397 } | 324 } |
398 | 325 |
399 void | 326 void |
400 EdcaParameterSet::SerializeInformationField (Buffer::Iterator start) const | 327 EdcaParameterSet::SerializeInformationField (Buffer::Iterator start) const |
401 { | 328 { |
402 if (m_qosSupported) | 329 if (m_qosSupported) |
403 { | 330 { |
404 start.WriteU8 (m_qosInfo); | 331 start.WriteU8 (GetQosInfo ()); |
405 start.WriteU8 (m_reserved); | 332 start.WriteU8 (m_reserved); |
406 start.WriteU32 (m_acBE); | 333 start.WriteU32 (m_acBE); |
407 start.WriteU32 (m_acBK); | 334 start.WriteU32 (m_acBK); |
408 start.WriteU32 (m_acVI); | 335 start.WriteU32 (m_acVI); |
409 start.WriteU32 (m_acVO); | 336 start.WriteU32 (m_acVO); |
410 } | 337 } |
411 } | 338 } |
412 | 339 |
413 uint8_t | 340 uint8_t |
414 EdcaParameterSet::DeserializeInformationField (Buffer::Iterator start, uint8_t l
ength) | 341 EdcaParameterSet::DeserializeInformationField (Buffer::Iterator start, uint8_t l
ength) |
415 { | 342 { |
416 Buffer::Iterator i = start; | 343 Buffer::Iterator i = start; |
417 m_qosInfo = i.ReadU8 (); | 344 m_qosInfo = i.ReadU8 (); |
418 m_reserved = i.ReadU8 (); | 345 m_reserved = i.ReadU8 (); |
419 m_acBE = i.ReadU32 (); | 346 m_acBE = i.ReadU32 (); |
420 m_acBK = i.ReadU32 (); | 347 m_acBK = i.ReadU32 (); |
421 m_acVI = i.ReadU32 (); | 348 m_acVI = i.ReadU32 (); |
422 m_acVO = i.ReadU32 (); | 349 m_acVO = i.ReadU32 (); |
423 return length; | 350 return length; |
424 } | 351 } |
425 | 352 |
426 /// EdcaParameterSet | |
427 ATTRIBUTE_HELPER_CPP (EdcaParameterSet); | |
428 | |
429 /** | |
430 * output operator | |
431 * | |
432 * \param os output stream | |
433 * \param edcaParameterSet | |
434 * | |
435 * \return output stream | |
436 */ | |
437 std::ostream & operator << (std::ostream &os, const EdcaParameterSet &edcaParame
terSet) | |
438 { | |
439 NS_UNUSED(edcaParameterSet); | |
440 return os; | |
441 } | |
442 | |
443 /** | |
444 * input operator | |
445 * | |
446 * \param is input stream | |
447 * \param edcaParameterSet | |
448 * | |
449 * \return output stream | |
450 */ | |
451 std::istream &operator >> (std::istream &is, EdcaParameterSet &edcaParameterSet) | |
452 { | |
453 NS_UNUSED(edcaParameterSet); | |
454 return is; | |
455 } | |
456 | |
457 } //namespace ns3 | 353 } //namespace ns3 |
LEFT | RIGHT |