|
20 |
* Author: Mirko Banchi <mk.banchi@gmail.com> |
20 |
* Author: Mirko Banchi <mk.banchi@gmail.com> |
21 |
*/ |
21 |
*/ |
22 |
#include "mgt-headers.h" |
22 |
#include "mgt-headers.h" |
|
|
23 |
#include "wifi-information-element-vector.h" |
23 |
#include "ns3/simulator.h" |
24 |
#include "ns3/simulator.h" |
24 |
#include "ns3/assert.h" |
25 |
#include "ns3/assert.h" |
25 |
|
26 |
|
|
36 |
} |
37 |
} |
37 |
|
38 |
|
38 |
void |
39 |
void |
|
|
40 |
MgtProbeRequestHeader::AddInformationElement (Ptr<WifiInformationElement> ie) |
41 |
{ |
42 |
m_elements.AddInformationElement (ie); |
43 |
} |
44 |
|
45 |
void |
39 |
MgtProbeRequestHeader::SetSsid (Ssid ssid) |
46 |
MgtProbeRequestHeader::SetSsid (Ssid ssid) |
40 |
{ |
47 |
{ |
41 |
m_ssid = ssid; |
48 |
m_ssid = ssid; |
|
51 |
m_rates = rates; |
58 |
m_rates = rates; |
52 |
} |
59 |
} |
53 |
void |
60 |
void |
54 |
MgtProbeRequestHeader::SetHtCapabilities(HtCapabilities htcapabilities) |
61 |
MgtProbeRequestHeader::SetHtCapabilities(Ptr<HtCapabilities> htcapabilities) |
55 |
{ |
62 |
{ |
56 |
m_htCapability=htcapabilities; |
63 |
//m_htCapability = htcapabilities; |
|
|
64 |
m_elements.AddInformationElement (htcapabilities); |
57 |
} |
65 |
} |
58 |
|
66 |
|
59 |
HtCapabilities |
67 |
Ptr<HtCapabilities> |
60 |
MgtProbeRequestHeader::GetHtCapabilities (void) const |
68 |
MgtProbeRequestHeader::GetHtCapabilities (void) const |
61 |
{ |
69 |
{ |
62 |
return m_htCapability; |
70 |
//return m_htCapability; |
|
|
71 |
Ptr<WifiInformationElement> wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); |
72 |
Ptr<HtCapabilities> ht = DynamicCast<HtCapabilities> (wifiIe); |
73 |
return ht; |
63 |
} |
74 |
} |
64 |
SupportedRates |
75 |
SupportedRates |
65 |
MgtProbeRequestHeader::GetSupportedRates (void) const |
76 |
MgtProbeRequestHeader::GetSupportedRates (void) const |
|
73 |
size += m_ssid.GetSerializedSize (); |
84 |
size += m_ssid.GetSerializedSize (); |
74 |
size += m_rates.GetSerializedSize (); |
85 |
size += m_rates.GetSerializedSize (); |
75 |
size += m_rates.extended.GetSerializedSize (); |
86 |
size += m_rates.extended.GetSerializedSize (); |
76 |
size += m_htCapability.GetSerializedSize(); |
87 |
//size += m_htCapability.GetSerializedSize(); |
77 |
return size; |
88 |
return size; |
78 |
} |
89 |
} |
79 |
TypeId |
90 |
TypeId |
|
94 |
MgtProbeRequestHeader::Print (std::ostream &os) const |
105 |
MgtProbeRequestHeader::Print (std::ostream &os) const |
95 |
{ |
106 |
{ |
96 |
os << "ssid=" << m_ssid << ", " |
107 |
os << "ssid=" << m_ssid << ", " |
97 |
<< "rates=" << m_rates << ", " |
108 |
// << "rates=" << m_rates << ", " |
98 |
<< "HT Capabilities=" << m_htCapability; |
109 |
// << "HT Capabilities=" << m_htCapability; |
|
|
110 |
<< "rates=" << m_rates; |
99 |
} |
111 |
} |
100 |
void |
112 |
void |
101 |
MgtProbeRequestHeader::Serialize (Buffer::Iterator start) const |
113 |
MgtProbeRequestHeader::Serialize (Buffer::Iterator start) const |
|
104 |
i = m_ssid.Serialize (i); |
116 |
i = m_ssid.Serialize (i); |
105 |
i = m_rates.Serialize (i); |
117 |
i = m_rates.Serialize (i); |
106 |
i = m_rates.extended.Serialize (i); |
118 |
i = m_rates.extended.Serialize (i); |
107 |
i = m_htCapability.Serialize(i); |
119 |
// i = m_htCapability.Serialize(i); |
108 |
} |
120 |
} |
109 |
uint32_t |
121 |
uint32_t |
110 |
MgtProbeRequestHeader::Deserialize (Buffer::Iterator start) |
122 |
MgtProbeRequestHeader::Deserialize (Buffer::Iterator start) |
|
113 |
i = m_ssid.Deserialize (i); |
125 |
i = m_ssid.Deserialize (i); |
114 |
i = m_rates.Deserialize (i); |
126 |
i = m_rates.Deserialize (i); |
115 |
i = m_rates.extended.DeserializeIfPresent (i); |
127 |
i = m_rates.extended.DeserializeIfPresent (i); |
116 |
i = m_htCapability.DeserializeIfPresent (i); |
128 |
// i = m_htCapability.DeserializeIfPresent (i); |
117 |
return i.GetDistanceFrom (start); |
129 |
return i.GetDistanceFrom (start); |
118 |
} |
130 |
} |
119 |
|
131 |
|
|
130 |
MgtProbeResponseHeader::~MgtProbeResponseHeader () |
142 |
MgtProbeResponseHeader::~MgtProbeResponseHeader () |
131 |
{ |
143 |
{ |
132 |
} |
144 |
} |
|
|
145 |
|
146 |
void |
147 |
MgtProbeResponseHeader::AddInformationElement (Ptr<WifiInformationElement> ie) |
148 |
{ |
149 |
m_elements.AddInformationElement (ie); |
150 |
} |
151 |
|
133 |
uint64_t |
152 |
uint64_t |
134 |
MgtProbeResponseHeader::GetTimestamp () |
153 |
MgtProbeResponseHeader::GetTimestamp () |
135 |
{ |
154 |
{ |
|
151 |
return m_rates; |
170 |
return m_rates; |
152 |
} |
171 |
} |
153 |
void |
172 |
void |
154 |
MgtProbeResponseHeader::SetHtCapabilities(HtCapabilities htcapabilities) |
173 |
MgtProbeResponseHeader::SetHtCapabilities(Ptr<HtCapabilities> htcapabilities) |
155 |
{ |
174 |
{ |
156 |
m_htCapability=htcapabilities; |
175 |
//m_htCapability = htcapabilities; |
|
|
176 |
m_elements.AddInformationElement (htcapabilities); |
157 |
} |
177 |
} |
158 |
|
178 |
|
159 |
HtCapabilities |
179 |
Ptr<HtCapabilities> |
160 |
MgtProbeResponseHeader::GetHtCapabilities (void) const |
180 |
MgtProbeResponseHeader::GetHtCapabilities (void) const |
161 |
{ |
181 |
{ |
162 |
return m_htCapability; |
182 |
//return m_htCapability; |
|
|
183 |
Ptr<WifiInformationElement> wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); |
184 |
Ptr<HtCapabilities> ht = DynamicCast<HtCapabilities> (wifiIe); |
185 |
return ht; |
163 |
} |
186 |
} |
164 |
void |
187 |
void |
165 |
MgtProbeResponseHeader::SetSsid (Ssid ssid) |
188 |
MgtProbeResponseHeader::SetSsid (Ssid ssid) |
|
201 |
size += m_rates.GetSerializedSize (); |
224 |
size += m_rates.GetSerializedSize (); |
202 |
//size += 3; // ds parameter set |
225 |
//size += 3; // ds parameter set |
203 |
size += m_rates.extended.GetSerializedSize (); |
226 |
size += m_rates.extended.GetSerializedSize (); |
204 |
size += m_htCapability.GetSerializedSize(); |
227 |
//size += m_htCapability.GetSerializedSize(); |
205 |
// xxx |
228 |
// xxx |
206 |
return size; |
229 |
return size; |
207 |
} |
230 |
} |
|
209 |
MgtProbeResponseHeader::Print (std::ostream &os) const |
232 |
MgtProbeResponseHeader::Print (std::ostream &os) const |
210 |
{ |
233 |
{ |
211 |
os << "ssid=" << m_ssid << ", " |
234 |
os << "ssid=" << m_ssid << ", " |
212 |
<< "rates=" << m_rates << ", " |
235 |
// << "rates=" << m_rates << ", " |
213 |
<< "HT Capabilities=" << m_htCapability; |
236 |
// << "HT Capabilities=" << m_htCapability; |
|
|
237 |
<< "rates=" << m_rates; |
214 |
} |
238 |
} |
215 |
void |
239 |
void |
216 |
MgtProbeResponseHeader::Serialize (Buffer::Iterator start) const |
240 |
MgtProbeResponseHeader::Serialize (Buffer::Iterator start) const |
|
233 |
i = m_rates.Serialize (i); |
257 |
i = m_rates.Serialize (i); |
234 |
//i.WriteU8 (0, 3); // ds parameter set. |
258 |
//i.WriteU8 (0, 3); // ds parameter set. |
235 |
i = m_rates.extended.Serialize (i); |
259 |
i = m_rates.extended.Serialize (i); |
236 |
i = m_htCapability.Serialize(i); |
260 |
//i = m_htCapability.Serialize(i); |
237 |
} |
261 |
} |
238 |
uint32_t |
262 |
uint32_t |
239 |
MgtProbeResponseHeader::Deserialize (Buffer::Iterator start) |
263 |
MgtProbeResponseHeader::Deserialize (Buffer::Iterator start) |
|
247 |
i = m_rates.Deserialize (i); |
271 |
i = m_rates.Deserialize (i); |
248 |
//i.Next (3); // ds parameter set |
272 |
//i.Next (3); // ds parameter set |
249 |
i = m_rates.extended.DeserializeIfPresent (i); |
273 |
i = m_rates.extended.DeserializeIfPresent (i); |
250 |
i = m_htCapability.DeserializeIfPresent (i); |
274 |
//i = m_htCapability.DeserializeIfPresent (i); |
251 |
return i.GetDistanceFrom (start); |
275 |
return i.GetDistanceFrom (start); |
252 |
} |
276 |
} |
253 |
|
277 |
|
|
266 |
} |
290 |
} |
267 |
|
291 |
|
268 |
void |
292 |
void |
|
|
293 |
MgtAssocRequestHeader::AddInformationElement (Ptr<WifiInformationElement> ie) |
294 |
{ |
295 |
m_elements.AddInformationElement (ie); |
296 |
} |
297 |
|
298 |
void |
269 |
MgtAssocRequestHeader::SetSsid (Ssid ssid) |
299 |
MgtAssocRequestHeader::SetSsid (Ssid ssid) |
270 |
{ |
300 |
{ |
271 |
m_ssid = ssid; |
301 |
m_ssid = ssid; |
|
276 |
m_rates = rates; |
306 |
m_rates = rates; |
277 |
} |
307 |
} |
278 |
void |
308 |
void |
279 |
MgtAssocRequestHeader::SetHtCapabilities(HtCapabilities htcapabilities) |
309 |
MgtAssocRequestHeader::SetHtCapabilities(Ptr<HtCapabilities> htcapabilities) |
280 |
{ |
310 |
{ |
281 |
m_htCapability = htcapabilities; |
311 |
//m_htCapability = htcapabilities; |
|
|
312 |
m_elements.AddInformationElement (htcapabilities); |
282 |
} |
313 |
} |
283 |
void |
314 |
void |
284 |
MgtAssocRequestHeader::SetListenInterval (uint16_t interval) |
315 |
MgtAssocRequestHeader::SetListenInterval (uint16_t interval) |
285 |
{ |
316 |
{ |
286 |
m_listenInterval = interval; |
317 |
m_listenInterval = interval; |
287 |
} |
318 |
} |
288 |
HtCapabilities |
319 |
Ptr<HtCapabilities> |
289 |
MgtAssocRequestHeader::GetHtCapabilities (void) const |
320 |
MgtAssocRequestHeader::GetHtCapabilities (void) const |
290 |
{ |
321 |
{ |
291 |
return m_htCapability; |
322 |
//return m_htCapability; |
|
|
323 |
Ptr<WifiInformationElement> wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); |
324 |
Ptr<HtCapabilities> ht = DynamicCast<HtCapabilities> (wifiIe); |
325 |
return ht; |
292 |
} |
326 |
} |
293 |
Ssid |
327 |
Ssid |
294 |
MgtAssocRequestHeader::GetSsid (void) const |
328 |
MgtAssocRequestHeader::GetSsid (void) const |
|
328 |
size += 2; |
362 |
size += 2; |
329 |
size += m_ssid.GetSerializedSize (); |
363 |
size += m_ssid.GetSerializedSize (); |
330 |
size += m_rates.GetSerializedSize (); |
364 |
size += m_rates.GetSerializedSize (); |
331 |
size += m_htCapability.GetSerializedSize(); |
365 |
//size += m_htCapability.GetSerializedSize(); |
332 |
size += m_rates.extended.GetSerializedSize (); |
366 |
size += m_rates.extended.GetSerializedSize (); |
333 |
return size; |
367 |
return size; |
334 |
} |
368 |
} |
|
336 |
MgtAssocRequestHeader::Print (std::ostream &os) const |
370 |
MgtAssocRequestHeader::Print (std::ostream &os) const |
337 |
{ |
371 |
{ |
338 |
os << "ssid=" << m_ssid << ", " |
372 |
os << "ssid=" << m_ssid << ", " |
339 |
<< "rates=" << m_rates<< ", " |
373 |
// << "rates=" << m_rates<< ", " |
340 |
<< "HT Capabilities=" << m_htCapability; |
374 |
// << "HT Capabilities=" << m_htCapability; |
|
|
375 |
<< "rates=" << m_rates; |
341 |
} |
376 |
} |
342 |
void |
377 |
void |
343 |
MgtAssocRequestHeader::Serialize (Buffer::Iterator start) const |
378 |
MgtAssocRequestHeader::Serialize (Buffer::Iterator start) const |
|
348 |
i = m_ssid.Serialize (i); |
383 |
i = m_ssid.Serialize (i); |
349 |
i = m_rates.Serialize (i); |
384 |
i = m_rates.Serialize (i); |
350 |
i = m_rates.extended.Serialize (i); |
385 |
i = m_rates.extended.Serialize (i); |
351 |
i = m_htCapability.Serialize(i); |
386 |
//i = m_htCapability.Serialize(i); |
352 |
} |
387 |
} |
353 |
uint32_t |
388 |
uint32_t |
354 |
MgtAssocRequestHeader::Deserialize (Buffer::Iterator start) |
389 |
MgtAssocRequestHeader::Deserialize (Buffer::Iterator start) |
|
359 |
i = m_ssid.Deserialize (i); |
394 |
i = m_ssid.Deserialize (i); |
360 |
i = m_rates.Deserialize (i); |
395 |
i = m_rates.Deserialize (i); |
361 |
i = m_rates.extended.DeserializeIfPresent (i); |
396 |
i = m_rates.extended.DeserializeIfPresent (i); |
362 |
i = m_htCapability.DeserializeIfPresent (i); |
397 |
//i = m_htCapability.DeserializeIfPresent (i); |
363 |
return i.GetDistanceFrom (start); |
398 |
return i.GetDistanceFrom (start); |
364 |
} |
399 |
} |
365 |
|
400 |
|
|
377 |
{ |
412 |
{ |
378 |
} |
413 |
} |
379 |
|
414 |
|
|
|
415 |
void |
416 |
MgtAssocResponseHeader::AddInformationElement (Ptr<WifiInformationElement> ie) |
417 |
{ |
418 |
m_elements.AddInformationElement (ie); |
419 |
} |
420 |
|
380 |
StatusCode |
421 |
StatusCode |
381 |
MgtAssocResponseHeader::GetStatusCode (void) |
422 |
MgtAssocResponseHeader::GetStatusCode (void) |
382 |
{ |
423 |
{ |
|
398 |
m_rates = rates; |
439 |
m_rates = rates; |
399 |
} |
440 |
} |
400 |
void |
441 |
void |
401 |
MgtAssocResponseHeader::SetHtCapabilities(HtCapabilities htcapabilities) |
442 |
MgtAssocResponseHeader::SetHtCapabilities(Ptr<HtCapabilities> htcapabilities) |
402 |
{ |
443 |
{ |
403 |
m_htCapability=htcapabilities; |
444 |
//m_htCapability=htcapabilities; |
|
|
445 |
m_elements.AddInformationElement (htcapabilities); |
404 |
} |
446 |
} |
405 |
|
447 |
|
406 |
HtCapabilities |
448 |
Ptr<HtCapabilities> |
407 |
MgtAssocResponseHeader::GetHtCapabilities (void) const |
449 |
MgtAssocResponseHeader::GetHtCapabilities (void) const |
408 |
{ |
450 |
{ |
409 |
return m_htCapability; |
451 |
// return m_htCapability; |
|
|
452 |
Ptr<WifiInformationElement> wifiIe = m_elements.FindFirst (IE_HT_CAPABILITIES); |
453 |
Ptr<HtCapabilities> ht = DynamicCast<HtCapabilities> (wifiIe); |
454 |
return ht; |
410 |
} |
455 |
} |
411 |
TypeId |
456 |
TypeId |
412 |
MgtAssocResponseHeader::GetTypeId (void) |
457 |
MgtAssocResponseHeader::GetTypeId (void) |
|
431 |
size += 2; // aid |
476 |
size += 2; // aid |
432 |
size += m_rates.GetSerializedSize (); |
477 |
size += m_rates.GetSerializedSize (); |
433 |
size += m_rates.extended.GetSerializedSize (); |
478 |
size += m_rates.extended.GetSerializedSize (); |
434 |
size += m_htCapability.GetSerializedSize(); |
479 |
//size += m_htCapability.GetSerializedSize(); |
435 |
return size; |
480 |
return size; |
436 |
} |
481 |
} |
437 |
|
482 |
|
|
439 |
MgtAssocResponseHeader::Print (std::ostream &os) const |
484 |
MgtAssocResponseHeader::Print (std::ostream &os) const |
440 |
{ |
485 |
{ |
441 |
os << "status code=" << m_code << ", " |
486 |
os << "status code=" << m_code << ", " |
442 |
<< "rates=" << m_rates << ", " |
487 |
// << "rates=" << m_rates << ", " |
443 |
<< "HT Capabilities=" << m_htCapability; |
488 |
// << "HT Capabilities=" << m_htCapability; |
|
|
489 |
<< "rates=" << m_rates; |
444 |
} |
490 |
} |
445 |
void |
491 |
void |
446 |
MgtAssocResponseHeader::Serialize (Buffer::Iterator start) const |
492 |
MgtAssocResponseHeader::Serialize (Buffer::Iterator start) const |
|
451 |
i.WriteHtolsbU16 (m_aid); |
497 |
i.WriteHtolsbU16 (m_aid); |
452 |
i = m_rates.Serialize (i); |
498 |
i = m_rates.Serialize (i); |
453 |
i = m_rates.extended.Serialize (i); |
499 |
i = m_rates.extended.Serialize (i); |
454 |
i = m_htCapability.Serialize(i); |
500 |
//i = m_htCapability.Serialize(i); |
455 |
} |
501 |
} |
456 |
uint32_t |
502 |
uint32_t |
457 |
MgtAssocResponseHeader::Deserialize (Buffer::Iterator start) |
503 |
MgtAssocResponseHeader::Deserialize (Buffer::Iterator start) |
|
462 |
m_aid = i.ReadLsbtohU16 (); |
508 |
m_aid = i.ReadLsbtohU16 (); |
463 |
i = m_rates.Deserialize (i); |
509 |
i = m_rates.Deserialize (i); |
464 |
i = m_rates.extended.DeserializeIfPresent (i); |
510 |
i = m_rates.extended.DeserializeIfPresent (i); |
465 |
i = m_htCapability.DeserializeIfPresent (i); |
511 |
//i = m_htCapability.DeserializeIfPresent (i); |
466 |
return i.GetDistanceFrom (start); |
512 |
return i.GetDistanceFrom (start); |
467 |
} |
513 |
} |
468 |
/********************************************************** |
514 |
/********************************************************** |