A Discrete-Event Network Simulator
API
inter-bss-test-suite.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2018 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: S├ębastien Deronne <sebastien.deronne@gmail.com>
19  * Scott Carpenter <scarpenter44@windstream.net>
20  */
21 
22 #include "ns3/log.h"
23 #include "ns3/test.h"
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"
29 #include "ns3/ssid.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"
38 
39 using namespace ns3;
40 
41 NS_LOG_COMPONENT_DEFINE ("InterBssTestSuite");
42 
43 uint32_t
44 ConvertContextToNodeId (std::string context)
45 {
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 ());
49  return nodeId;
50 }
51 
79 {
80 public:
82 
83  virtual void DoRun (void);
84 
85 private:
92  void SendOnePacket (Ptr<WifiNetDevice> tx_dev, Ptr<WifiNetDevice> rx_dev, uint32_t payloadSize);
93 
103  Ptr<ListPositionAllocator> AllocatePositions (double d1, double d2, double d3, double d4, double d5);
104 
109  void SetExpectedTxPower (double txPowerDbm);
110 
114  void SetupSimulation ();
115 
119  void CheckResults ();
120 
124  void ResetResults ();
125 
129  void RunOne ();
130 
136  void CheckPhyState (Ptr<WifiNetDevice> device, WifiPhyState expectedState);
137 
144  void NotifyPhyTxBegin (std::string context, Ptr<const Packet> p, double txPowerW);
145 
151  void NotifyPhyRxEnd (std::string context, Ptr<const Packet> p);
152 
153  unsigned int m_numSta1PacketsSent;
154  unsigned int m_numSta2PacketsSent;
155  unsigned int m_numAp1PacketsSent;
156  unsigned int m_numAp2PacketsSent;
157 
160  unsigned int m_numAp1PacketsReceived;
161  unsigned int m_numAp2PacketsReceived;
162 
163  unsigned int m_payloadSize1;
164  unsigned int m_payloadSize2;
165  unsigned int m_payloadSize3;
166 
169 
170  double m_txPowerDbm;
174 
175  uint8_t m_bssColor1;
176  uint8_t m_bssColor2;
177  uint8_t m_bssColor3;
178 };
179 
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),
193  m_txPowerDbm (15),
194  m_obssPdLevelDbm (-72),
195  m_obssRxPowerDbm (-82),
196  m_expectedTxPowerDbm (15),
197  m_bssColor1 (1),
198  m_bssColor2 (2),
199  m_bssColor3 (3)
200 {
201 }
202 
204 TestInterBssConstantObssPdAlgo::AllocatePositions (double d1, double d2, double d3, double d4, double d5)
205 {
206  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
207  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // AP1
208  positionAlloc->Add (Vector (d1 + d2, 0.0, 0.0)); // AP2
209  positionAlloc->Add (Vector (d1 + d2 + d3 + d4, 0.0, 0.0)); // AP3
210  positionAlloc->Add (Vector (d1, 0.0, 0.0)); // STA1
211  positionAlloc->Add (Vector (d1 + d2 + d3, 0.0, 0.0)); // STA2
212  positionAlloc->Add (Vector (d1 + d2 + d3 + d4 + d5, 0.0, 0.0)); // STA3
213  return positionAlloc;
214 }
215 
216 void
218 {
219  Ptr<WifiNetDevice> ap_device1 = DynamicCast<WifiNetDevice> (m_apDevices.Get (0));
220  Ptr<WifiNetDevice> ap_device2 = DynamicCast<WifiNetDevice> (m_apDevices.Get (1));
221  Ptr<WifiNetDevice> ap_device3 = DynamicCast<WifiNetDevice> (m_apDevices.Get (2));
222  Ptr<WifiNetDevice> sta_device1 = DynamicCast<WifiNetDevice> (m_staDevices.Get (0));
223  Ptr<WifiNetDevice> sta_device2 = DynamicCast<WifiNetDevice> (m_staDevices.Get (1));
224  Ptr<WifiNetDevice> sta_device3 = DynamicCast<WifiNetDevice> (m_staDevices.Get (2));
225 
226  bool expectPhyReset = (m_bssColor1 != 0) && (m_bssColor2 != 0) && (m_obssPdLevelDbm >= m_obssRxPowerDbm);
227 
228  // In order to have all ADDBA handshakes established, each AP and STA sends a packet.
229 
230  Simulator::Schedule (Seconds (0.25), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device1, sta_device1, m_payloadSize1);
231  Simulator::Schedule (Seconds (0.5), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device1, ap_device1, m_payloadSize1);
232  Simulator::Schedule (Seconds (0.75), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
233  Simulator::Schedule (Seconds (1), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device2, ap_device2, m_payloadSize2);
234  Simulator::Schedule (Seconds (1.25), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device3, sta_device3, m_payloadSize3);
235  Simulator::Schedule (Seconds (1.5), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device3, ap_device3, m_payloadSize3);
236 
237  // We test PHY state and verify whether a CCA reset did occur.
238 
239  // AP2 sends a packet 0.5s later.
240  Simulator::Schedule (Seconds (2.0), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
241  Simulator::Schedule (Seconds (2.0) + MicroSeconds (5), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device2, WifiPhyState::TX);
242  // All other PHYs should have stay idle until 4us (preamble detection time).
243  Simulator::Schedule (Seconds (2.0) + MicroSeconds (6), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, WifiPhyState::IDLE);
244  Simulator::Schedule (Seconds (2.0) + MicroSeconds (6), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::IDLE);
245  Simulator::Schedule (Seconds (2.0) + MicroSeconds (6), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, WifiPhyState::IDLE);
246  // All PHYs should be receiving the PHY header (i.e. PHY state is CCA_BUSY) if preamble has been detected (always the case in this test).
247  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, WifiPhyState::CCA_BUSY);
248  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::CCA_BUSY);
249  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, WifiPhyState::CCA_BUSY);
250  // PHYs of AP1 and STA1 should be idle if they were reset by OBSS_PD SR, otherwise they should be receiving.
251  Simulator::Schedule (Seconds (2.0) + MicroSeconds (50), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, expectPhyReset ? WifiPhyState::IDLE : WifiPhyState::RX);
252  Simulator::Schedule (Seconds (2.0) + MicroSeconds (50), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, expectPhyReset ? WifiPhyState::IDLE : WifiPhyState::RX);
253  // STA2 should be receiving
254  Simulator::Schedule (Seconds (2.0) + MicroSeconds (50), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::RX);
255 
256  // We test whether two networks can transmit simultaneously, and whether transmit power restrictions are applied.
257 
258  // AP2 sends another packet 0.1s later.
259  Simulator::Schedule (Seconds (2.1), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
260  // STA1 sends a packet 90us later. Even though AP2 is still transmitting, STA1 can transmit simultaneously if it's PHY was reset by OBSS_PD SR.
261  Simulator::Schedule (Seconds (2.1) + MicroSeconds (90), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device1, ap_device1, m_payloadSize1);
262  if (expectPhyReset)
263  {
264  // In this case, we check the TX power is restricted (and set the expected value slightly before transmission should occur)
265  double expectedTxPower = std::min (m_txPowerDbm, 21 - (m_obssPdLevelDbm + 82));
266  Simulator::Schedule (Seconds (2.1) + MicroSeconds (89), &TestInterBssConstantObssPdAlgo::SetExpectedTxPower, this, expectedTxPower);
267  }
268  // Check simultaneous transmissions
269  Simulator::Schedule (Seconds (2.1) + MicroSeconds (100), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device2, WifiPhyState::TX);
270  Simulator::Schedule (Seconds (2.1) + MicroSeconds (100), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, expectPhyReset ? WifiPhyState::TX : WifiPhyState::RX);
271  Simulator::Schedule (Seconds (2.1) + MicroSeconds (100), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::RX);
272  Simulator::Schedule (Seconds (2.1) + MicroSeconds (100), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, expectPhyReset ? WifiPhyState::CCA_BUSY : WifiPhyState::RX);
273 
274  // Verify transmit power restrictions are not applied if access to the channel is requested after ignored OBSS transmissions.
275 
276  Simulator::Schedule (Seconds (2.2), &TestInterBssConstantObssPdAlgo::SetExpectedTxPower, this, m_txPowerDbm);
277  // AP2 sends another packet 0.1s later. Power restriction should not be applied.
278  Simulator::Schedule (Seconds (2.2), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
279  // STA1 sends a packet 0.1s later. Power restriction should not be applied.
280  Simulator::Schedule (Seconds (2.3), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device1, ap_device1, m_payloadSize1);
281 
282  // Verify a scenario that involves 3 networks in order to verify corner cases for transmit power restrictions.
283  // First, there is a transmission on network 2 from STA to AP, followed by a response from AP to STA.
284  // During that time, the STA on network 1 has a packet to send and request access to the channel.
285  // If a CCA reset occurred, it starts deferring while transmissions are ongoing from network 2.
286  // Before its backoff expires, a transmission on network 3 occurs, also eventually triggering another CCA reset (depending on the scenario that is being run).
287  // This test checks whether this sequence preserves transmit power restrictions if CCA resets occurred, since STA 1 has been deferring during ignored OBSS transmissions.
288 
289  Simulator::Schedule (Seconds (2.4), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device2, ap_device2, m_payloadSize2 / 10);
290  Simulator::Schedule (Seconds (2.4) + MicroSeconds (15), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2 / 10);
291  Simulator::Schedule (Seconds (2.4) + MicroSeconds (270), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device1, sta_device1, m_payloadSize1 / 10);
292  Simulator::Schedule (Seconds (2.4) + MicroSeconds (300), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device3, sta_device3, m_payloadSize3 / 10);
293  if (expectPhyReset)
294  {
295  // In this case, we check the TX power is restricted (and set the expected value slightly before transmission should occur)
296  double expectedTxPower = std::min (m_txPowerDbm, 21 - (m_obssPdLevelDbm + 82));
297  Simulator::Schedule (Seconds (2.4) + MicroSeconds (400), &TestInterBssConstantObssPdAlgo::SetExpectedTxPower, this, expectedTxPower);
298  }
299 
300  Simulator::Stop (Seconds (2.5));
301 }
302 
303 void
305 {
315 }
316 
317 void
319 {
320  NS_TEST_ASSERT_MSG_EQ (m_numSta1PacketsSent, 3, "The number of packets sent by STA1 is not correct!");
321  NS_TEST_ASSERT_MSG_EQ (m_numSta2PacketsSent, 2, "The number of packets sent by STA2 is not correct!");
322  NS_TEST_ASSERT_MSG_EQ (m_numAp1PacketsSent, 2, "The number of packets sent by AP1 is not correct!");
323  NS_TEST_ASSERT_MSG_EQ (m_numAp2PacketsSent, 5, "The number of packets sent by AP2 is not correct!");
324  NS_TEST_ASSERT_MSG_EQ (m_numSta1PacketsReceived, 2, "The number of packets received by STA1 is not correct!");
325  NS_TEST_ASSERT_MSG_EQ (m_numSta2PacketsReceived, 5, "The number of packets received by STA2 is not correct!");
326  NS_TEST_ASSERT_MSG_EQ (m_numAp1PacketsReceived, 3, "The number of packets received by AP1 is not correct!");
327  NS_TEST_ASSERT_MSG_EQ (m_numAp2PacketsReceived, 2, "The number of packets received by AP2 is not correct!");
328 }
329 
330 void
332 {
333  uint32_t idx = ConvertContextToNodeId (context);
334  uint32_t pktSize = p->GetSize () - 38;
335  if ((idx == 0) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
336  {
338  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
339  }
340  else if ((idx == 1) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
341  {
343  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
344  }
345  else if ((idx == 3) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
346  {
348  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
349  }
350  else if ((idx == 4) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
351  {
353  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
354  }
355 }
356 
357 void
359 {
360  uint32_t idx = ConvertContextToNodeId (context);
361  uint32_t pktSize = p->GetSize () - 38;
362  if ((idx == 0) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
363  {
365  }
366  else if ((idx == 1) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
367  {
369  }
370  else if ((idx == 3) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
371  {
373  }
374  else if ((idx == 4) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
375  {
377  }
378 }
379 
380 void
382 {
383  Ptr<Packet> p = Create<Packet> (payloadSize);
384  tx_dev->Send (p, rx_dev->GetAddress (), 1);
385 }
386 
387 void
389 {
390  m_expectedTxPowerDbm = txPowerDbm;
391 }
392 
393 void
395 {
396  WifiPhyState currentState;
397  PointerValue ptr;
398  Ptr<WifiPhy> phy = DynamicCast<WifiPhy> (device->GetPhy ());
399  phy->GetAttribute ("State", ptr);
400  Ptr <WifiPhyStateHelper> state = DynamicCast <WifiPhyStateHelper> (ptr.Get<WifiPhyStateHelper> ());
401  currentState = state->GetState ();
402  NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ());
403 }
404 
405 void
407 {
408  RngSeedManager::SetSeed (1);
409  RngSeedManager::SetRun (1);
410  int64_t streamNumber = 2;
411 
412  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize", UintegerValue (0));
413 
414  ResetResults ();
415 
417  wifiStaNodes.Create (3);
418 
419  NodeContainer wifiApNodes;
420  wifiApNodes.Create (3);
421 
422  Ptr<MatrixPropagationLossModel> lossModel = CreateObject<MatrixPropagationLossModel> ();
423  lossModel->SetDefaultLoss (m_txPowerDbm - m_obssRxPowerDbm); //Force received RSSI to be equal to m_obssRxPowerDbm
424 
425  SpectrumWifiPhyHelper phy = SpectrumWifiPhyHelper::Default ();
426  phy.DisablePreambleDetectionModel ();
427  Ptr<MultiModelSpectrumChannel> channel = CreateObject<MultiModelSpectrumChannel> ();
428  channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
429  channel->AddPropagationLossModel (lossModel);
430  phy.SetChannel (channel);
431  phy.Set ("TxPowerStart", DoubleValue (m_txPowerDbm));
432  phy.Set ("TxPowerEnd", DoubleValue (m_txPowerDbm));
433 
435  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
436  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
437  "DataMode", StringValue ("HeMcs5"),
438  "ControlMode", StringValue ("HeMcs0"));
439 
440  wifi.SetObssPdAlgorithm ("ns3::ConstantObssPdAlgorithm",
441  "ObssPdLevel", DoubleValue (m_obssPdLevelDbm));
442 
444  Ssid ssid = Ssid ("ns-3-ssid");
445  mac.SetType ("ns3::StaWifiMac",
446  "Ssid", SsidValue (ssid));
447  m_staDevices = wifi.Install (phy, mac, wifiStaNodes);
448 
449  // Assign fixed streams to random variables in use
450  wifi.AssignStreams (m_staDevices, streamNumber);
451 
452  mac.SetType ("ns3::ApWifiMac",
453  "Ssid", SsidValue (ssid));
454  m_apDevices = wifi.Install (phy, mac, wifiApNodes);
455 
456  // Assign fixed streams to random variables in use
457  wifi.AssignStreams (m_apDevices, streamNumber);
458 
459  for (uint32_t i = 0; i < m_apDevices.GetN (); i++)
460  {
461  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_apDevices.Get (i));
462  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
463  if (i == 0)
464  {
465  heConfiguration->SetAttribute ("BssColor", UintegerValue (m_bssColor1));
466  }
467  else if (i == 1)
468  {
469  heConfiguration->SetAttribute ("BssColor", UintegerValue (m_bssColor2));
470  }
471  else
472  {
473  heConfiguration->SetAttribute ("BssColor", UintegerValue (m_bssColor3));
474  }
475  }
476 
478  Ptr<ListPositionAllocator> positionAlloc = AllocatePositions (10, 50, 10, 50, 10); //distances do not really matter since we set RSSI per TX-RX pair to have full control
479  mobility.SetPositionAllocator (positionAlloc);
480  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
481  mobility.Install (wifiApNodes);
482  mobility.Install (wifiStaNodes);
483 
484  lossModel->SetLoss (wifiStaNodes.Get (0)->GetObject<MobilityModel> (), wifiApNodes.Get (0)->GetObject<MobilityModel> (), m_txPowerDbm + 30); //Low attenuation for IBSS transmissions
485  lossModel->SetLoss (wifiStaNodes.Get (1)->GetObject<MobilityModel> (), wifiApNodes.Get (1)->GetObject<MobilityModel> (), m_txPowerDbm + 30); //Low attenuation for IBSS transmissions
486  lossModel->SetLoss (wifiStaNodes.Get (2)->GetObject<MobilityModel> (), wifiApNodes.Get (2)->GetObject<MobilityModel> (), m_txPowerDbm + 30); //Low attenuation for IBSS transmissions
487 
488  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin", MakeCallback (&TestInterBssConstantObssPdAlgo::NotifyPhyTxBegin, this));
489  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd", MakeCallback (&TestInterBssConstantObssPdAlgo::NotifyPhyRxEnd, this));
490 
491  SetupSimulation ();
492 
493  Simulator::Run ();
494  Simulator::Destroy ();
495 
496  CheckResults ();
497 }
498 
499 void
501 {
502  //Test case 1: CCA CS Threshold = m_obssRxPowerDbm < m_obssPdLevelDbm
503  m_obssPdLevelDbm = -72;
504  m_obssRxPowerDbm = -82;
505  m_bssColor1 = 1;
506  m_bssColor2 = 2;
507  m_bssColor3 = 3;
508  RunOne ();
509 
510  //Test case 2: CCA CS Threshold < m_obssPdLevelDbm < m_obssRxPowerDbm
511  m_obssPdLevelDbm = -72;
512  m_obssRxPowerDbm = -62;
513  m_bssColor1 = 1;
514  m_bssColor2 = 2;
515  m_bssColor3 = 3;
516  RunOne ();
517 
518  //Test case 3: CCA CS Threshold = < m_obssPdLevelDbm = m_obssRxPowerDbm
519  m_obssPdLevelDbm = -72;
520  m_obssRxPowerDbm = -72;
521  m_bssColor1 = 1;
522  m_bssColor2 = 2;
523  m_bssColor3 = 3;
524  RunOne ();
525 
526  //Test case 4: CCA CS Threshold = m_obssRxPowerDbm < m_obssPdLevelDbm with BSS color 2 and 3 set to 0
527  m_obssPdLevelDbm = -72;
528  m_obssRxPowerDbm = -82;
529  m_bssColor1 = 1;
530  m_bssColor2 = 0;
531  m_bssColor3 = 0;
532  RunOne ();
533 
534  //Test case 5: CCA CS Threshold = m_obssRxPowerDbm < m_obssPdLevelDbm with BSS color 1 set to 0
535  m_obssPdLevelDbm = -72;
536  m_obssRxPowerDbm = -82;
537  m_bssColor1 = 0;
538  m_bssColor2 = 2;
539  m_bssColor3 = 3;
540  RunOne ();
541 }
542 
551 {
552 public:
554 };
555 
557  : TestSuite ("wifi-inter-bss", UNIT)
558 {
559  AddTestCase (new TestInterBssConstantObssPdAlgo, TestCase::QUICK);
560 }
561 
562 // Do not forget to allocate an instance of this TestSuite
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
Ptr< T > Get(void) const
Definition: pointer.h:201
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).
Definition: packet.h:852
Hold variables of type string.
Definition: string.h:41
#define min(a, b)
Definition: 80211b.c:42
void Set(std::string path, const AttributeValue &value)
Definition: config.cc:839
A suite of tests to run.
Definition: test.h:1343
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Definition: test.h:283
NetDeviceContainer m_staDevices
STA devices.
encapsulates test code
Definition: test.h:1153
void SetupSimulation()
Setup the simulation.
double m_obssPdLevelDbm
OBSS-PD level in dBm.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:318
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
channel
Definition: third.py:92
mobility
Definition: third.py:108
phy
Definition: third.py:93
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.
Definition: test.cc:299
Hold an unsigned integer type.
Definition: uinteger.h:44
ssid
Definition: third.py:100
#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.
Definition: test.h:166
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:99
virtual void DoRun(void)
Implementation to actually run this TestCase.
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...
Definition: test.cc:44
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)
Definition: config.cc:918
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
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>.
Definition: pointer.h:36
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
The PHY layer is IDLE.
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
Inter BSS Test Suite.
double WToDbm(double w)
Convert from Watts to dBm.
Definition: wifi-utils.cc:47
create MAC layers for a ns3::WifiNetDevice.
void SendOnePacket(Ptr< LrWpanPhy > sender, Ptr< LrWpanPhy > receiver)
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:35
unsigned int m_numSta2PacketsSent
number of sent packets from STA2
unsigned int m_numAp1PacketsReceived
number of received packets from AP1
wifi
Definition: third.py:96
Helper class used to assign positions and mobility models to nodes.
This objects implements the PHY state machine of the Wifi device.
uint32_t ConvertContextToNodeId(std::string context)
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.
Definition: nstime.h:1278
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
AttributeValue implementation for Ssid.
Definition: ssid.h:105
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.
Definition: nstime.h:1294
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
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.
wifiStaNodes
Definition: third.py:88
uint32_t pktSize
packet size used for the simulation (in bytes)
Definition: wifi-bianchi.cc:83
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
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...
Definition: callback.h:1642
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.