10#include "ns3/config.h"
11#include "ns3/constant-obss-pd-algorithm.h"
12#include "ns3/double.h"
13#include "ns3/he-configuration.h"
15#include "ns3/mobility-helper.h"
16#include "ns3/multi-model-spectrum-channel.h"
17#include "ns3/pointer.h"
18#include "ns3/rng-seed-manager.h"
19#include "ns3/spectrum-wifi-helper.h"
21#include "ns3/string.h"
23#include "ns3/uinteger.h"
24#include "ns3/wifi-net-device.h"
25#include "ns3/wifi-utils.h"
34 std::string sub = context.substr(10);
36 uint32_t nodeId = std::stoi(sub.substr(0, pos));
77 void DoRun()
override;
147 std::vector<WifiPhyRxfailureReason> expectedDropReasons);
207 :
TestCase(
"InterBssConstantObssPd"),
208 m_numSta1PacketsSent(0),
209 m_numSta2PacketsSent(0),
210 m_numAp1PacketsSent(0),
211 m_numAp2PacketsSent(0),
212 m_numSta1PacketsReceived(0),
213 m_numSta2PacketsReceived(0),
214 m_numAp1PacketsReceived(0),
215 m_numAp2PacketsReceived(0),
216 m_payloadSize1(1000),
217 m_payloadSize2(1500),
218 m_payloadSize3(2000),
222 m_expectedTxPower(15),
243 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
244 positionAlloc->Add(Vector(d1 + d2, 0.0, 0.0));
245 positionAlloc->Add(Vector(d1 + d2 + d3 + d4, 0.0, 0.0));
246 positionAlloc->Add(Vector(d1, 0.0, 0.0));
247 positionAlloc->Add(Vector(d1 + d2 + d3, 0.0, 0.0));
248 positionAlloc->Add(Vector(d1 + d2 + d3 + d4 + d5, 0.0, 0.0));
249 return positionAlloc;
264 std::vector<WifiPhyRxfailureReason> dropReasons;
266 expectFilter ? WifiPhyState::CCA_BUSY : WifiPhyState::RX;
352 WifiPhyState::CCA_BUSY);
357 WifiPhyState::CCA_BUSY);
362 WifiPhyState::CCA_BUSY);
374 expectPhyReset ? WifiPhyState::IDLE : WifiPhyState::CCA_BUSY);
384 expectPhyReset ? WifiPhyState::IDLE : WifiPhyState::CCA_BUSY);
391 expectPhyReset ? WifiPhyState::IDLE : stateDuringPayloadNeighboringBss);
396 expectPhyReset ? WifiPhyState::IDLE : stateDuringPayloadNeighboringBss);
448 expectPhyReset ? WifiPhyState::TX : stateDuringPayloadNeighboringBss);
463 stateDuringPayloadNeighboringBss);
468 expectPhyReset ? WifiPhyState::RX : stateDuringPayloadNeighboringBss);
516 expectPhyReset ? WifiPhyState::TX : stateDuringPayloadNeighboringBss);
531 stateDuringPayloadNeighboringBss);
536 expectPhyReset ? WifiPhyState::RX : stateDuringPayloadNeighboringBss);
637 "The number of packets sent by STA1 is not correct!");
640 "The number of packets sent by STA2 is not correct!");
643 "The number of packets sent by AP1 is not correct!");
646 "The number of packets sent by AP2 is not correct!");
649 "The number of packets received by STA1 is not correct!");
652 "The number of packets received by STA2 is not correct!");
655 "The number of packets received by AP1 is not correct!");
658 "The number of packets received by AP2 is not correct!");
673 "Tx power is not correct!");
680 "Tx power is not correct!");
687 "Tx power is not correct!");
694 "Tx power is not correct!");
752 tx_dev->Send(p, rx_dev->GetAddress(), 1);
767 phy->GetAttribute(
"State", ptr);
769 currentState = state->GetState();
772 "PHY State " << currentState <<
" does not match expected state "
779 std::vector<WifiPhyRxfailureReason> expectedDropReasons)
781 std::vector<WifiPhyRxfailureReason> currentDropReasons;
782 uint32_t nodeId = device->GetNode()->GetId();
801 expectedDropReasons.size(),
802 "Number of drop reasons "
803 << currentDropReasons.size() <<
" does not match expected one "
805 for (std::size_t i = 0; i < currentDropReasons.size(); ++i)
808 expectedDropReasons[i],
809 "Drop reason " << i <<
": " << currentDropReasons[i]
810 <<
" does not match expected reason "
811 << expectedDropReasons[i] <<
" at "
821 int64_t streamNumber = 50;
823 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize",
829 wifiStaNodes.Create(3);
839 phy.DisablePreambleDetectionModel();
840 phy.SetFrameCaptureModel(
"ns3::SimpleFrameCaptureModel");
843 channel->AddPropagationLossModel(lossModel);
844 phy.SetChannel(channel);
847 phy.Set(
"ChannelSettings",
StringValue(
"{36, 20, BAND_5GHZ, 0}"));
851 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
857 wifi.SetObssPdAlgorithm(
"ns3::ConstantObssPdAlgorithm",
863 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
869 mac.SetType(
"ns3::ApWifiMac",
"Ssid",
SsidValue(ssid));
900 mobility.SetPositionAllocator(positionAlloc);
901 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
902 mobility.Install(wifiApNodes);
903 mobility.Install(wifiStaNodes);
905 lossModel->SetLoss(wifiStaNodes.Get(0)->GetObject<
MobilityModel>(),
908 static_cast<dB_u>(30.0));
909 lossModel->SetLoss(wifiStaNodes.Get(1)->GetObject<
MobilityModel>(),
912 static_cast<dB_u>(30.0));
913 lossModel->SetLoss(wifiStaNodes.Get(2)->GetObject<
MobilityModel>(),
916 static_cast<dB_u>(30.0));
918 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
920 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
922 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
995 TestCase::Duration::QUICK);
997 TestCase::Duration::QUICK);
unsigned int m_numSta2PacketsSent
number of sent packets from STA2
unsigned int m_numAp2PacketsReceived
number of received packets from AP2
unsigned int m_numSta1PacketsSent
number of sent packets from STA1
unsigned int m_payloadSize2
size in bytes of packet payload in BSS 2
void ClearDropReasons()
Clear the drop reasons.
std::vector< WifiPhyRxfailureReason > m_dropReasonsAp2
drop reasons for AP2
void RunOne()
Run one function.
void SetupSimulation()
Setup the simulation.
void CheckPhyDropReasons(Ptr< WifiNetDevice > device, std::vector< WifiPhyRxfailureReason > expectedDropReasons)
Check if the Phy drop reasons for a device are as expected.
unsigned int m_payloadSize3
size in bytes of packet payload in BSS 3
void NotifyPhyTxBegin(std::string context, Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
dBm_u m_txPower
configured transmit power
unsigned int m_payloadSize1
size in bytes of packet payload in BSS 1
void ResetResults()
Reset the results.
unsigned int m_numSta2PacketsReceived
number of received packets from STA2
unsigned int m_numAp2PacketsSent
number of sent packets from AP2
void CheckPhyState(Ptr< WifiNetDevice > device, WifiPhyState expectedState)
Check if the Phy State for a device is an expected value.
void CheckResults()
Check the results.
void NotifyPhyRxDrop(std::string context, Ptr< const Packet > p, WifiPhyRxfailureReason reason)
Notify Phy receive drops.
dBm_u m_obssRxPower
forced RX power for OBSS
uint8_t m_bssColor1
color for BSS 1
void SetExpectedTxPower(dBm_u txPower)
Set the expected transmit power.
dBm_u m_obssPdLevel
OBSS-PD level.
NetDeviceContainer m_staDevices
STA devices.
std::vector< WifiPhyRxfailureReason > m_dropReasonsSta1
drop reasons for STA1
void NotifyPhyRxEnd(std::string context, Ptr< const Packet > p)
Notify Phy receive ends.
void SendOnePacket(Ptr< WifiNetDevice > tx_dev, Ptr< WifiNetDevice > rx_dev, uint32_t payloadSize)
Send one packet function.
void DoRun() override
Implementation to actually run this TestCase.
TestInterBssConstantObssPdAlgo(WifiStandard standard)
Constructor.
std::vector< WifiPhyRxfailureReason > m_dropReasonsSta2
drop reasons for STA2
NetDeviceContainer m_apDevices
AP devices.
uint8_t m_bssColor3
color for BSS 3
unsigned int m_numAp1PacketsSent
number of sent packets from AP1
uint8_t m_bssColor2
color for BSS 2
std::vector< WifiPhyRxfailureReason > m_dropReasonsAp1
drop reasons for AP1
Ptr< ListPositionAllocator > AllocatePositions(meter_u d1, meter_u d2, meter_u d3, meter_u d4, meter_u d5)
Allocate the node positions.
unsigned int m_numSta1PacketsReceived
number of received packets from STA1
unsigned int m_numAp1PacketsReceived
number of received packets from AP1
~TestInterBssConstantObssPdAlgo() override
WifiStandard m_standard
the standard to use for the test
dBm_u m_expectedTxPower
expected transmit power
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class used to assign positions and mobility models to nodes.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in 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.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
AttributeValue implementation for Pointer.
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.
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 objects implements the PHY state machine of the Wifi device.
void Connect(std::string path, const CallbackBase &cb)
void Set(std::string path, const AttributeValue &value)
#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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
bool TestDoubleIsEqual(const double x1, const double x2, const double epsilon)
Compare two double precision floating point numbers and declare them equal if they are within some ep...
#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_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.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
static uint32_t ConvertContextToNodeId(std::string context)
static InterBssTestSuite interBssTestSuite
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyState
The state of the PHY layer.
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...
dBm_u WToDbm(Watt_u val)
Convert from Watts to dBm.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
uint32_t pktSize
packet size used for the simulation (in bytes)