8#include "ns3/boolean.h"
10#include "ns3/eht-configuration.h"
12#include "ns3/he-phy.h"
13#include "ns3/integer.h"
14#include "ns3/mobility-helper.h"
15#include "ns3/multi-model-spectrum-channel.h"
17#include "ns3/node-list.h"
18#include "ns3/object.h"
19#include "ns3/packet-socket-client.h"
20#include "ns3/packet-socket-helper.h"
21#include "ns3/packet-socket-server.h"
22#include "ns3/packet.h"
23#include "ns3/pointer.h"
24#include "ns3/rng-seed-manager.h"
25#include "ns3/spectrum-wifi-helper.h"
27#include "ns3/string.h"
29#include "ns3/uinteger.h"
30#include "ns3/wifi-co-trace-helper.h"
31#include "ns3/wifi-helper.h"
32#include "ns3/wifi-mac.h"
33#include "ns3/wifi-mpdu.h"
34#include "ns3/wifi-net-device.h"
35#include "ns3/wifi-phy-state.h"
36#include "ns3/wifi-psdu.h"
37#include "ns3/yans-wifi-helper.h"
138const std::map<WifiPhyState, Time>&
144 auto senderRecord = std::find_if(devRecords.cbegin(), devRecords.cend(), [nodeId](
auto& x) {
145 return x.m_nodeId == nodeId;
148 NS_ASSERT_MSG((senderRecord != devRecords.end()),
"Expected statistics for nodeId: " << nodeId);
150 auto stats = senderRecord->m_linkStateDurations.find(linkId);
151 auto endItr = senderRecord->m_linkStateDurations.end();
153 "Expected statistics at nodeId: " << nodeId <<
", linkId: " << linkId);
155 return stats->second;
164 wifiDevice->GetMac()->GetEhtConfiguration()->SetAttribute(
165 "TidToLinkMappingNegSupport",
166 EnumValue(WifiTidToLinkMappingNegSupport::ANY_LINK_SET));
168 wifiDevice->GetMac()->GetEhtConfiguration()->SetAttribute(
"TidToLinkMappingUl",
187 psServer->SetLocal(srvAddr);
188 node->AddApplication(psServer);
189 psServer->SetStartTime(startAfter);
204 NS_LOG_INFO(
"Start Flow on node:" << client->GetId()
214 clientApp->SetAttribute(
"PacketSize",
UintegerValue(pktLen));
215 clientApp->SetAttribute(
"MaxPackets",
UintegerValue(numPkts));
218 clientApp->SetRemote(sockAddr);
219 clientApp->SetStartTime(startAfter);
221 staDevice->GetNode()->AddApplication(clientApp);
253 device->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
254 device->GetMac()->SetAttribute(
"BK_MaxAmpduSize",
UintegerValue(0));
255 device->GetMac()->SetAttribute(
"VO_MaxAmpduSize",
UintegerValue(0));
256 device->GetMac()->SetAttribute(
"VI_MaxAmpduSize",
UintegerValue(0));
258 device->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(0));
259 device->GetMac()->SetAttribute(
"BK_MaxAmsduSize",
UintegerValue(0));
260 device->GetMac()->SetAttribute(
"VO_MaxAmsduSize",
UintegerValue(0));
261 device->GetMac()->SetAttribute(
"VI_MaxAmsduSize",
UintegerValue(0));
282 void DoRun()
override;
289 "SendOnePacketTestCase: Send one packet from one WifiNetDevice to other.")
296 size_t senderNodeId = 1;
297 size_t recNodeId = 0;
315 size_t packetLen = 200;
362 "TX duration does not match");
367 "TX duration does not match");
372 "TX duration does not match");
385 "TX duration does not match");
391 std::string mcs{
"11"};
410 phy.Set(0,
"ChannelSettings",
StringValue(
"{0, 40, BAND_5GHZ, 0}"));
413 wifi.SetRemoteStationManager(linkId,
414 "ns3::ConstantRateWifiManager",
420 mac.SetType(
"ns3::AdhocWifiMac");
425 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
427 positionAlloc->Add(Vector(distance, 0.0, 0.0));
428 mobility.SetPositionAllocator(positionAlloc);
429 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
435 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HeConfiguration/GuardInterval",
458 void DoRun()
override;
464 "MLOTestCase: Track channel occupancy on multiple links of a multi-link device (MLD).")
475 size_t senderNodeId = 1;
476 size_t recNodeId = 0;
501 std::cout <<
"## MLOTestCase: Tid 0 Packet ##\n";
502 helper0.PrintStatistics(std::cout);
503 std::cout <<
"## MLOTestCase: Tid 3 Packet ##\n";
504 helper1.PrintStatistics(std::cout);
512 "TX duration does not match");
518 "TX duration does not match");
556 phy.Set(0,
"ChannelSettings",
StringValue(
"{0, 40, BAND_5GHZ, 0}"));
557 phy.Set(1,
"ChannelSettings",
StringValue(
"{0, 40, BAND_6GHZ, 0}"));
561 wifi.SetRemoteStationManager(linkId,
562 "ns3::ConstantRateWifiManager",
567 wifi.SetRemoteStationManager(1,
568 "ns3::ConstantRateWifiManager",
574 mac.SetType(
"ns3::ApWifiMac",
"Ssid",
SsidValue(ssid));
582 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
584 positionAlloc->Add(Vector(distance, 0.0, 0.0));
585 mobility.SetPositionAllocator(positionAlloc);
587 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
593 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/HeConfiguration/GuardInterval",
615 void DoRun()
override;
621 "LinkRenameTestCase: WifiCoTraceHelper should record statistics under new LinkId.")
640 std::cout <<
"## LinkRenameTestCase ##\n";
643 auto staStatistics = coHelper.
GetDeviceRecords().at(staNodeId).m_linkStateDurations;
647 auto renamedLinkId = 2;
648 auto it = staStatistics.find(renamedLinkId);
651 "Link: " << renamedLinkId <<
" isn't present at non-AP MLD");
686 nonApPhyHelper.
Set(0,
"ChannelSettings",
StringValue(
"{42, 80, BAND_5GHZ, 0}"));
687 nonApPhyHelper.
Set(1,
"ChannelSettings",
StringValue(
"{0, 80, BAND_5GHZ, 0}"));
695 uint8_t firstLinkId = 0;
697 "ns3::ConstantRateWifiManager",
703 "ns3::ConstantRateWifiManager",
716 apPhyHelper.
Set(0,
"ChannelSettings",
StringValue(
"{6, 40, BAND_2_4GHZ, 0}"));
717 apPhyHelper.
Set(1,
"ChannelSettings",
StringValue(
"{42, 80, BAND_5GHZ, 0}"));
718 apPhyHelper.
Set(2,
"ChannelSettings",
StringValue(
"{0, 0, BAND_5GHZ, 0}"));
726 "ns3::ConstantRateWifiManager",
732 "ns3::ConstantRateWifiManager",
738 "ns3::ConstantRateWifiManager",
753 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
755 positionAlloc->Add(Vector(distance, 0.0, 0.0));
756 mobility.SetPositionAllocator(positionAlloc);
758 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
LinkId of non-AP MLD changes after MLO setup.
void DoRun() override
Implementation to actually run this TestCase.
LinkRenameTestCase()
Constructor.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
Trace channel occupany on each link of MLDs.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
MLOTestCase()
Constructor.
Send one packet from one WifiNetDevice to other.
SendOnePacketTestCase()
Constructor.
void DoRun() override
Executes test case and assertions.
void DoSetup() override
Setup test case's scenario.
Wifi Channel Occupancy Helper Test Suite.
WifiCoHelperTestSuite()
Constructor.
It's a base class with some utility methods for other test cases in this file.
NodeContainer m_nodes
Container of all nodes instantiated in this test case.
WifiCoTraceHelperBaseTestCase(const std::string &testName)
Constructor.
void SchedulePackets(Ptr< Node > from, Ptr< Node > to, Time startAfter, size_t numPkts, size_t pktLen, size_t tid)
A helper function that schedules to send given number of packets from one node to another.
Time m_simulationStop
Instant at which simulation should stop.
Ptr< PacketSocketClient > InstallPacketSocketClient(Ptr< Node > client, Ptr< Node > server, size_t prot, Time startAfter, size_t numPkts, size_t pktLen, size_t tid)
A helper function that installs PacketSocketClient application on a node.
void DisableAggregation()
A helper function that disables frame aggregation.
void ConfigureTidToLinkMapping(const std::string &mapping)
A helper function that sets tid-to-link mapping.
size_t protocol
A unique Protocol used in each PacketSocketClient and PacketSocketServer pair.
void InstallPacketSocketServer(Ptr< Node > node, Time startAfter, size_t prot)
A helper function that installs PacketSocketServer on a node.
const std::map< WifiPhyState, Time > & GetChannelOccupancy(size_t nodeId, size_t linkId, WifiCoTraceHelper &coHelper)
It gets the channel occupancy of a link on a node measured by WifiCoTraceHelper.
NetDeviceContainer m_devices
Container of all devices instantiated in this test case.
Hold variables of type enum.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of 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.
uint32_t GetN() const
Get the number of Ptr<Node> stored in this container.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated 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 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.
void AddChannel(const Ptr< SpectrumChannel > channel, const FrequencyRange &freqRange=WHOLE_WIFI_SPECTRUM)
The IEEE 802.11 SSID Information Element.
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.
Hold an unsigned integer type.
Track channel occupancy durations for WifiNetDevice.
void Stop(Time stopTime)
Stops the collection of statistics at a specified time.
void Enable(NodeContainer nodes)
Enables trace collection for all nodes and WifiNetDevices in the specified NodeContainer.
void PrintStatistics(std::ostream &os, Time::Unit unit=Time::Unit::AUTO) const
Print measurement results on an output stream.
const std::vector< DeviceRecord > & GetDeviceRecords() const
Returns measurement results on each installed device.
helps to create WifiNetDevice objects
void SetRemoteStationManager(std::string type, Args &&... args)
Helper function used to set the station manager.
virtual void SetStandard(WifiStandard standard)
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
create MAC layers for a ns3::WifiNetDevice.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
void Set(std::string name, const AttributeValue &v)
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void Set(std::string path, const AttributeValue &value)
#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.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
static WifiCoHelperTestSuite g_WifiCoHelperTestSuite
WifiCoHelperTestSuite instance variable.
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.
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.
constexpr FrequencyRange WIFI_SPECTRUM_2_4_GHZ
Identifier for the frequency range covering the wifi spectrum in the 2.4 GHz band.