4444
4545using namespace ns3 ;
4646
47+ namespace
48+ {
49+
50+ // / Map standard to aPSDUMaxLength
51+ const std::map<WifiStandard, uint32_t > maxPsduLengths = {
52+ {WIFI_STANDARD_80211n, WIFI_PSDU_MAX_LENGTH_HT},
53+ {WIFI_STANDARD_80211ac, WIFI_PSDU_MAX_LENGTH_VHT},
54+ {WIFI_STANDARD_80211ax, WIFI_PSDU_MAX_LENGTH_HE},
55+ {WIFI_STANDARD_80211be, WIFI_PSDU_MAX_LENGTH_EHT},
56+ };
57+ } // namespace
58+
4759/* *
4860 * @ingroup wifi-test
4961 * @ingroup tests
@@ -92,6 +104,14 @@ class AmpduAggregationTest : public TestCase
92104 */
93105 void EnqueuePkts (std::size_t count, uint32_t size, const Mac48Address& dest);
94106
107+ /* *
108+ * Check the maximum PSDU size
109+ *
110+ * @param phy the PHY
111+ * @param fem the HT frame exchange manager
112+ */
113+ void CheckMaxPsduSize (Ptr<WifiPhy> phy, Ptr<HtFrameExchangeManager> fem);
114+
95115 /* *
96116 * @return the Best Effort QosTxop
97117 */
@@ -387,26 +407,53 @@ AmpduAggregationTest::EnqueuePkts(std::size_t count, uint32_t size, const Mac48A
387407 }
388408}
389409
410+ void
411+ AmpduAggregationTest::CheckMaxPsduSize (Ptr<WifiPhy> phy, Ptr<HtFrameExchangeManager> fem)
412+ {
413+ const auto expectedMaxPsduLength = maxPsduLengths.at (phy->GetStandard ());
414+ const auto mc = phy->GetMaxModulationClassSupported ();
415+
416+ NS_TEST_EXPECT_MSG_EQ (phy->GetMaxPsduSize (mc),
417+ expectedMaxPsduLength,
418+ "Unexpected aPSDUMaxLength");
419+
420+ const auto maxAmpduSize = std::min(m_params.maxAmpduSize, expectedMaxPsduLength);
421+ const auto recipient = Mac48Address (" 00:00:00:00:00:02" );
422+
423+ auto isWithinAmpduSizeLimit = fem->IsWithinAmpduSizeLimit (maxAmpduSize, recipient, 0 , mc);
424+ NS_TEST_EXPECT_MSG_EQ (isWithinAmpduSizeLimit,
425+ true ,
426+ " A-MPDU size limit check failed when the size is smaller than the limit" );
427+
428+ isWithinAmpduSizeLimit = fem->IsWithinAmpduSizeLimit (maxAmpduSize + 1 , recipient, 0 , mc);
429+ NS_TEST_EXPECT_MSG_EQ (isWithinAmpduSizeLimit,
430+ false ,
431+ " A-MPDU size limit check failed when the size is larger than the limit" );
432+ }
433+
390434void
391435AmpduAggregationTest::DoRun ()
392436{
393437 /*
394438 * Test behavior when no other packets are in the queue
395439 */
440+ auto phy = m_phys.at (SINGLE_LINK_OP_ID);
396441 auto fem = m_mac->GetFrameExchangeManager (SINGLE_LINK_OP_ID);
397442 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
398443 auto mpduAggregator = htFem->GetMpduAggregator ();
399444
445+ CheckMaxPsduSize (phy, htFem);
446+
400447 /*
401448 * Create a dummy packet of 1500 bytes and fill mac header fields.
402449 */
403450 EnqueuePkts (1 , 1500 , Mac48Address (" 00:00:00:00:00:02" ));
404451
405452 auto peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
406453 WifiTxParameters txParams;
407- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
408- peeked->GetHeader (),
409- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
454+ txParams.m_txVector =
455+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
456+ phy ->GetChannelWidth ());
410457 auto item = GetBeQueue ()->GetNextMpdu (SINGLE_LINK_OP_ID, peeked, txParams, Time::Min (), true );
411458
412459 auto mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min ());
@@ -455,9 +502,9 @@ AmpduAggregationTest::DoRun()
455502
456503 peeked = GetBeQueue()->PeekNextMpdu(SINGLE_LINK_OP_ID);
457504 txParams.Clear ();
458- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
459- peeked->GetHeader (),
460- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
505+ txParams.m_txVector =
506+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
507+ phy ->GetChannelWidth ());
461508 item = GetBeQueue ()->GetNextMpdu (SINGLE_LINK_OP_ID, peeked, txParams, Time::Min (), true );
462509
463510 mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min ());
@@ -470,9 +517,9 @@ AmpduAggregationTest::DoRun()
470517
471518 peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
472519 txParams.Clear ();
473- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
474- peeked->GetHeader (),
475- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
520+ txParams.m_txVector =
521+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
522+ phy ->GetChannelWidth ());
476523 item = GetBeQueue ()->GetNextMpdu (SINGLE_LINK_OP_ID, peeked, txParams, Time::Min (), true );
477524
478525 mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min ());
@@ -549,16 +596,19 @@ TwoLevelAggregationTest::DoRun()
549596 * is such that only two MSDUs can be aggregated. Therefore, the first MPDU we get contains
550597 * an A-MSDU of 2 MSDUs.
551598 */
599+ auto phy = m_phys.at (SINGLE_LINK_OP_ID);
552600 auto fem = m_mac->GetFrameExchangeManager (SINGLE_LINK_OP_ID);
553601 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
554602 auto msduAggregator = htFem->GetMsduAggregator ();
555603 auto mpduAggregator = htFem->GetMpduAggregator ();
556604
605+ CheckMaxPsduSize (phy, htFem);
606+
557607 auto peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
558608 WifiTxParameters txParams;
559- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
560- peeked->GetHeader (),
561- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
609+ txParams.m_txVector =
610+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
611+ phy ->GetChannelWidth ());
562612 htFem->TryAddMpdu (peeked, txParams, Time::Min ());
563613 auto item = msduAggregator->GetNextAmsdu (peeked, txParams, Time::Min ());
564614
@@ -581,9 +631,9 @@ TwoLevelAggregationTest::DoRun()
581631
582632 peeked = GetBeQueue()->PeekNextMpdu(SINGLE_LINK_OP_ID);
583633 txParams.Clear ();
584- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
585- peeked->GetHeader (),
586- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
634+ txParams.m_txVector =
635+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
636+ phy ->GetChannelWidth ());
587637 htFem->TryAddMpdu (peeked, txParams, Time::Min ());
588638 item = msduAggregator->GetNextAmsdu (peeked, txParams, Time::Min ());
589639
@@ -607,9 +657,9 @@ TwoLevelAggregationTest::DoRun()
607657
608658 peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
609659 txParams.Clear ();
610- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
611- peeked->GetHeader (),
612- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
660+ txParams.m_txVector =
661+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
662+ phy ->GetChannelWidth ());
613663
614664 // Compute the first MPDU to be aggregated in an A-MPDU. It must contain an A-MSDU
615665 // aggregating two MSDUs
@@ -657,9 +707,9 @@ TwoLevelAggregationTest::DoRun()
657707 // prepare another A-MPDU (e.g., for transmission on another link)
658708 peeked = GetBeQueue()->PeekNextMpdu(SINGLE_LINK_OP_ID, 0 , psdu->GetAddr1 (), mpduList.at(2 ));
659709 txParams.Clear();
660- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
661- peeked->GetHeader (),
662- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
710+ txParams.m_txVector =
711+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
712+ phy ->GetChannelWidth ());
663713
664714 // Compute the first MPDU to be aggregated in an A-MPDU. It must contain an A-MSDU
665715 // aggregating two MSDUs
@@ -691,9 +741,9 @@ TwoLevelAggregationTest::DoRun()
691741 // A-MSDU aggregation now fails because the first item in the queue contain A-MSDUs
692742 peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
693743 txParams.Clear ();
694- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
695- peeked->GetHeader (),
696- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
744+ txParams.m_txVector =
745+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
746+ phy ->GetChannelWidth ());
697747
698748 htFem->TryAddMpdu (peeked, txParams, Time::Min ());
699749 item = msduAggregator->GetNextAmsdu (peeked, txParams, Time::Min ());
@@ -710,9 +760,9 @@ TwoLevelAggregationTest::DoRun()
710760
711761 peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
712762 txParams.Clear ();
713- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
714- peeked->GetHeader (),
715- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
763+ txParams.m_txVector =
764+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
765+ phy ->GetChannelWidth ());
716766
717767 NS_TEST_EXPECT_MSG_EQ (peeked->GetHeader ().IsQosAmsdu(),
718768 false,
@@ -755,7 +805,7 @@ HeAggregationTest::HeAggregationTest(uint16_t bufferSize)
755805 .dataMode = " HeMcs11" ,
756806 .bufferSize = bufferSize,
757807 .maxAmsduSize = 0 ,
758- .maxAmpduSize = 65535 ,
808+ .maxAmpduSize = 6500631 ,
759809 .txopLimit = Seconds (0 )})
760810{
761811}
@@ -766,17 +816,21 @@ HeAggregationTest::DoRun()
766816 /*
767817 * Test behavior when 300 packets are ready for transmission
768818 */
769- EnqueuePkts (300 , 100 , Mac48Address (" 00:00:00:00:00:02" ));
819+ const std::size_t numPackets = 300 ;
820+ EnqueuePkts (numPackets, 100 , Mac48Address (" 00:00:00:00:00:02" ));
770821
822+ auto phy = m_phys.at (SINGLE_LINK_OP_ID);
771823 auto fem = m_mac->GetFrameExchangeManager (SINGLE_LINK_OP_ID);
772824 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
773825 auto mpduAggregator = htFem->GetMpduAggregator ();
774826
827+ CheckMaxPsduSize (phy, htFem);
828+
775829 auto peeked = GetBeQueue ()->PeekNextMpdu (SINGLE_LINK_OP_ID);
776830 WifiTxParameters txParams;
777- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
778- peeked->GetHeader (),
779- m_phys. at (SINGLE_LINK_OP_ID) ->GetChannelWidth ());
831+ txParams.m_txVector =
832+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
833+ phy ->GetChannelWidth ());
780834 auto item = GetBeQueue ()->GetNextMpdu (SINGLE_LINK_OP_ID, peeked, txParams, Time::Min (), true );
781835
782836 auto mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min ());
@@ -786,7 +840,7 @@ HeAggregationTest::DoRun()
786840 NS_TEST_EXPECT_MSG_EQ (mpduList.size(),
787841 m_params.bufferSize,
788842 "A-MPDU contains an unexpected number of MPDUs");
789- uint16_t expectedRemainingPacketsInQueue = 300 - m_params.bufferSize ;
843+ uint16_t expectedRemainingPacketsInQueue = numPackets - m_params.bufferSize ;
790844 NS_TEST_EXPECT_MSG_EQ (GetBeQueue()->GetWifiMacQueue()->GetNPackets(),
791845 expectedRemainingPacketsInQueue,
792846 "Queue contains an unexpected number of MPDUs");
@@ -834,23 +888,27 @@ EhtAggregationTest::DoRun()
834888 * A-MPDU size limit (102000 B) is computed to have at most 750 MPDUs aggregated in a single
835889 * A-MPDU (each MPDU is 130 B, plus 4 B of A-MPDU subframe header, plus 2 B of padding).
836890 */
837- EnqueuePkts (1200 , 100 , Mac48Address (" 00:00:00:00:00:02" ));
891+ const std::size_t numPackets = 1200 ;
892+ EnqueuePkts (numPackets, 100 , Mac48Address (" 00:00:00:00:00:02" ));
838893 const std::size_t maxNMpdus = 750 ;
839894
840895 for (uint8_t linkId = 0 ; linkId < m_params.nLinks ; linkId++)
841896 {
897+ auto phy = m_phys.at (linkId);
842898 auto fem = m_mac->GetFrameExchangeManager (linkId);
843899 auto htFem = DynamicCast<HtFrameExchangeManager>(fem);
844900 auto mpduAggregator = htFem->GetMpduAggregator ();
845901 std::vector<Ptr<WifiMpdu>> mpduList;
846902
903+ CheckMaxPsduSize (phy, htFem);
904+
847905 auto peeked = GetBeQueue ()->PeekNextMpdu (linkId);
848906 if (peeked)
849907 {
850908 WifiTxParameters txParams;
851- txParams.m_txVector = m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector (
852- peeked->GetHeader (),
853- m_phys. at (linkId) ->GetChannelWidth ());
909+ txParams.m_txVector =
910+ m_mac-> GetWifiRemoteStationManager ()-> GetDataTxVector ( peeked->GetHeader (),
911+ phy ->GetChannelWidth ());
854912 auto item = GetBeQueue ()->GetNextMpdu (linkId, peeked, txParams, Time::Min (), true );
855913
856914 mpduList = mpduAggregator->GetNextAmpdu (item, txParams, Time::Min ());
@@ -871,7 +929,7 @@ EhtAggregationTest::DoRun()
871929 NS_TEST_EXPECT_MSG_EQ (mpduList.size(),
872930 maxNMpdus,
873931 "A-MPDU contains an unexpected number of MPDUs");
874- expectedRemainingPacketsInQueue = 1200 - maxNMpdus;
932+ expectedRemainingPacketsInQueue = numPackets - maxNMpdus;
875933 NS_TEST_EXPECT_MSG_EQ (GetBeQueue()->GetWifiMacQueue()->GetNPackets(),
876934 expectedRemainingPacketsInQueue,
877935 "Queue contains an unexpected number of MPDUs");
@@ -882,7 +940,7 @@ EhtAggregationTest::DoRun()
882940 NS_TEST_EXPECT_MSG_EQ (mpduList.size(),
883941 m_params.bufferSize - maxNMpdus,
884942 "A-MPDU contains an unexpected number of MPDUs");
885- expectedRemainingPacketsInQueue = 1200 - m_params.bufferSize ;
943+ expectedRemainingPacketsInQueue = numPackets - m_params.bufferSize ;
886944 NS_TEST_EXPECT_MSG_EQ (GetBeQueue()->GetWifiMacQueue()->GetNPackets(),
887945 expectedRemainingPacketsInQueue,
888946 "Queue contains an unexpected number of MPDUs");
@@ -902,15 +960,15 @@ EhtAggregationTest::DoRun()
902960 NS_TEST_EXPECT_MSG_EQ (mpduList.size(),
903961 m_params.bufferSize,
904962 "A-MPDU contains an unexpected number of MPDUs");
905- expectedRemainingPacketsInQueue = 1200 - m_params.bufferSize ;
963+ expectedRemainingPacketsInQueue = numPackets - m_params.bufferSize ;
906964 NS_TEST_EXPECT_MSG_EQ (GetBeQueue()->GetWifiMacQueue()->GetNPackets(),
907965 expectedRemainingPacketsInQueue,
908966 "Queue contains an unexpected number of MPDUs");
909967 break ;
910968 case 1 :
911969 // no more MPDUs can be sent, aggregation fails
912970 NS_TEST_EXPECT_MSG_EQ (mpduList.empty(), true, "MPDU aggregation did not fail");
913- expectedRemainingPacketsInQueue = 1200 - m_params.bufferSize ;
971+ expectedRemainingPacketsInQueue = numPackets - m_params.bufferSize ;
914972 NS_TEST_EXPECT_MSG_EQ (GetBeQueue()->GetWifiMacQueue()->GetNPackets(),
915973 expectedRemainingPacketsInQueue,
916974 "Queue contains an unexpected number of MPDUs");
0 commit comments