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{
836 return (m_qosAckPolicy == 3);
837}
838
839bool
841{
843 return (m_qosAckPolicy == 1);
844}
845
846bool
848{
850 return (m_qosAckPolicy == 0);
851}
852
853bool
855{
857 return (m_qosEosp == 1);
858}
859
862{
864 QosAckPolicy policy;
865
866 switch (m_qosAckPolicy)
867 {
868 case 0:
869 policy = NORMAL_ACK;
870 break;
871 case 1:
872 policy = NO_ACK;
873 break;
874 case 2:
875 policy = NO_EXPLICIT_ACK;
876 break;
877 case 3:
878 policy = BLOCK_ACK;
879 break;
880 default:
881 NS_ABORT_MSG("Unknown QoS Ack policy");
882 }
883 return policy;
884}
885
886bool
888{
890 return (m_amsduPresent == 1);
891}
892
893uint8_t
895{
897 return m_qosTid;
898}
899
900uint8_t
902{
903 NS_ASSERT(m_qosEosp == 1);
904 return m_qosStuff;
905}
906
907uint16_t
909{
910 uint16_t val = 0;
911 val |= (m_ctrlType << 2) & (0x3 << 2);
912 val |= (m_ctrlSubtype << 4) & (0xf << 4);
913 val |= (m_ctrlToDs << 8) & (0x1 << 8);
914 val |= (m_ctrlFromDs << 9) & (0x1 << 9);
915 val |= (m_ctrlMoreFrag << 10) & (0x1 << 10);
916 val |= (m_ctrlRetry << 11) & (0x1 << 11);
917 val |= (m_ctrlPowerManagement << 12) & (0x1 << 12);
918 val |= (m_ctrlMoreData << 13) & (0x1 << 13);
919 val |= (m_ctrlWep << 14) & (0x1 << 14);
920 val |= (m_ctrlOrder << 15) & (0x1 << 15);
921 return val;
922}
923
924uint16_t
926{
927 uint16_t val = 0;
928 val |= m_qosTid;
929 val |= m_qosEosp << 4;
930 val |= m_qosAckPolicy << 5;
931 val |= m_amsduPresent << 7;
932 val |= m_qosStuff << 8;
933 return val;
934}
935
936void
938{
939 m_ctrlType = (ctrl >> 2) & 0x03;
940 m_ctrlSubtype = (ctrl >> 4) & 0x0f;
941 m_ctrlToDs = (ctrl >> 8) & 0x01;
942 m_ctrlFromDs = (ctrl >> 9) & 0x01;
943 m_ctrlMoreFrag = (ctrl >> 10) & 0x01;
944 m_ctrlRetry = (ctrl >> 11) & 0x01;
945 m_ctrlPowerManagement = (ctrl >> 12) & 0x01;
946 m_ctrlMoreData = (ctrl >> 13) & 0x01;
947 m_ctrlWep = (ctrl >> 14) & 0x01;
948 m_ctrlOrder = (ctrl >> 15) & 0x01;
949}
950
951void
953{
954 m_seqFrag = seq & 0x0f;
955 m_seqSeq = (seq >> 4) & 0x0fff;
956}
957
958void
960{
961 m_qosTid = qos & 0x000f;
962 m_qosEosp = (qos >> 4) & 0x0001;
963 m_qosAckPolicy = (qos >> 5) & 0x0003;
964 m_amsduPresent = (qos >> 7) & 0x0001;
965 m_qosStuff = (qos >> 8) & 0x00ff;
966}
967
970{
971 uint32_t size = 0;
972 switch (m_ctrlType)
973 {
974 case TYPE_MGT:
975 size = 2 + 2 + 6 + 6 + 6 + 2;
976 break;
977 case TYPE_CTL:
978 switch (m_ctrlSubtype)
979 {
981 case SUBTYPE_CTL_RTS:
985 case SUBTYPE_CTL_END:
987 size = 2 + 2 + 6 + 6;
988 break;
989 case SUBTYPE_CTL_CTS:
990 case SUBTYPE_CTL_ACK:
991 size = 2 + 2 + 6;
992 break;
994 size = 2 + 2 + 6 + 2 + 4;
995 break;
996 }
997 break;
998 case TYPE_DATA:
999 size = 2 + 2 + 6 + 6 + 6 + 2;
1000 if (m_ctrlToDs && m_ctrlFromDs)
1001 {
1002 size += 6;
1003 }
1004 if (m_ctrlSubtype & 0x08)
1005 {
1006 size += 2;
1007 }
1008 break;
1009 }
1010 return size;
1011}
1012
1013const char*
1015{
1016#define CASE_WIFI_MAC_TYPE(x) \
1017 case WIFI_MAC_##x: \
1018 return #x;
1019
1020 switch (GetType())
1021 {
1022 CASE_WIFI_MAC_TYPE(CTL_RTS);
1023 CASE_WIFI_MAC_TYPE(CTL_CTS);
1024 CASE_WIFI_MAC_TYPE(CTL_ACK);
1025 CASE_WIFI_MAC_TYPE(CTL_BACKREQ);
1026 CASE_WIFI_MAC_TYPE(CTL_BACKRESP);
1027 CASE_WIFI_MAC_TYPE(CTL_END);
1028 CASE_WIFI_MAC_TYPE(CTL_END_ACK);
1029 CASE_WIFI_MAC_TYPE(CTL_PSPOLL);
1030 CASE_WIFI_MAC_TYPE(CTL_TRIGGER);
1031
1032 CASE_WIFI_MAC_TYPE(MGT_BEACON);
1033 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_REQUEST);
1034 CASE_WIFI_MAC_TYPE(MGT_ASSOCIATION_RESPONSE);
1035 CASE_WIFI_MAC_TYPE(MGT_DISASSOCIATION);
1036 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_REQUEST);
1037 CASE_WIFI_MAC_TYPE(MGT_REASSOCIATION_RESPONSE);
1038 CASE_WIFI_MAC_TYPE(MGT_PROBE_REQUEST);
1039 CASE_WIFI_MAC_TYPE(MGT_PROBE_RESPONSE);
1040 CASE_WIFI_MAC_TYPE(MGT_AUTHENTICATION);
1041 CASE_WIFI_MAC_TYPE(MGT_DEAUTHENTICATION);
1042 CASE_WIFI_MAC_TYPE(MGT_ACTION);
1043 CASE_WIFI_MAC_TYPE(MGT_ACTION_NO_ACK);
1044 CASE_WIFI_MAC_TYPE(MGT_MULTIHOP_ACTION);
1045
1047 CASE_WIFI_MAC_TYPE(DATA_CFACK);
1048 CASE_WIFI_MAC_TYPE(DATA_CFPOLL);
1049 CASE_WIFI_MAC_TYPE(DATA_CFACK_CFPOLL);
1050 CASE_WIFI_MAC_TYPE(DATA_NULL);
1051 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK);
1052 CASE_WIFI_MAC_TYPE(DATA_NULL_CFPOLL);
1053 CASE_WIFI_MAC_TYPE(DATA_NULL_CFACK_CFPOLL);
1054 CASE_WIFI_MAC_TYPE(QOSDATA);
1055 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK);
1056 CASE_WIFI_MAC_TYPE(QOSDATA_CFPOLL);
1057 CASE_WIFI_MAC_TYPE(QOSDATA_CFACK_CFPOLL);
1058 CASE_WIFI_MAC_TYPE(QOSDATA_NULL);
1059 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFPOLL);
1060 CASE_WIFI_MAC_TYPE(QOSDATA_NULL_CFACK_CFPOLL);
1061 default:
1062 return "ERROR";
1063 }
1064#undef CASE_WIFI_MAC_TYPE
1065#ifndef _WIN32
1066 // needed to make gcc 4.0.1 ppc darwin happy.
1067 return "BIG_ERROR";
1068#endif
1069}
1070
1071TypeId
1073{
1074 static TypeId tid = TypeId("ns3::WifiMacHeader")
1075 .SetParent<Header>()
1076 .SetGroupName("Wifi")
1077 .AddConstructor<WifiMacHeader>();
1078 return tid;
1079}
1080
1081TypeId
1083{
1084 return GetTypeId();
1085}
1086
1087void
1089{
1090 os << "ToDS=" << std::hex << static_cast<int>(m_ctrlToDs)
1091 << ", FromDS=" << static_cast<int>(m_ctrlFromDs)
1092 << ", MoreFrag=" << static_cast<int>(m_ctrlMoreFrag)
1093 << ", Retry=" << static_cast<int>(m_ctrlRetry)
1094 << ", PowerManagement=" << static_cast<int>(m_ctrlPowerManagement)
1095 << ", MoreData=" << static_cast<int>(m_ctrlMoreData) << std::dec;
1096}
1097
1098void
1099WifiMacHeader::Print(std::ostream& os) const
1100{
1101 os << GetTypeString() << " ";
1102 switch (GetType())
1103 {
1105 os << "Duration/ID=" << std::hex << m_duration << std::dec << ", BSSID(RA)=" << m_addr1
1106 << ", TA=" << m_addr2;
1107 break;
1108 case WIFI_MAC_CTL_RTS:
1110 os << "Duration/ID=" << m_duration << "us"
1111 << ", RA=" << m_addr1 << ", TA=" << m_addr2;
1112 break;
1113 case WIFI_MAC_CTL_CTS:
1114 case WIFI_MAC_CTL_ACK:
1115 os << "Duration/ID=" << m_duration << "us"
1116 << ", RA=" << m_addr1;
1117 break;
1131 os << " Duration/ID=" << m_duration << "us"
1132 << ", DA=" << m_addr1 << ", SA=" << m_addr2 << ", BSSID=" << m_addr3
1133 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1134 << ", SeqNumber=" << m_seqSeq;
1135 break;
1137 os << " Duration/ID=" << m_duration << "us"
1138 << ", RA=" << m_addr1 << ", TA=" << m_addr2 << ", DA=" << m_addr3
1139 << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1140 << ", SeqNumber=" << m_seqSeq;
1141 break;
1142 case WIFI_MAC_DATA:
1144 os << " Duration/ID=" << m_duration << "us";
1145 if (!m_ctrlToDs && !m_ctrlFromDs)
1146 {
1147 os << ", DA(RA)=" << m_addr1 << ", SA(TA)=" << m_addr2 << ", BSSID=" << m_addr3;
1148 }
1149 else if (!m_ctrlToDs && m_ctrlFromDs)
1150 {
1151 os << ", DA(RA)=" << m_addr1 << ", SA=" << m_addr3 << ", BSSID(TA)=" << m_addr2;
1152 }
1153 else if (m_ctrlToDs && !m_ctrlFromDs)
1154 {
1155 os << ", DA=" << m_addr3 << ", SA(TA)=" << m_addr2 << ", BSSID(RA)=" << m_addr1;
1156 }
1157 else if (m_ctrlToDs && m_ctrlFromDs)
1158 {
1159 os << ", DA=" << m_addr3 << ", SA=" << m_addr4 << ", RA=" << m_addr1
1160 << ", TA=" << m_addr2;
1161 }
1162 else
1163 {
1164 NS_FATAL_ERROR("Impossible ToDs and FromDs flags combination");
1165 }
1166 os << ", FragNumber=" << std::hex << (int)m_seqFrag << std::dec
1167 << ", SeqNumber=" << m_seqSeq;
1168 if (IsQosData())
1169 {
1170 os << ", tid=" << +m_qosTid;
1171 if (IsQosAmsdu())
1172 {
1173 os << ", A-MSDU";
1174 }
1175 if (IsQosNoAck())
1176 {
1177 os << ", ack=NoAck";
1178 }
1179 else if (IsQosAck())
1180 {
1181 os << ", ack=NormalAck";
1182 }
1183 else if (IsQosBlockAck())
1184 {
1185 os << ", ack=BlockAck";
1186 }
1187 }
1188 break;
1192 case WIFI_MAC_CTL_END:
1197 case WIFI_MAC_DATA_NULL:
1201 case WIFI_MAC_QOSDATA:
1208 default:
1209 break;
1210 }
1211}
1212
1215{
1216 return GetSize();
1217}
1218
1219void
1221{
1224 WriteTo(i, m_addr1);
1225 switch (m_ctrlType)
1226 {
1227 case TYPE_MGT:
1228 WriteTo(i, m_addr2);
1229 WriteTo(i, m_addr3);
1231 break;
1232 case TYPE_CTL:
1233 switch (m_ctrlSubtype)
1234 {
1235 case SUBTYPE_CTL_PSPOLL:
1236 case SUBTYPE_CTL_RTS:
1240 case SUBTYPE_CTL_END:
1242 WriteTo(i, m_addr2);
1243 break;
1244 case SUBTYPE_CTL_CTS:
1245 case SUBTYPE_CTL_ACK:
1246 break;
1247 default:
1248 // NOTREACHED
1249 NS_ASSERT(false);
1250 break;
1251 }
1252 break;
1253 case TYPE_DATA: {
1254 WriteTo(i, m_addr2);
1255 WriteTo(i, m_addr3);
1257 if (m_ctrlToDs && m_ctrlFromDs)
1258 {
1259 WriteTo(i, m_addr4);
1260 }
1261 if (m_ctrlSubtype & 0x08)
1262 {
1264 }
1265 }
1266 break;
1267 default:
1268 // NOTREACHED
1269 NS_ASSERT(false);
1270 break;
1271 }
1272}
1273
1276{
1277 Buffer::Iterator i = start;
1278 uint16_t frame_control = i.ReadLsbtohU16();
1279 SetFrameControl(frame_control);
1281 ReadFrom(i, m_addr1);
1282 switch (m_ctrlType)
1283 {
1284 case TYPE_MGT:
1285 ReadFrom(i, m_addr2);
1286 ReadFrom(i, m_addr3);
1288 break;
1289 case TYPE_CTL:
1290 switch (m_ctrlSubtype)
1291 {
1292 case SUBTYPE_CTL_PSPOLL:
1293 case SUBTYPE_CTL_RTS:
1297 case SUBTYPE_CTL_END:
1299 ReadFrom(i, m_addr2);
1300 break;
1301 case SUBTYPE_CTL_CTS:
1302 case SUBTYPE_CTL_ACK:
1303 break;
1304 }
1305 break;
1306 case TYPE_DATA:
1307 ReadFrom(i, m_addr2);
1308 ReadFrom(i, m_addr3);
1310 if (m_ctrlToDs && m_ctrlFromDs)
1311 {
1312 ReadFrom(i, m_addr4);
1313 }
1314 if (m_ctrlSubtype & 0x08)
1315 {
1317 }
1318 break;
1319 }
1320 return i.GetDistanceFrom(start);
1321}
1322
1323} // 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:48
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 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 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 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 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 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:1332
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)