A Discrete-Event Network Simulator
API
wifi-mac-header.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #include "ns3/address-utils.h"
24 #include "wifi-mac-header.h"
25 
26 namespace ns3 {
27 
28 NS_OBJECT_ENSURE_REGISTERED (WifiMacHeader);
29 
31 enum
32 {
33  TYPE_MGT = 0,
34  TYPE_CTL = 1,
36 };
37 
39 enum
40 {
41  //Reserved: 0 - 6
48 };
49 
51  : m_ctrlMoreData (0),
52  m_ctrlWep (0),
53  m_ctrlOrder (1),
54  m_amsduPresent (0)
55 {
56 }
57 
59 {
60 }
61 
62 void
64 {
65  m_ctrlFromDs = 1;
66 }
67 
68 void
70 {
71  m_ctrlFromDs = 0;
72 }
73 
74 void
76 {
77  m_ctrlToDs = 1;
78 }
79 
80 void
82 {
83  m_ctrlToDs = 0;
84 }
85 
86 void
88 {
89  m_addr1 = address;
90 }
91 
92 void
94 {
95  m_addr2 = address;
96 }
97 
98 void
100 {
101  m_addr3 = address;
102 }
103 
104 void
106 {
107  m_addr4 = address;
108 }
109 
110 void
112 {
113  switch (type)
114  {
118  break;
122  break;
126  break;
127  case WIFI_MAC_CTL_RTS:
130  break;
131  case WIFI_MAC_CTL_CTS:
134  break;
135  case WIFI_MAC_CTL_ACK:
138  break;
141  m_ctrlSubtype = 0;
142  break;
145  m_ctrlSubtype = 1;
146  break;
149  m_ctrlSubtype = 2;
150  break;
153  m_ctrlSubtype = 3;
154  break;
157  m_ctrlSubtype = 4;
158  break;
161  m_ctrlSubtype = 5;
162  break;
163  case WIFI_MAC_MGT_BEACON:
165  m_ctrlSubtype = 8;
166  break;
169  m_ctrlSubtype = 10;
170  break;
173  m_ctrlSubtype = 11;
174  break;
177  m_ctrlSubtype = 12;
178  break;
179  case WIFI_MAC_MGT_ACTION:
181  m_ctrlSubtype = 13;
182  break;
185  m_ctrlSubtype = 14;
186  break;
189  m_ctrlSubtype = 15;
190  break;
191  case WIFI_MAC_DATA:
193  m_ctrlSubtype = 0;
194  break;
195  case WIFI_MAC_DATA_CFACK:
197  m_ctrlSubtype = 1;
198  break;
201  m_ctrlSubtype = 2;
202  break;
205  m_ctrlSubtype = 3;
206  break;
207  case WIFI_MAC_DATA_NULL:
209  m_ctrlSubtype = 4;
210  break;
213  m_ctrlSubtype = 5;
214  break;
217  m_ctrlSubtype = 6;
218  break;
221  m_ctrlSubtype = 7;
222  break;
223  case WIFI_MAC_QOSDATA:
225  m_ctrlSubtype = 8;
226  break;
229  m_ctrlSubtype = 9;
230  break;
233  m_ctrlSubtype = 10;
234  break;
237  m_ctrlSubtype = 11;
238  break;
241  m_ctrlSubtype = 12;
242  break;
245  m_ctrlSubtype = 14;
246  break;
249  m_ctrlSubtype = 15;
250  break;
251  }
252  m_ctrlToDs = 0;
253  m_ctrlFromDs = 0;
254 }
255 
256 void
258 {
259  int64_t duration_us = ceil (static_cast<double> (duration.GetNanoSeconds ()) / 1000);
260  NS_ASSERT (duration_us >= 0 && duration_us <= 0x7fff);
261  m_duration = static_cast<uint16_t> (duration_us);
262 }
263 
264 void WifiMacHeader::SetId (uint16_t id)
265 {
266  m_duration = id;
267 }
268 
270 {
271  m_seqSeq = seq;
272 }
273 
275 {
276  m_seqFrag = frag;
277 }
278 
280 {
281  m_ctrlMoreFrag = 0;
282 }
283 
285 {
286  m_ctrlMoreFrag = 1;
287 }
288 
290 {
291  m_ctrlOrder = 1;
292 }
293 
295 {
296  m_ctrlOrder = 0;
297 }
298 
300 {
301  m_ctrlRetry = 1;
302 }
303 
305 {
306  m_ctrlRetry = 0;
307 }
308 
309 void WifiMacHeader::SetQosTid (uint8_t tid)
310 {
311  m_qosTid = tid;
312 }
313 
315 {
316  m_qosEosp = 1;
317 }
318 
320 {
321  m_qosEosp = 0;
322 }
323 
325 {
326  switch (policy)
327  {
328  case NORMAL_ACK:
329  m_qosAckPolicy = 0;
330  break;
331  case NO_ACK:
332  m_qosAckPolicy = 1;
333  break;
334  case NO_EXPLICIT_ACK:
335  m_qosAckPolicy = 2;
336  break;
337  case BLOCK_ACK:
338  m_qosAckPolicy = 3;
339  break;
340  }
341 }
342 
344 {
345  m_amsduPresent = 1;
346 }
347 
349 {
350  m_amsduPresent = 0;
351 }
352 
354 {
355  m_qosStuff = txop;
356 }
357 
359 {
360  //Mark bit 0 of this variable instead of bit 8, since m_qosStuff is
361  //shifted by one byte when serialized
362  m_qosStuff = m_qosStuff | 0x01; //bit 8 of QoS Control Field
363 }
364 
366 {
367  //Clear bit 0 of this variable instead of bit 8, since m_qosStuff is
368  //shifted by one byte when serialized
369  m_qosStuff = m_qosStuff & 0xfe; //bit 8 of QoS Control Field
370 }
371 
372 
375 {
376  return m_addr1;
377 }
378 
381 {
382  return m_addr2;
383 }
384 
387 {
388  return m_addr3;
389 }
390 
393 {
394  return m_addr4;
395 }
396 
399 {
400  switch (m_ctrlType)
401  {
402  case TYPE_MGT:
403  switch (m_ctrlSubtype)
404  {
405  case 0:
407  case 1:
409  case 2:
411  case 3:
413  case 4:
415  case 5:
417  case 8:
418  return WIFI_MAC_MGT_BEACON;
419  case 10:
421  case 11:
423  case 12:
425  case 13:
426  return WIFI_MAC_MGT_ACTION;
427  case 14:
429  case 15:
431  }
432  break;
433  case TYPE_CTL:
434  switch (m_ctrlSubtype)
435  {
436  case SUBTYPE_CTL_BACKREQ:
437  return WIFI_MAC_CTL_BACKREQ;
439  return WIFI_MAC_CTL_BACKRESP;
440  case SUBTYPE_CTL_RTS:
441  return WIFI_MAC_CTL_RTS;
442  case SUBTYPE_CTL_CTS:
443  return WIFI_MAC_CTL_CTS;
444  case SUBTYPE_CTL_ACK:
445  return WIFI_MAC_CTL_ACK;
446  }
447  break;
448  case TYPE_DATA:
449  switch (m_ctrlSubtype)
450  {
451  case 0:
452  return WIFI_MAC_DATA;
453  case 1:
454  return WIFI_MAC_DATA_CFACK;
455  case 2:
456  return WIFI_MAC_DATA_CFPOLL;
457  case 3:
459  case 4:
460  return WIFI_MAC_DATA_NULL;
461  case 5:
463  case 6:
465  case 7:
467  case 8:
468  return WIFI_MAC_QOSDATA;
469  case 9:
470  return WIFI_MAC_QOSDATA_CFACK;
471  case 10:
473  case 11:
475  case 12:
476  return WIFI_MAC_QOSDATA_NULL;
477  case 14:
479  case 15:
481  }
482  break;
483  }
484  // NOTREACHED
485  NS_ASSERT (false);
486  return (WifiMacType) - 1;
487 }
488 
489 bool
491 {
492  return m_ctrlFromDs == 1;
493 }
494 
495 bool
497 {
498  return m_ctrlToDs == 1;
499 }
500 
501 bool
503 {
504  return (m_ctrlType == TYPE_DATA);
505 
506 }
507 
508 bool
510 {
511  return (m_ctrlType == TYPE_DATA && (m_ctrlSubtype & 0x08));
512 }
513 
514 bool
516 {
517  return (m_ctrlType == TYPE_CTL);
518 }
519 
520 bool
522 {
523  return (m_ctrlType == TYPE_MGT);
524 }
525 
526 bool
528 {
529  switch (GetType ())
530  {
539  return true;
540  default:
541  return false;
542  }
543 }
544 
545 bool
547 {
548  return (GetType () == WIFI_MAC_CTL_RTS);
549 }
550 
551 bool
553 {
554  return (GetType () == WIFI_MAC_CTL_CTS);
555 }
556 
557 bool
559 {
560  return (GetType () == WIFI_MAC_CTL_ACK);
561 }
562 
563 bool
565 {
567 }
568 
569 bool
571 {
573 }
574 
575 bool
577 {
579 }
580 
581 bool
583 {
585 }
586 
587 bool
589 {
590  return (GetType () == WIFI_MAC_MGT_PROBE_REQUEST);
591 }
592 
593 bool
595 {
596  return (GetType () == WIFI_MAC_MGT_PROBE_RESPONSE);
597 }
598 
599 bool
601 {
602  return (GetType () == WIFI_MAC_MGT_BEACON);
603 }
604 
605 bool
607 {
608  return (GetType () == WIFI_MAC_MGT_DISASSOCIATION);
609 }
610 
611 bool
613 {
614  return (GetType () == WIFI_MAC_MGT_AUTHENTICATION);
615 }
616 
617 bool
619 {
620  return (GetType () == WIFI_MAC_MGT_DEAUTHENTICATION);
621 }
622 
623 bool
625 {
626  return (GetType () == WIFI_MAC_MGT_ACTION);
627 }
628 
629 bool
631 {
632  return (GetType () == WIFI_MAC_MGT_MULTIHOP_ACTION);
633 }
634 
635 bool
637 {
638  return (GetType () == WIFI_MAC_CTL_BACKREQ) ? true : false;
639 }
640 
641 bool
643 {
644  return (GetType () == WIFI_MAC_CTL_BACKRESP) ? true : false;
645 }
646 
647 Time
649 {
650  return MicroSeconds (m_duration);
651 }
652 
653 uint16_t
655 {
656  return (m_seqSeq << 4) | m_seqFrag;
657 }
658 
659 uint16_t
661 {
662  return m_seqSeq;
663 }
664 
665 uint8_t
667 {
668  return m_seqFrag;
669 }
670 
671 bool
673 {
674  return (m_ctrlRetry == 1);
675 }
676 
677 bool
679 {
680  return (m_ctrlMoreFrag == 1);
681 }
682 
683 bool
685 {
686  NS_ASSERT (IsQosData ());
687  return (m_qosAckPolicy == 3);
688 }
689 
690 bool
692 {
693  NS_ASSERT (IsQosData ());
694  return (m_qosAckPolicy == 1);
695 }
696 
697 bool
699 {
700  NS_ASSERT (IsQosData ());
701  return (m_qosAckPolicy == 0);
702 }
703 
704 bool
706 {
707  NS_ASSERT (IsQosData ());
708  return (m_qosEosp == 1);
709 }
710 
711 bool
713 {
714  NS_ASSERT (IsQosData ());
715  return (m_amsduPresent == 1);
716 }
717 
718 uint8_t
720 {
721  NS_ASSERT (IsQosData ());
722  return m_qosTid;
723 }
724 
725 uint8_t
727 {
728  NS_ASSERT (IsQosData ());
729  return m_qosStuff;
730 }
731 
732 uint16_t
734 {
735  uint16_t val = 0;
736  val |= (m_ctrlType << 2) & (0x3 << 2);
737  val |= (m_ctrlSubtype << 4) & (0xf << 4);
738  val |= (m_ctrlToDs << 8) & (0x1 << 8);
739  val |= (m_ctrlFromDs << 9) & (0x1 << 9);
740  val |= (m_ctrlMoreFrag << 10) & (0x1 << 10);
741  val |= (m_ctrlRetry << 11) & (0x1 << 11);
742  val |= (m_ctrlMoreData << 13) & (0x1 << 13);
743  val |= (m_ctrlWep << 14) & (0x1 << 14);
744  val |= (m_ctrlOrder << 15) & (0x1 << 15);
745  return val;
746 }
747 
748 uint16_t
750 {
751  uint16_t val = 0;
752  val |= m_qosTid;
753  val |= m_qosEosp << 4;
754  val |= m_qosAckPolicy << 5;
755  val |= m_amsduPresent << 7;
756  val |= m_qosStuff << 8;
757  return val;
758 }
759 
760 void
762 {
763  m_ctrlType = (ctrl >> 2) & 0x03;
764  m_ctrlSubtype = (ctrl >> 4) & 0x0f;
765  m_ctrlToDs = (ctrl >> 8) & 0x01;
766  m_ctrlFromDs = (ctrl >> 9) & 0x01;
767  m_ctrlMoreFrag = (ctrl >> 10) & 0x01;
768  m_ctrlRetry = (ctrl >> 11) & 0x01;
769  m_ctrlMoreData = (ctrl >> 13) & 0x01;
770  m_ctrlWep = (ctrl >> 14) & 0x01;
771  m_ctrlOrder = (ctrl >> 15) & 0x01;
772 }
773 void
775 {
776  m_seqFrag = seq & 0x0f;
777  m_seqSeq = (seq >> 4) & 0x0fff;
778 }
779 void
781 {
782  m_qosTid = qos & 0x000f;
783  m_qosEosp = (qos >> 4) & 0x0001;
784  m_qosAckPolicy = (qos >> 5) & 0x0003;
785  m_amsduPresent = (qos >> 7) & 0x0001;
786  m_qosStuff = (qos >> 8) & 0x00ff;
787 }
788 
789 uint32_t
791 {
792  uint32_t size = 0;
793  switch (m_ctrlType)
794  {
795  case TYPE_MGT:
796  size = 2 + 2 + 6 + 6 + 6 + 2;
797  break;
798  case TYPE_CTL:
799  switch (m_ctrlSubtype)
800  {
801  case SUBTYPE_CTL_RTS:
802  size = 2 + 2 + 6 + 6;
803  break;
804  case SUBTYPE_CTL_CTS:
805  case SUBTYPE_CTL_ACK:
806  size = 2 + 2 + 6;
807  break;
808  case SUBTYPE_CTL_BACKREQ:
810  size = 2 + 2 + 6 + 6;
811  break;
813  size = 2 + 2 + 6 + 2 + 4;
814  break;
815  }
816  break;
817  case TYPE_DATA:
818  size = 2 + 2 + 6 + 6 + 6 + 2;
819  if (m_ctrlToDs && m_ctrlFromDs)
820  {
821  size += 6;
822  }
823  if (m_ctrlSubtype & 0x08)
824  {
825  size += 2;
826  }
827  break;
828  }
829  return size;
830 }
831 
832 const char *
834 {
835 #define FOO(x) \
836 case WIFI_MAC_ ## x: \
837  return # x; \
838  break;
839 
840  switch (GetType ())
841  {
842  FOO (CTL_RTS);
843  FOO (CTL_CTS);
844  FOO (CTL_ACK);
845  FOO (CTL_BACKREQ);
846  FOO (CTL_BACKRESP);
847 
848  FOO (MGT_BEACON);
849  FOO (MGT_ASSOCIATION_REQUEST);
850  FOO (MGT_ASSOCIATION_RESPONSE);
851  FOO (MGT_DISASSOCIATION);
852  FOO (MGT_REASSOCIATION_REQUEST);
853  FOO (MGT_REASSOCIATION_RESPONSE);
854  FOO (MGT_PROBE_REQUEST);
855  FOO (MGT_PROBE_RESPONSE);
856  FOO (MGT_AUTHENTICATION);
857  FOO (MGT_DEAUTHENTICATION);
858  FOO (MGT_ACTION);
859  FOO (MGT_ACTION_NO_ACK);
860  FOO (MGT_MULTIHOP_ACTION);
861 
862  FOO (DATA);
863  FOO (DATA_CFACK);
864  FOO (DATA_CFPOLL);
865  FOO (DATA_CFACK_CFPOLL);
866  FOO (DATA_NULL);
867  FOO (DATA_NULL_CFACK);
868  FOO (DATA_NULL_CFPOLL);
869  FOO (DATA_NULL_CFACK_CFPOLL);
870  FOO (QOSDATA);
871  FOO (QOSDATA_CFACK);
872  FOO (QOSDATA_CFPOLL);
873  FOO (QOSDATA_CFACK_CFPOLL);
874  FOO (QOSDATA_NULL);
875  FOO (QOSDATA_NULL_CFPOLL);
876  FOO (QOSDATA_NULL_CFACK_CFPOLL);
877  default:
878  return "ERROR";
879  }
880 #undef FOO
881  // needed to make gcc 4.0.1 ppc darwin happy.
882  return "BIG_ERROR";
883 }
884 
885 TypeId
887 {
888  static TypeId tid = TypeId ("ns3::WifiMacHeader")
889  .SetParent<Header> ()
890  .SetGroupName ("Wifi")
891  .AddConstructor<WifiMacHeader> ()
892  ;
893  return tid;
894 }
895 
896 TypeId
898 {
899  return GetTypeId ();
900 }
901 
902 void
903 WifiMacHeader::PrintFrameControl (std::ostream &os) const
904 {
905  os << "ToDS=" << std::hex << (int) m_ctrlToDs << ", FromDS=" << std::hex << (int) m_ctrlFromDs
906  << ", MoreFrag=" << std::hex << (int) m_ctrlMoreFrag << ", Retry=" << std::hex << (int) m_ctrlRetry
907  << ", MoreData=" << std::hex << (int) m_ctrlMoreData << std::dec
908  ;
909 }
910 
911 void
912 WifiMacHeader::Print (std::ostream &os) const
913 {
914  os << GetTypeString () << " ";
915  switch (GetType ())
916  {
917  case WIFI_MAC_CTL_RTS:
918  os << "Duration/ID=" << m_duration << "us"
919  << ", RA=" << m_addr1 << ", TA=" << m_addr2;
920  break;
921  case WIFI_MAC_CTL_CTS:
922  case WIFI_MAC_CTL_ACK:
923  os << "Duration/ID=" << m_duration << "us"
924  << ", RA=" << m_addr1;
925  break;
929  break;
930  case WIFI_MAC_MGT_BEACON:
940  PrintFrameControl (os);
941  os << " Duration/ID=" << m_duration << "us"
942  << ", DA=" << m_addr1 << ", SA=" << m_addr2
943  << ", BSSID=" << m_addr3 << ", FragNumber=" << std::hex << (int) m_seqFrag << std::dec
944  << ", SeqNumber=" << m_seqSeq;
945  break;
946  case WIFI_MAC_MGT_ACTION:
948  PrintFrameControl (os);
949  os << " Duration/ID=" << m_duration << "us"
950  << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
951  << ", FragNumber=" << std::hex << (int) m_seqFrag << std::dec << ", SeqNumber=" << m_seqSeq;
952  break;
954  os << " Duration/ID=" << m_duration << "us"
955  << ", RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
956  << ", FragNumber=" << std::hex << (int) m_seqFrag << std::dec << ", SeqNumber=" << m_seqSeq;
957  break;
958  case WIFI_MAC_DATA:
959  PrintFrameControl (os);
960  os << " Duration/ID=" << m_duration << "us";
961  if (!m_ctrlToDs && !m_ctrlFromDs)
962  {
963  os << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3;
964  }
965  else if (!m_ctrlToDs && m_ctrlFromDs)
966  {
967  os << ", DA=" << m_addr1 << ", SA=" << m_addr3 << ", BSSID=" << m_addr2;
968  }
969  else if (m_ctrlToDs && !m_ctrlFromDs)
970  {
971  os << ", DA=" << m_addr3 << ", SA=" << m_addr2 << ", BSSID=" << m_addr1;
972  }
973  else if (m_ctrlToDs && m_ctrlFromDs)
974  {
975  os << ", DA=" << m_addr3 << ", SA=" << m_addr4 << ", RA=" << m_addr1 << ", TA=" << m_addr2;
976  }
977  else
978  {
979  NS_FATAL_ERROR ("Impossible ToDs and FromDs flags combination");
980  }
981  os << ", FragNumber=" << std::hex << (int) m_seqFrag << std::dec
982  << ", SeqNumber=" << m_seqSeq;
983  break;
984  case WIFI_MAC_DATA_CFACK:
987  case WIFI_MAC_DATA_NULL:
991  case WIFI_MAC_QOSDATA:
998  break;
999  }
1000 }
1001 
1002 uint32_t
1004 {
1005  return GetSize ();
1006 }
1007 
1008 void
1010 {
1013  WriteTo (i, m_addr1);
1014  switch (m_ctrlType)
1015  {
1016  case TYPE_MGT:
1017  WriteTo (i, m_addr2);
1018  WriteTo (i, m_addr3);
1020  break;
1021  case TYPE_CTL:
1022  switch (m_ctrlSubtype)
1023  {
1024  case SUBTYPE_CTL_RTS:
1025  WriteTo (i, m_addr2);
1026  break;
1027  case SUBTYPE_CTL_CTS:
1028  case SUBTYPE_CTL_ACK:
1029  break;
1030  case SUBTYPE_CTL_BACKREQ:
1031  case SUBTYPE_CTL_BACKRESP:
1032  WriteTo (i, m_addr2);
1033  break;
1034  default:
1035  //NOTREACHED
1036  NS_ASSERT (false);
1037  break;
1038  }
1039  break;
1040  case TYPE_DATA:
1041  {
1042  WriteTo (i, m_addr2);
1043  WriteTo (i, m_addr3);
1045  if (m_ctrlToDs && m_ctrlFromDs)
1046  {
1047  WriteTo (i, m_addr4);
1048  }
1049  if (m_ctrlSubtype & 0x08)
1050  {
1052  }
1053  } break;
1054  default:
1055  //NOTREACHED
1056  NS_ASSERT (false);
1057  break;
1058  }
1059 }
1060 
1061 uint32_t
1063 {
1064  Buffer::Iterator i = start;
1065  uint16_t frame_control = i.ReadLsbtohU16 ();
1066  SetFrameControl (frame_control);
1067  m_duration = i.ReadLsbtohU16 ();
1068  ReadFrom (i, m_addr1);
1069  switch (m_ctrlType)
1070  {
1071  case TYPE_MGT:
1072  ReadFrom (i, m_addr2);
1073  ReadFrom (i, m_addr3);
1075  break;
1076  case TYPE_CTL:
1077  switch (m_ctrlSubtype)
1078  {
1079  case SUBTYPE_CTL_RTS:
1080  ReadFrom (i, m_addr2);
1081  break;
1082  case SUBTYPE_CTL_CTS:
1083  case SUBTYPE_CTL_ACK:
1084  break;
1085  case SUBTYPE_CTL_BACKREQ:
1086  case SUBTYPE_CTL_BACKRESP:
1087  ReadFrom (i, m_addr2);
1088  break;
1089  }
1090  break;
1091  case TYPE_DATA:
1092  ReadFrom (i, m_addr2);
1093  ReadFrom (i, m_addr3);
1095  if (m_ctrlToDs && m_ctrlFromDs)
1096  {
1097  ReadFrom (i, m_addr4);
1098  }
1099  if (m_ctrlSubtype & 0x08)
1100  {
1102  }
1103  break;
1104  }
1105  return i.GetDistanceFrom (start);
1106 }
1107 
1108 } //namespace ns3
uint8_t m_ctrlMoreData
control more data
Protocol header serialization and deserialization.
Definition: header.h:42
bool IsBeacon(void) const
Return true if the header is a Beacon header.
void SetRetry(void)
Set the Retry bit in the Frame Control field.
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
uint32_t GetSize(void) const
Return the size of the WifiMacHeader in octets.
void SetFrameControl(uint16_t control)
Set the Frame Control field with the given raw value.
bool IsReassocResp(void) const
Return true if the header is a Reassociation Response header.
void SetType(WifiMacType type)
Set Type/Subtype values with the correct values depending on the given type.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
uint8_t m_ctrlType
control type
bool IsAction() const
Return true if the header is an Action header.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
def start()
Definition: core.py:1790
Mac48Address m_addr2
address 2
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
uint8_t m_qosAckPolicy
QOS ack policy.
Mac48Address GetAddr4(void) const
Return the address in the Address 4 field.
#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 WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
uint8_t m_qosEosp
QOS EOSP.
void SetId(uint16_t id)
Set the Duration/ID field with the given ID.
bool IsAssocReq(void) const
Return true if the header is an Association Request header.
uint16_t GetQosControl(void) const
Return the raw QoS Control field.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
bool IsBlockAck(void) const
Return true if the header is a Block ACK header.
bool IsAssocResp(void) const
Return true if the header is an Association Response header.
void SetQosControl(uint16_t qos)
Set the QoS Control field with the given raw value.
uint16_t GetFrameControl(void) const
Return the raw Frame Control field.
bool IsCtl(void) const
Return true if the Type is Control.
uint8_t m_seqFrag
sequence fragment
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
bool IsProbeResp(void) const
Return true if the header is a Probe Response header.
Mac48Address m_addr1
address 1
uint32_t GetDistanceFrom(Iterator const &o) const
Definition: buffer.cc:786
Mac48Address m_addr3
address 3
iterator in a Buffer instance
Definition: buffer.h:98
bool IsCfpoll(void) const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
bool IsMoreFragments(void) const
Return if the More Fragment bit is set.
Time GetDuration(void) const
Return the duration from the Duration/ID field (Time object).
uint8_t GetFragmentNumber(void) const
Return the fragment number of the header.
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
bool IsReassocReq(void) const
Return true if the header is a Reassociation Request header.
uint32_t GetSerializedSize(void) const
uint8_t GetQosTxopLimit(void) const
Return the TXOP limit.
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
uint8_t m_ctrlToDs
control to DS
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
void SetAddr4(Mac48Address address)
Fill the Address 4 field with the given address.
WifiMacType
Combination of valid MAC header type/subtype.
uint16_t GetSequenceControl(void) const
Return the raw Sequence Control field.
bool IsProbeReq(void) const
Return true if the header is a Probe Request header.
void Print(std::ostream &os) const
void SetOrder(void)
Set order bit in the frame control field.
bool IsAuthentication(void) const
Return true if the header is an Authentication header.
bool IsQosBlockAck(void) const
Return if the QoS ACK policy is Block ACK.
uint8_t m_amsduPresent
AMSDU present.
Mac48Address m_addr4
address 4
uint8_t m_ctrlMoreFrag
control more fragments
uint8_t m_ctrlFromDs
control from DS
bool IsMgt(void) const
Return true if the Type is Management.
uint8_t m_ctrlOrder
control order
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
void SetSequenceControl(uint16_t seq)
Set the Sequence Control field with the given raw value.
void SetNoRetry(void)
Un-set the Retry bit in the Frame Control field.
bool IsToDs(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t m_seqSeq
sequence sequence
bool IsDisassociation(void) const
Return true if the header is a Disassociation header.
uint8_t m_qosStuff
QOS stuff.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
QosAckPolicy
ACK policy for QoS frames.
an EUI-48 address
Definition: mac48-address.h:43
void PrintFrameControl(std::ostream &os) const
Print the Frame Control field to the output stream.
const char * GetTypeString(void) const
Return a string corresponds to the header type.
#define FOO(x)
void WriteHtolsbU16(uint16_t data)
Definition: buffer.cc:913
uint16_t m_duration
duration
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:367
uint8_t m_ctrlRetry
control retry
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
bool IsData(void) const
Return true if the Type is DATA.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
bool IsBlockAckReq(void) const
Return true if the header is a Block ACK Request header.
WifiMacType GetType(void) const
Return the type (enum WifiMacType)
void SetQosNoAmsdu(void)
Set that A-MSDU is not present.
void Serialize(Buffer::Iterator start) const
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
bool IsFromDs(void) const
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
bool IsQosEosp(void) const
Return if the end of service period (EOSP) is set.
uint32_t Deserialize(Buffer::Iterator start)
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
void SetNoOrder(void)
Unset order bit in the frame control field.
uint16_t ReadLsbtohU16(void)
Definition: buffer.cc:1068
bool IsMultihopAction() const
Check if the header is a Multihop action header.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1023
bool IsCts(void) const
Return true if the header is a CTS header.
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
tuple address
Definition: first.py:37
uint8_t m_qosTid
QOS TID.
void SetQosMeshControlPresent()
Set the Mesh Control Present flag for the QoS header.
void SetQosNoMeshControlPresent()
Clear the Mesh Control Present flag for the QoS header.
uint8_t m_ctrlSubtype
control subtype
bool IsDeauthentication(void) const
Return true if the header is a Deauthentication header.
bool IsRts(void) const
Return true if the header is a RTS header.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
bool IsAck(void) const
Return true if the header is an ACK header.
static TypeId GetTypeId(void)
Get the type ID.
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
void SetQosAmsdu(void)
Set that A-MSDU is present.
bool IsRetry(void) const
Return if the Retry bit is set.
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
bool IsQosNoAck(void) const
Return if the QoS ACK policy is No ACK.
uint8_t m_ctrlWep
control WEP
bool IsQosAck(void) const
Return if the QoS ACK policy is Normal ACK.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.