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 
102  Ptr<ListPositionAllocator> AllocatePositions (double d1, double d2, double d3, double d4, double d5);
103 
104  void SetExpectedTxPower (double txPowerDbm);
105 
109  void SetupSimulation ();
110 
114  void CheckResults ();
115 
119  void ResetResults ();
120 
124  void RunOne ();
125 
129  void CheckPhyState (Ptr<WifiNetDevice> device, WifiPhyState expectedState);
130 
137  void NotifyPhyTxBegin (std::string context, Ptr<const Packet> p, double txPowerW);
138 
144  void NotifyPhyRxEnd (std::string context, Ptr<const Packet> p);
145 
146  unsigned int m_numSta1PacketsSent;
147  unsigned int m_numSta2PacketsSent;
148  unsigned int m_numAp1PacketsSent;
149  unsigned int m_numAp2PacketsSent;
150 
153  unsigned int m_numAp1PacketsReceived;
154  unsigned int m_numAp2PacketsReceived;
155 
156  unsigned int m_payloadSize1;
157  unsigned int m_payloadSize2;
158  unsigned int m_payloadSize3;
159 
162 
163  double m_txPowerDbm;
167 
168  uint8_t m_bssColor1;
169  uint8_t m_bssColor2;
170  uint8_t m_bssColor3;
171 };
172 
174  : TestCase ("InterBssConstantObssPd"),
175  m_numSta1PacketsSent (0),
176  m_numSta2PacketsSent (0),
177  m_numAp1PacketsSent (0),
178  m_numAp2PacketsSent (0),
179  m_numSta1PacketsReceived (0),
180  m_numSta2PacketsReceived (0),
181  m_numAp1PacketsReceived (0),
182  m_numAp2PacketsReceived (0),
183  m_payloadSize1 (1000),
184  m_payloadSize2 (1500),
185  m_payloadSize3 (2000),
186  m_txPowerDbm (15),
187  m_obssPdLevelDbm (-72),
188  m_obssRxPowerDbm (-82),
189  m_expectedTxPowerDbm (15),
190  m_bssColor1 (1),
191  m_bssColor2 (2),
192  m_bssColor3 (3)
193 {
194 }
195 
197 TestInterBssConstantObssPdAlgo::AllocatePositions (double d1, double d2, double d3, double d4, double d5)
198 {
199  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
200  positionAlloc->Add (Vector (0.0, 0.0, 0.0)); // AP1
201  positionAlloc->Add (Vector (d1 + d2, 0.0, 0.0)); // AP2
202  positionAlloc->Add (Vector (d1 + d2 + d3 + d4, 0.0, 0.0)); // AP3
203  positionAlloc->Add (Vector (d1, 0.0, 0.0)); // STA1
204  positionAlloc->Add (Vector (d1 + d2 + d3, 0.0, 0.0)); // STA2
205  positionAlloc->Add (Vector (d1 + d2 + d3 + d4 + d5, 0.0, 0.0)); // STA3
206  return positionAlloc;
207 }
208 
209 void
211 {
212  Ptr<WifiNetDevice> ap_device1 = DynamicCast<WifiNetDevice> (m_apDevices.Get (0));
213  Ptr<WifiNetDevice> ap_device2 = DynamicCast<WifiNetDevice> (m_apDevices.Get (1));
214  Ptr<WifiNetDevice> ap_device3 = DynamicCast<WifiNetDevice> (m_apDevices.Get (2));
215  Ptr<WifiNetDevice> sta_device1 = DynamicCast<WifiNetDevice> (m_staDevices.Get (0));
216  Ptr<WifiNetDevice> sta_device2 = DynamicCast<WifiNetDevice> (m_staDevices.Get (1));
217  Ptr<WifiNetDevice> sta_device3 = DynamicCast<WifiNetDevice> (m_staDevices.Get (2));
218 
219  bool expectPhyReset = (m_bssColor1 != 0) && (m_bssColor2 != 0) && (m_obssPdLevelDbm >= m_obssRxPowerDbm);
220 
221  // In order to have all ADDBA handshakes established, each AP and STA sends a packet.
222 
223  Simulator::Schedule (Seconds (0.25), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device1, sta_device1, m_payloadSize1);
224  Simulator::Schedule (Seconds (0.5), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device1, ap_device1, m_payloadSize1);
225  Simulator::Schedule (Seconds (0.75), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
226  Simulator::Schedule (Seconds (1), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device2, ap_device2, m_payloadSize2);
227  Simulator::Schedule (Seconds (1.25), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device3, sta_device3, m_payloadSize3);
228  Simulator::Schedule (Seconds (1.5), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device3, ap_device3, m_payloadSize3);
229 
230  // We test PHY state and verify whether a CCA reset did occur.
231 
232  // AP2 sends a packet 0.5s later.
233  Simulator::Schedule (Seconds (2.0), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
234  Simulator::Schedule (Seconds (2.0) + MicroSeconds (1), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device2, WifiPhyState::TX);
235  // All other PHYs should have stay idle until 4us (preamble detection time).
236  Simulator::Schedule (Seconds (2.0) + MicroSeconds (2), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, WifiPhyState::IDLE);
237  Simulator::Schedule (Seconds (2.0) + MicroSeconds (2), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::IDLE);
238  Simulator::Schedule (Seconds (2.0) + MicroSeconds (2), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, WifiPhyState::IDLE);
239  // All PHYs should be receiving the PHY header if preamble has been detected (always the case in this test).
240  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, WifiPhyState::RX);
241  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::RX);
242  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, WifiPhyState::RX);
243  // PHYs of AP1 and STA1 should be idle if they were reset by OBSS_PD SR, otherwise they should be receiving.
244  Simulator::Schedule (Seconds (2.0) + MicroSeconds (50), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, expectPhyReset ? WifiPhyState::IDLE : WifiPhyState::RX);
245  Simulator::Schedule (Seconds (2.0) + MicroSeconds (50), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, expectPhyReset ? WifiPhyState::IDLE : WifiPhyState::RX);
246  // STA2 should be receiving
247  Simulator::Schedule (Seconds (2.0) + MicroSeconds (50), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::RX);
248 
249  // We test whether two networks can transmit simultaneously, and whether transmit power restrictions are applied.
250 
251  // AP2 sends another packet 0.1s later.
252  Simulator::Schedule (Seconds (2.1), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
253  // STA1 sends a packet 100us later. Even though AP2 is still transmitting, STA1 can transmit simultaneously if it's PHY was reset by OBSS_PD SR.
254  Simulator::Schedule (Seconds (2.1) + MicroSeconds (100), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device1, ap_device1, m_payloadSize1);
255  if (expectPhyReset)
256  {
257  // In this case, we check the TX power is restricted (and set the expected value slightly before transmission should occur)
258  double expectedTxPower = std::min (m_txPowerDbm, 21 - (m_obssPdLevelDbm + 82));
259  Simulator::Schedule (Seconds (2.1) + MicroSeconds (99), &TestInterBssConstantObssPdAlgo::SetExpectedTxPower, this, expectedTxPower);
260  }
261  // Check simultaneous transmissions
262  Simulator::Schedule (Seconds (2.1) + MicroSeconds (105), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device1, expectPhyReset ? WifiPhyState::TX : WifiPhyState::RX);
263  Simulator::Schedule (Seconds (2.1) + MicroSeconds (105), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device1, WifiPhyState::RX);
264  Simulator::Schedule (Seconds (2.1) + MicroSeconds (105), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, sta_device2, WifiPhyState::RX);
265  Simulator::Schedule (Seconds (2.1) + MicroSeconds (105), &TestInterBssConstantObssPdAlgo::CheckPhyState, this, ap_device2, WifiPhyState::TX);
266 
267  // Verify transmit power restrictions are not applied if access to the channel is requested after ignored OBSS transmissions.
268 
269  Simulator::Schedule (Seconds (2.2), &TestInterBssConstantObssPdAlgo::SetExpectedTxPower, this, m_txPowerDbm);
270  // AP2 sends another packet 0.1s later. Power retriction should not be applied.
271  Simulator::Schedule (Seconds (2.2), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2);
272  // STA1 sends a packet 0.1s later. Power retriction should not be applied.
273  Simulator::Schedule (Seconds (2.3), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device1, ap_device1, m_payloadSize1);
274 
275  // Verify a scenario that involves 3 networks in order to verify corner cases for transmit power restrictions.
276  // First, there is a transmission on network 2 from STA to AP, followed by a response from AP to STA.
277  // During that time, the STA on network 1 has a packet to send and request access to the channel.
278  // If a CCA reset occured, it starts deferring while transmissions are ongoing from network 2.
279  // Before its backoff expires, a transmission on network 3 occurs, also eventually triggering another CCA reset (depending on the scenario that is being run).
280  // This test checks whether this sequence preserves transmit power restrictions if CCA resets occured, since STA 1 has been defering during ignored OBSS transmissions.
281 
282  Simulator::Schedule (Seconds (2.4), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, sta_device2, ap_device2, m_payloadSize2 / 10);
283  Simulator::Schedule (Seconds (2.4) + MicroSeconds (5), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device2, sta_device2, m_payloadSize2 / 10);
284  Simulator::Schedule (Seconds (2.4) + MicroSeconds (55), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device1, sta_device1, m_payloadSize1 / 10);
285  Simulator::Schedule (Seconds (2.4) + MicroSeconds (105), &TestInterBssConstantObssPdAlgo::SendOnePacket, this, ap_device3, sta_device3, m_payloadSize3 / 10);
286  if (expectPhyReset)
287  {
288  // In this case, we check the TX power is restricted (and set the expected value slightly before transmission should occur)
289  double expectedTxPower = std::min (m_txPowerDbm, 21 - (m_obssPdLevelDbm + 82));
290  Simulator::Schedule (Seconds (2.4) + MicroSeconds (300), &TestInterBssConstantObssPdAlgo::SetExpectedTxPower, this, expectedTxPower);
291  }
292 
293  Simulator::Stop (Seconds (2.5));
294 }
295 
296 void
298 {
308 }
309 
310 void
312 {
313  NS_TEST_ASSERT_MSG_EQ (m_numSta1PacketsSent, 3, "The number of packets sent by STA1 is not correct!");
314  NS_TEST_ASSERT_MSG_EQ (m_numSta2PacketsSent, 2, "The number of packets sent by STA2 is not correct!");
315  NS_TEST_ASSERT_MSG_EQ (m_numAp1PacketsSent, 2, "The number of packets sent by AP1 is not correct!");
316  NS_TEST_ASSERT_MSG_EQ (m_numAp2PacketsSent, 5, "The number of packets sent by AP2 is not correct!");
317  NS_TEST_ASSERT_MSG_EQ (m_numSta1PacketsReceived, 2, "The number of packets received by STA1 is not correct!");
318  NS_TEST_ASSERT_MSG_EQ (m_numSta2PacketsReceived, 5, "The number of packets received by STA2 is not correct!");
319  NS_TEST_ASSERT_MSG_EQ (m_numAp1PacketsReceived, 3, "The number of packets received by AP1 is not correct!");
320  NS_TEST_ASSERT_MSG_EQ (m_numAp2PacketsReceived, 2, "The number of packets received by AP2 is not correct!");
321 }
322 
323 void
325 {
326  uint32_t idx = ConvertContextToNodeId (context);
327  uint32_t pktSize = p->GetSize () - 38;
328  if ((idx == 0) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
329  {
331  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
332  }
333  else if ((idx == 1) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
334  {
336  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
337  }
338  else if ((idx == 3) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
339  {
341  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
342  }
343  else if ((idx == 4) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
344  {
346  NS_TEST_EXPECT_MSG_EQ (TestDoubleIsEqual (WToDbm (txPowerW), m_expectedTxPowerDbm, 1e-12), true, "Tx power is not correct!");
347  }
348 }
349 
350 void
352 {
353  uint32_t idx = ConvertContextToNodeId (context);
354  uint32_t pktSize = p->GetSize () - 38;
355  if ((idx == 0) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
356  {
358  }
359  else if ((idx == 1) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
360  {
362  }
363  else if ((idx == 3) && ((pktSize == m_payloadSize1) || (pktSize == (m_payloadSize1 / 10))))
364  {
366  }
367  else if ((idx == 4) && ((pktSize == m_payloadSize2) || (pktSize == (m_payloadSize2 / 10))))
368  {
370  }
371 }
372 
373 void
375 {
376  Ptr<Packet> p = Create<Packet> (payloadSize);
377  tx_dev->Send (p, rx_dev->GetAddress (), 1);
378 }
379 
380 void
382 {
383  m_expectedTxPowerDbm = txPowerDbm;
384 }
385 
386 void
388 {
389  WifiPhyState currentState;
390  PointerValue ptr;
391  Ptr<WifiPhy> phy = DynamicCast<WifiPhy> (device->GetPhy ());
392  phy->GetAttribute ("State", ptr);
393  Ptr <WifiPhyStateHelper> state = DynamicCast <WifiPhyStateHelper> (ptr.Get<WifiPhyStateHelper> ());
394  currentState = state->GetState ();
395  NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ());
396 }
397 
398 void
400 {
401  RngSeedManager::SetSeed (1);
402  RngSeedManager::SetRun (1);
403  int64_t streamNumber = 2;
404 
405  Config::Set ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize", UintegerValue (0));
406 
407  ResetResults ();
408 
410  wifiStaNodes.Create (3);
411 
412  NodeContainer wifiApNodes;
413  wifiApNodes.Create (3);
414 
415  Ptr<MatrixPropagationLossModel> lossModel = CreateObject<MatrixPropagationLossModel> ();
416  lossModel->SetDefaultLoss (m_txPowerDbm - m_obssRxPowerDbm); //Force received RSSI to be equal to m_obssRxPowerDbm
417 
418  SpectrumWifiPhyHelper phy = SpectrumWifiPhyHelper::Default ();
419  phy.DisablePreambleDetectionModel ();
420  Ptr<MultiModelSpectrumChannel> channel = CreateObject<MultiModelSpectrumChannel> ();
421  channel->SetPropagationDelayModel (CreateObject<ConstantSpeedPropagationDelayModel> ());
422  channel->AddPropagationLossModel (lossModel);
423  phy.SetChannel (channel);
424  phy.Set ("TxPowerStart", DoubleValue (m_txPowerDbm));
425  phy.Set ("TxPowerEnd", DoubleValue (m_txPowerDbm));
426 
428  wifi.SetStandard (WIFI_PHY_STANDARD_80211ax_5GHZ);
429  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
430  "DataMode", StringValue ("HeMcs5"),
431  "ControlMode", StringValue ("HeMcs0"));
432 
433  wifi.SetObssPdAlgorithm ("ns3::ConstantObssPdAlgorithm",
434  "ObssPdLevel", DoubleValue (m_obssPdLevelDbm));
435 
437  Ssid ssid = Ssid ("ns-3-ssid");
438  mac.SetType ("ns3::StaWifiMac",
439  "Ssid", SsidValue (ssid));
440  m_staDevices = wifi.Install (phy, mac, wifiStaNodes);
441 
442  // Assign fixed streams to random variables in use
443  wifi.AssignStreams (m_staDevices, streamNumber);
444 
445  mac.SetType ("ns3::ApWifiMac",
446  "Ssid", SsidValue (ssid));
447  m_apDevices = wifi.Install (phy, mac, wifiApNodes);
448 
449  // Assign fixed streams to random variables in use
450  wifi.AssignStreams (m_apDevices, streamNumber);
451 
452  for (uint32_t i = 0; i < m_apDevices.GetN (); i++)
453  {
454  Ptr<WifiNetDevice> device = DynamicCast<WifiNetDevice> (m_apDevices.Get (i));
455  Ptr<HeConfiguration> heConfiguration = device->GetHeConfiguration ();
456  if (i == 0)
457  {
458  heConfiguration->SetAttribute ("BssColor", UintegerValue (m_bssColor1));
459  }
460  else if (i == 1)
461  {
462  heConfiguration->SetAttribute ("BssColor", UintegerValue (m_bssColor2));
463  }
464  else
465  {
466  heConfiguration->SetAttribute ("BssColor", UintegerValue (m_bssColor3));
467  }
468  }
469 
471  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
472  mobility.SetPositionAllocator (positionAlloc);
473  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
474  mobility.Install (wifiApNodes);
475  mobility.Install (wifiStaNodes);
476 
477  lossModel->SetLoss (wifiStaNodes.Get (0)->GetObject<MobilityModel> (), wifiApNodes.Get (0)->GetObject<MobilityModel> (), m_txPowerDbm + 30); //Low attenuation for IBSS transmissions
478  lossModel->SetLoss (wifiStaNodes.Get (1)->GetObject<MobilityModel> (), wifiApNodes.Get (1)->GetObject<MobilityModel> (), m_txPowerDbm + 30); //Low attenuation for IBSS transmissions
479  lossModel->SetLoss (wifiStaNodes.Get (2)->GetObject<MobilityModel> (), wifiApNodes.Get (2)->GetObject<MobilityModel> (), m_txPowerDbm + 30); //Low attenuation for IBSS transmissions
480 
481  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxBegin", MakeCallback (&TestInterBssConstantObssPdAlgo::NotifyPhyTxBegin, this));
482  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxEnd", MakeCallback (&TestInterBssConstantObssPdAlgo::NotifyPhyRxEnd, this));
483 
484  SetupSimulation ();
485 
486  Simulator::Run ();
487  Simulator::Destroy ();
488 
489  CheckResults ();
490 }
491 
492 void
494 {
495  //Test case 1: CCA CS Threshold = m_obssRxPowerDbm < m_obssPdLevelDbm
496  m_obssPdLevelDbm = -72;
497  m_obssRxPowerDbm = -82;
498  m_bssColor1 = 1;
499  m_bssColor2 = 2;
500  m_bssColor3 = 3;
501  RunOne ();
502 
503  //Test case 2: CCA CS Threshold < m_obssPdLevelDbm < m_obssRxPowerDbm
504  m_obssPdLevelDbm = -72;
505  m_obssRxPowerDbm = -62;
506  m_bssColor1 = 1;
507  m_bssColor2 = 2;
508  m_bssColor3 = 3;
509  RunOne ();
510 
511  //Test case 3: CCA CS Threshold = < m_obssPdLevelDbm = m_obssRxPowerDbm
512  m_obssPdLevelDbm = -72;
513  m_obssRxPowerDbm = -72;
514  m_bssColor1 = 1;
515  m_bssColor2 = 2;
516  m_bssColor3 = 3;
517  RunOne ();
518 
519  //Test case 4: CCA CS Threshold = m_obssRxPowerDbm < m_obssPdLevelDbm with BSS color 2 and 3 set to 0
520  m_obssPdLevelDbm = -72;
521  m_obssRxPowerDbm = -82;
522  m_bssColor1 = 1;
523  m_bssColor2 = 0;
524  m_bssColor3 = 0;
525  RunOne ();
526 
527  //Test case 5: CCA CS Threshold = m_obssRxPowerDbm < m_obssPdLevelDbm with BSS color 1 set to 0
528  m_obssPdLevelDbm = -72;
529  m_obssRxPowerDbm = -82;
530  m_bssColor1 = 0;
531  m_bssColor2 = 2;
532  m_bssColor3 = 3;
533  RunOne ();
534 }
535 
544 {
545 public:
547 };
548 
550  : TestSuite ("wifi-inter-bss", UNIT)
551 {
552  AddTestCase (new TestInterBssConstantObssPdAlgo, TestCase::QUICK);
553 }
554 
555 // 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
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:805
A suite of tests to run.
Definition: test.h:1342
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:204
#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:285
encapsulates test code
Definition: test.h:1155
void SetupSimulation()
Setup the simulation.
helps to create WifiNetDevice objects
Definition: wifi-helper.h:299
unsigned int m_numSta2PacketsReceived
number of received packets from STA2
void SetExpectedTxPower(double txPowerDbm)
unsigned int m_numAp1PacketsSent
number of sent packets from AP1
Address GetAddress(void) const
channel
Definition: third.py:85
mobility
Definition: third.py:101
phy
Definition: third.py:86
Keep track of the current position and velocity of an object.
unsigned int m_numAp2PacketsReceived
number of received packets from AP2
HE PHY for the 5 GHz band (clause 26)
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:93
#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:168
holds a vector of ns3::NetDevice pointers
mac
Definition: third.py:92
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
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void CheckPhyState(Ptr< WifiNetDevice > device, WifiPhyState expectedState)
Check if the Phy State for a device is an expected value.
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:871
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:459
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.
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:89
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:1062
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
AttributeValue implementation for Ssid.
Definition: ssid.h:110
The PHY layer is receiving a packet.
void NotifyPhyRxEnd(std::string context, Ptr< const Packet > p)
Notify Phy receive endsn.
Ptr< T > Get(void) const
Definition: pointer.h:194
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
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:81
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
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
void CheckResults()
Check the results.
Make it easy to create and manage PHY objects for the spectrum model.