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) 2009 MIRKO BANCHI | 3 * Copyright (c) 2009 MIRKO BANCHI |
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 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 uint32_t | 66 uint32_t |
67 CtrlBAckRequestHeader::GetSerializedSize () const | 67 CtrlBAckRequestHeader::GetSerializedSize () const |
68 { | 68 { |
69 uint32_t size = 0; | 69 uint32_t size = 0; |
70 size += 2; //Bar control | 70 size += 2; //Bar control |
71 if (!m_multiTid) | 71 if (!m_multiTid) |
72 { | 72 { |
73 size += 2; //Starting sequence control | 73 size += 2; //Starting sequence control |
74 } | 74 } |
75 else | 75 else if (m_compressed) |
76 { | 76 { |
77 if (m_compressed) | 77 size += (2 + 2) * (m_tidInfo + 1); //Multi-tid block ack |
78 { | 78 } |
79 size += (2 + 2) * (m_tidInfo + 1); //Multi-tid block ack | 79 else |
80 } | 80 { |
81 else | 81 NS_FATAL_ERROR ("Reserved configuration."); |
82 { | |
83 NS_FATAL_ERROR ("Reserved configuration."); | |
84 } | |
85 } | 82 } |
86 return size; | 83 return size; |
87 } | 84 } |
88 | 85 |
89 void | 86 void |
90 CtrlBAckRequestHeader::Serialize (Buffer::Iterator start) const | 87 CtrlBAckRequestHeader::Serialize (Buffer::Iterator start) const |
91 { | 88 { |
92 Buffer::Iterator i = start; | 89 Buffer::Iterator i = start; |
93 i.WriteHtolsbU16 (GetBarControl ()); | 90 i.WriteHtolsbU16 (GetBarControl ()); |
94 if (!m_multiTid) | 91 if (!m_multiTid) |
95 { | 92 { |
96 i.WriteHtolsbU16 (GetStartingSequenceControl ()); | 93 i.WriteHtolsbU16 (GetStartingSequenceControl ()); |
97 } | 94 } |
98 else | 95 else if (m_compressed) |
99 { | 96 { |
100 if (m_compressed) | 97 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
101 { | 98 } |
102 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 99 else |
103 } | 100 { |
104 else | 101 NS_FATAL_ERROR ("Reserved configuration."); |
105 { | |
106 NS_FATAL_ERROR ("Reserved configuration."); | |
107 } | |
108 } | 102 } |
109 } | 103 } |
110 | 104 |
111 uint32_t | 105 uint32_t |
112 CtrlBAckRequestHeader::Deserialize (Buffer::Iterator start) | 106 CtrlBAckRequestHeader::Deserialize (Buffer::Iterator start) |
113 { | 107 { |
114 Buffer::Iterator i = start; | 108 Buffer::Iterator i = start; |
115 SetBarControl (i.ReadLsbtohU16 ()); | 109 SetBarControl (i.ReadLsbtohU16 ()); |
116 if (!m_multiTid) | 110 if (!m_multiTid) |
117 { | 111 { |
118 SetStartingSequenceControl (i.ReadLsbtohU16 ()); | 112 SetStartingSequenceControl (i.ReadLsbtohU16 ()); |
119 } | 113 } |
120 else | 114 else if (m_compressed) |
121 { | 115 { |
122 if (m_compressed) | 116 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
123 { | 117 } |
124 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 118 else |
125 } | 119 { |
126 else | 120 NS_FATAL_ERROR ("Reserved configuration."); |
127 { | |
128 NS_FATAL_ERROR ("Reserved configuration."); | |
129 } | |
130 } | 121 } |
131 return i.GetDistanceFrom (start); | 122 return i.GetDistanceFrom (start); |
132 } | 123 } |
133 | 124 |
134 uint16_t | 125 uint16_t |
135 CtrlBAckRequestHeader::GetBarControl (void) const | 126 CtrlBAckRequestHeader::GetBarControl (void) const |
136 { | 127 { |
137 uint16_t res = 0; | 128 uint16_t res = 0; |
138 if (m_barAckPolicy) | 129 if (m_barAckPolicy) |
139 { | 130 { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 void | 316 void |
326 CtrlBAckResponseHeader::Serialize (Buffer::Iterator start) const | 317 CtrlBAckResponseHeader::Serialize (Buffer::Iterator start) const |
327 { | 318 { |
328 Buffer::Iterator i = start; | 319 Buffer::Iterator i = start; |
329 i.WriteHtolsbU16 (GetBaControl ()); | 320 i.WriteHtolsbU16 (GetBaControl ()); |
330 if (!m_multiTid) | 321 if (!m_multiTid) |
331 { | 322 { |
332 i.WriteHtolsbU16 (GetStartingSequenceControl ()); | 323 i.WriteHtolsbU16 (GetStartingSequenceControl ()); |
333 i = SerializeBitmap (i); | 324 i = SerializeBitmap (i); |
334 } | 325 } |
335 else | 326 else if (m_compressed) |
336 { | 327 { |
337 if (m_compressed) | 328 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
338 { | 329 } |
339 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 330 else |
340 } | 331 { |
341 else | 332 NS_FATAL_ERROR ("Reserved configuration."); |
342 { | |
343 NS_FATAL_ERROR ("Reserved configuration."); | |
344 } | |
345 } | 333 } |
346 } | 334 } |
347 | 335 |
348 uint32_t | 336 uint32_t |
349 CtrlBAckResponseHeader::Deserialize (Buffer::Iterator start) | 337 CtrlBAckResponseHeader::Deserialize (Buffer::Iterator start) |
350 { | 338 { |
351 Buffer::Iterator i = start; | 339 Buffer::Iterator i = start; |
352 SetBaControl (i.ReadLsbtohU16 ()); | 340 SetBaControl (i.ReadLsbtohU16 ()); |
353 if (!m_multiTid) | 341 if (!m_multiTid) |
354 { | 342 { |
355 SetStartingSequenceControl (i.ReadLsbtohU16 ()); | 343 SetStartingSequenceControl (i.ReadLsbtohU16 ()); |
356 i = DeserializeBitmap (i); | 344 i = DeserializeBitmap (i); |
357 } | 345 } |
358 else | 346 else if (m_compressed) |
359 { | 347 { |
360 if (m_compressed) | 348 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
361 { | 349 } |
362 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 350 else |
363 } | 351 { |
364 else | 352 NS_FATAL_ERROR ("Reserved configuration."); |
365 { | |
366 NS_FATAL_ERROR ("Reserved configuration."); | |
367 } | |
368 } | 353 } |
369 return i.GetDistanceFrom (start); | 354 return i.GetDistanceFrom (start); |
370 } | 355 } |
371 | 356 |
372 void | 357 void |
373 CtrlBAckResponseHeader::SetHtImmediateAck (bool immediateAck) | 358 CtrlBAckResponseHeader::SetHtImmediateAck (bool immediateAck) |
374 { | 359 { |
375 m_baAckPolicy = immediateAck; | 360 m_baAckPolicy = immediateAck; |
376 } | 361 } |
377 | 362 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); | 667 NS_FATAL_ERROR ("Multi-tid block ack is not supported."); |
683 } | 668 } |
684 else | 669 else |
685 { | 670 { |
686 NS_FATAL_ERROR ("Reserved configuration."); | 671 NS_FATAL_ERROR ("Reserved configuration."); |
687 } | 672 } |
688 } | 673 } |
689 return false; | 674 return false; |
690 } | 675 } |
691 | 676 |
692 uint8_t | 677 uint16_t |
693 CtrlBAckResponseHeader::IndexInBitmap (uint16_t seq) const | 678 CtrlBAckResponseHeader::IndexInBitmap (uint16_t seq) const |
694 { | 679 { |
695 uint8_t index; | 680 uint16_t index; |
696 if (seq >= m_startingSeq) | 681 if (seq >= m_startingSeq) |
697 { | 682 { |
698 index = static_cast<uint8_t> (seq - m_startingSeq); | 683 index = seq - m_startingSeq; |
699 } | 684 } |
700 else | 685 else |
701 { | 686 { |
702 index = static_cast<uint8_t> (4096 - m_startingSeq + seq); | 687 index = 4096 - m_startingSeq + seq; |
703 } | 688 } |
704 NS_ASSERT (index <= 63); | 689 NS_ASSERT (index <= 63); |
705 return index; | 690 return index; |
706 } | 691 } |
707 | 692 |
708 bool | 693 bool |
709 CtrlBAckResponseHeader::IsInBitmap (uint16_t seq) const | 694 CtrlBAckResponseHeader::IsInBitmap (uint16_t seq) const |
710 { | 695 { |
711 return (seq - m_startingSeq + 4096) % 4096 < 64; | 696 return (seq - m_startingSeq + 4096) % 4096 < 64; |
712 } | 697 } |
(...skipping 10 matching lines...) Expand all Loading... |
723 return bitmap.m_compressedBitmap; | 708 return bitmap.m_compressedBitmap; |
724 } | 709 } |
725 | 710 |
726 void | 711 void |
727 CtrlBAckResponseHeader::ResetBitmap (void) | 712 CtrlBAckResponseHeader::ResetBitmap (void) |
728 { | 713 { |
729 memset (&bitmap, 0, sizeof (bitmap)); | 714 memset (&bitmap, 0, sizeof (bitmap)); |
730 } | 715 } |
731 | 716 |
732 } //namespace ns3 | 717 } //namespace ns3 |
LEFT | RIGHT |