20 #include "ns3/channel-access-manager.h"
21 #include "ns3/config.h"
22 #include "ns3/mobility-helper.h"
23 #include "ns3/multi-model-spectrum-channel.h"
24 #include "ns3/packet-socket-client.h"
25 #include "ns3/packet-socket-helper.h"
26 #include "ns3/packet-socket-server.h"
27 #include "ns3/qos-txop.h"
28 #include "ns3/rng-seed-manager.h"
29 #include "ns3/spectrum-wifi-helper.h"
30 #include "ns3/string.h"
32 #include "ns3/wifi-mac.h"
33 #include "ns3/wifi-net-device.h"
34 #include "ns3/wifi-psdu.h"
83 void DoRun()
override;
110 :
TestCase(
"Check transmission on available bandwidth"),
111 m_channelStr(channelStr),
112 m_bss0Width(bss0Width),
113 m_txPkts(bss0Width / 10),
135 auto psdu = psduMap.begin()->second;
141 if (!psdu->GetHeader(0).IsMgt() && now >
MilliSeconds(400))
151 NS_LOG_INFO(now <<
" BSS " << +bss <<
" " << psdu->GetHeader(0).GetTypeString() <<
" seq "
152 << psdu->GetHeader(0).GetSequenceNumber() <<
" to " << psdu->GetAddr1()
153 <<
" #MPDUs " << psdu->GetNMpdus() <<
" size " << psdu->GetSize()
156 <<
"TXVECTOR " << txVector <<
"\n");
176 auto cam =
mac->GetChannelAccessManager();
180 "Unexpected width of the largest idle primary channel");
188 RngSeedManager::SetSeed(1);
189 RngSeedManager::SetRun(40);
190 int64_t streamNumber = 100;
195 auto spectrumChannel = CreateObject<MultiModelSpectrumChannel>();
197 spectrumChannel->AddPropagationLossModel(lossModel);
199 CreateObject<ConstantSpeedPropagationDelayModel>();
200 spectrumChannel->SetPropagationDelayModel(delayModel);
203 phy.SetChannel(spectrumChannel);
207 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
214 apMac.
SetType(
"ns3::ApWifiMac",
"Ssid", SsidValue(
Ssid(
"dynamic-bw-op-ssid")));
217 staMac.
SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(
Ssid(
"dynamic-bw-op-ssid")));
241 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
242 positionAlloc->Add(Vector(50.0, 0.0, 0.0));
243 positionAlloc->Add(Vector(0.0, 50.0, 0.0));
244 positionAlloc->Add(Vector(50.0, 50.0, 0.0));
245 mobility.SetPositionAllocator(positionAlloc);
247 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
261 packetSocket.
Install(wifiApNodes);
265 for (uint8_t bss : {0, 1})
280 client1->SetStopTime(
Seconds(2.0));
291 client2->SetStartTime(
Seconds(1.5));
292 client2->SetStopTime(
Seconds(2.0));
303 "/ApplicationList/*/$ns3::PacketSocketServer/Rx",
307 "/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
311 "/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxPsduBegin",
320 Simulator::Destroy();
344 psduIt->txVector.GetChannelWidth(),
345 StaticCast<WifiNetDevice>(
m_apDevices.
Get(0))->GetPhy()->GetChannelWidth(),
346 "Expected a transmission on the whole channel width");
366 psduIt->txVector.GetChannelWidth(),
367 StaticCast<WifiNetDevice>(
m_apDevices.
Get(1))->GetPhy()->GetChannelWidth(),
368 "Expected a transmission on the whole channel width");
380 "Expected an A-MPDU of " << +
m_txPkts <<
" MPDUs");
382 psduIt->txVector.GetChannelWidth(),
383 StaticCast<WifiNetDevice>(
m_apDevices.
Get(1))->GetPhy()->GetChannelWidth(),
384 "Expected a transmission on the whole channel width");
392 "Expected an A-MPDU of " << +
m_txPkts <<
" MPDUs");
395 "Unexpected transmission width");
398 "AP 0 is expected to transmit before the end of transmission of AP 1");
414 "Unexpected number of packets received by STA 0");
417 "Unexpected number of packets received by STA 1");
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.
uint16_t m_bss0Width
width (MHz) 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, uint16_t 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.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
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, TestDuration 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
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
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.
Time Now()
create an ns3::Time instance which contains the current simulation time.
#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.
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
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...
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