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
20
21/// type enumeration
22enum
23{
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
360{
361 m_ctrlMoreData = flag ? 1 : 0;
362}
363
364void
369
370void
375
376void
378{
379 switch (policy)
380 {
381 case NORMAL_ACK:
382 m_qosAckPolicy = 0;
383 break;
384 case NO_ACK:
385 m_qosAckPolicy = 1;
386 break;
387 case NO_EXPLICIT_ACK:
388 m_qosAckPolicy = 2;
389 break;
390 case BLOCK_ACK:
391 m_qosAckPolicy = 3;
392 break;
393 }
394}
395
396void
401
402void
407
408void
410{
411 m_qosStuff = txop;
412}
413
414void
416{
417 m_qosEosp = 1;
418 m_qosStuff = size;
419}
420
421void
423{
424 // Mark bit 0 of this variable instead of bit 8, since m_qosStuff is
425 // shifted by one byte when serialized
426 m_qosStuff = m_qosStuff | 0x01; // bit 8 of QoS Control Field
427}
428
429void
431{
432 // Clear bit 0 of this variable instead of bit 8, since m_qosStuff is
433 // shifted by one byte when serialized
434 m_qosStuff = m_qosStuff & 0xfe; // bit 8 of QoS Control Field
435}
436
439{
440 return m_addr1;
441}
442
445{
446 return m_addr2;
447}
448
451{
452 return m_addr3;
453}
454
457{
458 return m_addr4;
459}
460
463{
464 switch (m_ctrlType)
465 {
466 case TYPE_MGT:
467 switch (m_ctrlSubtype)
468 {
469 case 0:
471 case 1:
473 case 2:
475 case 3:
477 case 4:
479 case 5:
481 case 8:
482 return WIFI_MAC_MGT_BEACON;
483 case 10:
485 case 11:
487 case 12:
489 case 13:
490 return WIFI_MAC_MGT_ACTION;
491 case 14:
493 case 15:
495 }
496 break;
497 case TYPE_CTL:
498 switch (m_ctrlSubtype)
499 {
507 return WIFI_MAC_CTL_PSPOLL;
508 case SUBTYPE_CTL_RTS:
509 return WIFI_MAC_CTL_RTS;
510 case SUBTYPE_CTL_CTS:
511 return WIFI_MAC_CTL_CTS;
512 case SUBTYPE_CTL_ACK:
513 return WIFI_MAC_CTL_ACK;
514 case SUBTYPE_CTL_END:
515 return WIFI_MAC_CTL_END;
518 }
519 break;
520 case TYPE_DATA:
521 switch (m_ctrlSubtype)
522 {
523 case 0:
524 return WIFI_MAC_DATA;
525 case 1:
526 return WIFI_MAC_DATA_CFACK;
527 case 2:
529 case 3:
531 case 4:
532 return WIFI_MAC_DATA_NULL;
533 case 5:
535 case 6:
537 case 7:
539 case 8:
540 return WIFI_MAC_QOSDATA;
541 case 9:
543 case 10:
545 case 11:
547 case 12:
549 case 14:
551 case 15:
553 }
554 break;
555 }
556 // NOTREACHED
557 NS_ASSERT(false);
558 return (WifiMacType)-1;
559}
560
561bool
563{
564 return m_ctrlFromDs == 1;
565}
566
567bool
569{
570 return m_ctrlToDs == 1;
571}
572
573bool
575{
576 return (m_ctrlType == TYPE_DATA);
577}
578
579bool
581{
582 return (m_ctrlType == TYPE_DATA && (m_ctrlSubtype & 0x08));
583}
584
585bool
587{
588 return (m_ctrlType == TYPE_CTL);
589}
590
591bool
593{
594 return (m_ctrlType == TYPE_MGT);
595}
596
597bool
599{
600 switch (GetType())
601 {
610 return true;
611 default:
612 return false;
613 }
614}
615
616bool
618{
619 switch (GetType())
620 {
621 case WIFI_MAC_CTL_END:
623 return true;
624 default:
625 return false;
626 }
627}
628
629bool
631{
632 switch (GetType())
633 {
639 return true;
640 default:
641 return false;
642 }
643}
644
645bool
647{
648 switch (GetType())
649 {
650 case WIFI_MAC_DATA:
654 case WIFI_MAC_QOSDATA:
658 return true;
659 default:
660 return false;
661 }
662}
663
664bool
666{
667 return (GetType() == WIFI_MAC_CTL_RTS);
668}
669
670bool
672{
673 return (GetType() == WIFI_MAC_CTL_CTS);
674}
675
676bool
678{
679 return (GetType() == WIFI_MAC_CTL_PSPOLL);
680}
681
682bool
684{
685 return (GetType() == WIFI_MAC_CTL_ACK);
686}
687
688bool
693
694bool
699
700bool
705
706bool
711
712bool
717
718bool
723
724bool
726{
727 return (GetType() == WIFI_MAC_MGT_BEACON);
728}
729
730bool
735
736bool
741
742bool
747
748bool
750{
751 return (GetType() == WIFI_MAC_MGT_ACTION);
752}
753
754bool
759
760bool
765
766bool
768{
769 return (GetType() == WIFI_MAC_CTL_BACKREQ);
770}
771
772bool
774{
775 return (GetType() == WIFI_MAC_CTL_BACKRESP);
776}
777
778bool
780{
781 return (GetType() == WIFI_MAC_CTL_TRIGGER);
782}
783
784uint16_t
786{
787 return m_duration;
788}
789
790Time
795
796bool
798{
799 // When the contents of a received Duration/ID field, treated as an unsigned integer,
800 // are greater than 32 768, the contents are interpreted as appropriate for the frame
801 // type and subtype or ignored if the receiving MAC entity does not have a defined
802 // interpretation for that type and subtype (IEEE 802.11-2016 sec. 10.27.3)
803 return (GetRawDuration() & 0x8000) == 0;
804}
805
806uint16_t
808{
809 return (m_seqSeq << 4) | m_seqFrag;
810}
811
812uint16_t
814{
815 return m_seqSeq;
816}
817
818uint8_t
820{
821 return m_seqFrag;
822}
823
824bool
826{
827 return (m_ctrlRetry == 1);
828}
829
830bool
832{
833 return (m_ctrlMoreData == 1);
834}
835
836bool
838{
839 return (m_ctrlMoreFrag == 1);
840}
841
842bool
844{
845 return (m_ctrlPowerManagement == 1);
846}
847
848bool
850{
851 return (IsQosData() && m_qosAckPolicy == 3);
852}
853
854bool
856{
857 return (IsQosData() && m_qosAckPolicy == 1);
858}
859
860bool
862{
863 return (IsQosData() && m_qosAckPolicy == 0);
864}
865
866bool
868{
869 return (IsQosData() && m_qosEosp == 1);
870}
871
874{
876 QosAckPolicy policy;
877
878 switch (m_qosAckPolicy)
879 {
880 case 0:
881 policy = NORMAL_ACK;
882 break;
883 case 1:
884 policy = NO_ACK;
885 break;
886 case 2:
887 policy = NO_EXPLICIT_ACK;
888 break;
889 case 3:
890 policy = BLOCK_ACK;
891 break;
892 default:
893 NS_ABORT_MSG("Unknown QoS Ack policy");
894 }
895 return policy;
896}
897
898bool
900{
901 return (IsQosData() && m_amsduPresent == 1);
902}
903
904uint8_t
906{
908 return m_qosTid;
909}
910
911uint8_t
913{
914 NS_ASSERT(m_qosEosp == 1);
915 return m_qosStuff;
916}
917
918uint16_t
920{
921 uint16_t val = 0;
922 val |= (m_ctrlType << 2) & (0x3 << 2);
923 val |= (m_ctrlSubtype << 4) & (0xf << 4);
924 val |= (m_ctrlToDs << 8) & (0x1 << 8);
925 val |= (m_ctrlFromDs << 9) & (0x1 << 9);
926 val |= (m_ctrlMoreFrag << 10) & (0x1 << 10);
927 val |= (m_ctrlRetry << 11) & (0x1 << 11);
928 val |= (m_ctrlPowerManagement << 12) & (0x1 << 12);
929 val |= (m_ctrlMoreData << 13) & (0x1 << 13);
930 val |= (m_ctrlWep << 14) & (0x1 << 14);
931 val |= (m_ctrlOrder << 15) & (0x1 << 15);
932 return val;
933}
934
935uint16_t
937{
938 uint16_t val = 0;
939 val |= m_qosTid;
940 val |= m_qosEosp << 4;
941 val |= m_qosAckPolicy << 5;
942 val |= m_amsduPresent << 7;
943 val |= m_qosStuff << 8;
944 return val;
945}
946
947void
949{
950 m_ctrlType = (ctrl >> 2) & 0x03;
951 m_ctrlSubtype = (ctrl >> 4) & 0x0f;
952 m_ctrlToDs = (ctrl >> 8) & 0x01;
953 m_ctrlFromDs = (ctrl >> 9) & 0x01;
954 m_ctrlMoreFrag = (ctrl >> 10) & 0x01;
955 m_ctrlRetry = (ctrl >> 11) & 0x01;
956 m_ctrlPowerManagement = (ctrl >> 12) & 0x01;
957 m_ctrlMoreData = (ctrl >> 13) & 0x01;
958 m_ctrlWep = (ctrl >> 14) & 0x01;
959 m_ctrlOrder = (ctrl >> 15) & 0x01;
960}
961
962void
964{
965 m_seqFrag = seq & 0x0f;
966 m_seqSeq = (seq >> 4) & 0x0fff;
967}
968
969void
971{
972 m_qosTid = qos & 0x000f;
973 m_qosEosp = (qos >> 4) & 0x0001;
974 m_qosAckPolicy = (qos >> 5) & 0x0003;
975 m_amsduPresent = (qos >> 7) & 0x0001;
976 m_qosStuff = (qos >> 8) & 0x00ff;
977}
978
981{
982 uint32_t size = 0;
983 switch (m_ctrlType)
984 {
985 case TYPE_MGT:
986 size = 2 + 2 + 6 + 6 + 6 + 2;
987 break;
988 case TYPE_CTL:
989 switch (m_ctrlSubtype)
990 {
992 case SUBTYPE_CTL_RTS:
996 case SUBTYPE_CTL_END:
998 size = 2 + 2 + 6 + 6;
999 break;
1000 case SUBTYPE_CTL_CTS:
1001 case SUBTYPE_CTL_ACK:
1002 size = 2 + 2 + 6;
1003 break;
1005 size = 2 + 2 + 6 + 2 + 4;
1006 break;
1007 }
1008 break;
1009 case TYPE_DATA:
1010 size = 2 + 2 + 6 + 6 + 6 + 2;
1011 if (m_ctrlToDs && m_ctrlFromDs)
1012 {
1013 size += 6;
1014 }
1015 if (m_ctrlSubtype & 0x08)
1016 {
1017 size += 2;
1018 }
1019 break;
1020 }
1021 return size;
1022}
1023
1024const char*
1026{
1027#define CASE_WIFI_MAC_TYPE(x) \
1028 case WIFI_MAC_##x: \
1029 return #x;
1030
1031 switch (GetType())
1032 {
1033 CASE_WIFI_MAC_TYPE(CTL_RTS);
1034 CASE_WIFI_MAC_TYPE(CTL_CTS);
1035 CASE_WIFI_MAC_TYPE(CTL_ACK);
1036 CASE_WIFI_MAC_TYPE(CTL_BACKREQ);
1037 CASE_WIFI_MAC_TYPE(CTL_BACKRESP);
1038 CASE_WIFI_MAC_TYPE(CTL_END);
1039 CASE_WIFI_MAC_TYPE(CTL_END_ACK);
1040 CASE_WIFI_MAC_TYPE(CTL_PSPOLL);
1041 CASE_WIFI_MAC_TYPE(CTL_TRIGGER);
1042
1043 CASE_WIFI_MAC_TYPE(MGT_BEACON);
1044 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_REQUEST);
1045 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_RESPONSE);
1046 CASE_WIFI_MAC_TYPE(MGT_DISASSOCIATION);
1047 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_REQUEST);
1048 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_RESPONSE);
1049 CASE_WIFI_MAC_TYPE(MGT_PROBE_REQUEST);
1050 CASE_WIFI_MAC_TYPE(MGT_PROBE_RESPONSE);
1051 CASE_WIFI_MAC_TYPE(MGT_AUTHENTICATION);
1052 CASE_WIFI_MAC_TYPE(MGT_DEAUTHENTICATION);
1053 CASE_WIFI_MAC_TYPE(MGT_ACTION);
1054 CASE_WIFI_MAC_TYPE(MGT_ACTION_NO_ACK);
1055 CASE_WIFI_MAC_TYPE(MGT_MULTIHOP_ACTION);
1056
1057 CASE_WIFI_MAC_TYPE(DATA);
1058 CASE_WIFI_MAC_TYPE(DATA_CFACK);
1059 CASE_WIFI_MAC_TYPE(DATA_CFPOLL);
1060 CASE_WIFI_MAC_TYPE(DATA_CFACK_CFPOLL);
1061 CASE_WIFI_MAC_TYPE(DATA_NULL);
1062 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK);
1063 CASE_WIFI_MAC_TYPE(DATA_NULL_CFPOLL);
1064 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK_CFPOLL);
1065 CASE_WIFI_MAC_TYPE(QOSDATA);
1066 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK);
1067 CASE_WIFI_MAC_TYPE(QOSDATA_CFPOLL);
1068 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK_CFPOLL);
1069 CASE_WIFI_MAC_TYPE(QOSDATA_NULL);
1070 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFPOLL);
1071 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFACK_CFPOLL);
1072 default:
1073 return "ERROR";
1074 }
1075#undef CASE_WIFI_MAC_TYPE
1076#ifndef _WIN32
1077 // needed to make gcc 4.0.1 ppc darwin happy.
1078 return "BIG_ERROR";
1079#endif
1080}
1081
1082TypeId
1084{
1085 static TypeId tid = TypeId("ns3::WifiMacHeader")
1086 .SetParent<Header>()
1087 .SetGroupName("Wifi")
1088 .AddConstructor<WifiMacHeader>();
1089 return tid;
1090}
1091
1092TypeId
1094{
1095 return GetTypeId();
1096}
1097
1098void
1100{
1101 os << "ToDS=" << std::hex << static_cast<int>(m_ctrlToDs)
1102 << ", FromDS=" << static_cast<int>(m_ctrlFromDs)
1103 << ", MoreFrag=" << static_cast<int>(m_ctrlMoreFrag)
1104 << ", Retry=" << static_cast<int>(m_ctrlRetry)
1105 << ", PowerManagement=" << static_cast<int>(m_ctrlPowerManagement)
1106 << ", MoreData=" << static_cast<int>(m_ctrlMoreData) << std::dec;
1107}
1108
1109void
1110WifiMacHeader::Print(std::ostream& os) const
1111{
1112 os << GetTypeString() << " ";
1113 switch (GetType())
1114 {
1116 os << "Duration/ID=" << std::hex << m_duration << std::dec << ", BSSID(RA)=" << m_addr1
1117 << ", TA=" << m_addr2;
1118 break;
1119 case WIFI_MAC_CTL_RTS:
1121 os << "Duration/ID=" << m_duration << "us"
1122 << ", RA=" << m_addr1 << ", TA=" << m_addr2;
1123 break;
1124 case WIFI_MAC_CTL_CTS:
1125 case WIFI_MAC_CTL_ACK:
1126 os << "Duration/ID=" << m_duration << "us"
1127 << ", RA=" << m_addr1;
1128 break;
1142 os << " Duration/ID=" << m_duration << "us"
1143 << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
1144 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1145 << ", SeqNumber=" << m_seqSeq;
1146 break;
1148 os << " Duration/ID=" << m_duration << "us"
1149 << ", RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
1150 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1151 << ", SeqNumber=" << m_seqSeq;
1152 break;
1153 case WIFI_MAC_DATA:
1154 case WIFI_MAC_QOSDATA:
1156 os << " Duration/ID=" << m_duration << "us";
1157 if (!m_ctrlToDs && !m_ctrlFromDs)
1158 {
1159 os << ", DA(RA)=" << m_addr1 << ", SA(TA)=" << m_addr2 << ", BSSID=" << m_addr3;
1160 }
1161 else if (!m_ctrlToDs && m_ctrlFromDs)
1162 {
1163 os << ", DA(RA)=" << m_addr1 << ", SA=" << m_addr3 << ", BSSID(TA)=" << m_addr2;
1164 }
1165 else if (m_ctrlToDs && !m_ctrlFromDs)
1166 {
1167 os << ", DA=" << m_addr3 << ", SA(TA)=" << m_addr2 << ", BSSID(RA)=" << m_addr1;
1168 }
1169 else if (m_ctrlToDs && m_ctrlFromDs)
1170 {
1171 os << ", DA=" << m_addr3 << ", SA=" << m_addr4 << ", RA=" << m_addr1
1172 << ", TA=" << m_addr2;
1173 }
1174 else
1175 {
1176 NS_FATAL_ERROR("Impossible ToDs and FromDs flags combination");
1177 }
1178 os << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1179 << ", SeqNumber=" << m_seqSeq;
1180 if (IsQosData())
1181 {
1182 os << ", tid=" << +m_qosTid;
1183 if (IsQosAmsdu())
1184 {
1185 os << ", A-MSDU";
1186 }
1187 if (IsQosNoAck())
1188 {
1189 os << ", ack=NoAck";
1190 }
1191 else if (IsQosAck())
1192 {
1193 os << ", ack=NormalAck";
1194 }
1195 else if (IsQosBlockAck())
1196 {
1197 os << ", ack=BlockAck";
1198 }
1199 }
1200 break;
1203 os << "RA=" << m_addr1 << ", TA=" << m_addr2 << ", Duration/ID=" << m_duration << "us";
1204 break;
1206 case WIFI_MAC_CTL_END:
1211 case WIFI_MAC_DATA_NULL:
1221 default:
1222 break;
1223 }
1224}
1225
1228{
1229 return GetSize();
1230}
1231
1232void
1234{
1237 WriteTo(i, m_addr1);
1238 switch (m_ctrlType)
1239 {
1240 case TYPE_MGT:
1241 WriteTo(i, m_addr2);
1242 WriteTo(i, m_addr3);
1244 break;
1245 case TYPE_CTL:
1246 switch (m_ctrlSubtype)
1247 {
1248 case SUBTYPE_CTL_PSPOLL:
1249 case SUBTYPE_CTL_RTS:
1253 case SUBTYPE_CTL_END:
1255 WriteTo(i, m_addr2);
1256 break;
1257 case SUBTYPE_CTL_CTS:
1258 case SUBTYPE_CTL_ACK:
1259 break;
1260 default:
1261 // NOTREACHED
1262 NS_ASSERT(false);
1263 break;
1264 }
1265 break;
1266 case TYPE_DATA: {
1267 WriteTo(i, m_addr2);
1268 WriteTo(i, m_addr3);
1270 if (m_ctrlToDs && m_ctrlFromDs)
1271 {
1272 WriteTo(i, m_addr4);
1273 }
1274 if (m_ctrlSubtype & 0x08)
1275 {
1277 }
1278 }
1279 break;
1280 default:
1281 // NOTREACHED
1282 NS_ASSERT(false);
1283 break;
1284 }
1285}
1286
1289{
1290 Buffer::Iterator i = start;
1291 uint16_t frame_control = i.ReadU16();
1292 SetFrameControl(frame_control);
1293 m_duration = i.ReadU16();
1294 ReadFrom(i, m_addr1);
1295 switch (m_ctrlType)
1296 {
1297 case TYPE_MGT:
1298 ReadFrom(i, m_addr2);
1299 ReadFrom(i, m_addr3);
1301 break;
1302 case TYPE_CTL:
1303 switch (m_ctrlSubtype)
1304 {
1305 case SUBTYPE_CTL_PSPOLL:
1306 case SUBTYPE_CTL_RTS:
1310 case SUBTYPE_CTL_END:
1312 ReadFrom(i, m_addr2);
1313 break;
1314 case SUBTYPE_CTL_CTS:
1315 case SUBTYPE_CTL_ACK:
1316 break;
1317 }
1318 break;
1319 case TYPE_DATA:
1320 ReadFrom(i, m_addr2);
1321 ReadFrom(i, m_addr3);
1323 if (m_ctrlToDs && m_ctrlFromDs)
1324 {
1325 ReadFrom(i, m_addr4);
1326 }
1327 if (m_ctrlSubtype & 0x08)
1328 {
1330 }
1331 break;
1332 }
1333 return i.GetDistanceFrom(start);
1334}
1335
1336} // namespace ns3
iterator in a Buffer instance
Definition buffer.h:98
void WriteU16(uint16_t data)
Definition buffer.cc:848
uint32_t GetDistanceFrom(const Iterator &o) const
Definition buffer.cc:769
uint16_t ReadU16()
Definition buffer.h:1051
Protocol header serialization and deserialization.
Definition header.h:36
an EUI-48 address
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
Definition nstime.h:413
a unique identifier for an interface.
Definition type-id.h:50
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:999
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 SetMoreData(bool flag)
Set the More Data bit in the Frame 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:1307
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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
@ 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 WriteTo(Buffer::Iterator &i, Ipv4Address ad)
Write an Ipv4Address to a Buffer.
void ReadFrom(Buffer::Iterator &i, Ipv4Address &ad)
Read an Ipv4Address from a Buffer.
#define CASE_WIFI_MAC_TYPE(x)