21 #include "ns3/config.h"
22 #include "ns3/constant-obss-pd-algorithm.h"
23 #include "ns3/double.h"
24 #include "ns3/he-configuration.h"
26 #include "ns3/mobility-helper.h"
27 #include "ns3/multi-model-spectrum-channel.h"
28 #include "ns3/pointer.h"
29 #include "ns3/rng-seed-manager.h"
30 #include "ns3/spectrum-wifi-helper.h"
32 #include "ns3/string.h"
34 #include "ns3/uinteger.h"
35 #include "ns3/wifi-net-device.h"
36 #include "ns3/wifi-utils.h"
45 std::string sub = context.substr(10);
46 uint32_t pos = sub.find(
"/Device");
47 uint32_t nodeId = std::stoi(sub.substr(0, pos));
88 void DoRun()
override;
118 void SetExpectedTxPower(
double txPowerDbm);
123 void SetupSimulation();
138 void ClearDropReasons();
158 std::vector<WifiPhyRxfailureReason> expectedDropReasons);
166 void NotifyPhyTxBegin(std::string context,
Ptr<const Packet> p,
double txPowerW);
218 :
TestCase(
"InterBssConstantObssPd"),
219 m_numSta1PacketsSent(0),
220 m_numSta2PacketsSent(0),
221 m_numAp1PacketsSent(0),
222 m_numAp2PacketsSent(0),
223 m_numSta1PacketsReceived(0),
224 m_numSta2PacketsReceived(0),
225 m_numAp1PacketsReceived(0),
226 m_numAp2PacketsReceived(0),
227 m_payloadSize1(1000),
228 m_payloadSize2(1500),
229 m_payloadSize3(2000),
231 m_obssPdLevelDbm(-72),
232 m_obssRxPowerDbm(-82),
233 m_expectedTxPowerDbm(15),
254 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
255 positionAlloc->Add(Vector(d1 + d2, 0.0, 0.0));
256 positionAlloc->Add(Vector(d1 + d2 + d3 + d4, 0.0, 0.0));
257 positionAlloc->Add(Vector(d1, 0.0, 0.0));
258 positionAlloc->Add(Vector(d1 + d2 + d3, 0.0, 0.0));
259 positionAlloc->Add(Vector(d1 + d2 + d3 + d4 + d5, 0.0, 0.0));
260 return positionAlloc;
275 std::vector<WifiPhyRxfailureReason> dropReasons;
289 Simulator::Schedule(
Seconds(0.25),
295 Simulator::Schedule(
Seconds(0.5),
301 Simulator::Schedule(
Seconds(0.75),
307 Simulator::Schedule(
Seconds(1),
313 Simulator::Schedule(
Seconds(1.25),
319 Simulator::Schedule(
Seconds(1.5),
330 Simulator::Schedule(
Seconds(2.0),
420 Simulator::Schedule(
Seconds(2.1),
474 stateDuringPayloadNeighboringBss);
484 Simulator::Schedule(
Seconds(2.2),
488 Simulator::Schedule(
Seconds(2.2),
542 stateDuringPayloadNeighboringBss);
552 Simulator::Schedule(
Seconds(2.3),
557 Simulator::Schedule(
Seconds(2.3),
564 Simulator::Schedule(
Seconds(2.4),
581 Simulator::Schedule(
Seconds(2.5),
648 "The number of packets sent by STA1 is not correct!");
651 "The number of packets sent by STA2 is not correct!");
654 "The number of packets sent by AP1 is not correct!");
657 "The number of packets sent by AP2 is not correct!");
660 "The number of packets received by STA1 is not correct!");
663 "The number of packets received by STA2 is not correct!");
666 "The number of packets received by AP1 is not correct!");
669 "The number of packets received by AP2 is not correct!");
684 "Tx power is not correct!");
691 "Tx power is not correct!");
698 "Tx power is not correct!");
705 "Tx power is not correct!");
760 uint32_t payloadSize)
778 phy->GetAttribute(
"State", ptr);
780 currentState = state->GetState();
783 "PHY State " << currentState <<
" does not match expected state "
790 std::vector<WifiPhyRxfailureReason> expectedDropReasons)
792 std::vector<WifiPhyRxfailureReason> currentDropReasons;
812 expectedDropReasons.size(),
813 "Number of drop reasons "
814 << currentDropReasons.size() <<
" does not match expected one "
816 for (std::size_t i = 0; i < currentDropReasons.size(); ++i)
819 expectedDropReasons[i],
820 "Drop reason " << i <<
": " << currentDropReasons[i]
821 <<
" does not match expected reason "
822 << expectedDropReasons[i] <<
" at "
830 RngSeedManager::SetSeed(1);
831 RngSeedManager::SetRun(3);
832 int64_t streamNumber = 50;
834 Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize",
846 lossModel->SetDefaultLoss(
850 phy.DisablePreambleDetectionModel();
851 phy.SetFrameCaptureModel(
"ns3::SimpleFrameCaptureModel");
853 channel->SetPropagationDelayModel(CreateObject<ConstantSpeedPropagationDelayModel>());
854 channel->AddPropagationLossModel(lossModel);
858 phy.Set(
"ChannelSettings",
StringValue(
"{36, 20, BAND_5GHZ, 0}"));
862 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
868 wifi.SetObssPdAlgorithm(
"ns3::ConstantObssPdAlgorithm",
874 mac.SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(
ssid));
880 mac.SetType(
"ns3::ApWifiMac",
"Ssid", SsidValue(
ssid));
911 mobility.SetPositionAllocator(positionAlloc);
912 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
926 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin",
928 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd",
930 Config::Connect(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
936 Simulator::Destroy();
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
double m_obssRxPowerDbm
forced RX power in dBm for OBSS
unsigned int m_payloadSize2
size in bytes of packet payload in BSS 2
Ptr< ListPositionAllocator > AllocatePositions(double d1, double d2, double d3, double d4, double d5)
Allocate the node positions.
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.
void SetExpectedTxPower(double txPowerDbm)
Set the expected transmit power in dBm.
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.
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.
uint8_t m_bssColor1
color for BSS 1
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
double m_txPowerDbm
configured transmit power in dBm
std::vector< WifiPhyRxfailureReason > m_dropReasonsAp1
drop reasons for AP1
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
double m_obssPdLevelDbm
OBSS-PD level in dBm.
double m_expectedTxPowerDbm
expected transmit power in dBm
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.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold objects of type Ptr<T>.
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.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Ptr< HeConfiguration > GetHeConfiguration() const
Ptr< WifiPhy > GetPhy() const
Address GetAddress() const override
Ptr< Node > GetNode() const override
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.
Time Now()
create an ns3::Time instance which contains the current simulation time.
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
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
Send one packet.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double WToDbm(double w)
Convert from Watts to dBm.
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...
uint32_t pktSize
packet size used for the simulation (in bytes)
WifiPhyState
The state of the PHY layer.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ RX
The PHY layer is receiving a packet.
@ TX
The PHY layer is sending a packet.
@ IDLE
The PHY layer is IDLE.