22 #include "ns3/string.h"
23 #include "ns3/qos-utils.h"
24 #include "ns3/packet.h"
25 #include "ns3/wifi-net-device.h"
26 #include "ns3/wifi-mac-header.h"
27 #include "ns3/he-frame-exchange-manager.h"
28 #include "ns3/wifi-acknowledgment.h"
29 #include "ns3/wifi-protection.h"
30 #include "ns3/he-configuration.h"
31 #include "ns3/mobility-helper.h"
32 #include "ns3/spectrum-wifi-helper.h"
33 #include "ns3/multi-model-spectrum-channel.h"
34 #include "ns3/packet-socket-server.h"
35 #include "ns3/packet-socket-client.h"
36 #include "ns3/packet-socket-helper.h"
37 #include "ns3/config.h"
38 #include "ns3/pointer.h"
39 #include "ns3/rng-seed-manager.h"
40 #include "ns3/wifi-psdu.h"
41 #include "ns3/multi-user-scheduler.h"
42 #include "ns3/he-phy.h"
67 static TypeId GetTypeId (
void);
73 TxFormat SelectTxFormat (
void)
override;
74 DlMuInfo ComputeDlMuInfo (
void)
override;
75 UlMuInfo ComputeUlMuInfo (
void)
override;
80 void ComputeWifiTxVector (
void);
97 static TypeId tid =
TypeId (
"ns3::TestMultiUserScheduler")
99 .SetGroupName (
"Wifi")
106 : m_txFormat (SU_TX),
146 Time duration = WifiPhy::CalculateTxDuration (ampduSize, txVector,
147 m_apMac->GetWifiPhy ()->GetPhyBand (),
148 m_apMac->GetStaList ().begin ()->first);
150 uint16_t length = HePhy::ConvertHeTbPpduDurationToLSigLength (duration,
151 m_apMac->GetWifiPhy ()->GetPhyBand ());
153 m_heFem->SetTargetRssi (trigger);
159 hdr.
SetAddr1 (Mac48Address::GetBroadcast ());
164 m_trigger = Create<WifiMacQueueItem> (packet, hdr);
174 +
m_apMac->GetWifiPhy ()->GetSifs ()
179 NS_LOG_DEBUG (
"Remaining TXOP duration is not enough for BSRP TF exchange");
191 const std::map<uint16_t, Mac48Address>& staList =
m_apMac->GetStaList ();
192 NS_ABORT_MSG_IF (staList.size () != 4,
"There must be 4 associated stations");
198 for (
auto& sta : staList)
214 NS_LOG_DEBUG (
"Not enough time to send frames to all the stations");
218 std::vector<Ptr<WifiMacQueueItem>> mpduList;
221 if (mpduList.size () > 1)
223 m_psduMap[sta.first] = Create<WifiPsdu> (std::move (mpduList));
227 m_psduMap[sta.first] = Create<WifiPsdu> (mpdu,
true);
251 uint16_t bw =
m_apMac->GetWifiPhy ()->GetChannelWidth ();
258 const std::map<uint16_t, Mac48Address>& staList =
m_apMac->GetStaList ();
259 NS_ABORT_MSG_IF (staList.size () != 4,
"There must be 4 associated stations");
265 ruType = HeRu::RU_52_TONE;
268 ruType = HeRu::RU_106_TONE;
271 ruType = HeRu::RU_242_TONE;
274 ruType = HeRu::RU_484_TONE;
280 bool primary80 =
true;
281 std::size_t ruIndex = 1;
283 for (
auto& sta : staList)
285 if (bw == 160 && ruIndex == 3)
291 {{ruType, ruIndex++, primary80},
WifiMode (
"HeMcs11"), 1});
349 uint16_t txopLimit, uint16_t nPktsPerSta,
366 void TraceCw (uint32_t staIndex, uint32_t oldCw, uint32_t cw);
384 void DoRun (
void)
override;
412 uint32_t maxAmpduSize, uint16_t txopLimit,
413 uint16_t nPktsPerSta,
415 :
TestCase (
"Check correct operation of DL OFDMA acknowledgment sequences"),
417 m_channelWidth (width),
418 m_dlMuAckType (dlType),
419 m_maxAmpduSize (maxAmpduSize),
420 m_txopLimit (txopLimit),
421 m_nPktsPerSta (nPktsPerSta),
422 m_muEdcaParameterSet (muEdcaParameterSet),
425 m_edcaDisabledStartTime (
Seconds (0)),
426 m_cwValues (std::vector<uint32_t> (m_nStations, 2))
459 if (!psduMap.begin ()->second->GetHeader (0).IsBeacon ()
467 for (
const auto& psduPair : psduMap)
469 NS_LOG_INFO (
"Sending " << psduPair.second->GetHeader (0).GetTypeString ()
470 <<
" #MPDUs " << psduPair.second->GetNMpdus ()
471 <<
" txDuration " << txDuration
472 <<
" duration/ID " << psduPair.second->GetHeader (0).GetDuration ()
473 <<
" #TX PSDUs = " <<
m_txPsdus.size ());
481 auto dev = DynamicCast<WifiNetDevice> (
m_apDevice);
482 Ptr<WifiMacQueue> queue = DynamicCast<RegularWifiMac> (dev->GetMac ())->GetQosTxop (
AC_BE)->GetWifiMacQueue ();
484 for (
auto it = queue->begin (); it != queue->end (); )
487 if (!(*tmp)->IsInFlight ())
495 && psduMap.begin ()->second->GetHeader (0).HasData ())
497 Mac48Address sender = psduMap.begin ()->second->GetAddr2 ();
503 if (dev->GetAddress () == sender)
505 Ptr<QosTxop> qosTxop = DynamicCast<RegularWifiMac> (dev->GetMac ())->GetQosTxop (
AC_BE);
527 else if (!txVector.
IsMu () && psduMap.begin ()->second->GetHeader (0).IsBlockAck ()
532 psduMap.begin ()->second->GetPayload (0)->PeekHeader (blockAck);
551 ifs = (
m_txopLimit > 0 ? sifs : sifs + aifsn * slotTime),
575 true,
"Expected a Trigger Frame");
583 &&
m_txPsdus[1].psduMap.begin ()->second->GetNMpdus () == 8),
584 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
585 for (uint8_t i = 0; i < 8; i++)
603 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
609 &&
m_txPsdus[2].psduMap.begin ()->second->GetNMpdus () == 8),
610 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
611 for (uint8_t i = 0; i < 8; i++)
627 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
633 &&
m_txPsdus[3].psduMap.begin ()->second->GetNMpdus () == 8),
634 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
635 for (uint8_t i = 0; i < 8; i++)
651 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
657 &&
m_txPsdus[4].psduMap.begin ()->second->GetNMpdus () == 8),
658 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
659 for (uint8_t i = 0; i < 8; i++)
675 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
683 true,
"Expected a Trigger Frame");
698 &&
m_txPsdus[6].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
699 true,
"Expected QoS data frames in an HE TB PPDU");
703 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
708 &&
m_txPsdus[7].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
709 true,
"Expected QoS data frames in an HE TB PPDU");
713 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
718 &&
m_txPsdus[8].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
719 true,
"Expected QoS data frames in an HE TB PPDU");
723 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
728 &&
m_txPsdus[9].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
729 true,
"Expected QoS data frames in an HE TB PPDU");
733 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
739 true,
"Expected a Block Ack");
743 "Expected one Per AID TID Info subfield per station");
744 for (uint8_t i = 0; i < 4; i++)
768 "Expected a DL MU PPDU");
773 "TX duration cannot exceed max PPDU duration");
788 navEnd += psdu.second->GetDuration ();
793 "Duration/ID must be the same for all PSDUs");
798 std::size_t nTxPsdus = 0;
800 if (
m_dlMuAckType == WifiAcknowledgment::DL_MU_BAR_BA_SEQUENCE)
824 true,
"Expected a Block Ack");
833 true,
"Expected a Block Ack Request");
842 true,
"Expected a Block Ack");
851 true,
"Expected a Block Ack Request");
860 true,
"Expected a Block Ack");
869 true,
"Expected a Block Ack Request");
878 true,
"Expected a Block Ack");
900 else if (
m_dlMuAckType == WifiAcknowledgment::DL_MU_TF_MU_BAR)
922 true,
"Expected a MU-BAR Trigger Frame");
930 &&
m_txPsdus[13].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
931 true,
"Expected a Block Ack");
940 &&
m_txPsdus[14].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
941 true,
"Expected a Block Ack");
950 &&
m_txPsdus[15].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
951 true,
"Expected a Block Ack");
960 &&
m_txPsdus[16].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
961 true,
"Expected a Block Ack");
984 else if (
m_dlMuAckType == WifiAcknowledgment::DL_MU_AGGREGATE_TF)
1003 for (
auto& psdu :
m_txPsdus[11].psduMap)
1006 "Expected an aggregated MU-BAR Trigger Frame");
1012 &&
m_txPsdus[12].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
1013 true,
"Expected a Block Ack");
1023 &&
m_txPsdus[13].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
1024 true,
"Expected a Block Ack");
1034 &&
m_txPsdus[14].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
1035 true,
"Expected a Block Ack");
1045 &&
m_txPsdus[15].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
1046 true,
"Expected a Block Ack");
1057 "Not all DL packets have been received");
1064 for (std::size_t i = nTxPsdus; i <
m_txPsdus.size (); ++i)
1073 "A station transmitted before the MU EDCA timer expired");
1084 true,
"A station did not set the correct MU CW min");
1094 RngSeedManager::SetSeed (1);
1095 RngSeedManager::SetRun (2);
1096 int64_t streamNumber = 100;
1111 phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
1112 phy.SetErrorRateModel (
"ns3::NistErrorRateModel");
1113 phy.SetChannel (spectrumChannel);
1129 NS_ABORT_MSG (
"Invalid channel bandwidth (must be 20, 40, 80 or 160)");
1154 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
1158 mac.SetType (
"ns3::StaWifiMac",
1168 mac.SetType (
"ns3::ApWifiMac",
1173 mac.SetMultiUserScheduler (
"ns3::TestMultiUserScheduler");
1185 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
1186 positionAlloc->
Add (Vector (1.0, 0.0, 0.0));
1187 positionAlloc->
Add (Vector (0.0, 1.0, 0.0));
1188 positionAlloc->
Add (Vector (-1.0, 0.0, 0.0));
1189 positionAlloc->
Add (Vector (-1.0, -1.0, 0.0));
1190 mobility.SetPositionAllocator (positionAlloc);
1192 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
1204 dev = DynamicCast<WifiNetDevice> (
m_apDevice);
1208 dev->
GetMac ()->GetAttribute (
"BE_Txop", ptr);
1232 wifiApNode.Get (0)->AddApplication (client1);
1243 wifiApNode.Get (0)->AddApplication (client2);
1291 Config::Connect (
"/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx",
1294 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
1297 Simulator::Stop (
Seconds (3));
1303 Simulator::Destroy ();
1322 using MuEdcaParams = std::initializer_list<OfdmaAckSequenceTest::MuEdcaParameterSet>;
1324 for (
auto& muEdcaParameterSet : MuEdcaParams {{0, 0, 0, 0} ,
1325 {0, 127, 2047, 100} ,
1326 {10, 127, 2047, 100} })