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;
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);
1087 wifiApNode.Get (0)->AddApplication (client1);
1098 wifiApNode.Get (0)->AddApplication (client2);
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 ();
WifiTxParameters m_txParams
TX parameters.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
void SetStopTime(Time stop)
Specify application stop time.
Simulation virtual time values and global simulation resolution.
void CheckResults(Time sifs, Time slotTime, uint8_t aifsn)
Check correctness of transmitted frames.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void Transmit(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when FrameExchangeManager passes PSDUs to the PHY.
Ptr< WifiMacQueueItem > m_trigger
Trigger Frame to send.
AttributeValue implementation for Boolean.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint16_t m_nStations
number of stations
uint16_t m_received
number of packets received by the stations
std::unique_ptr< WifiProtection > m_protection
protection method
WifiTxVector m_txVector
the TX vector for MU PPDUs
bool m_initialFrame
true if a TXOP is being started
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
void Clear(void)
Reset the TX parameters.
an address for a packet socket
Information needed to remove an MSDU from the queue.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint16_t m_txopLimit
TXOP limit in microseconds.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
static TypeId GetTypeId(void)
Get the type ID.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Time m_txDuration
TX duration of the frame.
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
helps to create WifiNetDevice objects
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
UlMuInfo ComputeUlMuInfo(void) override
Prepare the information required to solicit an UL MU transmission.
WifiTxVector txVector
TXVECTOR.
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Time startTx
start TX 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.
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
a polymophic address class
OfdmaAckSequenceTest(uint16_t width, WifiAcknowledgment::Method dlType, uint32_t maxAmpduSize, uint16_t txopLimit, uint16_t nPktsPerSta)
Constructor.
WifiPreamble GetPreambleType(void) const
void DoRun(void) override
Implementation to actually run this TestCase.
WifiConstPsduMap psduMap
transmitted PSDU map
Hold variables of type enum.
TriggerFrameType
The different Trigger frame types.
Time m_availableTime
the time available for frame exchange
AttributeValue implementation for Time.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint16_t m_nPktsPerSta
number of packets to send to each station
void SetGuardInterval(uint16_t guardInterval)
Sets the guard interval duration (in nanoseconds)
TriggerFrameType m_ulTriggerType
Trigger Frame type for UL MU.
Hold an unsigned integer type.
Ptr< ApWifiMac > m_apMac
the AP wifi MAC
holds a vector of ns3::NetDevice pointers
Ptr< HeFrameExchangeManager > m_heFem
HE Frame Exchange Manager.
WifiPsduMap m_psduMap
the DL MU PPDU to transmit
Method
Available acknowledgment methods.
MultiUserScheduler is an abstract base class defining the API that APs supporting at least VHT can us...
TxFormat m_txFormat
the format of next transmission
void Connect(std::string path, const CallbackBase &cb)
void SetHeMuUserInfo(uint16_t staId, HeMuUserInfo userInfo)
Set the HE MU user-specific transmission information for the given STA-ID.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Get the station manager attached to the AP.
static WifiMacOfdmaTestSuite g_wifiMacOfdmaTestSuite
the test suite
WifiAcknowledgment::Method m_dlMuAckType
DL MU ack sequence type.
TxFormat SelectTxFormat(void) override
Select the format of the next transmission.
WifiTxVector m_txVector
TXVECTOR of the frame being prepared.
Information to be provided in case of UL MU transmission.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPhysicalAddress(const Address address)
Set the destination address.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
void SetPreambleType(WifiPreamble preamble)
Sets the preamble type.
NetDeviceContainer m_staDevices
stations' devices
RuType
The different HE Resource Unit (RU) types.
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
create MAC layers for a ns3::WifiNetDevice.
Information about transmitted frames.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
Time m_tbPpduDuration
Duration of the solicited TB PPDUs.
The IEEE 802.11 SSID Information Element.
DlMuInfo ComputeDlMuInfo(void) override
Compute the information required to perform a DL MU transmission.
Helper class used to assign positions and mobility models to nodes.
Ptr< WifiMac > GetMac(void) const
void L7Receive(std::string context, Ptr< const Packet > p, const Address &addr)
Function to trace packets received by the server application.
Time GetPpduMaxTime(WifiPreamble preamble)
Get the maximum PPDU duration (see Section 10.14 of 802.11-2016) for the PHY layers defining the aPPD...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
uint32_t m_sizeOf8QosNull
size in bytes of 8 QoS Null frames
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
AttributeValue implementation for Ssid.
TxFormat
Enumeration of the possible transmission formats.
This class stores the TX parameters (TX vector, protection mechanism, acknowledgment mechanism...
void SetProtocol(uint16_t protocol)
Set the protocol.
void Add(Vector v)
Add a position to the list of positions.
wifi MAC OFDMA Test Suite
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
virtual ~OfdmaAckSequenceTest()
void ComputeWifiTxVector(void)
Compute the TX vector to use for MU PPDUs.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
virtual ~TestMultiUserScheduler()
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
std::unique_ptr< WifiAcknowledgment > m_acknowledgment
acknowledgment method
Dummy Multi User Scheduler used to test OFDMA ack sequences.
Test OFDMA acknowledgment sequences.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
uint16_t m_channelWidth
PHY channel bandwidth in MHz.
a unique identifier for an interface.
std::unordered_map< uint16_t, Ptr< WifiPsdu > > WifiPsduMap
Map of PSDUs indexed by STA-ID.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void SetStartTime(Time start)
Specify application start time.
#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.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const 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...
uint32_t m_maxAmpduSize
maximum A-MPDU size in bytes
void AddHeader(const Header &header)
Add header to this packet.
Make it easy to create and manage PHY objects for the spectrum model.
Information to be provided in case of DL MU transmission.