9#include "ns3/attribute-container.h"
10#include "ns3/boolean.h"
11#include "ns3/config.h"
12#include "ns3/frame-exchange-manager.h"
13#include "ns3/he-phy.h"
15#include "ns3/mobility-helper.h"
16#include "ns3/multi-model-spectrum-channel.h"
17#include "ns3/packet-socket-client.h"
18#include "ns3/packet-socket-helper.h"
19#include "ns3/packet-socket-server.h"
20#include "ns3/packet.h"
21#include "ns3/pointer.h"
22#include "ns3/qos-txop.h"
23#include "ns3/qos-utils.h"
24#include "ns3/rng-seed-manager.h"
25#include "ns3/spectrum-wifi-helper.h"
26#include "ns3/sta-wifi-mac.h"
27#include "ns3/string.h"
29#include "ns3/wifi-mac-header.h"
30#include "ns3/wifi-mac-queue.h"
31#include "ns3/wifi-net-device.h"
32#include "ns3/wifi-psdu.h"
101 void DoRun()
override;
121 void CheckValues(
const std::map<uint16_t, uint32_t>& seqNoRetryCountMap,
124 std::optional<std::size_t> qsrcOther);
168 :
TestCase(
std::string(
"Check retransmit procedure (useRts=") +
std::to_string(params.useRts) +
169 ", incrRetryCountUnderBa=" +
std::to_string(params.incrRetryCountUnderBa) +
170 ", useBarAfterBaTimeout=" +
std::to_string(params.useBarAfterBaTimeout) +
171 ", pifsRecovery=" +
std::to_string(params.pifsRecovery) +
")"),
172 m_nLinks(params.isMld ? 2 : 1),
173 m_useRts(params.useRts),
174 m_incrRetryCountUnderBa(params.incrRetryCountUnderBa),
175 m_useBarAfterBaTimeout(params.useBarAfterBaTimeout),
176 m_pifsRecovery(params.pifsRecovery),
186 int64_t streamNumber = 10;
194 phy.Set(0,
"ChannelSettings",
StringValue(
"{0, 20, BAND_5GHZ, 0}"));
198 phy.Set(1,
"ChannelSettings",
StringValue(
"{0, 20, BAND_6GHZ, 0}"));
212 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
219 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(
Ssid(
"retransmit-ssid")));
224 mac.SetType(
"ns3::ApWifiMac");
229 m_apDevice = wifi.Install(phy, mac, wifiApNode);
238 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
239 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
240 mobility.SetPositionAllocator(positionAlloc);
242 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
243 mobility.Install(wifiApNode);
244 mobility.Install(wifiStaNode);
247 packetSocket.
Install(wifiApNode);
248 packetSocket.
Install(wifiStaNode);
255 server->SetLocal(srvAddr);
256 wifiApNode.Get(0)->AddApplication(server);
257 server->SetStartTime(
Time{0});
258 server->SetStopTime(
Seconds(1.0));
267 for (std::size_t linkId = 0; linkId <
m_nLinks; ++linkId)
269 dev->GetMac()->GetWifiPhy(linkId)->SetPostReceptionErrorModel(
m_apErrorModel);
277 m_staMac->BlockTxOnLink(1, WifiQueueBlockedReason::TID_NOT_MAPPED);
281 m_staMac->GetQosTxop(
AC_BE)->TraceConnectWithoutContext(
"BaEstablished", baEstablished);
284 for (std::size_t phyId = 0; phyId <
m_nLinks; phyId++)
287 "/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phys/" + std::to_string(phyId) +
299 std::optional<std::size_t> qsrcOther)
306 staQueue->GetNPackets(queueId),
307 "Unexpected number of queued MPDUs when transmitting frame #"
311 while ((mpdu = staQueue->PeekByQueueId(queueId, mpdu)))
313 const auto seqNo = mpdu->GetHeader().GetSequenceNumber();
314 const auto it = seqNoRetryCountMap.find(seqNo);
317 "SeqNo " << seqNo <<
" not found in PSDU #" << psduNumber);
320 "Unexpected retry count for MPDU with SeqNo=" << seqNo <<
" in PSDU #"
326 "QSRC for other link can be provided iff devices are multi-link");
328 std::map<uint8_t, std::size_t> qsrcLinkIdMap{{linkId, qsrc}};
332 qsrcLinkIdMap.emplace((linkId == 0 ? 1 : 0), qsrcOther.value());
337 for (
const auto& [
id, expectedQsrc] : qsrcLinkIdMap)
341 "Unexpected QSRC value on link " << +
id <<
" when transmitting PSDU #"
344 const auto cwMin = txop->GetMinCw(
id);
345 const auto cwMax = txop->GetMaxCw(
id);
346 const auto expectedCw = std::min(cwMax, (1 << expectedQsrc) * (cwMin + 1) - 1);
350 "Unexpected CW value on link " << +
id <<
" when transmitting PSDU #"
361 const auto psdu = psduMap.cbegin()->second;
362 const auto& hdr = psdu->GetHeader(0);
363 const auto printAndQuit = (!
m_baEstablished || hdr.IsBeacon() || hdr.IsCfEnd());
365 std::stringstream ss;
366 ss <<
" Phy ID " << +phyId;
375 ss <<
"\nTXVECTOR = " << txVector <<
"\n";
390 "Unexpected MAC header type for frame #"
407 std::list<uint64_t> uids;
410 uids.push_back(mpdu->GetPacket()->GetUid());
417 auto alternateLinks =
419 m_staMac->BlockTxOnLink(0, WifiQueueBlockedReason::TID_NOT_MAPPED);
421 const auto txDuration =
425 m_staMac->UnblockTxOnLink({1}, WifiQueueBlockedReason::TID_NOT_MAPPED);
429 std::size_t qsrc = 0;
431 std::optional<std::size_t> qsrcOther;
442 CheckValues({{0, 0}, {1, 0}}, 0, linkId, qsrcOther);
444 dropPsdu(psdu, txVector);
455 m_staMac->GetFrameExchangeManager(0)->GetWifiTxTimer().GetDelayLeft());
491 alternateLinks(psdu, txVector,
Time{0});
508 CheckValues({{0, 1}, {1, 1}, {2, 0}, {3, 0}}, qsrc, linkId, qsrcOther);
512 CheckValues({{0, 0}, {1, 0}, {2, 0}, {3, 0}}, qsrc, linkId, qsrcOther);
532 CheckValues({{1, 1}, {2, 0}}, qsrc, linkId, qsrcOther);
536 CheckValues({{1, 0}, {2, 0}}, qsrc, linkId, qsrcOther);
561 CheckValues({{1, retryCount}, {2, retryCount - 1}},
568 CheckValues({{1, 0}, {2, 0}}, qsrc, linkId, qsrcOther);
585 CheckValues({{1, retryCount}, {2, retryCount - 1}}, qsrc, linkId, qsrcOther);
589 CheckValues({{1, 0}, {2, 0}}, qsrc, linkId, qsrcOther);
592 dropPsdu(psdu, txVector);
607 for (std::size_t count = 0; count < 4; ++count)
622 dropPsdu(psdu, txVector);
638 CheckValues({{1, 0}, {2, 0}}, qsrc, linkId, qsrcOther);
672 client->SetStartTime(
Time{0});
673 client->SetStopTime(
Seconds(1.0));
693 for (
auto isMld : {
true,
false})
695 for (
auto useRts : {
true,
false})
697 for (
auto incrRetryCountUnderBa : {
true,
false})
699 for (
auto useBarAfterBaTimeout : {
true,
false})
701 for (
auto pifsRecovery : {
true,
false})
706 .incrRetryCountUnderBa = incrRetryCountUnderBa,
707 .useBarAfterBaTimeout = useBarAfterBaTimeout,
708 .pifsRecovery = pifsRecovery}),
709 TestCase::Duration::QUICK);
Test retransmit procedure.
std::list< Events >::const_iterator m_eventIt
iterator over the list of events
NetDeviceContainer m_apDevice
container for AP's NetDevice
bool m_incrRetryCountUnderBa
whether retry count is incremented under block ack
bool m_useBarAfterBaTimeout
whether to send a BAR after a missed BlockAck
PacketSocketAddress m_ulSocket
packet socket address for UL traffic
const uint32_t m_frameRetryLimit
frame retry limit
void DoSetup() override
Implementation to do any local setup required for this TestCase.
const std::size_t m_pktSize
size in bytes of generated packets
std::list< Events > m_events
list of events for a test run
const Time m_txopLimit
TXOP limit.
void DoRun() override
Implementation to actually run this TestCase.
void SetEvents()
Set the list of events to expect in this test run.
std::size_t m_nLinks
number of links for the devices
Ptr< StaWifiMac > m_staMac
MAC of the non-AP STA.
WifiRetransmitTest(const Params ¶ms)
Constructor.
void CheckValues(const std::map< uint16_t, uint32_t > &seqNoRetryCountMap, std::size_t qsrc, uint8_t linkId, std::optional< std::size_t > qsrcOther)
Check the retry count of the MPDUs stored in the STA MAC queue, the CW and the QSRC of the given link...
Ptr< ListErrorModel > m_apErrorModel
error model to install on the AP
void Transmit(uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when PHY receives a PSDU to transmit.
bool m_pifsRecovery
whether to use PIFS recovery
Ptr< PacketSocketClient > GetApplication(std::size_t count, std::size_t pktSize) const
bool m_baEstablished
whether BA agreement has been established
bool m_useRts
whether RTS is used to protect frame transmissions
wifi retransmit procedure Test Suite
WifiRetransmitTestSuite()
A container for one type of attribute.
AttributeValue implementation for Boolean.
static WifiMode GetHeMcs8()
Return MCS 8 from HE MCS values.
Provide a list of Packet uids to corrupt.
void SetList(const std::list< uint64_t > &packetlist)
static Mac48Address ConvertFrom(const Address &address)
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
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.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
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.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Make it easy to create and manage PHY objects for the spectrum model.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
static int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the PHY and MAC aspects ...
create MAC layers for a ns3::WifiNetDevice.
AttributeValue implementation for WifiMode.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetDefault(std::string name, const AttributeValue &value)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort 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 Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
U * PeekPointer(const Ptr< U > &p)
std:: tuple< WifiContainerQueueType, WifiReceiverAddressType, Mac48Address, std::optional< uint8_t > > WifiContainerQueueId
Tuple (queue type, receiver address type, Address, TID) identifying a container queue.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
WifiMacType
Combination of valid MAC header type/subtype.
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
Actions and checks to perform upon the transmission of each frame.
std::function< void(Ptr< const WifiPsdu >, const WifiTxVector &)> func
function to perform actions and checks
WifiMacType hdrType
MAC header type of frame being transmitted.
Events(WifiMacType type, std::function< void(Ptr< const WifiPsdu >, const WifiTxVector &)> &&f={})
Constructor.
Parameters for this test.
bool useRts
whether RTS is used to protect frame transmissions
bool useBarAfterBaTimeout
whether to send a BAR after a missed BlockAck
bool pifsRecovery
whether PIFS recovery is used after failure of a non-initial
bool isMld
whether devices are MLDs
bool incrRetryCountUnderBa
whether retry count is incremented under block ack
uint32_t pktSize
packet size used for the simulation (in bytes)
static WifiRetransmitTestSuite g_wifiRetransmitTestSuite
the test suite