9#include "ns3/ap-wifi-mac.h"
10#include "ns3/boolean.h"
11#include "ns3/config.h"
12#include "ns3/eht-configuration.h"
14#include "ns3/mobility-helper.h"
15#include "ns3/multi-model-spectrum-channel.h"
16#include "ns3/packet-socket-client.h"
17#include "ns3/packet-socket-helper.h"
18#include "ns3/packet-socket-server.h"
19#include "ns3/packet.h"
20#include "ns3/pointer.h"
21#include "ns3/qos-txop.h"
22#include "ns3/qos-utils.h"
23#include "ns3/rng-seed-manager.h"
24#include "ns3/single-model-spectrum-channel.h"
25#include "ns3/spectrum-wifi-helper.h"
26#include "ns3/string.h"
28#include "ns3/wifi-mac-header.h"
29#include "ns3/wifi-mac.h"
30#include "ns3/wifi-net-device.h"
31#include "ns3/wifi-ppdu.h"
32#include "ns3/wifi-psdu.h"
33#include "ns3/wifi-tx-stats-helper.h"
99 std::map<uint8_t, std::vector<Time>>
102 std::map<uint8_t, uint32_t>
104 std::map<uint8_t, Time>
108 void DoRun()
override;
129 const auto linkId =
atoi(context.c_str());
136 else if (linkId == 1)
158 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
170 std::string dataMode;
174 dataMode =
"OfdmRate12Mbps";
179 dataMode =
"EhtMcs6";
189 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
204 mac.SetType(
"ns3::StaWifiMac",
211 mac.SetType(
"ns3::ApWifiMac",
218 "EnableBeaconJitter",
235 wifi.SetRemoteStationManager(
static_cast<uint8_t
>(1),
236 "ns3::ConstantRateWifiManager",
245 wifi.SetRemoteStationManager(
static_cast<uint8_t
>(0),
246 "ns3::ConstantRateWifiManager",
265 for (uint8_t linkId = 0; linkId < 2; ++linkId)
271 mac.SetType(
"ns3::StaWifiMac",
278 mac.SetType(
"ns3::ApWifiMac",
285 "EnableBeaconJitter",
311 ->GetEhtConfiguration()
324 server->SetLocal(socket);
326 server->SetStartTime(
Seconds(0.0));
327 server->SetStopTime(
Seconds(1.0));
334 client->SetRemote(socket);
337 client->SetStopTime(
Seconds(1.0));
385 apPem->SetList({3, 5, 6, 7, 8, 9, 10, 11});
389 ->SetPostReceptionErrorModel(
apPem);
446 apPem0->SetList({6, 7, 9, 10, 11, 12, 13, 14, 15, 16});
450 ->SetPostReceptionErrorModel(
apPem0);
454 apPem1->SetList({5, 6, 7, 9, 10, 11, 12, 13, 14, 15});
458 ->SetPostReceptionErrorModel(
apPem1);
475 dev->GetPhy()->TraceConnect(
"PhyTxPsduBegin",
486 dev->GetPhy(0)->TraceConnect(
"PhyTxPsduBegin",
489 dev->GetPhy(1)->TraceConnect(
"PhyTxPsduBegin",
525 wifiTxStats.GetFailures(WifiMacDropReason::WIFI_MAC_DROP_REACHED_RETRY_LIMIT);
527 WifiMacDropReason::WIFI_MAC_DROP_REACHED_RETRY_LIMIT);
531 "Number of success packets should be 2");
534 "Number of success packets should be 2");
539 "Number of retransmitted successful packets should be 1");
542 "Number of retransmitted successful packets should be 1");
546 "Number of failed packets should be 1");
551 "Number of dropped packets (aggregate) due to retry limit reached should be 1");
555 "Number of dropped packets (aggregate) due to retry limit reached should be 1");
560 "Source node ID of the 1st successful data packet should be 1");
564 "Source node ID of the 2nd successful data packet should be 1");
568 "Source node ID of the failed data packet should be 1");
574 "The retransmission count of the 1st successful data packet should be 0");
579 "The retransmission count of the 2nd successful data packet should be 1");
582 "The retransmission count of the failed data packet should be 6");
587 "The 1st successful data packet should have been TXed");
591 "The 2nd successful data packet should have been TXed");
594 "The failed data packet should have been TXed");
599 "The 1st successful data packet should have been acked");
603 "The 2nd successful data packet should have been acked");
606 "The failed data packet should not have been acked");
611 "The 1st successful data packet should have been dequeued");
615 "The 2nd successful data packet should have been dequeued");
619 "The failed data packet should have been dequeued");
626 "Three packets should be enqueued at the same time");
629 "Three packets should be enqueued at the same time");
634 "Packets should be TXed after enqueued");
638 "Packet backoff slots should not exceed cwMin");
642 "Wrong TX start time");
647 "Wrong Ack reception time");
652 "Wrong Ack reception time");
657 "Packets should be TXed after enqueued");
662 "Packet backoff slots should not exceed cwMin");
665 "Wrong TX start time");
670 "Wrong Ack reception time");
676 "Wrong Ack reception time");
681 "Packets should be TXed after enqueued");
686 "Packet backoff slots should not exceed cwMin");
689 "Wrong TX start time");
693 "Missing drop time or reason");
697 "Wrong Dequeue time for failed packet");
702 "Wrong Dequeue time for failed packet");
704 WifiMacDropReason::WIFI_MAC_DROP_REACHED_RETRY_LIMIT,
705 "Wrong drop reason");
710 wifiTxStats.GetFailures(WifiMacDropReason::WIFI_MAC_DROP_QOS_OLD_PACKET);
712 wifiTxStats.GetFailuresByNodeDevice(WifiMacDropReason::WIFI_MAC_DROP_QOS_OLD_PACKET);
725 "Number of success packets on link 0 should be 2");
728 "Number of success packets on link 1 should be 2");
731 "Number of success packets should be 4");
736 "Number of retransmitted successful packets should be 2");
739 "Number of retransmitted successful packets (aggregate) should be 2");
742 "Number of failed packets should be 2");
746 "Number of dropped packets (aggregate) by QosTxop should be 2");
749 "Number of dropped packets (aggregate) by QosTxop should be 2");
755 "Source node ID of the 1st successful data packet on link 0 should be 1");
760 "Source node ID of the 2nd successful data packet on link 0 should be 1");
765 "Source node ID of the 1st successful data packet on link 0 should be 1");
770 "Source node ID of the 2nd successful data packet on link 0 should be 1");
774 "Source node ID of the failed data packet on link 0 should be 1");
778 "Source node ID of the failed data packet on link 1 should be 1");
783 "Device ID of the 1st successful data packet on link 0 should be 0");
787 "Device ID of the 2nd successful data packet on link 0 should be 0");
791 "Device ID of the 1st successful data packet on link 0 should be 0");
795 "Device ID of the 2nd successful data packet on link 1 should be 0");
799 "Device ID of the failed data packet on link 1 should be 0");
803 "Device ID of the failed data packet on link 1 should be 0");
809 "Successful link ID of the 1st successful data packet on link 0 should be 0");
814 "Successful link ID of the 2nd successful data packet on link 0 should be 0");
819 "Successful link ID of the 1st successful data packet on link 1 should be 1");
824 "Successful link ID of the 2nd successful data packet on link 1 should be 1");
829 "Successful link ID set of the failed data packet on link 0 should be empty");
834 "Successful link ID set of the failed data packet on link 1 should be empty");
840 "The 1st successful data packet on link 0 should have no retransmissions");
845 "The 2nd successful data packet on link 0 should have 1 retransmission");
850 "The 1st successful data packet on link 1 should have no retransmissions");
855 "The 2nd successful data packet on link 1 should have 1 retransmission");
859 "The failed data packet on link 0 should have 8 retransmissions");
863 "The failed data packet on link 1 should have 8 retransmissions");
868 "The 1st successful data packet on link 0 should have a TID of 3");
872 "The 2nd successful data packet on link 0 should have a TID of 3");
876 "The 1st successful data packet on link 1 should have a TID of 4");
880 "The 2nd successful data packet on link 1 should have a TID of 4");
884 "The failed data packet on link 0 should have a TID of 3");
888 "The failed data packet on link 1 should have a TID of 4");
894 "The 1st successful data packet on link 0 should have a Seq Num of 0");
899 "The 2nd successful data packet on link 0 should have a Seq Num of 1");
904 "The 1st successful data packet on link 1 should have a Seq Num of 0");
909 "The 2nd successful data packet on link 1 should have a Seq Num of 2");
913 "The failed data packet on link 0 should have a Seq Num of 2");
917 "The failed data packet on link 1 should have a Seq Num of 1");
922 "The 1st successful data packet on link 0 should have been TXed");
926 "The 2nd successful data packet on link 0 should have been TXed");
930 "The 1st successful data packet on link 1 should have been TXed");
934 "The 2nd successful data packet on link 1 should have been TXed");
938 "The failed data packet on link 0 should have been TXed");
942 "The failed data packet on link 1 should have been TXed");
947 "The 1st successful data packet on link 0 should have been acked");
951 "The 2nd successful data packet on link 0 should have been acked");
955 "The 1st successful data packet on link 1 should have been acked");
959 "The 2nd successful data packet on link 1 should have been acked");
963 "The failed data packet on link 0 should not have been acked");
967 "The failed data packet on link 1 should not have been acked");
972 "The 1st successful data packet on link 0 should have been dequeued");
976 "The 2nd successful data packet on link 0 should have been dequeued");
980 "The 1st successful data packet on link 1 should have been dequeued");
984 "The 2nd successful data packet on link 1 should have been dequeued");
989 "Missing drop time or reason");
992 "The failed data packet on link 0 should have been dequeued");
994 WifiMacDropReason::WIFI_MAC_DROP_QOS_OLD_PACKET,
995 "Wrong drop reason");
1000 "Missing drop time or reason");
1003 "The failed data packet on link 1 should have been dequeued");
1005 WifiMacDropReason::WIFI_MAC_DROP_QOS_OLD_PACKET,
1006 "Wrong drop reason");
1014 "Packets on link 0 should be enqueued at the same time");
1017 "Packets on link 0 should be enqueued at the same time");
1024 "Packets on link 1 should be enqueued at the same time");
1027 "Packets on link 1 should be enqueued at the same time");
1032 "The 1st data packet on link 0 should be TXed after enqueued");
1036 "The 2nd data packet on link 0 should be TXed after enqueued");
1040 "The 1st data packet on link 1 should be TXed after enqueued");
1044 "The 2nd data packet on link 1 should be TXed after enqueued");
1048 "The 3rd data packet on link 0 should be TXed after enqueued");
1052 "The 3rd data packet on link 1 should be TXed after enqueued");
1057 "link 0 pkt first tx should be after the 11th packet on link");
1061 "link 0 pkt first backoff should not exceed cwMin");
1067 "3 pkts of link 0 should tx at the same time");
1070 "3 pkts of link 0 should tx at the same time");
1075 "link 1 pkt first tx should be after the 10th packet on link");
1079 "link 1 pkt first backoff should not exceed cwMin");
1086 "3 pkts of link 1 should tx at the same time");
1089 "3 pkts of link 1 should tx at the same time");
1095 "Wrong first Block Ack reception time on link 0");
1099 "Wrong first Block Ack reception time on link 0");
1104 "Wrong first Block Ack reception time on link 1");
1108 "Wrong first Block Ack reception time on link 1");
1115 "Wrong second Block Ack reception time on link 0");
1119 "Wrong second Block Ack reception time on link 0");
1125 "Wrong second Block Ack reception time on link 1");
1129 "Wrong second Block Ack reception time on link 1");
1163 TestCase::Duration::QUICK);
1182 TestCase::Duration::QUICK);
Implements a test case to evaluate the transmission process of multiple Wi-Fi MAC Layer MPDUs.
void DoRun() override
Implementation to actually run this TestCase.
void CheckResults(const WifiTxStatsHelper &wifiTxStats)
Check correctness of test.
int64_t m_streamNumber
Random variable stream number.
NodeContainer m_wifiStaNodes
NodeContainer for STAs.
std::map< uint8_t, Time > m_aifss
Map of AIFSs, indexed per link (for MULTI_LINK_QOS case only)
std::map< uint8_t, std::vector< Time > > m_durations
Map of vector of MPDU durations, indexed per link.
std::map< uint8_t, std::vector< Time > > m_txStartTimes
Map of independently obtain vector of PhyTxBegin trace, indexed per link.
TestOption
Option for the test.
WifiTxStatsHelperTest(const std::string &testName, TestOption option)
Constructor.
std::map< uint8_t, uint32_t > m_cwMins
Map of CW Mins, indexed per link.
std::map< uint8_t, uint32_t > m_aifsns
Map of AIFSNs, indexed per link (for MULTI_LINK_QOS case only)
NodeContainer m_wifiApNode
NodeContainer for AP.
Time m_difs
DIFS time (for SINGLE_LINK_NON_QOS case only)
void Transmit(std::string context, WifiConstPsduMap psduMap, WifiTxVector txVector, Watt_u txPower)
Callback invoked when PHY starts transmission of a PSDU, used to record TX start time and TX duration...
TestOption m_option
Test option.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
WifiTxStatsHelper Test Suite.
WifiTxStatsHelperTestSuite()
AttributeValue implementation for Boolean.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
an address for a packet socket
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.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
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.
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Statistics helper for tracking outcomes of data MPDU transmissions.
void Enable(const NodeContainer &nodes)
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#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 > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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_ASSERT_MSG_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report and abort if not.
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to a limit and report and abort 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.
@ WIFI_PHY_BAND_6GHZ
The 6 GHz band.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
constexpr FrequencyRange WIFI_SPECTRUM_6_GHZ
Identifier for the frequency range covering the wifi spectrum in the 6 GHz band.
std::unordered_map< uint16_t, Ptr< const WifiPsdu > > WifiConstPsduMap
Map of const PSDUs indexed by STA-ID.
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...
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
static WifiTxStatsHelperTestSuite g_wifiTxStatsHelperTestSuite
the test suite