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});
337 uint16_t txopLimit, uint16_t nPktsPerSta);
364 void DoRun (
void)
override;
387 uint32_t maxAmpduSize, uint16_t txopLimit,
388 uint16_t nPktsPerSta)
389 :
TestCase (
"Check correct operation of DL OFDMA acknowledgment sequences"),
391 m_channelWidth (width),
392 m_dlMuAckType (dlType),
393 m_maxAmpduSize (maxAmpduSize),
394 m_txopLimit (txopLimit),
395 m_nPktsPerSta (nPktsPerSta),
418 if (!psduMap.begin ()->second->GetHeader (0).IsBeacon ()
426 NS_LOG_INFO (
"Sending " << psduMap.begin ()->second->GetHeader (0).GetTypeString ()
427 <<
" #MPDUs " << psduMap.begin ()->second->GetNMpdus ()
428 <<
" txDuration " << txDuration
429 <<
" duration/ID " << psduMap.begin ()->second->GetHeader (0).GetDuration ()
430 <<
" #TX PSDUs = " <<
m_txPsdus.size ());
437 && psduMap.begin ()->second->GetHeader (0).HasData ())
439 Mac48Address sender = psduMap.begin ()->second->GetAddr2 ();
445 if (dev->GetAddress () == sender)
447 DynamicCast<RegularWifiMac> (dev->GetMac ())->GetQosTxop (
AC_BE)->GetWifiMacQueue ()->Flush ();
462 ifs = (
m_txopLimit > 0 ? sifs : sifs + aifsn * slotTime),
486 true,
"Expected a Trigger Frame");
494 &&
m_txPsdus[1].psduMap.begin ()->second->GetNMpdus () == 8),
495 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
496 for (uint8_t i = 0; i < 8; i++)
514 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
520 &&
m_txPsdus[2].psduMap.begin ()->second->GetNMpdus () == 8),
521 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
522 for (uint8_t i = 0; i < 8; i++)
538 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
544 &&
m_txPsdus[3].psduMap.begin ()->second->GetNMpdus () == 8),
545 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
546 for (uint8_t i = 0; i < 8; i++)
562 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
568 &&
m_txPsdus[4].psduMap.begin ()->second->GetNMpdus () == 8),
569 true,
"Expected 8 QoS Null frames in an HE TB PPDU");
570 for (uint8_t i = 0; i < 8; i++)
586 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS Null frames in HE TB PPDU sent too late");
594 true,
"Expected a Trigger Frame");
609 &&
m_txPsdus[6].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
610 true,
"Expected QoS data frames in an HE TB PPDU");
614 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
619 &&
m_txPsdus[7].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
620 true,
"Expected QoS data frames in an HE TB PPDU");
624 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
629 &&
m_txPsdus[8].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
630 true,
"Expected QoS data frames in an HE TB PPDU");
634 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
639 &&
m_txPsdus[9].psduMap.begin ()->second->GetHeader (0).IsQosData ()),
640 true,
"Expected QoS data frames in an HE TB PPDU");
644 NS_TEST_EXPECT_MSG_LT (tStart, tEnd + sifs + tolerance,
"QoS data frames in HE TB PPDU sent too late");
650 true,
"Expected a Block Ack");
654 "Expected one Per AID TID Info subfield per station");
655 for (uint8_t i = 0; i < 4; i++)
679 "Expected a DL MU PPDU");
684 "TX duration cannot exceed max PPDU duration");
699 navEnd += psdu.second->GetDuration ();
704 "Duration/ID must be the same for all PSDUs");
709 if (
m_dlMuAckType == WifiAcknowledgment::DL_MU_BAR_BA_SEQUENCE)
733 true,
"Expected a Block Ack");
742 true,
"Expected a Block Ack Request");
751 true,
"Expected a Block Ack");
760 true,
"Expected a Block Ack Request");
769 true,
"Expected a Block Ack");
778 true,
"Expected a Block Ack Request");
787 true,
"Expected a Block Ack");
808 else if (
m_dlMuAckType == WifiAcknowledgment::DL_MU_TF_MU_BAR)
830 true,
"Expected a MU-BAR Trigger Frame");
838 &&
m_txPsdus[13].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
839 true,
"Expected a Block Ack");
848 &&
m_txPsdus[14].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
849 true,
"Expected a Block Ack");
858 &&
m_txPsdus[15].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
859 true,
"Expected a Block Ack");
868 &&
m_txPsdus[16].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
869 true,
"Expected a Block Ack");
890 else if (
m_dlMuAckType == WifiAcknowledgment::DL_MU_AGGREGATE_TF)
912 "Expected an aggregated MU-BAR Trigger Frame");
918 &&
m_txPsdus[12].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
919 true,
"Expected a Block Ack");
929 &&
m_txPsdus[13].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
930 true,
"Expected a Block Ack");
940 &&
m_txPsdus[14].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
941 true,
"Expected a Block Ack");
951 &&
m_txPsdus[15].psduMap.begin ()->second->GetHeader (0).IsBlockAck ()),
952 true,
"Expected a Block Ack");
967 RngSeedManager::SetSeed (1);
968 RngSeedManager::SetRun (2);
969 int64_t streamNumber = 100;
979 spectrumChannel->AddPropagationLossModel (lossModel);
981 spectrumChannel->SetPropagationDelayModel (delayModel);
984 phy.SetPcapDataLinkType (WifiPhyHelper::DLT_IEEE802_11_RADIO);
985 phy.SetErrorRateModel (
"ns3::NistErrorRateModel");
986 phy.SetChannel (spectrumChannel);
1002 NS_ABORT_MSG (
"Invalid channel bandwidth (must be 20, 40, 80 or 160)");
1008 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
1012 mac.SetType (
"ns3::StaWifiMac",
1022 mac.SetType (
"ns3::ApWifiMac",
1027 mac.SetMultiUserScheduler (
"ns3::TestMultiUserScheduler");
1034 streamNumber +=
wifi.AssignStreams (
apDevices, streamNumber);
1040 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1041 positionAlloc->Add (Vector (1.0, 0.0, 0.0));
1042 positionAlloc->Add (Vector (0.0, 1.0, 0.0));
1043 positionAlloc->Add (Vector (-1.0, 0.0, 0.0));
1044 positionAlloc->Add (Vector (-1.0, -1.0, 0.0));
1045 mobility.SetPositionAllocator (positionAlloc);
1047 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
1059 dev = DynamicCast<WifiNetDevice> (
apDevices.Get (0));
1063 dev->
GetMac ()->GetAttribute (
"BE_Txop", ptr);
1086 client1->SetRemote (socket);
1087 wifiApNode.Get (0)->AddApplication (client1);
1089 client1->SetStopTime (
Seconds (2.0));
1094 client2->SetAttribute (
"PacketSize",
UintegerValue (1400 + i * 100));
1097 client2->SetRemote (socket);
1098 wifiApNode.Get (0)->AddApplication (client2);
1099 client2->SetStartTime (
Seconds (1.5));
1100 client2->SetStopTime (
Seconds (2.5));
1103 server->SetLocal (socket);
1105 server->SetStartTime (
Seconds (0.0));
1106 server->SetStopTime (
Seconds (3.0));
1123 client1->SetRemote (socket);
1126 client1->SetStopTime (
Seconds (2.0));
1131 client2->SetAttribute (
"PacketSize",
UintegerValue (1400 + i * 100));
1134 client2->SetRemote (socket);
1136 client2->SetStartTime (
Seconds (1.50011));
1137 client2->SetStopTime (
Seconds (2.5));
1140 server->SetLocal (socket);
1142 server->SetStartTime (
Seconds (0.0));
1143 server->SetStopTime (
Seconds (3.0));
1146 Config::Connect (
"/NodeList/*/ApplicationList/0/$ns3::PacketSocketServer/Rx",
1149 Config::Connect (
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
1152 Simulator::Stop (
Seconds (3));
1158 Simulator::Destroy ();
Test OFDMA acknowledgment sequences.
virtual ~OfdmaAckSequenceTest()
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
void Transmit(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when FrameExchangeManager passes PSDUs to the PHY.
uint16_t m_received
number of packets received by the stations
void CheckResults(Time sifs, Time slotTime, uint8_t aifsn)
Check correctness of transmitted frames.
WifiAcknowledgment::Method m_dlMuAckType
DL MU ack sequence type.
uint16_t m_nPktsPerSta
number of packets to send to each station
OfdmaAckSequenceTest(uint16_t width, WifiAcknowledgment::Method dlType, uint32_t maxAmpduSize, uint16_t txopLimit, uint16_t nPktsPerSta)
Constructor.
NetDeviceContainer m_staDevices
stations' devices
uint16_t m_txopLimit
TXOP limit in microseconds.
void L7Receive(std::string context, Ptr< const Packet > p, const Address &addr)
Function to trace packets received by the server application.
uint16_t m_channelWidth
PHY channel bandwidth in MHz.
uint32_t m_maxAmpduSize
maximum A-MPDU size in bytes
void DoRun(void) override
Implementation to actually run this TestCase.
uint16_t m_nStations
number of stations
Dummy Multi User Scheduler used to test OFDMA ack sequences.
TxFormat SelectTxFormat(void) override
Select the format of the next transmission.
WifiPsduMap m_psduMap
the DL MU PPDU to transmit
Ptr< WifiMacQueueItem > m_trigger
Trigger Frame to send.
virtual ~TestMultiUserScheduler()
TxFormat m_txFormat
the format of next transmission
WifiTxVector m_txVector
the TX vector for MU PPDUs
UlMuInfo ComputeUlMuInfo(void) override
Prepare the information required to solicit an UL MU transmission.
static TypeId GetTypeId(void)
Get the type ID.
TriggerFrameType m_ulTriggerType
Trigger Frame type for UL MU.
WifiTxParameters m_txParams
TX parameters.
DlMuInfo ComputeDlMuInfo(void) override
Compute the information required to perform a DL MU transmission.
Time m_tbPpduDuration
Duration of the solicited TB PPDUs.
void ComputeWifiTxVector(void)
Compute the TX vector to use for MU PPDUs.
wifi MAC OFDMA Test Suite
a polymophic address class
AttributeValue implementation for Boolean.
Hold variables of type enum.
RuType
The different HE Resource Unit (RU) types.
Helper class used to assign positions and mobility models to nodes.
MultiUserScheduler is an abstract base class defining the API that APs supporting at least VHT can us...
bool m_initialFrame
true if a TXOP is being started
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
Time m_availableTime
the time available for frame exchange
Ptr< HeFrameExchangeManager > m_heFem
HE Frame Exchange Manager.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Get the station manager attached to the AP.
uint32_t m_sizeOf8QosNull
size in bytes of 8 QoS Null frames
TxFormat
Enumeration of the possible transmission formats.
holds a vector of ns3::NetDevice pointers
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void AddHeader(const Header &header)
Add header to this packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Hold objects of type Ptr<T>.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
represent a single transmission mode
Ptr< WifiMac > GetMac(void) const
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism,...
void Clear(void)
Reset the TX parameters.
std::unique_ptr< WifiProtection > m_protection
protection method
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
Time m_txDuration
TX duration of the frame.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
void SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
WifiPreamble GetPreambleType(void) const
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
void Connect(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
#define NS_TEST_EXPECT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to limit and report if not.
#define NS_TEST_EXPECT_MSG_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report if not.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
TriggerFrameType
The different Trigger frame types.
@ WIFI_STANDARD_80211ax_5GHZ
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time GetPpduMaxTime(WifiPreamble preamble)
Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for the PHY layers defining the aPPD...
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Information about transmitted frames.
Time startTx
start TX time
WifiTxVector txVector
TXVECTOR.
WifiConstPsduMap psduMap
transmitted PSDU map
Information to be provided in case of DL MU transmission.
Information to be provided in case of UL MU transmission.
Method
Available acknowledgment methods.
Information needed to remove an MSDU from the queue.
static WifiMacOfdmaTestSuite g_wifiMacOfdmaTestSuite
the test suite