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
790uint16_t
792{
793 return (m_seqSeq << 4) | m_seqFrag;
794}
795
796uint16_t
798{
799 return m_seqSeq;
800}
801
802uint8_t
804{
805 return m_seqFrag;
806}
807
808bool
810{
811 return (m_ctrlRetry == 1);
812}
813
814bool
816{
817 return (m_ctrlMoreData == 1);
818}
819
820bool
822{
823 return (m_ctrlMoreFrag == 1);
824}
825
826bool
828{
829 return (m_ctrlPowerManagement == 1);
830}
831
832bool
834{
835 return (IsQosData() && m_qosAckPolicy == 3);
836}
837
838bool
840{
841 return (IsQosData() && m_qosAckPolicy == 1);
842}
843
844bool
846{
847 return (IsQosData() && m_qosAckPolicy == 0);
848}
849
850bool
852{
853 return (IsQosData() && m_qosEosp == 1);
854}
855
858{
860 QosAckPolicy policy;
861
862 switch (m_qosAckPolicy)
863 {
864 case 0:
865 policy = NORMAL_ACK;
866 break;
867 case 1:
868 policy = NO_ACK;
869 break;
870 case 2:
871 policy = NO_EXPLICIT_ACK;
872 break;
873 case 3:
874 policy = BLOCK_ACK;
875 break;
876 default:
877 NS_ABORT_MSG("Unknown QoS Ack policy");
878 }
879 return policy;
880}
881
882bool
884{
885 return (IsQosData() && m_amsduPresent == 1);
886}
887
888uint8_t
890{
892 return m_qosTid;
893}
894
895uint8_t
897{
898 NS_ASSERT(m_qosEosp == 1);
899 return m_qosStuff;
900}
901
902uint16_t
904{
905 uint16_t val = 0;
906 val |= (m_ctrlType << 2) & (0x3 << 2);
907 val |= (m_ctrlSubtype << 4) & (0xf << 4);
908 val |= (m_ctrlToDs << 8) & (0x1 << 8);
909 val |= (m_ctrlFromDs << 9) & (0x1 << 9);
910 val |= (m_ctrlMoreFrag << 10) & (0x1 << 10);
911 val |= (m_ctrlRetry << 11) & (0x1 << 11);
912 val |= (m_ctrlPowerManagement << 12) & (0x1 << 12);
913 val |= (m_ctrlMoreData << 13) & (0x1 << 13);
914 val |= (m_ctrlWep << 14) & (0x1 << 14);
915 val |= (m_ctrlOrder << 15) & (0x1 << 15);
916 return val;
917}
918
919uint16_t
921{
922 uint16_t val = 0;
923 val |= m_qosTid;
924 val |= m_qosEosp << 4;
925 val |= m_qosAckPolicy << 5;
926 val |= m_amsduPresent << 7;
927 val |= m_qosStuff << 8;
928 return val;
929}
930
931void
933{
934 m_ctrlType = (ctrl >> 2) & 0x03;
935 m_ctrlSubtype = (ctrl >> 4) & 0x0f;
936 m_ctrlToDs = (ctrl >> 8) & 0x01;
937 m_ctrlFromDs = (ctrl >> 9) & 0x01;
938 m_ctrlMoreFrag = (ctrl >> 10) & 0x01;
939 m_ctrlRetry = (ctrl >> 11) & 0x01;
940 m_ctrlPowerManagement = (ctrl >> 12) & 0x01;
941 m_ctrlMoreData = (ctrl >> 13) & 0x01;
942 m_ctrlWep = (ctrl >> 14) & 0x01;
943 m_ctrlOrder = (ctrl >> 15) & 0x01;
944}
945
946void
948{
949 m_seqFrag = seq & 0x0f;
950 m_seqSeq = (seq >> 4) & 0x0fff;
951}
952
953void
955{
956 m_qosTid = qos & 0x000f;
957 m_qosEosp = (qos >> 4) & 0x0001;
958 m_qosAckPolicy = (qos >> 5) & 0x0003;
959 m_amsduPresent = (qos >> 7) & 0x0001;
960 m_qosStuff = (qos >> 8) & 0x00ff;
961}
962
965{
966 uint32_t size = 0;
967 switch (m_ctrlType)
968 {
969 case TYPE_MGT:
970 size = 2 + 2 + 6 + 6 + 6 + 2;
971 break;
972 case TYPE_CTL:
973 switch (m_ctrlSubtype)
974 {
976 case SUBTYPE_CTL_RTS:
980 case SUBTYPE_CTL_END:
982 size = 2 + 2 + 6 + 6;
983 break;
984 case SUBTYPE_CTL_CTS:
985 case SUBTYPE_CTL_ACK:
986 size = 2 + 2 + 6;
987 break;
989 size = 2 + 2 + 6 + 2 + 4;
990 break;
991 }
992 break;
993 case TYPE_DATA:
994 size = 2 + 2 + 6 + 6 + 6 + 2;
996 {
997 size += 6;
998 }
999 if (m_ctrlSubtype & 0x08)
1000 {
1001 size += 2;
1002 }
1003 break;
1004 }
1005 return size;
1006}
1007
1008const char*
1010{
1011#define CASE_WIFI_MAC_TYPE(x) \
1012 case WIFI_MAC_##x: \
1013 return #x;
1014
1015 switch (GetType())
1016 {
1017 CASE_WIFI_MAC_TYPE(CTL_RTS);
1018 CASE_WIFI_MAC_TYPE(CTL_CTS);
1019 CASE_WIFI_MAC_TYPE(CTL_ACK);
1020 CASE_WIFI_MAC_TYPE(CTL_BACKREQ);
1021 CASE_WIFI_MAC_TYPE(CTL_BACKRESP);
1022 CASE_WIFI_MAC_TYPE(CTL_END);
1023 CASE_WIFI_MAC_TYPE(CTL_END_ACK);
1024 CASE_WIFI_MAC_TYPE(CTL_PSPOLL);
1025 CASE_WIFI_MAC_TYPE(CTL_TRIGGER);
1026
1027 CASE_WIFI_MAC_TYPE(MGT_BEACON);
1028 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_REQUEST);
1029 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_RESPONSE);
1030 CASE_WIFI_MAC_TYPE(MGT_DISASSOCIATION);
1031 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_REQUEST);
1032 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_RESPONSE);
1033 CASE_WIFI_MAC_TYPE(MGT_PROBE_REQUEST);
1034 CASE_WIFI_MAC_TYPE(MGT_PROBE_RESPONSE);
1035 CASE_WIFI_MAC_TYPE(MGT_AUTHENTICATION);
1036 CASE_WIFI_MAC_TYPE(MGT_DEAUTHENTICATION);
1037 CASE_WIFI_MAC_TYPE(MGT_ACTION);
1038 CASE_WIFI_MAC_TYPE(MGT_ACTION_NO_ACK);
1039 CASE_WIFI_MAC_TYPE(MGT_MULTIHOP_ACTION);
1040
1042 CASE_WIFI_MAC_TYPE(DATA_CFACK);
1043 CASE_WIFI_MAC_TYPE(DATA_CFPOLL);
1044 CASE_WIFI_MAC_TYPE(DATA_CFACK_CFPOLL);
1045 CASE_WIFI_MAC_TYPE(DATA_NULL);
1046 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK);
1047 CASE_WIFI_MAC_TYPE(DATA_NULL_CFPOLL);
1048 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK_CFPOLL);
1049 CASE_WIFI_MAC_TYPE(QOSDATA);
1050 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK);
1051 CASE_WIFI_MAC_TYPE(QOSDATA_CFPOLL);
1052 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK_CFPOLL);
1053 CASE_WIFI_MAC_TYPE(QOSDATA_NULL);
1054 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFPOLL);
1055 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFACK_CFPOLL);
1056 default:
1057 return "ERROR";
1058 }
1059#undef CASE_WIFI_MAC_TYPE
1060#ifndef _WIN32
1061 // needed to make gcc 4.0.1 ppc darwin happy.
1062 return "BIG_ERROR";
1063#endif
1064}
1065
1066TypeId
1068{
1069 static TypeId tid = TypeId("ns3::WifiMacHeader")
1070 .SetParent<Header>()
1071 .SetGroupName("Wifi")
1072 .AddConstructor<WifiMacHeader>();
1073 return tid;
1074}
1075
1076TypeId
1078{
1079 return GetTypeId();
1080}
1081
1082void
1084{
1085 os << "ToDS=" << std::hex << static_cast<int>(m_ctrlToDs)
1086 << ", FromDS=" << static_cast<int>(m_ctrlFromDs)
1087 << ", MoreFrag=" << static_cast<int>(m_ctrlMoreFrag)
1088 << ", Retry=" << static_cast<int>(m_ctrlRetry)
1089 << ", PowerManagement=" << static_cast<int>(m_ctrlPowerManagement)
1090 << ", MoreData=" << static_cast<int>(m_ctrlMoreData) << std::dec;
1091}
1092
1093void
1094WifiMacHeader::Print(std::ostream& os) const
1095{
1096 os << GetTypeString() << " ";
1097 switch (GetType())
1098 {
1100 os << "Duration/ID=" << std::hex << m_duration << std::dec << ", BSSID(RA)=" << m_addr1
1101 << ", TA=" << m_addr2;
1102 break;
1103 case WIFI_MAC_CTL_RTS:
1105 os << "Duration/ID=" << m_duration << "us"
1106 << ", RA=" << m_addr1 << ", TA=" << m_addr2;
1107 break;
1108 case WIFI_MAC_CTL_CTS:
1109 case WIFI_MAC_CTL_ACK:
1110 os << "Duration/ID=" << m_duration << "us"
1111 << ", RA=" << m_addr1;
1112 break;
1126 os << " Duration/ID=" << m_duration << "us"
1127 << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
1128 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1129 << ", SeqNumber=" << m_seqSeq;
1130 break;
1132 os << " Duration/ID=" << m_duration << "us"
1133 << ", RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
1134 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1135 << ", SeqNumber=" << m_seqSeq;
1136 break;
1137 case WIFI_MAC_DATA:
1138 case WIFI_MAC_QOSDATA:
1140 os << " Duration/ID=" << m_duration << "us";
1141 if (!m_ctrlToDs && !m_ctrlFromDs)
1142 {
1143 os << ", DA(RA)=" << m_addr1 << ", SA(TA)=" << m_addr2 << ", BSSID=" << m_addr3;
1144 }
1145 else if (!m_ctrlToDs && m_ctrlFromDs)
1146 {
1147 os << ", DA(RA)=" << m_addr1 << ", SA=" << m_addr3 << ", BSSID(TA)=" << m_addr2;
1148 }
1149 else if (m_ctrlToDs && !m_ctrlFromDs)
1150 {
1151 os << ", DA=" << m_addr3 << ", SA(TA)=" << m_addr2 << ", BSSID(RA)=" << m_addr1;
1152 }
1153 else if (m_ctrlToDs && m_ctrlFromDs)
1154 {
1155 os << ", DA=" << m_addr3 << ", SA=" << m_addr4 << ", RA=" << m_addr1
1156 << ", TA=" << m_addr2;
1157 }
1158 else
1159 {
1160 NS_FATAL_ERROR("Impossible ToDs and FromDs flags combination");
1161 }
1162 os << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1163 << ", SeqNumber=" << m_seqSeq;
1164 if (IsQosData())
1165 {
1166 os << ", tid=" << +m_qosTid;
1167 if (IsQosAmsdu())
1168 {
1169 os << ", A-MSDU";
1170 }
1171 if (IsQosNoAck())
1172 {
1173 os << ", ack=NoAck";
1174 }
1175 else if (IsQosAck())
1176 {
1177 os << ", ack=NormalAck";
1178 }
1179 else if (IsQosBlockAck())
1180 {
1181 os << ", ack=BlockAck";
1182 }
1183 }
1184 break;
1188 case WIFI_MAC_CTL_END:
1193 case WIFI_MAC_DATA_NULL:
1203 default:
1204 break;
1205 }
1206}
1207
1210{
1211 return GetSize();
1212}
1213
1214void
1216{
1219 WriteTo(i, m_addr1);
1220 switch (m_ctrlType)
1221 {
1222 case TYPE_MGT:
1223 WriteTo(i, m_addr2);
1224 WriteTo(i, m_addr3);
1226 break;
1227 case TYPE_CTL:
1228 switch (m_ctrlSubtype)
1229 {
1230 case SUBTYPE_CTL_PSPOLL:
1231 case SUBTYPE_CTL_RTS:
1235 case SUBTYPE_CTL_END:
1237 WriteTo(i, m_addr2);
1238 break;
1239 case SUBTYPE_CTL_CTS:
1240 case SUBTYPE_CTL_ACK:
1241 break;
1242 default:
1243 // NOTREACHED
1244 NS_ASSERT(false);
1245 break;
1246 }
1247 break;
1248 case TYPE_DATA: {
1249 WriteTo(i, m_addr2);
1250 WriteTo(i, m_addr3);
1252 if (m_ctrlToDs && m_ctrlFromDs)
1253 {
1254 WriteTo(i, m_addr4);
1255 }
1256 if (m_ctrlSubtype & 0x08)
1257 {
1259 }
1260 }
1261 break;
1262 default:
1263 // NOTREACHED
1264 NS_ASSERT(false);
1265 break;
1266 }
1267}
1268
1271{
1272 Buffer::Iterator i = start;
1273 uint16_t frame_control = i.ReadLsbtohU16();
1274 SetFrameControl(frame_control);
1276 ReadFrom(i, m_addr1);
1277 switch (m_ctrlType)
1278 {
1279 case TYPE_MGT:
1280 ReadFrom(i, m_addr2);
1281 ReadFrom(i, m_addr3);
1283 break;
1284 case TYPE_CTL:
1285 switch (m_ctrlSubtype)
1286 {
1287 case SUBTYPE_CTL_PSPOLL:
1288 case SUBTYPE_CTL_RTS:
1292 case SUBTYPE_CTL_END:
1294 ReadFrom(i, m_addr2);
1295 break;
1296 case SUBTYPE_CTL_CTS:
1297 case SUBTYPE_CTL_ACK:
1298 break;
1299 }
1300 break;
1301 case TYPE_DATA:
1302 ReadFrom(i, m_addr2);
1303 ReadFrom(i, m_addr3);
1305 if (m_ctrlToDs && m_ctrlFromDs)
1306 {
1307 ReadFrom(i, m_addr4);
1308 }
1309 if (m_ctrlSubtype & 0x08)
1310 {
1312 }
1313 break;
1314 }
1315 return i.GetDistanceFrom(start);
1316}
1317
1318} // 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)