895 constexpr auto DTIM =
true;
896 constexpr auto NO_DTIM =
false;
897 constexpr auto MCAST_PENDING =
true;
898 constexpr auto MCAST_NOT_PENDING =
false;
899 constexpr std::size_t NON_AP_MLD = 0;
900 constexpr std::size_t NON_AP_STA = 1;
901 constexpr auto SLEEP =
true;
902 constexpr auto AWAKE =
false;
907 bool hasMulticastPending,
908 const std::map<uint16_t, bool>& aidIsSetMap) {
912 "Expected PSDU transmitted at " << now <<
" to be a Beacon frame");
914 mpdu->GetPacket()->PeekHeader(beacon);
915 auto& tim = beacon.Get<
Tim>();
918 "Expected beacon in PSDU transmitted at "
919 << now <<
" to contain a TIM element");
922 "Unexpected DTIM count value for PSDU transmitted at " << now);
925 "Unexpected multicast pending bit value for PSDU transmitted at "
927 for (
const auto& [aid, isSet] : aidIsSetMap)
931 "Unexpected AID " << aid <<
" bit value for PSDU transmitted at "
938 auto checkSleep = [
this](std::size_t staId,
943 m_apMac->GetWifiRemoteStationManager(linkId)->IsInPsMode(
947 <<
"Unexpected power management mode stored at the AP MLD for the non-AP STA"
948 << (staId == 0 ?
" affiliated with the non-AP MLD and operating on link " +
949 std::to_string(linkId)
955 <<
"Unexpected power management mode for non-AP STA"
956 << (staId == 0 ?
" affiliated with the non-AP MLD and operating on link " +
957 std::to_string(linkId)
960 m_staMacs[staId]->GetWifiPhy(linkId)->IsStateSleep(),
963 <<
"Unexpected sleep state for the PHY of the non-AP STA"
964 << (staId == 0 ?
" affiliated with the non-AP MLD and operating on link " +
965 std::to_string(linkId)
971 std::list<uint64_t> uids;
974 uids.push_back(mpdu->GetPacket()->GetUid());
976 model->SetList(uids);
986 checkTim(*psdu->begin(), DTIM, MCAST_NOT_PENDING, {});
991 checkTim(*psdu->begin(), DTIM, MCAST_NOT_PENDING, {});
1007 "Expected non-AP MLD to be associated");
1008 const auto nonApMldAid =
m_staMacs[0]->GetAssociationId();
1011 "Unexpected AID for non-AP MLD (" << nonApMldAid <<
")");
1014 "Expected non-AP STA to be associated");
1015 const auto nonApStaAid =
m_staMacs[1]->GetAssociationId();
1018 "Unexpected AID for non-AP STA (" << nonApStaAid <<
")");
1022 "Expected the Power Management flag not to be set");
1052 checkTim(*psdu->begin(),
1055 {{1, false}, {2, false}, {3, false}});
1058 m_events.emplace_back(
1061 checkTim(*psdu->begin(),
1064 {{1, false}, {2, false}, {3, false}});
1066 m_apMac->GetDevice()->GetNode()->AddApplication(
1067 GetApplication(broadcastAddr, 1, 1000, delay));
1070 m_events.emplace_back(
1075 "Expected a broadcast frame");
1079 "Non-AP MLD expected to receive a broadcast frame");
1081 (linkId == 0 ? 1 : 0),
1082 "Non-AP STA expected to receive a broadcast frame");
1086 m_events.emplace_back(
1091 "Expected a broadcast frame");
1095 "Non-AP MLD expected to receive another broadcast frame");
1098 "Non-AP STA expected to receive a broadcast frame");
1112 checkTim(*psdu->begin(),
1115 {{1, false}, {2, false}, {3, false}});
1118 m_events.emplace_back(
1121 checkTim(*psdu->begin(),
1124 {{1, false}, {2, false}, {3, false}});
1127 m_staMacs[0]->SetPowerSaveMode({
true, 1});
1128 m_staMacs[1]->SetPowerSaveMode({
true, 0});
1132 m_events.emplace_back(
1138 "Expected the Power Management flag to be set");
1140 m_events.emplace_back(
1146 "Expected the Power Management flag to be set");
1151 m_events.emplace_back(
1165 m_apMac->GetDevice()->GetNode()->AddApplication(
1166 GetApplication(broadcastAddr, 1, 1000, delay));
1176 m_events.emplace_back(
1179 checkTim(*psdu->begin(),
1182 {{1, false}, {2, false}, {3, false}});
1193 m_events.emplace_back(
1196 checkTim(*psdu->begin(),
1199 {{1, false}, {2, false}, {3, false}});
1224 m_events.emplace_back(
1227 checkTim(*psdu->begin(),
1230 {{1, true}, {2, false}, {3, false}});
1236 m_apMac->GetDevice()->GetNode()->AddApplication(
1237 GetApplication(nonApMldAddr, 1, 1000,
Time{0}, 4));
1258 m_events.emplace_back(
1263 "Expected a broadcast frame");
1266 "Expected the More Data flag not to be set");
1271 m_apMac->GetDevice()->GetNode()->AddApplication(GetApplication(broadcastAddr, 1, 1000));
1276 "Non-AP MLD expected to receive a broadcast frame");
1279 "Non-AP STA expected to receive a broadcast frame");
1294 m_events.emplace_back(
1298 psdu->GetHeader(0).GetAddr1(),
1299 m_staMacs[NON_AP_MLD]->GetFrameExchangeManager(linkId)->GetAddress(),
1300 "Expected a unicast frame addressed to the STA affiliated with non-AP MLD on link "
1322 m_events.emplace_back(
1325 checkTim(*psdu->begin(),
1328 {{1, true}, {2, false}, {3, false}});
1333 m_apMac->GetDevice()->GetNode()->AddApplication(
1334 GetApplication(nonApStaAddr, 2, 1000,
Time{0}));
1350 m_events.emplace_back(
1355 "Expected a broadcast frame");
1358 "Expected the More Data flag to be set");
1363 "Non-AP MLD expected to receive a broadcast frame");
1366 "Non-AP STA expected to receive a broadcast frame");
1373 m_events.emplace_back(
1378 "Expected a broadcast frame");
1381 "Expected the More Data flag not to be set");
1386 "Non-AP MLD expected to receive a broadcast frame");
1389 "Non-AP STA expected to receive a broadcast frame");
1403 m_events.emplace_back(
1409 "Beacon on link 0 should be sent first; try to modify the Beacon jitter");
1411 const auto aidNonApMld = m_staMacs[0]->GetAssociationId();
1412 const auto aidNonApSta = m_staMacs[1]->GetAssociationId();
1413 checkTim(*psdu->begin(),
1416 {{1, false}, {aidNonApMld, false}, {aidNonApSta, true}});
1428 m_events.emplace_back(
1432 m_staMacs[1]->GetAddress(),
1433 "Unexpected transmitter address for PS Poll frame");
1436 m_events.emplace_back(
1440 m_staMacs[1]->GetAddress(),
1441 "Unexpected receiver address for QoS Data frame after PS Poll");
1444 "Expected the More Data flag to be set");
1449 "Non-AP STA expected to receive a unicast frame");
1453 m_events.emplace_back(
1470 m_events.emplace_back(
1474 m_staMacs[1]->GetAddress(),
1475 "Unexpected transmitter address for PS Poll frame");
1476 dropPsdu(psdu, m_apErrorModel);
1483 m_events.emplace_back(
1493 m_apErrorModel->SetList({});
1506 m_events.emplace_back(
1511 checkTim(*psdu->begin(),
1514 {{1, false}, {2, false}, {3, false}});
1524 rsm->m_drop =
false;
1529 m_apMac->GetFrameExchangeManager(0)->GetAddress(),
1531 auto mpdu = m_apMac->GetTxopQueue(
AC_BE)->PeekByQueueId(queueId);
1533 m_apMac->GetTxopQueue(
AC_BE)->Remove(mpdu);
1550 m_events.emplace_back(
1555 const auto aidNonApMld = m_staMacs[0]->GetAssociationId();
1556 const auto aidNonApSta = m_staMacs[1]->GetAssociationId();
1557 checkTim(*psdu->begin(),
1560 {{1, false}, {aidNonApMld, false}, {aidNonApSta, true}});
1572 m_events.emplace_back(
1576 m_staMacs[1]->GetAddress(),
1577 "Unexpected transmitter address for PS Poll frame");
1580 m_events.emplace_back(
1584 m_staMacs[1]->GetAddress(),
1585 "Unexpected receiver address for QoS Data frame after PS Poll");
1588 "Expected the More Data flag not to be set");
1593 "Non-AP STA expected to receive a unicast frame");
1597 m_events.emplace_back(
1619 m_events.emplace_back(
1624 checkTim(*psdu->begin(),
1627 {{1, false}, {2, false}, {3, false}});
1637 m_apMac->GetDevice()->GetNode()->AddApplication(
1638 GetApplication(nonApMldAddr, 2, 1000,
Time{0}));
1642 m_events.emplace_back(
1648 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
1649 "Unexpected receiver address for first Action frame");
1653 psdu->GetPayload(0)->PeekHeader(actionHdr);
1656 "Expected an Action frame of BLOCK_ACK category");
1659 "Expected an ADDBA Request frame");
1670 m_events.emplace_back(
1676 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
1677 "Unexpected transmitter address for second Action frame");
1680 "Expected the More Data flag not to be set");
1683 "Expected the Power Management flag not to be set");
1686 psdu->GetPayload(0)->PeekHeader(actionHdr);
1689 "Expected an Action frame of BLOCK_ACK category");
1692 "Expected an ADDBA Response frame");
1703 m_events.emplace_back(
1709 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
1710 "Unexpected receiver address for unicast QoS Data frame");
1712 m_apMac->GetFrameExchangeManager(0)->GetAddress(),
1713 "Unexpected transmitter address for unicast QoS Data frame");
1717 "Expected the More Data flag of the first MPDU not to be set");
1720 "Expected the More Data flag of the second MPDU not to be set");
1722 psdu->GetHeader(0).IsPowerManagement(),
1724 "Expected the Power Management flag of the first MPDU not to be set");
1726 psdu->GetHeader(1).IsPowerManagement(),
1728 "Expected the Power Management flag of the second MPDU not to be set");
1731 "Unexpected TID value for the first MPDU");
1734 "Unexpected TID value for the second MPDU");
1739 "Non-AP MLD expected to receive two more (unicast) frames");
1749 m_events.emplace_back(
1760 m_apMac->GetDevice()->GetNode()->AddApplication(
1761 GetApplication(nonApMldAddr, 2, 1000,
Time{0}, 2));
1771 m_events.emplace_back(
1776 const auto aidNonApMld = m_staMacs[0]->GetAssociationId();
1777 const auto aidNonApSta = m_staMacs[1]->GetAssociationId();
1778 checkTim(*psdu->begin(),
1781 {{1, false}, {aidNonApMld, true}, {aidNonApSta, false}});
1805 m_events.emplace_back(
1810 const auto aidNonApMld = m_staMacs[0]->GetAssociationId();
1811 const auto aidNonApSta = m_staMacs[1]->GetAssociationId();
1812 checkTim(*psdu->begin(),
1815 {{1, false}, {aidNonApMld, true}, {aidNonApSta, false}});
1828 m_events.emplace_back(
1832 m_staMacs[0]->GetFrameExchangeManager(1)->GetAddress(),
1833 "Unexpected transmitter address for PS Poll frame");
1836 m_events.emplace_back(
1840 m_staMacs[0]->GetFrameExchangeManager(1)->GetAddress(),
1841 "Unexpected receiver address for QoS Data frame after PS Poll");
1844 "Expected the More Data flag to be set");
1847 dropPsdu(psdu, m_nonApMldErrorModel);
1851 m_nonApMldErrorModel->SetList({});
1855 m_events.emplace_back(
1859 m_staMacs[0]->GetFrameExchangeManager(1)->GetAddress(),
1860 "Unexpected transmitter address for PS Poll frame");
1863 m_events.emplace_back(
1867 m_staMacs[0]->GetFrameExchangeManager(1)->GetAddress(),
1868 "Unexpected receiver address for QoS Data frame after PS Poll");
1871 "Expected the More Data flag to be set");
1876 "Non-AP MLD expected to receive another unicast frame");
1880 m_events.emplace_back(
1891 m_events.emplace_back(
1895 m_staMacs[0]->GetFrameExchangeManager(1)->GetAddress(),
1896 "Unexpected transmitter address for PS Poll frame");
1899 m_events.emplace_back(
1903 m_staMacs[0]->GetFrameExchangeManager(1)->GetAddress(),
1904 "Unexpected receiver address for QoS Data frame after PS Poll");
1907 "Expected the More Data flag not to be set");
1912 "Non-AP MLD expected to receive another unicast frame");
1921 m_events.emplace_back(
1930 m_staMacs[1]->GetDevice()->GetNode()->AddApplication(
1931 GetApplication(apMldAddr, 2, 1000,
Time{0}));
1951 m_events.emplace_back(
1957 m_staMacs[1]->GetFrameExchangeManager(0)->GetAddress(),
1958 "Unexpected transmitter address for Action frame");
1960 psdu->GetHeader(0).IsPowerManagement(),
1962 "Expected the Power Management flag of the ADDBA Request to be set");
1965 psdu->GetPayload(0)->PeekHeader(actionHdr);
1968 "Expected an Action frame of BLOCK_ACK category");
1971 "Expected an ADDBA Request frame");
1979 m_events.emplace_back(
1985 auto acBe = m_staMacs[1]->GetQosTxop(
AC_BE);
1987 m_staMacs[1]->GetChannelAccessManager()->GetBackoffEndFor(acBe);
1990 checkSleep(NON_AP_MLD,
1995 checkSleep(NON_AP_STA,
2004 m_events.emplace_back(
2008 m_staMacs[1]->GetFrameExchangeManager(0)->GetAddress(),
2009 "Unexpected transmitted address for QoS Data frame");
2012 "Expected the Power Management flag to be set");
2022 "AP MLD expected to receive the first unicast frame");
2028 m_events.emplace_back(
2032 m_staMacs[1]->GetFrameExchangeManager(0)->GetAddress(),
2033 "Unexpected transmitted address for QoS Data frame");
2036 "Expected the Power Management flag to be set");
2041 "AP MLD expected to receive the second unicast frame");
2045 m_events.emplace_back(
2060 m_events.emplace_back(
2063 const auto aidNonApMld = m_staMacs[0]->GetAssociationId();
2064 const auto aidNonApSta = m_staMacs[1]->GetAssociationId();
2067 checkTim(*psdu->begin(),
2070 {{1, false}, {aidNonApMld, false}, {aidNonApSta, is11n}});
2085 m_staMacs[0]->GetDevice()->GetNode()->AddApplication(
2086 GetApplication(apMldAddr, 2, 1000,
Time{0}));
2093 m_events.emplace_back(
2097 m_staMacs[1]->GetFrameExchangeManager(0)->GetAddress(),
2098 "Unexpected transmitter address for PS Poll frame");
2101 m_events.emplace_back(
2105 m_staMacs[1]->GetFrameExchangeManager(0)->GetAddress(),
2106 "Unexpected receiver address for Action frame");
2109 psdu->GetPayload(0)->PeekHeader(actionHdr);
2112 "Expected an Action frame of BLOCK_ACK category");
2115 "Expected an ADDBA Response frame");
2125 m_events.emplace_back(
2134 m_staMacs[0]->GetDevice()->GetNode()->AddApplication(
2135 GetApplication(apMldAddr, 2, 1000,
Time{0}));
2155 m_events.emplace_back(
2161 "Expected an Action frame on link 0, try changing RNG seed and run values");
2164 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2165 "Unexpected transmitter address for Action frame");
2167 psdu->GetHeader(0).IsPowerManagement(),
2169 "Expected the Power Management flag of the ADDBA Request not to be set");
2172 psdu->GetPayload(0)->PeekHeader(actionHdr);
2175 "Expected an Action frame of BLOCK_ACK category");
2178 "Expected an ADDBA Request frame");
2188 m_events.emplace_back(
2194 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2195 "Unexpected receiver address for Action frame");
2198 psdu->GetPayload(0)->PeekHeader(actionHdr);
2201 "Expected an Action frame of BLOCK_ACK category");
2204 "Expected an ADDBA Response frame");
2207 m_events.emplace_back(
2229 m_events.emplace_back(
2233 m_apMac->GetFrameExchangeManager(linkId)->GetAddress(),
2234 "Unexpected transmitter address for unicast QoS Data frame");
2236 m_staMacs[0]->GetFrameExchangeManager(linkId)->GetAddress(),
2237 "Unexpected receiver address for unicast QoS Data frame");
2240 psdu->GetHeader(0).IsPowerManagement(),
2242 "Unexpected value for the Power Management flag of the first MPDU");
2244 psdu->GetHeader(1).IsPowerManagement(),
2246 "Unexpected value for the Power Management flag of the second MPDU");
2249 "Unexpected TID value for the first MPDU");
2252 "Unexpected TID value for the second MPDU");
2257 "AP MLD expected to receive two more (unicast) frames");
2261 m_events.emplace_back(
2269 m_apMac->GetDevice()->GetNode()->AddApplication(
2270 GetApplication(nonApMldAddr, 1, 1000,
Time{0}));
2282 m_events.emplace_back(
2286 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2287 "Unexpected receiver address for QoS Data frame");
2290 "Expected the More Data flag not to be set");
2293 dropPsdu(psdu, m_nonApMldErrorModel);
2305 m_nonApMldErrorModel->SetList({});
2307 m_staMacs[0]->SetPowerSaveMode({
true, 0});
2311 m_events.emplace_back(
2315 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2316 "Unexpected transmitter address for Data Null frame");
2320 "Expected the Power Management flag to be set");
2324 m_apMac->GetTxopQueue(
AC_BE)->GetNPackets(),
2326 "Expected only one frame (BlockAckReq) to be queued at the AP MLD");
2327 auto mpdu = m_apMac->GetTxopQueue(
AC_BE)->Peek();
2331 "Expected a BlockAckReq to be queued at the non-AP MLD");
2334 m_events.emplace_back(
2355 m_events.emplace_back(
2360 checkTim(*psdu->begin(),
2363 {{1, false}, {2, false}, {3, false}});
2376 m_apMac->GetDevice()->GetNode()->AddApplication(
2377 GetApplication(nonApMldAddr, 1, 1000,
Time{0}));
2381 m_events.emplace_back(
2385 const auto aidNonApMld = m_staMacs[0]->GetAssociationId();
2386 const auto aidNonApSta = m_staMacs[1]->GetAssociationId();
2388 checkTim(*psdu->begin(),
2391 {{1, false}, {aidNonApMld, true}, {aidNonApSta, false}});
2404 m_events.emplace_back(
2409 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2410 "Unexpected transmitter address for PS Poll frame");
2413 m_events.emplace_back(
2419 "Expected the More Data flag to be set");
2422 m_events.emplace_back(
2427 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2428 "Unexpected transmitter address for PS Poll frame");
2431 m_events.emplace_back(
2436 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2437 "Unexpected transmitter address for PS Poll frame");
2440 m_events.emplace_back(
2444 m_staMacs[0]->GetFrameExchangeManager(0)->GetAddress(),
2445 "Unexpected receiver address for QoS Data frame");
2448 "Expected the More Data flag not to be set");
2452 "Non-AP MLD expected to receive another unicast frame");
2456 m_events.emplace_back(