A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mgt-headers.cc
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #include "mgt-headers.h"
23 #include "ns3/simulator.h"
24 #include "ns3/assert.h"
25 
26 namespace ns3 {
27 
28 /***********************************************************
29  * Probe Request
30  ***********************************************************/
31 
32 NS_OBJECT_ENSURE_REGISTERED (MgtProbeRequestHeader);
33 
34 MgtProbeRequestHeader::~MgtProbeRequestHeader ()
35 {
36 }
37 
38 void
39 MgtProbeRequestHeader::SetSsid (Ssid ssid)
40 {
41  m_ssid = ssid;
42 }
43 Ssid
44 MgtProbeRequestHeader::GetSsid (void) const
45 {
46  return m_ssid;
47 }
48 void
49 MgtProbeRequestHeader::SetSupportedRates (SupportedRates rates)
50 {
51  m_rates = rates;
52 }
53 
54 SupportedRates
55 MgtProbeRequestHeader::GetSupportedRates (void) const
56 {
57  return m_rates;
58 }
59 uint32_t
61 {
62  uint32_t size = 0;
63  size += m_ssid.GetSerializedSize ();
64  size += m_rates.GetSerializedSize ();
65  size += m_rates.extended.GetSerializedSize ();
66  return size;
67 }
68 TypeId
69 MgtProbeRequestHeader::GetTypeId (void)
70 {
71  static TypeId tid = TypeId ("ns3::MgtProbeRequestHeader")
72  .SetParent<Header> ()
73  .AddConstructor<MgtProbeRequestHeader> ()
74  ;
75  return tid;
76 }
77 TypeId
79 {
80  return GetTypeId ();
81 }
82 void
83 MgtProbeRequestHeader::Print (std::ostream &os) const
84 {
85  os << "ssid=" << m_ssid << ", "
86  << "rates=" << m_rates;
87 }
88 void
90 {
91  Buffer::Iterator i = start;
92  i = m_ssid.Serialize (i);
93  i = m_rates.Serialize (i);
94  i = m_rates.extended.Serialize (i);
95 }
96 uint32_t
98 {
99  Buffer::Iterator i = start;
100  i = m_ssid.Deserialize (i);
101  i = m_rates.Deserialize (i);
102  i = m_rates.extended.DeserializeIfPresent (i);
103  return i.GetDistanceFrom (start);
104 }
105 
106 
107 /***********************************************************
108  * Probe Response
109  ***********************************************************/
110 
111 NS_OBJECT_ENSURE_REGISTERED (MgtProbeResponseHeader);
112 
113 MgtProbeResponseHeader::MgtProbeResponseHeader ()
114 {
115 }
116 MgtProbeResponseHeader::~MgtProbeResponseHeader ()
117 {
118 }
119 uint64_t
120 MgtProbeResponseHeader::GetTimestamp ()
121 {
122  return m_timestamp;
123 }
124 Ssid
125 MgtProbeResponseHeader::GetSsid (void) const
126 {
127  return m_ssid;
128 }
129 uint64_t
130 MgtProbeResponseHeader::GetBeaconIntervalUs (void) const
131 {
132  return m_beaconInterval;
133 }
134 SupportedRates
135 MgtProbeResponseHeader::GetSupportedRates (void) const
136 {
137  return m_rates;
138 }
139 
140 void
141 MgtProbeResponseHeader::SetSsid (Ssid ssid)
142 {
143  m_ssid = ssid;
144 }
145 void
146 MgtProbeResponseHeader::SetBeaconIntervalUs (uint64_t us)
147 {
148  m_beaconInterval = us;
149 }
150 void
151 MgtProbeResponseHeader::SetSupportedRates (SupportedRates rates)
152 {
153  m_rates = rates;
154 }
155 TypeId
156 MgtProbeResponseHeader::GetTypeId (void)
157 {
158  static TypeId tid = TypeId ("ns3::MgtProbeResponseHeader")
159  .SetParent<Header> ()
160  .AddConstructor<MgtProbeResponseHeader> ()
161  ;
162  return tid;
163 }
164 TypeId
166 {
167  return GetTypeId ();
168 }
169 uint32_t
171 {
172  uint32_t size = 0;
173  size += 8; // timestamp
174  size += 2; // beacon interval
175  size += m_capability.GetSerializedSize ();
176  size += m_ssid.GetSerializedSize ();
177  size += m_rates.GetSerializedSize ();
178  //size += 3; // ds parameter set
179  size += m_rates.extended.GetSerializedSize ();
180  // xxx
181  return size;
182 }
183 void
184 MgtProbeResponseHeader::Print (std::ostream &os) const
185 {
186  os << "ssid=" << m_ssid << ", "
187  << "rates=" << m_rates;
188 }
189 void
191 {
192  // timestamp
193  // beacon interval
194  // capability information
195  // ssid
196  // supported rates
197  // fh parameter set
198  // ds parameter set
199  // cf parameter set
200  // ibss parameter set
201  //XXX
202  Buffer::Iterator i = start;
203  i.WriteHtolsbU64 (Simulator::Now ().GetMicroSeconds ());
204  i.WriteHtolsbU16 (m_beaconInterval / 1024);
205  i = m_capability.Serialize (i);
206  i = m_ssid.Serialize (i);
207  i = m_rates.Serialize (i);
208  //i.WriteU8 (0, 3); // ds parameter set.
209  i = m_rates.extended.Serialize (i);
210 }
211 uint32_t
213 {
214  Buffer::Iterator i = start;
215  m_timestamp = i.ReadLsbtohU64 ();
216  m_beaconInterval = i.ReadLsbtohU16 ();
217  m_beaconInterval *= 1024;
218  i = m_capability.Deserialize (i);
219  i = m_ssid.Deserialize (i);
220  i = m_rates.Deserialize (i);
221  //i.Next (3); // ds parameter set
222  i = m_rates.extended.DeserializeIfPresent (i);
223  return i.GetDistanceFrom (start);
224 }
225 
226 /***********************************************************
227  * Assoc Request
228  ***********************************************************/
229 
230 NS_OBJECT_ENSURE_REGISTERED (MgtAssocRequestHeader);
231 
232 MgtAssocRequestHeader::MgtAssocRequestHeader ()
233  : m_listenInterval (0)
234 {
235 }
236 MgtAssocRequestHeader::~MgtAssocRequestHeader ()
237 {
238 }
239 
240 void
241 MgtAssocRequestHeader::SetSsid (Ssid ssid)
242 {
243  m_ssid = ssid;
244 }
245 void
246 MgtAssocRequestHeader::SetSupportedRates (SupportedRates rates)
247 {
248  m_rates = rates;
249 }
250 void
251 MgtAssocRequestHeader::SetListenInterval (uint16_t interval)
252 {
253  m_listenInterval = interval;
254 }
255 Ssid
256 MgtAssocRequestHeader::GetSsid (void) const
257 {
258  return m_ssid;
259 }
260 SupportedRates
261 MgtAssocRequestHeader::GetSupportedRates (void) const
262 {
263  return m_rates;
264 }
265 uint16_t
266 MgtAssocRequestHeader::GetListenInterval (void) const
267 {
268  return m_listenInterval;
269 }
270 
271 TypeId
272 MgtAssocRequestHeader::GetTypeId (void)
273 {
274  static TypeId tid = TypeId ("ns3::MgtAssocRequestHeader")
275  .SetParent<Header> ()
276  .AddConstructor<MgtAssocRequestHeader> ()
277  ;
278  return tid;
279 }
280 TypeId
282 {
283  return GetTypeId ();
284 }
285 uint32_t
287 {
288  uint32_t size = 0;
289  size += m_capability.GetSerializedSize ();
290  size += 2;
291  size += m_ssid.GetSerializedSize ();
292  size += m_rates.GetSerializedSize ();
293  size += m_rates.extended.GetSerializedSize ();
294  return size;
295 }
296 void
297 MgtAssocRequestHeader::Print (std::ostream &os) const
298 {
299  os << "ssid=" << m_ssid << ", "
300  << "rates=" << m_rates;
301 }
302 void
304 {
305  Buffer::Iterator i = start;
306  i = m_capability.Serialize (i);
307  i.WriteHtolsbU16 (m_listenInterval);
308  i = m_ssid.Serialize (i);
309  i = m_rates.Serialize (i);
310  i = m_rates.extended.Serialize (i);
311 }
312 uint32_t
314 {
315  Buffer::Iterator i = start;
316  i = m_capability.Deserialize (i);
317  m_listenInterval = i.ReadLsbtohU16 ();
318  i = m_ssid.Deserialize (i);
319  i = m_rates.Deserialize (i);
320  i = m_rates.extended.DeserializeIfPresent (i);
321  return i.GetDistanceFrom (start);
322 }
323 
324 /***********************************************************
325  * Assoc Response
326  ***********************************************************/
327 
328 NS_OBJECT_ENSURE_REGISTERED (MgtAssocResponseHeader);
329 
330 MgtAssocResponseHeader::MgtAssocResponseHeader ()
331  : m_aid (0)
332 {
333 }
334 MgtAssocResponseHeader::~MgtAssocResponseHeader ()
335 {
336 }
337 
338 StatusCode
339 MgtAssocResponseHeader::GetStatusCode (void)
340 {
341  return m_code;
342 }
343 SupportedRates
344 MgtAssocResponseHeader::GetSupportedRates (void)
345 {
346  return m_rates;
347 }
348 void
349 MgtAssocResponseHeader::SetStatusCode (StatusCode code)
350 {
351  m_code = code;
352 }
353 void
354 MgtAssocResponseHeader::SetSupportedRates (SupportedRates rates)
355 {
356  m_rates = rates;
357 }
358 
359 TypeId
360 MgtAssocResponseHeader::GetTypeId (void)
361 {
362  static TypeId tid = TypeId ("ns3::MgtAssocResponseHeader")
363  .SetParent<Header> ()
364  .AddConstructor<MgtAssocResponseHeader> ()
365  ;
366  return tid;
367 }
368 TypeId
370 {
371  return GetTypeId ();
372 }
373 uint32_t
375 {
376  uint32_t size = 0;
377  size += m_capability.GetSerializedSize ();
378  size += m_code.GetSerializedSize ();
379  size += 2; // aid
380  size += m_rates.GetSerializedSize ();
381  size += m_rates.extended.GetSerializedSize ();
382  return size;
383 }
384 
385 void
386 MgtAssocResponseHeader::Print (std::ostream &os) const
387 {
388  os << "status code=" << m_code << ", "
389  << "rates=" << m_rates;
390 }
391 void
393 {
394  Buffer::Iterator i = start;
395  i = m_capability.Serialize (i);
396  i = m_code.Serialize (i);
397  i.WriteHtolsbU16 (m_aid);
398  i = m_rates.Serialize (i);
399  i = m_rates.extended.Serialize (i);
400 }
401 uint32_t
403 {
404  Buffer::Iterator i = start;
405  i = m_capability.Deserialize (i);
406  i = m_code.Deserialize (i);
407  m_aid = i.ReadLsbtohU16 ();
408  i = m_rates.Deserialize (i);
409  i = m_rates.extended.DeserializeIfPresent (i);
410  return i.GetDistanceFrom (start);
411 }
412 /**********************************************************
413  * ActionFrame
414  **********************************************************/
415 WifiActionHeader::WifiActionHeader ()
416 {
417 }
418 WifiActionHeader::~WifiActionHeader ()
419 {
420 }
421 void
422 WifiActionHeader::SetAction (WifiActionHeader::CategoryValue type,
423  WifiActionHeader::ActionValue action)
424 {
425  m_category = type;
426 
427  switch (type)
428  {
429  case BLOCK_ACK:
430  {
431  m_actionValue = action.blockAck;
432  break;
433  }
434  case MESH_PEERING_MGT:
435  {
436  m_actionValue = action.peerLink;
437  break;
438  }
439  case MESH_PATH_SELECTION:
440  {
441  m_actionValue = action.pathSelection;
442  break;
443  }
444  case MESH_LINK_METRIC:
445  case MESH_INTERWORKING:
446  case MESH_RESOURCE_COORDINATION:
447  case MESH_PROXY_FORWARDING:
448  break;
449  }
450 }
451 WifiActionHeader::CategoryValue
452 WifiActionHeader::GetCategory ()
453 {
454  switch (m_category)
455  {
456  case BLOCK_ACK:
457  return BLOCK_ACK;
458  case MESH_PEERING_MGT:
459  return MESH_PEERING_MGT;
460  case MESH_LINK_METRIC:
461  return MESH_LINK_METRIC;
462  case MESH_PATH_SELECTION:
463  return MESH_PATH_SELECTION;
464  case MESH_INTERWORKING:
465  return MESH_INTERWORKING;
466  case MESH_RESOURCE_COORDINATION:
467  return MESH_RESOURCE_COORDINATION;
468  case MESH_PROXY_FORWARDING:
469  return MESH_PROXY_FORWARDING;
470  default:
471  NS_FATAL_ERROR ("Unknown action value");
472  return MESH_PEERING_MGT;
473  }
474 }
475 WifiActionHeader::ActionValue
476 WifiActionHeader::GetAction ()
477 {
478  ActionValue retval;
479  retval.peerLink = PEER_LINK_OPEN; // Needs to be initialized to something to quiet valgrind in default cases
480  switch (m_category)
481  {
482  case BLOCK_ACK:
483  switch (m_actionValue)
484  {
485  case BLOCK_ACK_ADDBA_REQUEST:
486  retval.blockAck = BLOCK_ACK_ADDBA_REQUEST;
487  return retval;
488  case BLOCK_ACK_ADDBA_RESPONSE:
489  retval.blockAck = BLOCK_ACK_ADDBA_RESPONSE;
490  return retval;
491  case BLOCK_ACK_DELBA:
492  retval.blockAck = BLOCK_ACK_DELBA;
493  return retval;
494  }
495  case MESH_PEERING_MGT:
496  switch (m_actionValue)
497  {
498  case PEER_LINK_OPEN:
499  retval.peerLink = PEER_LINK_OPEN;
500  return retval;
501  case PEER_LINK_CONFIRM:
502  retval.peerLink = PEER_LINK_CONFIRM;
503  return retval;
504  case PEER_LINK_CLOSE:
505  retval.peerLink = PEER_LINK_CLOSE;
506  return retval;
507  default:
508  NS_FATAL_ERROR ("Unknown mesh peering management action code");
509  retval.peerLink = PEER_LINK_OPEN; /* quiet compiler */
510  return retval;
511  }
512  case MESH_PATH_SELECTION:
513  switch (m_actionValue)
514  {
515  case PATH_SELECTION:
516  retval.pathSelection = PATH_SELECTION;
517  return retval;
518  default:
519  NS_FATAL_ERROR ("Unknown mesh path selection action code");
520  retval.peerLink = PEER_LINK_OPEN; /* quiet compiler */
521  return retval;
522  }
523  case MESH_LINK_METRIC:
524  // not yet supported
525  case MESH_INTERWORKING:
526  // not yet supported
527  case MESH_RESOURCE_COORDINATION:
528  // not yet supported
529  default:
530  NS_FATAL_ERROR ("Unsupported mesh action");
531  retval.peerLink = PEER_LINK_OPEN; /* quiet compiler */
532  return retval;
533  }
534 }
535 TypeId
536 WifiActionHeader::GetTypeId ()
537 {
538  static TypeId tid = TypeId ("ns3::WifiActionHeader")
539  .SetParent<Header> ()
540  .AddConstructor<WifiActionHeader> ();
541  return tid;
542 }
543 TypeId
545 {
546  return GetTypeId ();
547 }
548 void
549 WifiActionHeader::Print (std::ostream &os) const
550 {
551 }
552 uint32_t
554 {
555  return 2;
556 }
557 void
559 {
560  start.WriteU8 (m_category);
561  start.WriteU8 (m_actionValue);
562 }
563 uint32_t
565 {
566  Buffer::Iterator i = start;
567  m_category = i.ReadU8 ();
568  m_actionValue = i.ReadU8 ();
569  return i.GetDistanceFrom (start);
570 }
571 
572 /***************************************************
573 * ADDBARequest
574 ****************************************************/
575 
576 NS_OBJECT_ENSURE_REGISTERED (MgtAddBaRequestHeader);
577 
578 MgtAddBaRequestHeader::MgtAddBaRequestHeader ()
579  : m_dialogToken (1),
580  m_amsduSupport (1),
581  m_bufferSize (0)
582 {
583 }
584 
585 TypeId
586 MgtAddBaRequestHeader::GetTypeId (void)
587 {
588  static TypeId tid = TypeId ("ns3::MgtAddBaRequestHeader")
589  .SetParent<Header> ()
590  .AddConstructor<MgtAddBaRequestHeader> ();
591  return tid;
592 }
593 
594 TypeId
596 {
597  return GetTypeId ();
598 }
599 
600 void
601 MgtAddBaRequestHeader::Print (std::ostream &os) const
602 {
603 }
604 
605 uint32_t
607 {
608  uint32_t size = 0;
609  size += 1; //Dialog token
610  size += 2; //Block ack parameter set
611  size += 2; //Block ack timeout value
612  size += 2; //Starting sequence control
613  return size;
614 }
615 
616 void
618 {
619  Buffer::Iterator i = start;
620  i.WriteU8 (m_dialogToken);
621  i.WriteHtolsbU16 (GetParameterSet ());
622  i.WriteHtolsbU16 (m_timeoutValue);
623  i.WriteHtolsbU16 (GetStartingSequenceControl ());
624 }
625 
626 uint32_t
628 {
629  Buffer::Iterator i = start;
630  m_dialogToken = i.ReadU8 ();
631  SetParameterSet (i.ReadLsbtohU16 ());
632  m_timeoutValue = i.ReadLsbtohU16 ();
633  SetStartingSequenceControl (i.ReadLsbtohU16 ());
634  return i.GetDistanceFrom (start);
635 }
636 
637 void
638 MgtAddBaRequestHeader::SetDelayedBlockAck ()
639 {
640  m_policy = 0;
641 }
642 
643 void
644 MgtAddBaRequestHeader::SetImmediateBlockAck ()
645 {
646  m_policy = 1;
647 }
648 
649 void
650 MgtAddBaRequestHeader::SetTid (uint8_t tid)
651 {
652  NS_ASSERT (tid < 16);
653  m_tid = tid;
654 }
655 
656 void
657 MgtAddBaRequestHeader::SetTimeout (uint16_t timeout)
658 {
659  m_timeoutValue = timeout;
660 }
661 
662 void
663 MgtAddBaRequestHeader::SetBufferSize (uint16_t size)
664 {
665  m_bufferSize = size;
666 }
667 
668 void
669 MgtAddBaRequestHeader::SetStartingSequence (uint16_t seq)
670 {
671  m_startingSeq = seq;
672 }
673 
674 void
675 MgtAddBaRequestHeader::SetAmsduSupport (bool supported)
676 {
677  m_amsduSupport = supported;
678 }
679 
680 uint8_t
681 MgtAddBaRequestHeader::GetTid (void) const
682 {
683  return m_tid;
684 }
685 
686 bool
687 MgtAddBaRequestHeader::IsImmediateBlockAck (void) const
688 {
689  return (m_policy == 1) ? true : false;
690 }
691 
692 uint16_t
693 MgtAddBaRequestHeader::GetTimeout (void) const
694 {
695  return m_timeoutValue;
696 }
697 
698 uint16_t
699 MgtAddBaRequestHeader::GetBufferSize (void) const
700 {
701  return m_bufferSize;
702 }
703 
704 bool
705 MgtAddBaRequestHeader::IsAmsduSupported (void) const
706 {
707  return (m_amsduSupport == 1) ? true : false;
708 }
709 
710 uint16_t
711 MgtAddBaRequestHeader::GetStartingSequence (void) const
712 {
713  return m_startingSeq;
714 }
715 
716 uint16_t
717 MgtAddBaRequestHeader::GetStartingSequenceControl (void) const
718 {
719  return (m_startingSeq << 4) & 0xfff0;
720 }
721 
722 void
723 MgtAddBaRequestHeader::SetStartingSequenceControl (uint16_t seqControl)
724 {
725  m_startingSeq = (seqControl >> 4) & 0x0fff;
726 }
727 
728 uint16_t
729 MgtAddBaRequestHeader::GetParameterSet (void) const
730 {
731  uint16_t res = 0;
732  res |= m_amsduSupport;
733  res |= m_policy << 1;
734  res |= m_tid << 2;
735  res |= m_bufferSize << 6;
736  return res;
737 }
738 
739 void
740 MgtAddBaRequestHeader::SetParameterSet (uint16_t params)
741 {
742  m_amsduSupport = (params) & 0x01;
743  m_policy = (params >> 1) & 0x01;
744  m_tid = (params >> 2) & 0x0f;
745  m_bufferSize = (params >> 6) & 0x03ff;
746 }
747 
748 /***************************************************
749 * ADDBAResponse
750 ****************************************************/
751 
752 NS_OBJECT_ENSURE_REGISTERED (MgtAddBaResponseHeader);
753 
754 MgtAddBaResponseHeader::MgtAddBaResponseHeader ()
755  : m_dialogToken (1),
756  m_amsduSupport (1),
757  m_bufferSize (0)
758 {
759 }
760 
761 TypeId
762 MgtAddBaResponseHeader::GetTypeId ()
763 {
764  static TypeId tid = TypeId ("ns3::MgtAddBaResponseHeader")
765  .SetParent<Header> ()
766  .AddConstructor<MgtAddBaResponseHeader> ()
767  ;
768  return tid;
769 }
770 
771 TypeId
773 {
774  return GetTypeId ();
775 }
776 
777 void
778 MgtAddBaResponseHeader::Print (std::ostream &os) const
779 {
780  os << "status code=" << m_code;
781 }
782 
783 uint32_t
785 {
786  uint32_t size = 0;
787  size += 1; //Dialog token
788  size += m_code.GetSerializedSize (); //Status code
789  size += 2; //Block ack parameter set
790  size += 2; //Block ack timeout value
791  return size;
792 }
793 
794 void
796 {
797  Buffer::Iterator i = start;
798  i.WriteU8 (m_dialogToken);
799  i = m_code.Serialize (i);
800  i.WriteHtolsbU16 (GetParameterSet ());
801  i.WriteHtolsbU16 (m_timeoutValue);
802 }
803 
804 uint32_t
806 {
807  Buffer::Iterator i = start;
808  m_dialogToken = i.ReadU8 ();
809  i = m_code.Deserialize (i);
810  SetParameterSet (i.ReadLsbtohU16 ());
811  m_timeoutValue = i.ReadLsbtohU16 ();
812  return i.GetDistanceFrom (start);
813 }
814 
815 void
816 MgtAddBaResponseHeader::SetDelayedBlockAck ()
817 {
818  m_policy = 0;
819 }
820 
821 void
822 MgtAddBaResponseHeader::SetImmediateBlockAck ()
823 {
824  m_policy = 1;
825 }
826 
827 void
828 MgtAddBaResponseHeader::SetTid (uint8_t tid)
829 {
830  NS_ASSERT (tid < 16);
831  m_tid = tid;
832 }
833 
834 void
835 MgtAddBaResponseHeader::SetTimeout (uint16_t timeout)
836 {
837  m_timeoutValue = timeout;
838 }
839 
840 void
841 MgtAddBaResponseHeader::SetBufferSize (uint16_t size)
842 {
843  m_bufferSize = size;
844 }
845 
846 void
847 MgtAddBaResponseHeader::SetStatusCode (StatusCode code)
848 {
849  m_code = code;
850 }
851 
852 void
853 MgtAddBaResponseHeader::SetAmsduSupport (bool supported)
854 {
855  m_amsduSupport = supported;
856 }
857 
858 StatusCode
859 MgtAddBaResponseHeader::GetStatusCode (void) const
860 {
861  return m_code;
862 }
863 
864 uint8_t
865 MgtAddBaResponseHeader::GetTid (void) const
866 {
867  return m_tid;
868 }
869 
870 bool
871 MgtAddBaResponseHeader::IsImmediateBlockAck (void) const
872 {
873  return (m_policy == 1) ? true : false;
874 }
875 
876 uint16_t
877 MgtAddBaResponseHeader::GetTimeout (void) const
878 {
879  return m_timeoutValue;
880 }
881 
882 uint16_t
883 MgtAddBaResponseHeader::GetBufferSize (void) const
884 {
885  return m_bufferSize;
886 }
887 
888 bool
889 MgtAddBaResponseHeader::IsAmsduSupported (void) const
890 {
891  return (m_amsduSupport == 1) ? true : false;
892 }
893 
894 uint16_t
895 MgtAddBaResponseHeader::GetParameterSet (void) const
896 {
897  uint16_t res = 0;
898  res |= m_amsduSupport;
899  res |= m_policy << 1;
900  res |= m_tid << 2;
901  res |= m_bufferSize << 6;
902  return res;
903 }
904 
905 void
906 MgtAddBaResponseHeader::SetParameterSet (uint16_t params)
907 {
908  m_amsduSupport = (params) & 0x01;
909  m_policy = (params >> 1) & 0x01;
910  m_tid = (params >> 2) & 0x0f;
911  m_bufferSize = (params >> 6) & 0x03ff;
912 }
913 
914 /***************************************************
915 * DelBa
916 ****************************************************/
917 
918 NS_OBJECT_ENSURE_REGISTERED (MgtDelBaHeader);
919 
920 MgtDelBaHeader::MgtDelBaHeader ()
921  : m_reasonCode (1)
922 {
923 }
924 
925 TypeId
926 MgtDelBaHeader::GetTypeId (void)
927 {
928  static TypeId tid = TypeId ("ns3::MgtDelBaHeader")
929  .SetParent<Header> ()
930  .AddConstructor<MgtDelBaHeader> ()
931  ;
932  return tid;
933 }
934 
935 TypeId
937 {
938  return GetTypeId ();
939 }
940 
941 void
942 MgtDelBaHeader::Print (std::ostream &os) const
943 {
944 }
945 
946 uint32_t
948 {
949  uint32_t size = 0;
950  size += 2; //DelBa parameter set
951  size += 2; //Reason code
952  return size;
953 }
954 
955 void
957 {
958  Buffer::Iterator i = start;
959  i.WriteHtolsbU16 (GetParameterSet ());
960  i.WriteHtolsbU16 (m_reasonCode);
961 }
962 
963 uint32_t
965 {
966  Buffer::Iterator i = start;
967  SetParameterSet (i.ReadLsbtohU16 ());
968  m_reasonCode = i.ReadLsbtohU16 ();
969  return i.GetDistanceFrom (start);
970 }
971 
972 bool
973 MgtDelBaHeader::IsByOriginator (void) const
974 {
975  return (m_initiator == 1) ? true : false;
976 }
977 
978 uint8_t
979 MgtDelBaHeader::GetTid (void) const
980 {
981  NS_ASSERT (m_tid < 16);
982  uint8_t tid = static_cast<uint8_t> (m_tid);
983  return tid;
984 }
985 
986 void
987 MgtDelBaHeader::SetByOriginator (void)
988 {
989  m_initiator = 1;
990 }
991 
992 void
993 MgtDelBaHeader::SetByRecipient (void)
994 {
995  m_initiator = 0;
996 }
997 
998 void
999 MgtDelBaHeader::SetTid (uint8_t tid)
1000 {
1001  NS_ASSERT (tid < 16);
1002  m_tid = static_cast<uint16_t> (tid);
1003 }
1004 
1005 uint16_t
1006 MgtDelBaHeader::GetParameterSet (void) const
1007 {
1008  uint16_t res = 0;
1009  res |= m_initiator << 11;
1010  res |= m_tid << 12;
1011  return res;
1012 }
1013 
1014 void
1015 MgtDelBaHeader::SetParameterSet (uint16_t params)
1016 {
1017  m_initiator = (params >> 11) & 0x01;
1018  m_tid = (params >> 12) & 0x0f;
1019 }
1020 
1021 } // namespace ns3
Protocol header serialization and deserialization.
Definition: header.h:42
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:627
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:392
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:947
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:281
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:549
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:165
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:601
#define NS_ASSERT(condition)
Definition: assert.h:64
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:286
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:778
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:772
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:78
Buffer::Iterator Deserialize(Buffer::Iterator i)
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:807
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
iterator in a Buffer instance
Definition: buffer.h:98
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:936
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:795
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:184
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:190
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:595
virtual TypeId GetInstanceTypeId() const
Definition: mgt-headers.cc:544
virtual uint32_t GetSerializedSize() const
Definition: mgt-headers.cc:553
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:83
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:97
Buffer::Iterator DeserializeIfPresent(Buffer::Iterator i)
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:617
virtual TypeId GetInstanceTypeId(void) const
Definition: mgt-headers.cc:369
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:606
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:297
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:784
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:956
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:564
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:212
static Time Now(void)
Definition: simulator.cc:179
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:386
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:935
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:805
void WriteU8(uint8_t data)
Definition: buffer.h:690
void WriteHtolsbU64(uint64_t data)
Definition: buffer.cc:951
uint8_t ReadU8(void)
Definition: buffer.h:819
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1090
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:313
uint64_t ReadLsbtohU64(void)
Definition: buffer.cc:1118
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:60
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:170
a unique identifier for an interface.
Definition: type-id.h:44
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:89
TypeId SetParent(TypeId tid)
Definition: type-id.cc:471
Buffer::Iterator Serialize(Buffer::Iterator i) const
Serialize entire IE including Element ID and length fields.
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:402
virtual uint32_t GetSerializedSize(void) const
Definition: mgt-headers.cc:374
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:558
virtual uint32_t Deserialize(Buffer::Iterator start)
Definition: mgt-headers.cc:964
virtual void Print(std::ostream &os) const
Definition: mgt-headers.cc:942
virtual void Serialize(Buffer::Iterator start) const
Definition: mgt-headers.cc:303