24 #include "ns3/uinteger.h" 25 #include "ns3/double.h" 26 #include "ns3/string.h" 27 #include "ns3/pointer.h" 28 #include "ns3/config.h" 30 #include "ns3/rng-seed-manager.h" 31 #include "ns3/mobility-helper.h" 32 #include "ns3/wifi-net-device.h" 33 #include "ns3/spectrum-wifi-helper.h" 34 #include "ns3/multi-model-spectrum-channel.h" 35 #include "ns3/constant-obss-pd-algorithm.h" 36 #include "ns3/he-configuration.h" 37 #include "ns3/wifi-utils.h" 46 std::string sub = context.substr (10);
47 uint32_t pos = sub.find (
"/Device");
48 uint32_t nodeId = atoi (sub.substr (0, pos).c_str ());
83 virtual void DoRun (
void);
109 void SetExpectedTxPower (
double txPowerDbm);
114 void SetupSimulation ();
119 void CheckResults ();
124 void ResetResults ();
144 void NotifyPhyTxBegin (std::string context,
Ptr<const Packet> p,
double txPowerW);
181 :
TestCase (
"InterBssConstantObssPd"),
182 m_numSta1PacketsSent (0),
183 m_numSta2PacketsSent (0),
184 m_numAp1PacketsSent (0),
185 m_numAp2PacketsSent (0),
186 m_numSta1PacketsReceived (0),
187 m_numSta2PacketsReceived (0),
188 m_numAp1PacketsReceived (0),
189 m_numAp2PacketsReceived (0),
190 m_payloadSize1 (1000),
191 m_payloadSize2 (1500),
192 m_payloadSize3 (2000),
194 m_obssPdLevelDbm (-72),
195 m_obssRxPowerDbm (-82),
196 m_expectedTxPowerDbm (15),
207 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
208 positionAlloc->
Add (Vector (d1 + d2, 0.0, 0.0));
209 positionAlloc->
Add (Vector (d1 + d2 + d3 + d4, 0.0, 0.0));
210 positionAlloc->
Add (Vector (d1, 0.0, 0.0));
211 positionAlloc->
Add (Vector (d1 + d2 + d3, 0.0, 0.0));
212 positionAlloc->
Add (Vector (d1 + d2 + d3 + d4 + d5, 0.0, 0.0));
213 return positionAlloc;
300 Simulator::Stop (
Seconds (2.5));
399 phy->GetAttribute (
"State", ptr);
408 RngSeedManager::SetSeed (1);
409 RngSeedManager::SetRun (1);
410 int64_t streamNumber = 2;
426 phy.DisablePreambleDetectionModel ();
428 channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
429 channel->AddPropagationLossModel (lossModel);
436 wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager",
440 wifi.SetObssPdAlgorithm (
"ns3::ConstantObssPdAlgorithm",
445 mac.SetType (
"ns3::StaWifiMac",
452 mac.SetType (
"ns3::ApWifiMac",
479 mobility.SetPositionAllocator (positionAlloc);
480 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
494 Simulator::Destroy ();
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
static InterBssTestSuite interBssTestSuite
unsigned int m_payloadSize1
size in bytes of packet payload in BSS 1
Ptr< HeConfiguration > GetHeConfiguration(void) const
void SetDefaultLoss(double defaultLoss)
Set the default propagation loss (in dB, positive) to be used, infinity if not set.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold variables of type string.
void Set(std::string path, const AttributeValue &value)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
NetDeviceContainer m_staDevices
STA devices.
void SetupSimulation()
Setup the simulation.
double m_obssPdLevelDbm
OBSS-PD level in dBm.
helps to create WifiNetDevice objects
unsigned int m_numSta2PacketsReceived
number of received packets from STA2
void SetExpectedTxPower(double txPowerDbm)
Set the expected transmit power in dBm.
unsigned int m_numAp1PacketsSent
number of sent packets from AP1
Address GetAddress(void) const
static uint32_t ConvertContextToNodeId(std::string context)
Keep track of the current position and velocity of an object.
NetDeviceContainer m_apDevices
AP devices.
unsigned int m_numAp2PacketsReceived
number of received packets from AP2
void ResetResults()
Reset the results.
Ptr< ListPositionAllocator > AllocatePositions(double d1, double d2, double d3, double d4, double d5)
Allocate the node positions.
unsigned int m_numSta1PacketsReceived
number of received packets from STA1
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Hold an unsigned integer type.
#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.
holds a vector of ns3::NetDevice pointers
virtual void DoRun(void)
Implementation to actually run this TestCase.
TestInterBssConstantObssPdAlgo()
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...
The PHY layer has sense the medium busy through the CCA mechanism.
void CheckPhyState(Ptr< WifiNetDevice > device, WifiPhyState expectedState)
Check if the Phy State for a device is an expected value.
double m_txPowerDbm
configured transmit power in dBm
void Connect(std::string path, const CallbackBase &cb)
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ptr< WifiPhy > GetPhy(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
WifiPhyState
The state of the PHY layer.
uint8_t m_bssColor1
color for BSS 1
double m_obssRxPowerDbm
forced RX power in dBm for OBSS
double WToDbm(double w)
Convert from Watts to dBm.
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
The IEEE 802.11 SSID Information Element.
unsigned int m_numSta2PacketsSent
number of sent packets from STA2
unsigned int m_numAp1PacketsReceived
number of received packets from AP1
Helper class used to assign positions and mobility models to nodes.
This objects implements the PHY state machine of the Wifi device.
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
The PHY layer is sending a packet.
unsigned int m_payloadSize3
size in bytes of packet payload in BSS 3
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
AttributeValue implementation for Ssid.
The PHY layer is receiving a packet.
void NotifyPhyRxEnd(std::string context, Ptr< const Packet > p)
Notify Phy receive endsn.
double m_expectedTxPowerDbm
expected transmit power in dBm
void Add(Vector v)
Add a position to the list of positions.
void SetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double loss, bool symmetric=true)
Set loss (in dB, positive) between pair of ns-3 objects (typically, nodes).
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
void NotifyPhyTxBegin(std::string context, Ptr< const Packet > p, double txPowerW)
Notify Phy transmit begin.
uint8_t m_bssColor3
color for BSS 3
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
unsigned int m_numAp2PacketsSent
number of sent packets from AP2
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
uint32_t pktSize
packet size used for the simulation (in bytes)
This class can be used to hold variables of floating point type such as 'double' or 'float'...
unsigned int m_numSta1PacketsSent
number of sent packets from STA1
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void RunOne()
Run one function.
void SendOnePacket(Ptr< WifiNetDevice > tx_dev, Ptr< WifiNetDevice > rx_dev, uint32_t payloadSize)
Send one packet function.
unsigned int m_payloadSize2
size in bytes of packet payload in BSS 2
uint8_t m_bssColor2
color for BSS 2
void CheckResults()
Check the results.
Make it easy to create and manage PHY objects for the spectrum model.