9#include "ns3/channel-access-manager.h"
10#include "ns3/config.h"
11#include "ns3/mobility-helper.h"
12#include "ns3/multi-model-spectrum-channel.h"
13#include "ns3/packet-socket-client.h"
14#include "ns3/packet-socket-helper.h"
15#include "ns3/packet-socket-server.h"
16#include "ns3/qos-txop.h"
17#include "ns3/rng-seed-manager.h"
18#include "ns3/spectrum-wifi-helper.h"
19#include "ns3/string.h"
21#include "ns3/wifi-mac.h"
22#include "ns3/wifi-net-device.h"
23#include "ns3/wifi-psdu.h"
72 void DoRun()
override;
99 :
TestCase(
"Check transmission on available bandwidth"),
100 m_channelStr(channelStr),
101 m_bss0Width(bss0Width),
102 m_txPkts(bss0Width / 10),
114 NS_LOG_INFO(
"Received " << p->GetSize() <<
" bytes in BSS " << +bss);
124 auto psdu = psduMap.begin()->second;
130 if (!psdu->GetHeader(0).IsMgt() && now >
MilliSeconds(400))
140 NS_LOG_INFO(now <<
" BSS " << +bss <<
" " << psdu->GetHeader(0).GetTypeString() <<
" seq "
141 << psdu->GetHeader(0).GetSequenceNumber() <<
" to " << psdu->GetAddr1()
142 <<
" #MPDUs " << psdu->GetNMpdus() <<
" size " << psdu->GetSize()
145 <<
"TXVECTOR " << txVector <<
"\n");
157 client->SetStartTime(
Seconds(0));
158 client->SetStopTime(
Seconds(1.0));
159 client->Initialize();
165 auto cam = mac->GetChannelAccessManager();
169 "Unexpected width of the largest idle primary channel");
179 int64_t streamNumber = 100;
186 spectrumChannel->AddPropagationLossModel(lossModel);
189 spectrumChannel->SetPropagationDelayModel(delayModel);
192 phy.SetChannel(spectrumChannel);
196 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
212 m_staDevices = wifi.Install(phy, staMac, wifiStaNodes.Get(0));
230 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
231 positionAlloc->Add(Vector(50.0, 0.0, 0.0));
232 positionAlloc->Add(Vector(0.0, 50.0, 0.0));
233 positionAlloc->Add(Vector(50.0, 50.0, 0.0));
234 mobility.SetPositionAllocator(positionAlloc);
236 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
237 mobility.Install(wifiApNodes);
238 mobility.Install(wifiStaNodes);
250 packetSocket.
Install(wifiApNodes);
251 packetSocket.
Install(wifiStaNodes);
254 for (uint8_t bss : {0, 1})
269 client1->SetStopTime(
Seconds(2.0));
280 client2->SetStartTime(
Seconds(1.5));
281 client2->SetStopTime(
Seconds(2.0));
286 wifiStaNodes.Get(bss)->AddApplication(server);
287 server->SetStartTime(
Seconds(0.0));
288 server->SetStopTime(
Seconds(2.0));
292 "/ApplicationList/*/$ns3::PacketSocketServer/Rx",
296 "/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
300 "/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
333 psduIt->txVector.GetChannelWidth(),
335 "Expected a transmission on the whole channel width");
355 psduIt->txVector.GetChannelWidth(),
357 "Expected a transmission on the whole channel width");
369 "Expected an A-MPDU of " << +
m_txPkts <<
" MPDUs");
371 psduIt->txVector.GetChannelWidth(),
373 "Expected a transmission on the whole channel width");
381 "Expected an A-MPDU of " << +
m_txPkts <<
" MPDUs");
384 "Unexpected transmission width");
386 std::prev(psduIt)->txStart + std::prev(psduIt)->txDuration,
387 "AP 0 is expected to transmit before the end of transmission of AP 1");
403 "Unexpected number of packets received by STA 0");
406 "Unexpected number of packets received by STA 1");
435 TestCase::Duration::QUICK);
449 TestCase::Duration::QUICK);
463 TestCase::Duration::QUICK);
wifi dynamic bandwidth operation Test Suite
WifiDynamicBwOpTestSuite()
Two BSSes, each with one AP and one non-AP STA, are configured to operate on different channels.
void Transmit(uint8_t bss, WifiConstPsduMap psduMap, WifiTxVector txVector, double txPowerW)
Callback invoked when a PHY receives a PSDU to transmit.
std::vector< std::string > m_channelStr
channel setting strings
~WifiUseAvailBwTest() override
std::array< uint8_t, 2 > m_rcvPkts
number of packets received by the stations
std::vector< FrameInfo > m_txPsdus
transmitted PSDUs
std::array< PacketSocketAddress, 2 > m_sockets
packet sockets for the two BSSes
void L7Receive(uint8_t bss, Ptr< const Packet > p, const Address &addr)
Function to trace packets received by the server application in the given BSS.
MHz_u m_bss0Width
width of the transmission in BSS 0 started when BSS 1 is transmitting
void DoRun() override
Implementation to actually run this TestCase.
uint8_t m_txPkts
TX packets per BSS (in addition to the two required to establish BA agreement)
void CheckResults()
Check correctness of transmitted frames.
NetDeviceContainer m_apDevices
container for AP's NetDevice
NetDeviceContainer m_staDevices
container for stations' NetDevices
WifiUseAvailBwTest(std::initializer_list< std::string > channelStr, MHz_u bss0Width)
Constructor.
a polymophic address class
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
Vector GetPosition() const
holds a vector of ns3::NetDevice pointers
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.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
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 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.
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.
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.
void SetType(std::string type, Args &&... args)
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 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_LT(actual, limit, msg)
Test that an actual value is less than a limit and report 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.
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
Information about transmitted frames.
uint8_t bss
BSS the frame belongs to.
Time txDuration
Frame TX duration.
std::size_t nMpdus
number of MPDUs in the PSDU
Time txStart
Frame start TX time.
WifiTxVector txVector
TX vector used to transmit the frame.
WifiMacHeader header
Frame MAC header.
static WifiDynamicBwOpTestSuite g_wifiDynamicBwOpTestSuite
the test suite