9#include "ns3/arp-header.h"
10#include "ns3/arp-l3-protocol.h"
11#include "ns3/config.h"
12#include "ns3/frame-exchange-manager.h"
13#include "ns3/internet-stack-helper.h"
14#include "ns3/ipv4-address-helper.h"
15#include "ns3/llc-snap-header.h"
16#include "ns3/mobility-helper.h"
17#include "ns3/pointer.h"
18#include "ns3/qos-txop.h"
19#include "ns3/rng-seed-manager.h"
21#include "ns3/string.h"
23#include "ns3/udp-client-server-helper.h"
24#include "ns3/wifi-mac-queue.h"
25#include "ns3/wifi-mac.h"
26#include "ns3/wifi-mlo-test.h"
27#include "ns3/wifi-net-device.h"
87 const std::vector<std::string>& firstStaChannels,
88 const std::vector<std::string>& secondStaChannels,
99 double txPowerW)
override;
100 void DoRun()
override;
139 const std::vector<std::string>& firstStaChannels,
140 const std::vector<std::string>& secondStaChannels,
145 std::string(
"Check UDP packet transmission between MLDs ") +
146 " (#AP_links: " +
std::to_string(apChannels.size()) +
147 ", #STA_1_links: " +
std::to_string(firstStaChannels.size()) +
148 ", #STA_2_links: " +
std::to_string(secondStaChannels.size()) +
149 ", Traffic pattern: " +
std::to_string(static_cast<uint8_t>(trafficPattern)) +
151 ", A-MSDU aggregation: " +
std::to_string(amsduAggr) +
")",
153 BaseParams{firstStaChannels, apChannels, {}}),
154 m_2ndStaChannels(secondStaChannels),
155 m_trafficPattern(trafficPattern),
156 m_assocType(assocType),
157 m_amsduAggr(amsduAggr)
168 int64_t streamNumber = 30;
176 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
194 mac.SetType(
"ns3::StaWifiMac",
200 NetDeviceContainer staDevices = wifi.Install(staPhyHelper1, mac, wifiStaNodes.Get(0));
202 mac.SetType(
"ns3::StaWifiMac",
208 staDevices.Add(wifi.Install(staPhyHelper2, mac, wifiStaNodes.Get(1)));
210 mac.SetType(
"ns3::ApWifiMac",
229 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
230 positionAlloc->Add(Vector(1.0, 0.0, 0.0));
231 mobility.SetPositionAllocator(positionAlloc);
233 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
234 mobility.Install(wifiApNode);
235 mobility.Install(wifiStaNodes);
245 for (uint8_t phyId = 0; phyId <
m_apMac->GetDevice()->GetNPhys(); phyId++)
248 "/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Phys/" + std::to_string(phyId) +
254 for (uint8_t phyId = 0; phyId <
m_staMacs[i]->GetDevice()->GetNPhys(); phyId++)
257 "/NodeList/" + std::to_string(i + 1) +
"/DeviceList/*/$ns3::WifiNetDevice/Phys/" +
258 std::to_string(phyId) +
"/PhyTxPsduBegin",
266 stack.Install(allNodes);
267 streamNumber += stack.AssignStreams(allNodes, streamNumber);
270 address.SetBase(
"10.1.0.0",
"255.255.255.0");
279 auto serverApps = serverHelper.
Install(allNodes);
280 serverApps.Start(
Seconds(0.0));
299 m_apMac->TraceConnectWithoutContext(
"AssociatedSta",
332 auto clientApp = clientHelper.
Install(srcMac->GetDevice()->GetNode());
346 auto psdu = psduMap.begin()->second;
349 if (!psdu->GetHeader(0).IsQosData() || !psdu->GetHeader(0).HasData())
357 std::list<Ptr<const Packet>> packets;
359 if (mpdu->GetHeader().IsQosAmsdu())
363 packets.push_back(msdu.first);
368 packets.push_back(mpdu->GetPacket());
371 for (
auto pkt : packets)
374 auto packet = pkt->Copy();
375 packet->RemoveHeader(llc);
383 packet->RemoveHeader(arp);
409 !srcMac->GetLinkIdByAddress(sender) && sender != srcMac->GetAddress())
426 ?
m_staMacs[0]->GetFrameExchangeManager(linkId)->GetAddress()
433 expectedSrc =
m_apMac->GetAddress();
443 "Unexpected source HW address");
446 "Unexpected destination HW address");
461 if (!srcMac->GetLinkIdByAddress(sender) && sender != srcMac->GetAddress())
470 ? srcMac->GetFrameExchangeManager(linkId)->GetAddress()
471 : srcMac->GetAddress();
477 "Unexpected source HW address");
489 "Unexpected number of received packets");
491 std::size_t expectedNOrigArpRequest{0};
492 std::size_t expectedNFwdArpRequest{0};
499 expectedNOrigArpRequest = 1;
500 expectedNFwdArpRequest =
m_apMac->GetNLinks();
504 expectedNOrigArpRequest =
m_apMac->GetNLinks();
505 expectedNFwdArpRequest = 0;
512 expectedNOrigArpRequest + expectedNFwdArpRequest,
513 "Unexpected number of transmitted ARP Request frames");
515 expectedNOrigArpRequest,
516 "Unexpected number of checked ARP Request frames");
518 std::size_t expectedNOrigArpReply{0};
519 std::size_t expectedNFwdArpReply{0};
525 expectedNOrigArpReply = 1;
526 expectedNFwdArpReply = 0;
531 expectedNOrigArpReply =
532 std::min<std::size_t>(
m_apMac->GetNLinks(),
m_staMacs[0]->GetSetupLinkIds().size());
533 expectedNFwdArpReply = 0;
538 expectedNOrigArpReply = expectedNFwdArpReply =
m_staMacs[1]->GetSetupLinkIds().size();
545 expectedNOrigArpReply + expectedNFwdArpReply,
546 "Unexpected number of transmitted ARP Reply frames");
548 expectedNOrigArpReply,
549 "Unexpected number of checked ARP Reply frames");
569 using ParamsTuple = std::array<std::vector<std::string>, 3>;
571 for (
const auto& channels :
574 {{
"{7, 80, BAND_6GHZ, 0}"},
575 {
"{42, 80, BAND_5GHZ, 2}",
"{5, 40, BAND_2_4GHZ, 0}",
"{7, 80, BAND_6GHZ, 0}"},
576 {
"{7, 80, BAND_6GHZ, 0}"}}},
579 {{
"{7, 80, BAND_6GHZ, 0}"},
580 {
"{42, 80, BAND_5GHZ, 2}",
"{5, 40, BAND_2_4GHZ, 0}",
"{7, 80, BAND_6GHZ, 0}"},
581 {
"{42, 80, BAND_5GHZ, 2}",
"{7, 80, BAND_6GHZ, 0}"}}},
584 {{
"{42, 80, BAND_5GHZ, 2}",
"{5, 40, BAND_2_4GHZ, 0}",
"{7, 80, BAND_6GHZ, 0}"},
585 {
"{7, 80, BAND_6GHZ, 0}"},
586 {
"{42, 80, BAND_5GHZ, 2}",
"{5, 40, BAND_2_4GHZ, 0}"}}},
589 {{
"{42, 80, BAND_5GHZ, 2}",
"{5, 40, BAND_2_4GHZ, 0}",
"{7, 80, BAND_6GHZ, 0}"},
590 {
"{42, 80, BAND_5GHZ, 2}",
"{5, 40, BAND_2_4GHZ, 0}",
"{7, 80, BAND_6GHZ, 0}"},
591 {
"{5, 40, BAND_2_4GHZ, 0}",
"{7, 80, BAND_6GHZ, 0}"}}}})
597 for (
const auto amsduAggr : {
false,
true})
599 for (
const auto assocType : {WifiAssocType::LEGACY, WifiAssocType::ML_SETUP})
607 TestCase::Duration::QUICK);
Base class for Multi-Link Operations tests.
virtual void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when a FEM passes PSDUs to the PHY.
void SetSsid(uint16_t aid, Mac48Address)
Set the SSID on the next station that needs to start the association procedure.
std::vector< Ptr< StaWifiMac > > m_staMacs
STA wifi MACs.
const std::vector< std::string > m_staChannels
strings specifying channels for STA
void SetChannels(SpectrumWifiPhyHelper &helper, const std::vector< std::string > &channels, const ChannelMap &channelMap)
Reset the given PHY helper, use the given strings to set the ChannelSettings attribute of the PHY obj...
const std::vector< std::string > m_apChannels
strings specifying channels for AP
std::map< FrequencyRange, Ptr< MultiModelSpectrumChannel > > ChannelMap
PHY band-indexed map of spectrum channels.
uint8_t m_nStations
number of stations to create
Time m_duration
simulation duration
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
Ptr< ApWifiMac > m_apMac
AP wifi MAC.
Test UDP packet transmission between MLDs and SLDs.
WifiMloUdpTest(const std::vector< std::string > &apChannels, const std::vector< std::string > &firstStaChannels, const std::vector< std::string > &secondStaChannels, WifiTrafficPattern trafficPattern, WifiAssocType assocType, bool amsduAggr)
Constructor.
const uint16_t m_udpPort
UDP port for application servers.
WifiAssocType m_assocType
association type
void CheckArpRequestHwAddresses(const ArpHeader &arp, Mac48Address sender, uint8_t linkId)
Check source and destination hardware addresses in ARP request frames.
std::size_t m_nArpRequest
counts how many ARP Requests are transmitted
WifiTrafficPattern m_trafficPattern
the pattern of traffic to generate
void CheckArpReplyHwAddresses(const ArpHeader &arp, Mac48Address sender, uint8_t linkId)
Check source and destination hardware addresses in ARP reply frames.
std::size_t m_nCheckedArpReply
counts how many ARP Replies are checked
const std::vector< std::string > m_2ndStaChannels
string specifying channels for second STA
Ipv4InterfaceContainer m_staInterfaces
IP interfaces for non-AP MLDs.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
const std::size_t m_nPackets
number of application packets to generate
std::size_t m_nArpReply
counts how many ARP Replies are transmitted
void Transmit(Ptr< WifiMac > mac, uint8_t phyId, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW) override
Callback invoked when a FEM passes PSDUs to the PHY.
void DoRun() override
Implementation to actually run this TestCase.
Ptr< UdpServer > m_sink
server app on the receiving node
Ipv4InterfaceContainer m_apInterface
IP interface for AP MLD.
void StartTraffic() override
Start the generation of traffic (needs to be overridden)
bool m_amsduAggr
whether A-MSDU aggregation is enabled
std::size_t m_nCheckedArpRequest
counts how many ARP Requests are checked
Multi-Link Operations with UDP traffic Test Suite.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
static const uint16_t PROT_NUMBER
ARP protocol number (0x0806)
AttributeValue implementation for Boolean.
Hold variables of type enum.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
static NodeContainer GetGlobal()
Create a NodeContainer that contains a list of all nodes created through NodeContainer::Create() and ...
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 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.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Create a server application which waits for input UDP packets and uses the information carried into t...
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.
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_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiAssocType
Type of association performed by this device (provided that it is supported by the standard configure...
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.
U * PeekPointer(const Ptr< U > &p)
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.
constexpr FrequencyRange WIFI_SPECTRUM_5_GHZ
Identifier for the frequency range covering the wifi spectrum in the 5 GHz band.
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.
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.
Configuration parameters common to all subclasses.
WifiTrafficPattern
Tested traffic patterns.
static WifiMloUdpTestSuite g_wifiMloUdpTestSuite
the test suite