A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-mac-header.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006, 2009 INRIA
3 * Copyright (c) 2009 MIRKO BANCHI
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
8 * Mirko Banchi <mk.banchi@gmail.com>
9 */
10
11#include "wifi-mac-header.h"
12
13#include "ns3/address-utils.h"
14#include "ns3/nstime.h"
15
16namespace ns3
17{
18
19NS_OBJECT_ENSURE_REGISTERED(WifiMacHeader);
20
21/// type enumeration
22enum
23{
26 TYPE_DATA = 2
27};
28
29/// subtype enumeration
30enum
31{
32 // Reserved: 0 - 1
34 // Reserved: 3
47};
48
54
55void
60
61void
66
67void
72
73void
78
79void
81{
82 m_addr1 = address;
83}
84
85void
87{
88 m_addr2 = address;
89}
90
91void
93{
94 m_addr3 = address;
95}
96
97void
99{
100 m_addr4 = address;
101}
102
103void
104WifiMacHeader::SetType(WifiMacType type, bool resetToDsFromDs)
105{
106 switch (type)
107 {
111 break;
115 break;
119 break;
123 break;
127 break;
128 case WIFI_MAC_CTL_RTS:
131 break;
132 case WIFI_MAC_CTL_CTS:
135 break;
136 case WIFI_MAC_CTL_ACK:
139 break;
140 case WIFI_MAC_CTL_END:
143 break;
147 break;
150 m_ctrlSubtype = 0;
151 break;
154 m_ctrlSubtype = 1;
155 break;
158 m_ctrlSubtype = 2;
159 break;
162 m_ctrlSubtype = 3;
163 break;
166 m_ctrlSubtype = 4;
167 break;
170 m_ctrlSubtype = 5;
171 break;
174 m_ctrlSubtype = 8;
175 break;
178 m_ctrlSubtype = 10;
179 break;
182 m_ctrlSubtype = 11;
183 break;
186 m_ctrlSubtype = 12;
187 break;
190 m_ctrlSubtype = 13;
191 break;
194 m_ctrlSubtype = 14;
195 break;
198 m_ctrlSubtype = 15;
199 break;
200 case WIFI_MAC_DATA:
202 m_ctrlSubtype = 0;
203 break;
206 m_ctrlSubtype = 1;
207 break;
210 m_ctrlSubtype = 2;
211 break;
214 m_ctrlSubtype = 3;
215 break;
218 m_ctrlSubtype = 4;
219 break;
222 m_ctrlSubtype = 5;
223 break;
226 m_ctrlSubtype = 6;
227 break;
230 m_ctrlSubtype = 7;
231 break;
232 case WIFI_MAC_QOSDATA:
234 m_ctrlSubtype = 8;
235 break;
238 m_ctrlSubtype = 9;
239 break;
242 m_ctrlSubtype = 10;
243 break;
246 m_ctrlSubtype = 11;
247 break;
250 m_ctrlSubtype = 12;
251 break;
254 m_ctrlSubtype = 14;
255 break;
258 m_ctrlSubtype = 15;
259 break;
260 default:
261 break;
262 }
263 if (resetToDsFromDs)
264 {
265 m_ctrlToDs = 0;
266 m_ctrlFromDs = 0;
267 }
268}
269
270void
272{
273 NS_ASSERT(duration <= 32768);
274 m_duration = duration;
275}
276
277void
279{
280 auto duration_us =
281 static_cast<int64_t>(ceil(static_cast<double>(duration.GetNanoSeconds()) / 1000));
282 NS_ASSERT(duration_us >= 0 && duration_us <= 0x7fff);
283 m_duration = static_cast<uint16_t>(duration_us);
284}
285
286void
288{
289 m_duration = id;
290}
291
292void
294{
295 m_seqSeq = seq;
296}
297
298void
300{
301 m_seqFrag = frag;
302}
303
304void
309
310void
315
316void
321
322void
327
328void
333
334void
339
340void
342{
343 m_qosTid = tid;
344}
345
346void
351
352void
357
358void
363
364void
369
370void
372{
373 switch (policy)
374 {
375 case NORMAL_ACK:
376 m_qosAckPolicy = 0;
377 break;
378 case NO_ACK:
379 m_qosAckPolicy = 1;
380 break;
381 case NO_EXPLICIT_ACK:
382 m_qosAckPolicy = 2;
383 break;
384 case BLOCK_ACK:
385 m_qosAckPolicy = 3;
386 break;
387 }
388}
389
390void
395
396void
401
402void
404{
405 m_qosStuff = txop;
406}
407
408void
410{
411 m_qosEosp = 1;
412 m_qosStuff = size;
413}
414
415void
417{
418 // Mark bit 0 of this variable instead of bit 8, since m_qosStuff is
419 // shifted by one byte when serialized
420 m_qosStuff = m_qosStuff | 0x01; // bit 8 of QoS Control Field
421}
422
423void
425{
426 // Clear bit 0 of this variable instead of bit 8, since m_qosStuff is
427 // shifted by one byte when serialized
428 m_qosStuff = m_qosStuff & 0xfe; // bit 8 of QoS Control Field
429}
430
433{
434 return m_addr1;
435}
436
439{
440 return m_addr2;
441}
442
445{
446 return m_addr3;
447}
448
451{
452 return m_addr4;
453}
454
457{
458 switch (m_ctrlType)
459 {
460 case TYPE_MGT:
461 switch (m_ctrlSubtype)
462 {
463 case 0:
465 case 1:
467 case 2:
469 case 3:
471 case 4:
473 case 5:
475 case 8:
476 return WIFI_MAC_MGT_BEACON;
477 case 10:
479 case 11:
481 case 12:
483 case 13:
484 return WIFI_MAC_MGT_ACTION;
485 case 14:
487 case 15:
489 }
490 break;
491 case TYPE_CTL:
492 switch (m_ctrlSubtype)
493 {
501 return WIFI_MAC_CTL_PSPOLL;
502 case SUBTYPE_CTL_RTS:
503 return WIFI_MAC_CTL_RTS;
504 case SUBTYPE_CTL_CTS:
505 return WIFI_MAC_CTL_CTS;
506 case SUBTYPE_CTL_ACK:
507 return WIFI_MAC_CTL_ACK;
508 case SUBTYPE_CTL_END:
509 return WIFI_MAC_CTL_END;
512 }
513 break;
514 case TYPE_DATA:
515 switch (m_ctrlSubtype)
516 {
517 case 0:
518 return WIFI_MAC_DATA;
519 case 1:
520 return WIFI_MAC_DATA_CFACK;
521 case 2:
523 case 3:
525 case 4:
526 return WIFI_MAC_DATA_NULL;
527 case 5:
529 case 6:
531 case 7:
533 case 8:
534 return WIFI_MAC_QOSDATA;
535 case 9:
537 case 10:
539 case 11:
541 case 12:
543 case 14:
545 case 15:
547 }
548 break;
549 }
550 // NOTREACHED
551 NS_ASSERT(false);
552 return (WifiMacType)-1;
553}
554
555bool
557{
558 return m_ctrlFromDs == 1;
559}
560
561bool
563{
564 return m_ctrlToDs == 1;
565}
566
567bool
569{
570 return (m_ctrlType == TYPE_DATA);
571}
572
573bool
575{
576 return (m_ctrlType == TYPE_DATA && (m_ctrlSubtype & 0x08));
577}
578
579bool
581{
582 return (m_ctrlType == TYPE_CTL);
583}
584
585bool
587{
588 return (m_ctrlType == TYPE_MGT);
589}
590
591bool
593{
594 switch (GetType())
595 {
604 return true;
605 default:
606 return false;
607 }
608}
609
610bool
612{
613 switch (GetType())
614 {
615 case WIFI_MAC_CTL_END:
617 return true;
618 default:
619 return false;
620 }
621}
622
623bool
625{
626 switch (GetType())
627 {
633 return true;
634 default:
635 return false;
636 }
637}
638
639bool
641{
642 switch (GetType())
643 {
644 case WIFI_MAC_DATA:
648 case WIFI_MAC_QOSDATA:
652 return true;
653 default:
654 return false;
655 }
656}
657
658bool
660{
661 return (GetType() == WIFI_MAC_CTL_RTS);
662}
663
664bool
666{
667 return (GetType() == WIFI_MAC_CTL_CTS);
668}
669
670bool
672{
673 return (GetType() == WIFI_MAC_CTL_PSPOLL);
674}
675
676bool
678{
679 return (GetType() == WIFI_MAC_CTL_ACK);
680}
681
682bool
687
688bool
693
694bool
699
700bool
705
706bool
711
712bool
717
718bool
720{
721 return (GetType() == WIFI_MAC_MGT_BEACON);
722}
723
724bool
729
730bool
735
736bool
741
742bool
744{
745 return (GetType() == WIFI_MAC_MGT_ACTION);
746}
747
748bool
753
754bool
759
760bool
762{
763 return (GetType() == WIFI_MAC_CTL_BACKREQ);
764}
765
766bool
768{
769 return (GetType() == WIFI_MAC_CTL_BACKRESP);
770}
771
772bool
774{
775 return (GetType() == WIFI_MAC_CTL_TRIGGER);
776}
777
778uint16_t
780{
781 return m_duration;
782}
783
784Time
789
790bool
792{
793 // When the contents of a received Duration/ID field, treated as an unsigned integer,
794 // are greater than 32 768, the contents are interpreted as appropriate for the frame
795 // type and subtype or ignored if the receiving MAC entity does not have a defined
796 // interpretation for that type and subtype (IEEE 802.11-2016 sec. 10.27.3)
797 return (GetRawDuration() & 0x8000) == 0;
798}
799
800uint16_t
802{
803 return (m_seqSeq << 4) | m_seqFrag;
804}
805
806uint16_t
808{
809 return m_seqSeq;
810}
811
812uint8_t
814{
815 return m_seqFrag;
816}
817
818bool
820{
821 return (m_ctrlRetry == 1);
822}
823
824bool
826{
827 return (m_ctrlMoreData == 1);
828}
829
830bool
832{
833 return (m_ctrlMoreFrag == 1);
834}
835
836bool
838{
839 return (m_ctrlPowerManagement == 1);
840}
841
842bool
844{
845 return (IsQosData() && m_qosAckPolicy == 3);
846}
847
848bool
850{
851 return (IsQosData() && m_qosAckPolicy == 1);
852}
853
854bool
856{
857 return (IsQosData() && m_qosAckPolicy == 0);
858}
859
860bool
862{
863 return (IsQosData() && m_qosEosp == 1);
864}
865
868{
870 QosAckPolicy policy;
871
872 switch (m_qosAckPolicy)
873 {
874 case 0:
875 policy = NORMAL_ACK;
876 break;
877 case 1:
878 policy = NO_ACK;
879 break;
880 case 2:
881 policy = NO_EXPLICIT_ACK;
882 break;
883 case 3:
884 policy = BLOCK_ACK;
885 break;
886 default:
887 NS_ABORT_MSG("Unknown QoS Ack policy");
888 }
889 return policy;
890}
891
892bool
894{
895 return (IsQosData() && m_amsduPresent == 1);
896}
897
898uint8_t
900{
902 return m_qosTid;
903}
904
905uint8_t
907{
908 NS_ASSERT(m_qosEosp == 1);
909 return m_qosStuff;
910}
911
912uint16_t
914{
915 uint16_t val = 0;
916 val |= (m_ctrlType << 2) & (0x3 << 2);
917 val |= (m_ctrlSubtype << 4) & (0xf << 4);
918 val |= (m_ctrlToDs << 8) & (0x1 << 8);
919 val |= (m_ctrlFromDs << 9) & (0x1 << 9);
920 val |= (m_ctrlMoreFrag << 10) & (0x1 << 10);
921 val |= (m_ctrlRetry << 11) & (0x1 << 11);
922 val |= (m_ctrlPowerManagement << 12) & (0x1 << 12);
923 val |= (m_ctrlMoreData << 13) & (0x1 << 13);
924 val |= (m_ctrlWep << 14) & (0x1 << 14);
925 val |= (m_ctrlOrder << 15) & (0x1 << 15);
926 return val;
927}
928
929uint16_t
931{
932 uint16_t val = 0;
933 val |= m_qosTid;
934 val |= m_qosEosp << 4;
935 val |= m_qosAckPolicy << 5;
936 val |= m_amsduPresent << 7;
937 val |= m_qosStuff << 8;
938 return val;
939}
940
941void
943{
944 m_ctrlType = (ctrl >> 2) & 0x03;
945 m_ctrlSubtype = (ctrl >> 4) & 0x0f;
946 m_ctrlToDs = (ctrl >> 8) & 0x01;
947 m_ctrlFromDs = (ctrl >> 9) & 0x01;
948 m_ctrlMoreFrag = (ctrl >> 10) & 0x01;
949 m_ctrlRetry = (ctrl >> 11) & 0x01;
950 m_ctrlPowerManagement = (ctrl >> 12) & 0x01;
951 m_ctrlMoreData = (ctrl >> 13) & 0x01;
952 m_ctrlWep = (ctrl >> 14) & 0x01;
953 m_ctrlOrder = (ctrl >> 15) & 0x01;
954}
955
956void
958{
959 m_seqFrag = seq & 0x0f;
960 m_seqSeq = (seq >> 4) & 0x0fff;
961}
962
963void
965{
966 m_qosTid = qos & 0x000f;
967 m_qosEosp = (qos >> 4) & 0x0001;
968 m_qosAckPolicy = (qos >> 5) & 0x0003;
969 m_amsduPresent = (qos >> 7) & 0x0001;
970 m_qosStuff = (qos >> 8) & 0x00ff;
971}
972
975{
976 uint32_t size = 0;
977 switch (m_ctrlType)
978 {
979 case TYPE_MGT:
980 size = 2 + 2 + 6 + 6 + 6 + 2;
981 break;
982 case TYPE_CTL:
983 switch (m_ctrlSubtype)
984 {
986 case SUBTYPE_CTL_RTS:
990 case SUBTYPE_CTL_END:
992 size = 2 + 2 + 6 + 6;
993 break;
994 case SUBTYPE_CTL_CTS:
995 case SUBTYPE_CTL_ACK:
996 size = 2 + 2 + 6;
997 break;
999 size = 2 + 2 + 6 + 2 + 4;
1000 break;
1001 }
1002 break;
1003 case TYPE_DATA:
1004 size = 2 + 2 + 6 + 6 + 6 + 2;
1005 if (m_ctrlToDs && m_ctrlFromDs)
1006 {
1007 size += 6;
1008 }
1009 if (m_ctrlSubtype & 0x08)
1010 {
1011 size += 2;
1012 }
1013 break;
1014 }
1015 return size;
1016}
1017
1018const char*
1020{
1021#define CASE_WIFI_MAC_TYPE(x) \
1022 case WIFI_MAC_##x: \
1023 return #x;
1024
1025 switch (GetType())
1026 {
1027 CASE_WIFI_MAC_TYPE(CTL_RTS);
1028 CASE_WIFI_MAC_TYPE(CTL_CTS);
1029 CASE_WIFI_MAC_TYPE(CTL_ACK);
1030 CASE_WIFI_MAC_TYPE(CTL_BACKREQ);
1031 CASE_WIFI_MAC_TYPE(CTL_BACKRESP);
1032 CASE_WIFI_MAC_TYPE(CTL_END);
1033 CASE_WIFI_MAC_TYPE(CTL_END_ACK);
1034 CASE_WIFI_MAC_TYPE(CTL_PSPOLL);
1035 CASE_WIFI_MAC_TYPE(CTL_TRIGGER);
1036
1037 CASE_WIFI_MAC_TYPE(MGT_BEACON);
1038 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_REQUEST);
1039 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_RESPONSE);
1040 CASE_WIFI_MAC_TYPE(MGT_DISASSOCIATION);
1041 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_REQUEST);
1042 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_RESPONSE);
1043 CASE_WIFI_MAC_TYPE(MGT_PROBE_REQUEST);
1044 CASE_WIFI_MAC_TYPE(MGT_PROBE_RESPONSE);
1045 CASE_WIFI_MAC_TYPE(MGT_AUTHENTICATION);
1046 CASE_WIFI_MAC_TYPE(MGT_DEAUTHENTICATION);
1047 CASE_WIFI_MAC_TYPE(MGT_ACTION);
1048 CASE_WIFI_MAC_TYPE(MGT_ACTION_NO_ACK);
1049 CASE_WIFI_MAC_TYPE(MGT_MULTIHOP_ACTION);
1050
1052 CASE_WIFI_MAC_TYPE(DATA_CFACK);
1053 CASE_WIFI_MAC_TYPE(DATA_CFPOLL);
1054 CASE_WIFI_MAC_TYPE(DATA_CFACK_CFPOLL);
1055 CASE_WIFI_MAC_TYPE(DATA_NULL);
1056 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK);
1057 CASE_WIFI_MAC_TYPE(DATA_NULL_CFPOLL);
1058 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK_CFPOLL);
1059 CASE_WIFI_MAC_TYPE(QOSDATA);
1060 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK);
1061 CASE_WIFI_MAC_TYPE(QOSDATA_CFPOLL);
1062 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK_CFPOLL);
1063 CASE_WIFI_MAC_TYPE(QOSDATA_NULL);
1064 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFPOLL);
1065 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFACK_CFPOLL);
1066 default:
1067 return "ERROR";
1068 }
1069#undef CASE_WIFI_MAC_TYPE
1070#ifndef _WIN32
1071 // needed to make gcc 4.0.1 ppc darwin happy.
1072 return "BIG_ERROR";
1073#endif
1074}
1075
1076TypeId
1078{
1079 static TypeId tid = TypeId("ns3::WifiMacHeader")
1080 .SetParent<Header>()
1081 .SetGroupName("Wifi")
1082 .AddConstructor<WifiMacHeader>();
1083 return tid;
1084}
1085
1086TypeId
1088{
1089 return GetTypeId();
1090}
1091
1092void
1094{
1095 os << "ToDS=" << std::hex << static_cast<int>(m_ctrlToDs)
1096 << ", FromDS=" << static_cast<int>(m_ctrlFromDs)
1097 << ", MoreFrag=" << static_cast<int>(m_ctrlMoreFrag)
1098 << ", Retry=" << static_cast<int>(m_ctrlRetry)
1099 << ", PowerManagement=" << static_cast<int>(m_ctrlPowerManagement)
1100 << ", MoreData=" << static_cast<int>(m_ctrlMoreData) << std::dec;
1101}
1102
1103void
1104WifiMacHeader::Print(std::ostream& os) const
1105{
1106 os << GetTypeString() << " ";
1107 switch (GetType())
1108 {
1110 os << "Duration/ID=" << std::hex << m_duration << std::dec << ", BSSID(RA)=" << m_addr1
1111 << ", TA=" << m_addr2;
1112 break;
1113 case WIFI_MAC_CTL_RTS:
1115 os << "Duration/ID=" << m_duration << "us"
1116 << ", RA=" << m_addr1 << ", TA=" << m_addr2;
1117 break;
1118 case WIFI_MAC_CTL_CTS:
1119 case WIFI_MAC_CTL_ACK:
1120 os << "Duration/ID=" << m_duration << "us"
1121 << ", RA=" << m_addr1;
1122 break;
1136 os << " Duration/ID=" << m_duration << "us"
1137 << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
1138 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1139 << ", SeqNumber=" << m_seqSeq;
1140 break;
1142 os << " Duration/ID=" << m_duration << "us"
1143 << ", RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
1144 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1145 << ", SeqNumber=" << m_seqSeq;
1146 break;
1147 case WIFI_MAC_DATA:
1148 case WIFI_MAC_QOSDATA:
1150 os << " Duration/ID=" << m_duration << "us";
1151 if (!m_ctrlToDs && !m_ctrlFromDs)
1152 {
1153 os << ", DA(RA)=" << m_addr1 << ", SA(TA)=" << m_addr2 << ", BSSID=" << m_addr3;
1154 }
1155 else if (!m_ctrlToDs && m_ctrlFromDs)
1156 {
1157 os << ", DA(RA)=" << m_addr1 << ", SA=" << m_addr3 << ", BSSID(TA)=" << m_addr2;
1158 }
1159 else if (m_ctrlToDs && !m_ctrlFromDs)
1160 {
1161 os << ", DA=" << m_addr3 << ", SA(TA)=" << m_addr2 << ", BSSID(RA)=" << m_addr1;
1162 }
1163 else if (m_ctrlToDs && m_ctrlFromDs)
1164 {
1165 os << ", DA=" << m_addr3 << ", SA=" << m_addr4 << ", RA=" << m_addr1
1166 << ", TA=" << m_addr2;
1167 }
1168 else
1169 {
1170 NS_FATAL_ERROR("Impossible ToDs and FromDs flags combination");
1171 }
1172 os << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1173 << ", SeqNumber=" << m_seqSeq;
1174 if (IsQosData())
1175 {
1176 os << ", tid=" << +m_qosTid;
1177 if (IsQosAmsdu())
1178 {
1179 os << ", A-MSDU";
1180 }
1181 if (IsQosNoAck())
1182 {
1183 os << ", ack=NoAck";
1184 }
1185 else if (IsQosAck())
1186 {
1187 os << ", ack=NormalAck";
1188 }
1189 else if (IsQosBlockAck())
1190 {
1191 os << ", ack=BlockAck";
1192 }
1193 }
1194 break;
1197 os << "RA=" << m_addr1 << ", TA=" << m_addr2 << ", Duration/ID=" << m_duration << "us";
1198 break;
1200 case WIFI_MAC_CTL_END:
1205 case WIFI_MAC_DATA_NULL:
1215 default:
1216 break;
1217 }
1218}
1219
1222{
1223 return GetSize();
1224}
1225
1226void
1228{
1231 WriteTo(i, m_addr1);
1232 switch (m_ctrlType)
1233 {
1234 case TYPE_MGT:
1235 WriteTo(i, m_addr2);
1236 WriteTo(i, m_addr3);
1238 break;
1239 case TYPE_CTL:
1240 switch (m_ctrlSubtype)
1241 {
1242 case SUBTYPE_CTL_PSPOLL:
1243 case SUBTYPE_CTL_RTS:
1247 case SUBTYPE_CTL_END:
1249 WriteTo(i, m_addr2);
1250 break;
1251 case SUBTYPE_CTL_CTS:
1252 case SUBTYPE_CTL_ACK:
1253 break;
1254 default:
1255 // NOTREACHED
1256 NS_ASSERT(false);
1257 break;
1258 }
1259 break;
1260 case TYPE_DATA: {
1261 WriteTo(i, m_addr2);
1262 WriteTo(i, m_addr3);
1264 if (m_ctrlToDs && m_ctrlFromDs)
1265 {
1266 WriteTo(i, m_addr4);
1267 }
1268 if (m_ctrlSubtype & 0x08)
1269 {
1271 }
1272 }
1273 break;
1274 default:
1275 // NOTREACHED
1276 NS_ASSERT(false);
1277 break;
1278 }
1279}
1280
1283{
1284 Buffer::Iterator i = start;
1285 uint16_t frame_control = i.ReadLsbtohU16();
1286 SetFrameControl(frame_control);
1288 ReadFrom(i, m_addr1);
1289 switch (m_ctrlType)
1290 {
1291 case TYPE_MGT:
1292 ReadFrom(i, m_addr2);
1293 ReadFrom(i, m_addr3);
1295 break;
1296 case TYPE_CTL:
1297 switch (m_ctrlSubtype)
1298 {
1299 case SUBTYPE_CTL_PSPOLL:
1300 case SUBTYPE_CTL_RTS:
1304 case SUBTYPE_CTL_END:
1306 ReadFrom(i, m_addr2);
1307 break;
1308 case SUBTYPE_CTL_CTS:
1309 case SUBTYPE_CTL_ACK:
1310 break;
1311 }
1312 break;
1313 case TYPE_DATA:
1314 ReadFrom(i, m_addr2);
1315 ReadFrom(i, m_addr3);
1317 if (m_ctrlToDs && m_ctrlFromDs)
1318 {
1319 ReadFrom(i, m_addr4);
1320 }
1321 if (m_ctrlSubtype & 0x08)
1322 {
1324 }
1325 break;
1326 }
1327 return i.GetDistanceFrom(start);
1328}
1329
1330} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:89
void WriteHtolsbU16(uint16_t data)
Definition buffer.cc:891
uint16_t ReadLsbtohU16()
Definition buffer.cc:1053
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
Protocol header serialization and deserialization.
Definition header.h:33
an EUI-48 address
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:407
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Implements the IEEE 802.11 MAC header.
uint8_t GetQosTid() const
Return the Traffic ID of a QoS header.
bool IsCfAck() const
Return true if the header is a CF-Ack header.
uint8_t m_qosEosp
QoS EOSP.
uint8_t m_ctrlRetry
control retry
uint8_t m_qosTid
QoS TID.
uint8_t m_ctrlPowerManagement
control power management
bool IsAssocReq() const
Return true if the header is an Association Request header.
bool IsCfPoll() const
Return true if the Type/Subtype is one of the possible CF-Poll headers.
void SetQosAckPolicy(QosAckPolicy policy)
Set the QoS Ack policy in the QoS control field.
bool IsAck() const
Return true if the header is an Ack header.
uint16_t GetRawDuration() const
Return the raw duration from the Duration/ID field.
void SetRawDuration(uint16_t duration)
Set the Duration/ID field with the given raw uint16_t value.
bool IsProbeReq() const
Return true if the header is a Probe Request header.
bool IsBlockAckReq() const
Return true if the header is a BlockAckRequest header.
bool IsQosAmsdu() const
Check if IsQosData() is true and the A-MSDU present bit is set in the QoS control field.
bool IsCts() const
Return true if the header is a CTS header.
Mac48Address GetAddr3() const
Return the address in the Address 3 field.
void SetQosAmsdu()
Set that A-MSDU is present.
virtual uint16_t GetFrameControl() const
Return the raw Frame Control field.
Mac48Address GetAddr4() const
Return the address in the Address 4 field.
virtual void SetFrameControl(uint16_t control)
Set the Frame Control field with the given raw value.
bool IsBeacon() const
Return true if the header is a Beacon header.
uint32_t GetSerializedSize() const override
bool IsAssocResp() const
Return true if the header is an Association Response header.
Mac48Address GetAddr1() const
Return the address in the Address 1 field.
uint16_t GetSequenceNumber() const
Return the sequence number of the header.
bool IsDisassociation() const
Return true if the header is a Disassociation header.
Mac48Address m_addr1
address 1
uint16_t m_seqSeq
sequence sequence
bool IsMoreFragments() const
Return if the More Fragment bit is set.
void SetRetry()
Set the Retry bit in the Frame Control field.
WifiMacHeader()=default
uint16_t GetSequenceControl() const
Return the raw Sequence Control field.
bool IsTrigger() const
Return true if the header is a Trigger header.
void SetQosTxopLimit(uint8_t txop)
Set TXOP limit in the QoS control field.
virtual WifiMacType GetType() const
Return the type (WifiMacType)
void SetNoMoreFragments()
Un-set the More Fragment bit in the Frame Control Field.
bool IsRetry() const
Return if the Retry bit is set.
bool IsActionNoAck() const
Return true if the header is an Action No Ack header.
bool IsMgt() const
Return true if the Type is Management.
bool IsCtl() const
Return true if the Type is Control.
Time GetDuration() const
Return the duration from the Duration/ID field (Time object).
virtual void SetQosControl(uint16_t qos)
Set the QoS Control field with the given raw value.
uint8_t m_ctrlSubtype
control subtype
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
void SetNoOrder()
Unset order bit in the frame control field.
virtual uint32_t GetSize() const
Return the size of the WifiMacHeader in octets.
uint8_t m_amsduPresent
A-MSDU present.
bool IsCfEnd() const
Return true if the header is a CF-End header.
void SetDsNotFrom()
Un-set the From DS bit in the Frame Control field.
virtual uint16_t GetQosControl() const
Return the raw QoS Control field.
bool IsProbeResp() const
Return true if the header is a Probe Response header.
bool IsAction() const
Return true if the header is an Action header.
void SetMoreFragments()
Set the More Fragment bit in the Frame Control field.
bool IsQosEosp() const
Return if IsQosData() is true and the end of service period (EOSP) is set.
Mac48Address m_addr4
address 4
Mac48Address m_addr2
address 2
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
void SetOrder()
Set order bit in the frame control field.
void SetSequenceControl(uint16_t seq)
Set the Sequence Control field with the given raw value.
void SetQosQueueSize(uint8_t size)
Set the Queue Size subfield in the QoS control field.
void SetQosNoAmsdu()
Set that A-MSDU is not present.
bool IsBlockAck() const
Return true if the header is a BlockAck header.
virtual void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
void SetAddr4(Mac48Address address)
Fill the Address 4 field with the given address.
uint8_t m_ctrlOrder
control order (set to 1 for QoS Data and Management frames to signify that HT/VHT/HE control field is...
uint8_t m_ctrlFromDs
control from DS
Mac48Address GetAddr2() const
Return the address in the Address 2 field.
uint16_t m_duration
duration
virtual const char * GetTypeString() const
Return a string corresponds to the header type.
uint8_t m_ctrlWep
control WEP
bool HasData() const
Return true if the header type is DATA and is not DATA_NULL.
bool IsReassocReq() const
Return true if the header is a Reassociation Request header.
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
QosAckPolicy GetQosAckPolicy() const
Return the QoS Ack policy in the QoS control field.
void SetDuration(Time duration)
Set the Duration/ID field with the given duration (Time object).
bool IsData() const
Return true if the Type is DATA.
void SetQosNoEosp()
Un-set the end of service period (EOSP) bit in the QoS control field.
uint8_t m_seqFrag
sequence fragment
uint8_t m_ctrlMoreData
control more data
bool IsReassocResp() const
Return true if the header is a Reassociation Response header.
bool IsRts() const
Return true if the header is a RTS header.
static TypeId GetTypeId()
Get the type ID.
bool IsQosAck() const
Return if IsQosData() is true and the QoS Ack policy is Normal Ack.
void Print(std::ostream &os) const override
bool IsMoreData() const
Return if the More Data bit is set.
void SetQosNoMeshControlPresent()
Clear the Mesh Control Present flag for the QoS header.
void SetDsFrom()
Set the From DS bit in the Frame Control field.
bool IsQosNoAck() const
Return if IsQosData() is true and the QoS Ack policy is No Ack.
uint8_t m_qosStuff
QoS stuff.
void SetDsTo()
Set the To DS bit in the Frame Control field.
void PrintFrameControl(std::ostream &os) const
Print the Frame Control field to the output stream.
uint8_t m_ctrlType
control type
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
void SetId(uint16_t id)
Set the Duration/ID field with the given ID.
bool IsQosBlockAck() const
Return if IsQosData() is true and the QoS Ack policy is Block Ack.
bool IsPsPoll() const
Return true if the header is a PS-POLL header.
uint32_t Deserialize(Buffer::Iterator start) override
uint8_t GetFragmentNumber() const
Return the fragment number of the header.
bool IsQosData() const
Return true if the Type is DATA and Subtype is one of the possible values for QoS Data.
void SetQosEosp()
Set the end of service period (EOSP) bit in the QoS control field.
void Serialize(Buffer::Iterator start) const override
uint8_t GetQosQueueSize() const
Get the Queue Size subfield in the QoS control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
void SetDsNotTo()
Un-set the To DS bit in the Frame Control field.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
void SetQosMeshControlPresent()
Set the Mesh Control Present flag for the QoS header.
Mac48Address m_addr3
address 3
bool IsPowerManagement() const
Return if the Power Management bit is set.
void SetPowerManagement()
Set the Power Management bit in the Frame Control field.
uint8_t m_ctrlMoreFrag
control more fragments
QosAckPolicy
Ack policy for QoS frames.
bool IsMultihopAction() const
Check if the header is a Multihop action header.
void SetNoRetry()
Un-set the Retry bit in the Frame Control field.
bool IsDeauthentication() const
Return true if the header is a Deauthentication header.
uint8_t m_ctrlToDs
control to DS
bool IsAuthentication() const
Return true if the header is an Authentication header.
void SetNoPowerManagement()
Un-set the Power Management bit in the Frame Control field.
uint8_t m_qosAckPolicy
QoS Ack policy.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
Definition abort.h:38
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition nstime.h:1369
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ DATA
Definition ul-job.h:30
WifiMacType
Combination of valid MAC header type/subtype.
@ WIFI_MAC_QOSDATA_NULL_CFACK_CFPOLL
@ WIFI_MAC_CTL_TRIGGER
@ WIFI_MAC_MGT_PROBE_REQUEST
@ WIFI_MAC_CTL_END_ACK
@ WIFI_MAC_DATA_CFACK
@ WIFI_MAC_CTL_BACKREQ
@ WIFI_MAC_DATA_NULL
@ WIFI_MAC_CTL_PSPOLL
@ WIFI_MAC_CTL_RTS
@ WIFI_MAC_CTL_CTS
@ WIFI_MAC_MGT_AUTHENTICATION
@ WIFI_MAC_MGT_MULTIHOP_ACTION
@ WIFI_MAC_CTL_CTLWRAPPER
@ WIFI_MAC_QOSDATA_CFACK_CFPOLL
@ WIFI_MAC_MGT_BEACON
@ WIFI_MAC_MGT_ACTION
@ WIFI_MAC_MGT_ASSOCIATION_RESPONSE
@ WIFI_MAC_CTL_ACK
@ WIFI_MAC_MGT_DISASSOCIATION
@ WIFI_MAC_QOSDATA_NULL_CFPOLL
@ WIFI_MAC_MGT_ASSOCIATION_REQUEST
@ WIFI_MAC_DATA_NULL_CFACK_CFPOLL
@ WIFI_MAC_MGT_REASSOCIATION_REQUEST
@ WIFI_MAC_QOSDATA_CFACK
@ WIFI_MAC_CTL_BACKRESP
@ WIFI_MAC_DATA_CFACK_CFPOLL
@ WIFI_MAC_DATA_CFPOLL
@ WIFI_MAC_CTL_END
@ WIFI_MAC_DATA_NULL_CFACK
@ WIFI_MAC_MGT_ACTION_NO_ACK
@ WIFI_MAC_MGT_DEAUTHENTICATION
@ WIFI_MAC_QOSDATA_NULL
@ WIFI_MAC_DATA_NULL_CFPOLL
@ WIFI_MAC_MGT_PROBE_RESPONSE
@ WIFI_MAC_QOSDATA_CFPOLL
@ WIFI_MAC_DATA
@ WIFI_MAC_MGT_REASSOCIATION_RESPONSE
@ WIFI_MAC_QOSDATA
void WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
@ SUBTYPE_CTL_PSPOLL
@ SUBTYPE_CTL_END
@ SUBTYPE_CTL_BACKREQ
@ SUBTYPE_CTL_NDPANNOUNCE
@ SUBTYPE_CTL_END_ACK
@ SUBTYPE_CTL_CTLWRAPPER
@ SUBTYPE_CTL_TRIGGER
@ SUBTYPE_CTL_CTS
@ SUBTYPE_CTL_BACKRESP
@ SUBTYPE_CTL_RTS
@ SUBTYPE_CTL_BEAMFORMINGRPOLL
@ SUBTYPE_CTL_CTLFRAMEEXT
@ SUBTYPE_CTL_ACK
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
#define CASE_WIFI_MAC_TYPE(x)