A Discrete-Event Network Simulator
API
wifi-phy-reception-test.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  * Author: S├ębastien Deronne <sebastien.deronne@gmail.com>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/mobility-helper.h"
23 #include "ns3/multi-model-spectrum-channel.h"
24 #include "ns3/config.h"
25 #include "ns3/ap-wifi-mac.h"
26 #include "ns3/packet-socket-address.h"
27 #include "ns3/packet-socket-client.h"
28 #include "ns3/packet-socket-helper.h"
29 #include "ns3/packet-socket-server.h"
30 #include "ns3/test.h"
31 #include "ns3/double.h"
32 #include "ns3/pointer.h"
33 #include "ns3/rng-seed-manager.h"
34 #include "ns3/spectrum-wifi-helper.h"
35 #include "ns3/wifi-net-device.h"
36 #include "ns3/wifi-spectrum-value-helper.h"
37 #include "ns3/spectrum-wifi-phy.h"
38 #include "ns3/nist-error-rate-model.h"
39 #include "ns3/wifi-mac-header.h"
40 #include "ns3/ampdu-tag.h"
41 #include "ns3/wifi-spectrum-signal-parameters.h"
42 #include "ns3/wifi-utils.h"
43 #include "ns3/threshold-preamble-detection-model.h"
44 #include "ns3/simple-frame-capture-model.h"
45 #include "ns3/wifi-mac-queue-item.h"
46 #include "ns3/mpdu-aggregator.h"
47 #include "ns3/wifi-psdu.h"
48 #include "ns3/he-ppdu.h"
49 #include "ns3/he-phy.h"
50 
51 using namespace ns3;
52 
53 NS_LOG_COMPONENT_DEFINE ("WifiPhyReceptionTest");
54 
55 static const uint8_t CHANNEL_NUMBER = 36;
56 static const uint32_t FREQUENCY = 5180; // MHz
57 static const uint16_t CHANNEL_WIDTH = 20; // MHz
58 static const uint16_t GUARD_WIDTH = CHANNEL_WIDTH; // MHz (expanded to channel width to model spectrum mask)
59 
67 {
68 public:
71 
72 protected:
73  void DoSetup (void) override;
74  void DoTeardown (void) override;
76 
80  void SendPacket (double rxPowerDbm);
88  void RxSuccess (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
89  WifiTxVector txVector, std::vector<bool> statusPerMpdu);
94  void RxFailure (Ptr<WifiPsdu> psdu);
95  uint32_t m_countRxSuccess;
96  uint32_t m_countRxFailure;
97 
98 private:
99  void DoRun (void) override;
100 
105  void CheckPhyState (WifiPhyState expectedState);
110  void DoCheckPhyState (WifiPhyState expectedState);
116  void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
117 
118  uint64_t m_uid;
119 };
120 
122  : TestCase ("Threshold preamble detection model test when no frame capture model is applied"),
123  m_countRxSuccess (0),
124  m_countRxFailure (0),
125  m_uid (0)
126 {
127 }
128 
129 void
131 {
132  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs7 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, 20, false);
133 
134  Ptr<Packet> pkt = Create<Packet> (1000);
135  WifiMacHeader hdr;
136 
138  hdr.SetQosTid (0);
139 
140  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
141  Time txDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand ());
142 
143  Ptr<WifiPpdu> ppdu = Create<HePpdu> (psdu, txVector, txDuration, WIFI_PHY_BAND_5GHZ, m_uid++);
144 
145  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, DbmToW (rxPowerDbm), GUARD_WIDTH);
146 
147  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
148  txParams->psd = txPowerSpectrum;
149  txParams->txPhy = 0;
150  txParams->duration = txDuration;
151  txParams->ppdu = ppdu;
152 
153  m_phy->StartRx (txParams);
154 }
155 
156 void
158 {
159  //This is needed to make sure PHY state will be checked as the last event if a state change occured at the exact same time as the check
160  Simulator::ScheduleNow (&TestThresholdPreambleDetectionWithoutFrameCapture::DoCheckPhyState, this, expectedState);
161 }
162 
163 void
165 {
166  WifiPhyState currentState;
167  PointerValue ptr;
168  m_phy->GetAttribute ("State", ptr);
169  Ptr <WifiPhyStateHelper> state = DynamicCast <WifiPhyStateHelper> (ptr.Get<WifiPhyStateHelper> ());
170  currentState = state->GetState ();
171  NS_LOG_FUNCTION (this << currentState);
172  NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ());
173 }
174 
175 void
176 TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
177 {
178  NS_TEST_ASSERT_MSG_EQ (m_countRxSuccess, expectedSuccessCount, "Didn't receive right number of successful packets");
179  NS_TEST_ASSERT_MSG_EQ (m_countRxFailure, expectedFailureCount, "Didn't receive right number of unsuccessful packets");
180 }
181 
182 void
184  WifiTxVector txVector, std::vector<bool> statusPerMpdu)
185 {
186  NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector);
188 }
189 
190 void
192 {
193  NS_LOG_FUNCTION (this << *psdu);
195 }
196 
198 {
199  m_phy = 0;
200 }
201 
202 void
204 {
205  m_phy = CreateObject<SpectrumWifiPhy> ();
207  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
208  m_phy->SetErrorRateModel (error);
213 
214  Ptr<ThresholdPreambleDetectionModel> preambleDetectionModel = CreateObject<ThresholdPreambleDetectionModel> ();
215  preambleDetectionModel->SetAttribute ("Threshold", DoubleValue (4));
216  preambleDetectionModel->SetAttribute ("MinimumRssi", DoubleValue (-82));
217  m_phy->SetPreambleDetectionModel (preambleDetectionModel);
218 }
219 
220 void
222 {
223  m_phy->Dispose ();
224  m_phy = 0;
225 }
226 
227 void
229 {
230  RngSeedManager::SetSeed (1);
231  RngSeedManager::SetRun (1);
232  int64_t streamNumber = 0;
233  m_phy->AssignStreams (streamNumber);
234 
235  //RX power > CCA-ED > CCA-PD
236  double rxPowerDbm = -50;
237 
238  // CASE 1: send one packet and check PHY state:
239  // All reception stages should succeed and PHY state should be RX for the duration of the packet minus the time to detect the preamble,
240  // otherwise it should be IDLE.
241 
242  Simulator::Schedule (Seconds (1.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
243  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
246  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
249  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us
252  // Packet should have been successfully received
253  Simulator::Schedule (Seconds (1.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 1, 0);
254 
255  // CASE 2: send two packets with same power within the 4us window and check PHY state:
256  // PHY preamble detection should fail because SNR is too low (around 0 dB, which is lower than the threshold of 4 dB),
257  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
258  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
259 
260  Simulator::Schedule (Seconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
261  Simulator::Schedule (Seconds (2.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
262  // At 4us, no preamble is successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
265  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
268  // No more packet should have been successfully received, and since preamble detection did not pass, the packet should not have been counted as a failure
269  Simulator::Schedule (Seconds (2.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 1, 0);
270 
271  // CASE 3: send two packets with second one 3 dB weaker within the 4us window and check PHY state:
272  // PHY preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
273  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
274  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
275 
276  Simulator::Schedule (Seconds (3.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
277  Simulator::Schedule (Seconds (3.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm - 3);
278  // At 4us, no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
281  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
284  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
285  Simulator::Schedule (Seconds (3.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 1, 0);
286 
287  // CASE 4: send two packets with second one 6 dB weaker within the 4us window and check PHY state:
288  // PHY preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
289  // but payload reception should fail (SNR too low to decode the modulation).
290 
291  Simulator::Schedule (Seconds (4.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
292  Simulator::Schedule (Seconds (4.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm - 6);
293  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
296  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
299  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
300  // However, since there is a second packet transmitted with a power above CCA-ED (-62 dBm), PHY should first be seen as CCA_BUSY for 2us.
305  // In this case, the first packet should be marked as a failure
306  Simulator::Schedule (Seconds (4.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 1, 1);
307 
308  // CASE 5: send two packets with second one 3 dB higher within the 4us window and check PHY state:
309  // PHY preamble detection should fail because SNR is too low (around -3 dB, which is lower than the threshold of 4 dB),
310  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
311  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
312 
313  Simulator::Schedule (Seconds (5.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
314  Simulator::Schedule (Seconds (5.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm + 3);
315  // At 6us (hence 4us after the last signal is received), no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
318  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
321  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
322  Simulator::Schedule (Seconds (5.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 1, 1);
323 
324  // CCA-PD < RX power < CCA-ED
325  rxPowerDbm = -70;
326 
327  // CASE 6: send one packet and check PHY state:
328  // All reception stages should succeed and PHY state should be RX for the duration of the packet minus the time to detect the preamble,
329  // otherwise it should be IDLE.
330 
331  Simulator::Schedule (Seconds (6.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
332  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
335  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
338  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us
341  // Packet should have been successfully received
342  Simulator::Schedule (Seconds (6.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 2, 1);
343 
344  // CASE 7: send two packets with same power within the 4us window and check PHY state:
345  // PHY preamble detection should fail because SNR is too low (around 0 dB, which is lower than the threshold of 4 dB),
346  // and PHY state should stay IDLE since the total energy is below CCA-ED (-62 dBm).
347 
348  Simulator::Schedule (Seconds (7.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
349  Simulator::Schedule (Seconds (7.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
350  // At 4us, STA PHY STATE should stay IDLE
352  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
353  Simulator::Schedule (Seconds (7.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 2, 1);
354 
355  // CASE 8: send two packets with second one 3 dB weaker within the 4us window and check PHY state: PHY preamble detection should fail
356  // PHY preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
357  // and PHY state should stay IDLE since the total energy is below CCA-ED (-62 dBm).
358 
359  Simulator::Schedule (Seconds (8.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
360  Simulator::Schedule (Seconds (8.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm - 3);
361  // At 4us, STA PHY STATE should stay IDLE
363  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
364  Simulator::Schedule (Seconds (8.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 2, 1);
365 
366  // CASE 9: send two packets with second one 6 dB weaker within the 4us window and check PHY state:
367  // PHY preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
368  // but payload reception should fail (SNR too low to decode the modulation).
369 
370  Simulator::Schedule (Seconds (9.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
371  Simulator::Schedule (Seconds (9.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm - 6);
372  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
375  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
378  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
381  // In this case, the first packet should be marked as a failure
382  Simulator::Schedule (Seconds (9.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 2, 2);
383 
384  // CASE 10: send two packets with second one 3 dB higher within the 4us window and check PHY state:
385  // PHY preamble detection should fail because SNR is too low (around -3 dB, which is lower than the threshold of 4 dB),
386  // and PHY state should stay IDLE since the total energy is below CCA-ED (-62 dBm).
387 
388  Simulator::Schedule (Seconds (10.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
389  Simulator::Schedule (Seconds (10.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm + 3);
390  // At 4us, STA PHY STATE should stay IDLE
392  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
393  Simulator::Schedule (Seconds (10.1), &TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount, this, 2, 2);
394 
395  // CASE 11: send one packet with a power slightly above the minimum RSSI needed for the preamble detection (-82 dBm) and check PHY state:
396  // preamble detection should succeed and PHY state should move to RX.
397 
398  rxPowerDbm = -81;
399 
400  Simulator::Schedule (Seconds (11.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
401  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
404  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
407  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
410 
411  // RX power < CCA-PD < CCA-ED
412  rxPowerDbm = -83;
413 
414  //CASE 12: send one packet with a power slightly below the minimum RSSI needed for the preamble detection (-82 dBm) and check PHY state:
415  //preamble detection should fail and PHY should be kept in IDLE state.
416 
417  Simulator::Schedule (Seconds (12.0), &TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket, this, rxPowerDbm);
418  // At 4us, STA PHY state should be IDLE
420 
421  Simulator::Run ();
422  Simulator::Destroy ();
423 }
424 
432 {
433 public:
436 
437 protected:
438  void DoSetup (void) override;
439  void DoTeardown (void) override;
441 
445  void SendPacket (double rxPowerDbm);
453  void RxSuccess (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
454  WifiTxVector txVector, std::vector<bool> statusPerMpdu);
459  void RxFailure (Ptr<WifiPsdu> psdu);
460  uint32_t m_countRxSuccess;
461  uint32_t m_countRxFailure;
462 
463 private:
464  void DoRun (void) override;
465 
470  void CheckPhyState (WifiPhyState expectedState);
475  void DoCheckPhyState (WifiPhyState expectedState);
481  void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
482 
483  uint64_t m_uid;
484 };
485 
487 : TestCase ("Threshold preamble detection model test when simple frame capture model is applied"),
488  m_countRxSuccess (0),
489  m_countRxFailure (0),
490  m_uid (0)
491 {
492 }
493 
494 void
496 {
497  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs7 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, 20, false);
498 
499  Ptr<Packet> pkt = Create<Packet> (1000);
500  WifiMacHeader hdr;
501 
503  hdr.SetQosTid (0);
504 
505  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
506  Time txDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand ());
507 
508  Ptr<WifiPpdu> ppdu = Create<HePpdu> (psdu, txVector, txDuration, WIFI_PHY_BAND_5GHZ, m_uid++);
509 
510  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, DbmToW (rxPowerDbm), GUARD_WIDTH);
511 
512  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
513  txParams->psd = txPowerSpectrum;
514  txParams->txPhy = 0;
515  txParams->duration = txDuration;
516  txParams->ppdu = ppdu;
517 
518  m_phy->StartRx (txParams);
519 }
520 
521 void
523 {
524  //This is needed to make sure PHY state will be checked as the last event if a state change occured at the exact same time as the check
525  Simulator::ScheduleNow (&TestThresholdPreambleDetectionWithFrameCapture::DoCheckPhyState, this, expectedState);
526 }
527 
528 void
530 {
531  WifiPhyState currentState;
532  PointerValue ptr;
533  m_phy->GetAttribute ("State", ptr);
534  Ptr <WifiPhyStateHelper> state = DynamicCast <WifiPhyStateHelper> (ptr.Get<WifiPhyStateHelper> ());
535  currentState = state->GetState ();
536  NS_LOG_FUNCTION (this << currentState);
537  NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ());
538 }
539 
540 void
541 TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
542 {
543  NS_TEST_ASSERT_MSG_EQ (m_countRxSuccess, expectedSuccessCount, "Didn't receive right number of successful packets");
544  NS_TEST_ASSERT_MSG_EQ (m_countRxFailure, expectedFailureCount, "Didn't receive right number of unsuccessful packets");
545 }
546 
547 void
549  WifiTxVector txVector, std::vector<bool> statusPerMpdu)
550 {
551  NS_LOG_FUNCTION (this << *psdu << txVector);
553 }
554 
555 void
557 {
558  NS_LOG_FUNCTION (this << *psdu);
560 }
561 
563 {
564  m_phy = 0;
565 }
566 
567 void
569 {
570  m_phy = CreateObject<SpectrumWifiPhy> ();
572  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
573  m_phy->SetErrorRateModel (error);
578 
579  Ptr<ThresholdPreambleDetectionModel> preambleDetectionModel = CreateObject<ThresholdPreambleDetectionModel> ();
580  preambleDetectionModel->SetAttribute ("Threshold", DoubleValue (4));
581  preambleDetectionModel->SetAttribute ("MinimumRssi", DoubleValue (-82));
582  m_phy->SetPreambleDetectionModel (preambleDetectionModel);
583 
584  Ptr<SimpleFrameCaptureModel> frameCaptureModel = CreateObject<SimpleFrameCaptureModel> ();
585  frameCaptureModel->SetAttribute ("Margin", DoubleValue (5));
586  frameCaptureModel->SetAttribute ("CaptureWindow", TimeValue (MicroSeconds (16)));
587  m_phy->SetFrameCaptureModel (frameCaptureModel);
588 }
589 
590 void
592 {
593  m_phy->Dispose ();
594  m_phy = 0;
595 }
596 
597 void
599 {
600  RngSeedManager::SetSeed (1);
601  RngSeedManager::SetRun (1);
602  int64_t streamNumber = 1;
603  m_phy->AssignStreams (streamNumber);
604 
605  //RX power > CCA-ED > CCA-PD
606  double rxPowerDbm = -50;
607 
608  // CASE 1: send one packet and check PHY state:
609  // All reception stages should succeed and PHY state should be RX for the duration of the packet minus the time to detect the preamble,
610  // otherwise it should be IDLE.
611 
612  Simulator::Schedule (Seconds (1.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
613  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
616  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
619  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us
622  // Packet should have been successfully received
623  Simulator::Schedule (Seconds (1.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 0);
624 
625  // CASE 2: send two packets with same power within the 4us window and check PHY state:
626  // PHY preamble detection should fail because SNR is too low (around 0 dB, which is lower than the threshold of 4 dB),
627  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
628  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
629 
630  Simulator::Schedule (Seconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
631  Simulator::Schedule (Seconds (2.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
632  // At 4us, no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
635  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
638  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
639  Simulator::Schedule (Seconds (2.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 0);
640 
641  // CASE 3: send two packets with second one 3 dB weaker within the 4us window and check PHY state:
642  // PHY preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
643  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
644  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
645 
646  Simulator::Schedule (Seconds (3.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
647  Simulator::Schedule (Seconds (3.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm - 3);
648  // At 4us, no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
651  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
654  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
655  Simulator::Schedule (Seconds (3.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 0);
656 
657  // CASE 4: send two packets with second one 6 dB weaker within the 4us window and check PHY state:
658  // PHY preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
659  // but payload reception should fail (SNR too low to decode the modulation).
660 
661  Simulator::Schedule (Seconds (4.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
662  Simulator::Schedule (Seconds (4.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm - 6);
663  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
666  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
669  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
670  // However, since there is a second packet transmitted with a power above CCA-ED (-62 dBm), PHY should first be seen as CCA_BUSY for 2us.
675  // In this case, the first packet should be marked as a failure
676  Simulator::Schedule (Seconds (4.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 1);
677 
678  // CASE 5: send two packets with second one 3 dB higher within the 4us window and check PHY state:
679  // PHY preamble detection should switch because a higher packet is received within the 4us window,
680  // but preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
681  // PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
682 
683  Simulator::Schedule (Seconds (5.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
684  Simulator::Schedule (Seconds (5.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm + 3);
685  // At 4us, STA PHY STATE should stay IDLE
687  // At 6us, STA PHY STATE should move from IDLE to CCA_BUSY
690  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
693  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
694  Simulator::Schedule (Seconds (5.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 1);
695 
696  // CASE 6: send two packets with second one 6 dB higher within the 4us window and check PHY state:
697  // PHY preamble detection should switch because a higher packet is received within the 4us window,
698  // and preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
699  // Payload reception should fail (SNR too low to decode the modulation).
700 
701  Simulator::Schedule (Seconds (6.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
702  Simulator::Schedule (Seconds (6.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm + 6);
703  // At 4us, STA PHY STATE should stay IDLE
705  // At 6us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
708  // At 46us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
711  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
714  // In this case, the second packet should be marked as a failure
715  Simulator::Schedule (Seconds (6.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 2);
716 
717  // CASE 7: send two packets with same power at the exact same time and check PHY state:
718  // PHY preamble detection should fail because SNR is too low (around 0 dB, which is lower than the threshold of 4 dB),
719  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
720  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
721 
722  Simulator::Schedule (Seconds (7.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
723  Simulator::Schedule (Seconds (7.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
724  // At 4us, no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
727  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
730  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
731  Simulator::Schedule (Seconds (7.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 2);
732 
733  // CASE 8: send two packets with second one 3 dB weaker at the exact same time and check PHY state:
734  // PHY preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
735  // and PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
736  // CCA_BUSY state should last for the duration of the two packets minus the time to detect the preamble.
737 
738  Simulator::Schedule (Seconds (8.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
739  Simulator::Schedule (Seconds (8.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm - 3);
740  // At 4us, no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
743  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 us
746  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
747  Simulator::Schedule (Seconds (8.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 2);
748 
749  // CASE 9: send two packets with second one 6 dB weaker at the exact same time and check PHY state:
750  // PHY preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
751  // but payload reception should fail (SNR too low to decode the modulation).
752 
753  Simulator::Schedule (Seconds (9.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
754  Simulator::Schedule (Seconds (9.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm - 6);
755  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
758  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
761  // Since it takes 152.8us to transmit the packets, PHY should be back to IDLE at time 152.8us.
764  // In this case, the first packet should be marked as a failure
765  Simulator::Schedule (Seconds (9.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 3);
766 
767  // CASE 10: send two packets with second one 3 dB higher at the exact same time and check PHY state:
768  // PHY preamble detection should switch because a higher packet is received within the 4us window,
769  // but preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
770  // PHY state should be CCA_BUSY since the total energy is above CCA-ED (-62 dBm).
771 
772  Simulator::Schedule (Seconds (10.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
773  Simulator::Schedule (Seconds (10.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm + 3);
774  // At 4us, no preamble is successfully detected, hence STA PHY STATE should move from IDLE to CCA_BUSY
777  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 us
780  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
781  Simulator::Schedule (Seconds (10.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 3);
782 
783  // CASE 11: send two packets with second one 6 dB higher at the exact same time and check PHY state:
784  // PHY preamble detection should switch because a higher packet is received within the 4us window,
785  // and preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
786  // Payload reception should fail (SNR too low to decode the modulation).
787 
788  Simulator::Schedule (Seconds (11.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
789  Simulator::Schedule (Seconds (11.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm + 6);
790  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
793  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
796  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 us
799  // In this case, the second packet should be marked as a failure
800  Simulator::Schedule (Seconds (11.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 1, 4);
801 
802  // CCA-PD < RX power < CCA-ED
803  rxPowerDbm = -70;
804 
805  // CASE 12: send one packet and check PHY state:
806  // All reception stages should succeed and PHY state should be RX for the duration of the packet minus the time to detect the preamble,
807  // otherwise it should be IDLE.
808 
809  Simulator::Schedule (Seconds (12.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
810  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
813  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
816  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us
819  // Packet should have been successfully received
820  Simulator::Schedule (Seconds (12.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 2, 4);
821 
822  // CASE 13: send two packets with same power within the 4us window and check PHY state:
823  // PHY preamble detection should fail because SNR is too low (around 0 dB, which is lower than the threshold of 4 dB),
824  // and PHY state should stay IDLE since the total energy is below CCA-ED (-62 dBm).
825 
826  Simulator::Schedule (Seconds (13.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
827  Simulator::Schedule (Seconds (13.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
828  // At 4us, STA PHY STATE should stay IDLE
830  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
831  Simulator::Schedule (Seconds (13.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 2, 4);
832 
833  // CASE 14: send two packets with second one 3 dB weaker within the 4us window and check PHY state: PHY preamble detection should fail
834  // PHY preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB),
835  // and PHY state should stay IDLE since the total energy is below CCA-ED (-62 dBm).
836 
837  Simulator::Schedule (Seconds (14.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
838  Simulator::Schedule (Seconds (14.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm - 3);
839  // At 4us, STA PHY STATE should stay IDLE
841  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
842  Simulator::Schedule (Seconds (14.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 2, 4);
843 
844  // CASE 15: send two packets with second one 6 dB weaker within the 4us window and check PHY state:
845  // PHY preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
846  // but payload reception should fail (SNR too low to decode the modulation).
847 
848  Simulator::Schedule (Seconds (15.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
849  Simulator::Schedule (Seconds (15.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm - 6);
850  // At 4us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
853  // At 44us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
856  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
859  // In this case, the first packet should be marked as a failure
860  Simulator::Schedule (Seconds (15.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 2, 5);
861 
862  // CASE 16: send two packets with second one 3 dB higher within the 4us window and check PHY state:
863  // PHY preamble detection should switch because a higher packet is received within the 4us window,
864  // but preamble detection should fail because SNR is too low (around 3 dB, which is lower than the threshold of 4 dB).
865  // PHY state should stay IDLE since the total energy is below CCA-ED (-62 dBm).
866 
867  Simulator::Schedule (Seconds (16.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
868  Simulator::Schedule (Seconds (16.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm + 3);
869  // At 4us, STA PHY STATE should stay IDLE
871  // At 6us, STA PHY STATE should stay IDLE
873  // No more packet should have been successfully received, and since preamble detection did not pass the packet should not have been counted as a failure
874  Simulator::Schedule (Seconds (16.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 2, 5);
875 
876  // CASE 17: send two packets with second one 6 dB higher within the 4us window and check PHY state:
877  // PHY preamble detection should switch because a higher packet is received within the 4us window,
878  // and preamble detection should succeed because SNR is high enough (around 6 dB, which is higher than the threshold of 4 dB),
879  // Payload reception should fail (SNR too low to decode the modulation).
880 
881  Simulator::Schedule (Seconds (17.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
882  Simulator::Schedule (Seconds (17.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm + 6);
883  // At 4us, STA PHY STATE should stay IDLE
885  // At 6us, preamble should be successfully detected and STA PHY STATE should move from IDLE to CCA_BUSY
888  // At 46us, PHY header should be successfully received and STA PHY STATE should move from CCA_BUSY to RX
891  // Since it takes 152.8us to transmit each packet, PHY should be back to IDLE at time 152.8 + 2 = 154.8us
894  // In this case, the second packet should be marked as a failure
895  Simulator::Schedule (Seconds (17.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 2, 6);
896 
897  rxPowerDbm = -50;
898  // CASE 18: send two packets with second one 50 dB higher within the 4us window
899 
900  Simulator::Schedule (Seconds (18.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
901  Simulator::Schedule (Seconds (18.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm+50);
902  // The second packet should be received successfully
903  Simulator::Schedule (Seconds (18.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 3, 6);
904 
905  // CASE 19: send two packets with second one 10 dB higher within the 4us window
906 
907  Simulator::Schedule (Seconds (19.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
908  Simulator::Schedule (Seconds (19.0) + MicroSeconds (2.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm+10);
909  // The second packet should be captured, but not decoded since SNR to low for used MCS
910  Simulator::Schedule (Seconds (19.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 3, 7);
911 
912  // CASE 20: send two packets with second one 50 dB higher in the same time
913 
914  Simulator::Schedule (Seconds (20.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
915  Simulator::Schedule (Seconds (20.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm+50);
916  // The second packet should be received successfully, same as in CASE 13
917  Simulator::Schedule (Seconds (20.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 4, 7);
918 
919  // CASE 21: send two packets with second one 10 dB higher in the same time
920 
921  Simulator::Schedule (Seconds (21.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm);
922  Simulator::Schedule (Seconds (21.0), &TestThresholdPreambleDetectionWithFrameCapture::SendPacket, this, rxPowerDbm+10);
923  // The second packet should be captured, but not decoded since SNR to low for used MCS, same as in CASE 19
924  Simulator::Schedule (Seconds (21.1), &TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount, this, 4, 8);
925 
926  Simulator::Run ();
927  Simulator::Destroy ();
928 }
929 
937 {
938 public:
940  virtual ~TestSimpleFrameCaptureModel ();
941 
942 protected:
943  void DoSetup (void) override;
944  void DoTeardown (void) override;
945 
946 private:
947  void DoRun (void) override;
948 
952  void Reset (void);
958  void SendPacket (double rxPowerDbm, uint32_t packetSize);
966  void RxSuccess (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
967  WifiTxVector txVector, std::vector<bool> statusPerMpdu);
974 
986  void Expect1000BPacketDropped ();
990  void Expect1500BPacketDropped ();
991 
993 
998 
999  uint64_t m_uid;
1000 };
1001 
1003 : TestCase ("Simple frame capture model test"),
1004  m_rxSuccess1000B (false),
1005  m_rxSuccess1500B (false),
1006  m_rxDropped1000B (false),
1007  m_rxDropped1500B (false),
1008  m_uid (0)
1009 {
1010 }
1011 
1012 void
1014 {
1015  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs0 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, 20, false);
1016 
1017  Ptr<Packet> pkt = Create<Packet> (packetSize);
1018  WifiMacHeader hdr;
1019 
1020  hdr.SetType (WIFI_MAC_QOSDATA);
1021  hdr.SetQosTid (0);
1022 
1023  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
1024  Time txDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand ());
1025 
1026  Ptr<WifiPpdu> ppdu = Create<HePpdu> (psdu, txVector, txDuration, WIFI_PHY_BAND_5GHZ, m_uid++);
1027 
1028  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, DbmToW (rxPowerDbm), GUARD_WIDTH);
1029 
1030  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
1031  txParams->psd = txPowerSpectrum;
1032  txParams->txPhy = 0;
1033  txParams->duration = txDuration;
1034  txParams->ppdu = ppdu;
1035 
1036  m_phy->StartRx (txParams);
1037 }
1038 
1039 void
1041  WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1042 {
1043  NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector);
1044  NS_ASSERT (!psdu->IsAggregate () || psdu->IsSingle ());
1045  if (psdu->GetSize () == 1030)
1046  {
1047  m_rxSuccess1000B = true;
1048  }
1049  else if (psdu->GetSize () == 1530)
1050  {
1051  m_rxSuccess1500B = true;
1052  }
1053 }
1054 
1055 void
1057 {
1058  NS_LOG_FUNCTION (this << p << reason);
1059  if (p->GetSize () == 1030)
1060  {
1061  m_rxDropped1000B = true;
1062  }
1063  else if (p->GetSize () == 1530)
1064  {
1065  m_rxDropped1500B = true;
1066  }
1067 }
1068 
1069 void
1071 {
1072  m_rxSuccess1000B = false;
1073  m_rxSuccess1500B = false;
1074  m_rxDropped1000B = false;
1075  m_rxDropped1500B = false;
1076 }
1077 
1078 void
1080 {
1081  NS_TEST_ASSERT_MSG_EQ (m_rxSuccess1000B, true, "Didn't receive 1000B packet");
1082 }
1083 
1084 void
1086 {
1087  NS_TEST_ASSERT_MSG_EQ (m_rxSuccess1500B, true, "Didn't receive 1500B packet");
1088 }
1089 void
1091 {
1092  NS_TEST_ASSERT_MSG_EQ (m_rxDropped1000B, true, "Didn't drop 1000B packet");
1093 }
1094 
1095 void
1097 {
1098  NS_TEST_ASSERT_MSG_EQ (m_rxDropped1500B, true, "Didn't drop 1500B packet");
1099 }
1100 
1102 {
1103  m_phy = 0;
1104 }
1105 
1106 void
1108 {
1109  m_phy = CreateObject<SpectrumWifiPhy> ();
1111  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
1112  m_phy->SetErrorRateModel (error);
1115 
1118 
1119  Ptr<ThresholdPreambleDetectionModel> preambleDetectionModel = CreateObject<ThresholdPreambleDetectionModel> ();
1120  preambleDetectionModel->SetAttribute ("Threshold", DoubleValue (2));
1121  m_phy->SetPreambleDetectionModel (preambleDetectionModel);
1122 
1123  Ptr<SimpleFrameCaptureModel> frameCaptureModel = CreateObject<SimpleFrameCaptureModel> ();
1124  frameCaptureModel->SetAttribute ("Margin", DoubleValue (5));
1125  frameCaptureModel->SetAttribute ("CaptureWindow", TimeValue (MicroSeconds (16)));
1126  m_phy->SetFrameCaptureModel (frameCaptureModel);
1127 }
1128 
1129 void
1131 {
1132  m_phy->Dispose ();
1133  m_phy = 0;
1134 }
1135 
1136 void
1138 {
1139  RngSeedManager::SetSeed (1);
1140  RngSeedManager::SetRun (1);
1141  int64_t streamNumber = 2;
1142  double rxPowerDbm = -30;
1143  m_phy->AssignStreams (streamNumber);
1144 
1145  // CASE 1: send two packets with same power within the capture window:
1146  // PHY should not switch reception because they have same power.
1147 
1148  Simulator::Schedule (Seconds (1.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm, 1000);
1149  Simulator::Schedule (Seconds (1.0) + MicroSeconds (10.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm, 1500);
1150  Simulator::Schedule (Seconds (1.1), &TestSimpleFrameCaptureModel::Expect1500BPacketDropped, this);
1151  Simulator::Schedule (Seconds (1.2), &TestSimpleFrameCaptureModel::Reset, this);
1152 
1153  // CASE 2: send two packets with second one 6 dB weaker within the capture window:
1154  // PHY should not switch reception because first one has higher power.
1155 
1156  Simulator::Schedule (Seconds (2.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm, 1000);
1157  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm - 6, 1500);
1158  Simulator::Schedule (Seconds (2.1), &TestSimpleFrameCaptureModel::Expect1000BPacketReceived, this);
1159  Simulator::Schedule (Seconds (2.1), &TestSimpleFrameCaptureModel::Expect1500BPacketDropped, this);
1160  Simulator::Schedule (Seconds (2.2), &TestSimpleFrameCaptureModel::Reset, this);
1161 
1162  // CASE 3: send two packets with second one 6 dB higher within the capture window:
1163  // PHY should switch reception because the second one has a higher power.
1164 
1165  Simulator::Schedule (Seconds (3.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm, 1000);
1166  Simulator::Schedule (Seconds (3.0) + MicroSeconds (10.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm + 6, 1500);
1167  Simulator::Schedule (Seconds (3.1), &TestSimpleFrameCaptureModel::Expect1000BPacketDropped, this);
1168  Simulator::Schedule (Seconds (3.1), &TestSimpleFrameCaptureModel::Expect1500BPacketReceived, this);
1169  Simulator::Schedule (Seconds (3.2), &TestSimpleFrameCaptureModel::Reset, this);
1170 
1171  // CASE 4: send two packets with second one 6 dB higher after the capture window:
1172  // PHY should not switch reception because capture window duration has elapsed when the second packet arrives.
1173 
1174  Simulator::Schedule (Seconds (4.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm, 1000);
1175  Simulator::Schedule (Seconds (4.0) + MicroSeconds (25.0), &TestSimpleFrameCaptureModel::SendPacket, this, rxPowerDbm + 6, 1500);
1176  Simulator::Schedule (Seconds (4.1), &TestSimpleFrameCaptureModel::Expect1500BPacketDropped, this);
1177  Simulator::Schedule (Seconds (4.2), &TestSimpleFrameCaptureModel::Reset, this);
1178 
1179  Simulator::Run ();
1180  Simulator::Destroy ();
1181 }
1182 
1190 {
1191 public:
1193  virtual ~TestPhyHeadersReception ();
1194 
1195 protected:
1196  void DoSetup (void) override;
1197  void DoTeardown (void) override;
1199 
1203  void SendPacket (double rxPowerDbm);
1204 
1205 private:
1206  void DoRun (void) override;
1207 
1212  void CheckPhyState (WifiPhyState expectedState);
1217  void DoCheckPhyState (WifiPhyState expectedState);
1218 
1219  uint64_t m_uid;
1220 };
1221 
1223 : TestCase ("PHY headers reception test"),
1224  m_uid (0)
1225 {
1226 }
1227 
1228 void
1230 {
1231  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs7 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, 20, false);
1232 
1233  Ptr<Packet> pkt = Create<Packet> (1000);
1234  WifiMacHeader hdr;
1235 
1236  hdr.SetType (WIFI_MAC_QOSDATA);
1237  hdr.SetQosTid (0);
1238 
1239  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (pkt, hdr);
1240  Time txDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand ());
1241 
1242  Ptr<WifiPpdu> ppdu = Create<HePpdu> (psdu, txVector, txDuration, WIFI_PHY_BAND_5GHZ, m_uid++);
1243 
1244  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, DbmToW (rxPowerDbm), GUARD_WIDTH);
1245 
1246  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
1247  txParams->psd = txPowerSpectrum;
1248  txParams->txPhy = 0;
1249  txParams->duration = txDuration;
1250  txParams->ppdu = ppdu;
1251 
1252  m_phy->StartRx (txParams);
1253 }
1254 
1255 void
1257 {
1258  //This is needed to make sure PHY state will be checked as the last event if a state change occured at the exact same time as the check
1259  Simulator::ScheduleNow (&TestPhyHeadersReception::DoCheckPhyState, this, expectedState);
1260 }
1261 
1262 void
1264 {
1265  WifiPhyState currentState;
1266  PointerValue ptr;
1267  m_phy->GetAttribute ("State", ptr);
1268  Ptr <WifiPhyStateHelper> state = DynamicCast <WifiPhyStateHelper> (ptr.Get<WifiPhyStateHelper> ());
1269  currentState = state->GetState ();
1270  NS_LOG_FUNCTION (this << currentState);
1271  NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ());
1272 }
1273 
1274 
1276 {
1277  m_phy = 0;
1278 }
1279 
1280 void
1282 {
1283  m_phy = CreateObject<SpectrumWifiPhy> ();
1285  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
1286  m_phy->SetErrorRateModel (error);
1289 }
1290 
1291 void
1293 {
1294  m_phy->Dispose ();
1295  m_phy = 0;
1296 }
1297 
1298 void
1300 {
1301  RngSeedManager::SetSeed (1);
1302  RngSeedManager::SetRun (1);
1303  int64_t streamNumber = 0;
1304  m_phy->AssignStreams (streamNumber);
1305 
1306  // RX power > CCA-ED
1307  double rxPowerDbm = -50;
1308 
1309  // CASE 1: send one packet followed by a second one with same power between the end of the 4us preamble detection window
1310  // and the start of L-SIG of the first packet: reception should be aborted since L-SIG cannot be decoded (SNR too low).
1311 
1312  Simulator::Schedule (Seconds (1.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1313  Simulator::Schedule (Seconds (1.0) + MicroSeconds (10), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1314  // At 10 us, STA PHY STATE should be CCA_BUSY.
1315  Simulator::Schedule (Seconds (1.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1316  // At 44us (end of PHY header), STA PHY STATE should not have moved to RX and be kept to CCA_BUSY.
1317  Simulator::Schedule (Seconds (1.0) + NanoSeconds (44000), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1318  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8 + 10 = 162.8us.
1319  Simulator::Schedule (Seconds (1.0) + NanoSeconds (162799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1320  Simulator::Schedule (Seconds (1.0) + NanoSeconds (162800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1321 
1322  // CASE 2: send one packet followed by a second one 3 dB weaker between the end of the 4us preamble detection window
1323  // and the start of L-SIG of the first packet: reception should not be aborted since L-SIG can be decoded (SNR high enough).
1324 
1325  Simulator::Schedule (Seconds (2.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1326  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm - 3);
1327  // At 10 us, STA PHY STATE should be CCA_BUSY.
1328  Simulator::Schedule (Seconds (2.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1329  // At 44us (end of PHY header), STA PHY STATE should have moved to RX since PHY header reception should have succeeded.
1330  Simulator::Schedule (Seconds (2.0) + NanoSeconds (43999), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1331  Simulator::Schedule (Seconds (2.0) + NanoSeconds (44000), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1332  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
1333  // However, since there is a second packet transmitted with a power above CCA-ED (-62 dBm), PHY should first be seen as CCA_BUSY for 10us.
1334  Simulator::Schedule (Seconds (2.0) + NanoSeconds (152799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1335  Simulator::Schedule (Seconds (2.0) + NanoSeconds (152800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1336  Simulator::Schedule (Seconds (2.0) + NanoSeconds (162799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1337  Simulator::Schedule (Seconds (2.0) + NanoSeconds (162800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1338 
1339  // CASE 3: send one packet followed by a second one with same power between the end of L-SIG and the start of HE-SIG of the first packet:
1340  // PHY header reception should not succeed but PHY should stay in RX state for the duration estimated from L-SIG.
1341 
1342  Simulator::Schedule (Seconds (3.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1343  Simulator::Schedule (Seconds (3.0) + MicroSeconds (25), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1344  // At 44us (end of PHY header), STA PHY STATE should not have moved to RX (HE-SIG failed) and be kept to CCA_BUSY.
1345  Simulator::Schedule (Seconds (3.0) + MicroSeconds (44.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1346  // STA PHY STATE should move back to IDLE once the duration estimated from L-SIG has elapsed, i.e. at 152.8us.
1347  // However, since there is a second packet transmitted with a power above CCA-ED (-62 dBm), PHY should first be seen as CCA_BUSY for 25us.
1348  Simulator::Schedule (Seconds (3.0) + NanoSeconds (152799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1349  Simulator::Schedule (Seconds (3.0) + NanoSeconds (152800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1350  Simulator::Schedule (Seconds (3.0) + NanoSeconds (177799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1351  Simulator::Schedule (Seconds (3.0) + NanoSeconds (177800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1352 
1353  // CASE 4: send one packet followed by a second one 3 dB weaker between the end of L-SIG and the start of HE-SIG of the first packet:
1354  // PHY header reception should succeed.
1355 
1356  Simulator::Schedule (Seconds (4.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1357  Simulator::Schedule (Seconds (4.0) + MicroSeconds (25), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm - 3);
1358  // At 10 us, STA PHY STATE should be CCA_BUSY.
1359  Simulator::Schedule (Seconds (4.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1360  // At 44 us (end of HE-SIG), STA PHY STATE should move to RX since the PHY header reception should have succeeded.
1361  Simulator::Schedule (Seconds (4.0) + NanoSeconds (43999), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1362  Simulator::Schedule (Seconds (4.0) + NanoSeconds (44000), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1363  // STA PHY STATE should move back to IDLE once the duration estimated from L-SIG has elapsed, i.e. at 152.8us.
1364  // However, since there is a second packet transmitted with a power above CCA-ED (-62 dBm), PHY should first be seen as CCA_BUSY for 25us.
1365  Simulator::Schedule (Seconds (4.0) + NanoSeconds (152799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1366  Simulator::Schedule (Seconds (4.0) + NanoSeconds (152800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1367  Simulator::Schedule (Seconds (4.0) + NanoSeconds (177799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1368  Simulator::Schedule (Seconds (4.0) + NanoSeconds (177800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1369 
1370  // RX power < CCA-ED
1371  rxPowerDbm = -70;
1372 
1373  // CASE 5: send one packet followed by a second one with same power between the end of the 4us preamble detection window
1374  // and the start of L-SIG of the first packet: reception should be aborted since L-SIG cannot be decoded (SNR too low).
1375 
1376  Simulator::Schedule (Seconds (5.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1377  Simulator::Schedule (Seconds (5.0) + MicroSeconds (10), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1378  // At 10 us, STA PHY STATE should be CCA_BUSY.
1379  Simulator::Schedule (Seconds (5.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1380  // At 24us (end of L-SIG), STA PHY STATE should go to IDLE because L-SIG reception failed and the total energy is below CCA-ED.
1381  Simulator::Schedule (Seconds (5.0) + NanoSeconds (23999), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1382  Simulator::Schedule (Seconds (5.0) + NanoSeconds (24000), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1383 
1384  // CASE 6: send one packet followed by a second one 3 dB weaker between the end of the 4us preamble detection window
1385  // and the start of L-SIG of the first packet: reception should not be aborted since L-SIG can be decoded (SNR high enough).
1386 
1387  Simulator::Schedule (Seconds (6.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1388  Simulator::Schedule (Seconds (6.0) + MicroSeconds (10), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm - 3);
1389  // At 10 us, STA PHY STATE should be CCA_BUSY.
1390  Simulator::Schedule (Seconds (6.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1391  // At 24us (end of L-SIG), STA PHY STATE should be unchanged because L-SIG reception should have succeeded.
1392  Simulator::Schedule (Seconds (6.0) + MicroSeconds (24.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1393  // At 44 us (end of HE-SIG), STA PHY STATE should move to RX since the PHY header reception should have succeeded.
1394  Simulator::Schedule (Seconds (6.0) + NanoSeconds (43999), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1395  Simulator::Schedule (Seconds (6.0) + NanoSeconds (44000), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1396  // Since it takes 152.8us to transmit the packet, PHY should be back to IDLE at time 152.8us.
1397  Simulator::Schedule (Seconds (6.0) + NanoSeconds (152799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1398  Simulator::Schedule (Seconds (6.0) + NanoSeconds (152800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1399 
1400  // CASE 7: send one packet followed by a second one with same power between the end of L-SIG and the start of HE-SIG of the first packet:
1401  // PHY header reception should not succeed but PHY should stay in RX state for the duration estimated from L-SIG.
1402 
1403  Simulator::Schedule (Seconds (7.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1404  Simulator::Schedule (Seconds (7.0) + MicroSeconds (25), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1405  // At 10 us, STA PHY STATE should be CCA_BUSY.
1406  Simulator::Schedule (Seconds (7.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1407  // At 24us (end of L-SIG), STA PHY STATE should be unchanged because L-SIG reception should have succeeded.
1408  Simulator::Schedule (Seconds (7.0) + MicroSeconds (24.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1409  // At 44 us (end of HE-SIG), STA PHY STATE should be not have moved to RX since reception of HE-SIG should have failed.
1410  Simulator::Schedule (Seconds (7.0) + MicroSeconds (44.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1411  // STA PHY STATE should move back to IDLE once the duration estimated from L-SIG has elapsed, i.e. at 152.8us.
1412  Simulator::Schedule (Seconds (7.0) + NanoSeconds (152799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1413  Simulator::Schedule (Seconds (7.0) + NanoSeconds (152800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1414 
1415  // CASE 8: send one packet followed by a second one 3 dB weaker between the end of L-SIG and the start of HE-SIG of the first packet:
1416  // PHY header reception should succeed.
1417 
1418  Simulator::Schedule (Seconds (8.0), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm);
1419  Simulator::Schedule (Seconds (8.0) + MicroSeconds (25), &TestPhyHeadersReception::SendPacket, this, rxPowerDbm - 3);
1420  // At 10 us, STA PHY STATE should be CCA_BUSY.
1421  Simulator::Schedule (Seconds (8.0) + MicroSeconds (10.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1422  // At 24us (end of L-SIG), STA PHY STATE should be unchanged because L-SIG reception should have succeeded.
1423  Simulator::Schedule (Seconds (8.0) + MicroSeconds (24.0), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1424  // At 44 us (end of HE-SIG), STA PHY STATE should move to RX since the PHY header reception should have succeeded.
1425  Simulator::Schedule (Seconds (8.0) + NanoSeconds (43999), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::CCA_BUSY);
1426  Simulator::Schedule (Seconds (8.0) + NanoSeconds (44000), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1427  // STA PHY STATE should move back to IDLE once the duration estimated from L-SIG has elapsed, i.e. at 152.8us.
1428  Simulator::Schedule (Seconds (8.0) + NanoSeconds (152799), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::RX);
1429  Simulator::Schedule (Seconds (8.0) + NanoSeconds (152800), &TestPhyHeadersReception::CheckPhyState, this, WifiPhyState::IDLE);
1430 
1431  Simulator::Run ();
1432  Simulator::Destroy ();
1433 }
1434 
1442 {
1443 public:
1444  TestAmpduReception ();
1445  virtual ~TestAmpduReception ();
1446 
1447 protected:
1448  void DoSetup (void) override;
1449  void DoTeardown (void) override;
1450 
1451 private:
1452  void DoRun (void) override;
1453 
1461  void RxSuccess (Ptr<WifiPsdu> psdu, RxSignalInfo rxSignalInfo,
1462  WifiTxVector txVector, std::vector<bool> statusPerMpdu);
1467  void RxFailure (Ptr<WifiPsdu> psdu);
1478  void IncrementSuccessBitmap (uint32_t size);
1483  void IncrementFailureBitmap (uint32_t size);
1484 
1488  void ResetBitmaps();
1489 
1495  void SendAmpduWithThreeMpdus (double rxPowerDbm, uint32_t referencePacketSize);
1496 
1501  void CheckRxSuccessBitmapAmpdu1 (uint8_t expected);
1506  void CheckRxSuccessBitmapAmpdu2 (uint8_t expected);
1511  void CheckRxFailureBitmapAmpdu1 (uint8_t expected);
1516  void CheckRxFailureBitmapAmpdu2 (uint8_t expected);
1521  void CheckRxDroppedBitmapAmpdu1 (uint8_t expected);
1526  void CheckRxDroppedBitmapAmpdu2 (uint8_t expected);
1527 
1532  void CheckPhyState (WifiPhyState expectedState);
1533 
1535 
1538 
1541 
1544 
1545  uint64_t m_uid;
1546 };
1547 
1549 : TestCase ("A-MPDU reception test"),
1550  m_rxSuccessBitmapAmpdu1 (0),
1551  m_rxSuccessBitmapAmpdu2 (0),
1552  m_rxFailureBitmapAmpdu1 (0),
1553  m_rxFailureBitmapAmpdu2 (0),
1554  m_rxDroppedBitmapAmpdu1 (0),
1555  m_rxDroppedBitmapAmpdu2 (0),
1556  m_uid (0)
1557 {
1558 }
1559 
1561 {
1562  m_phy = 0;
1563 }
1564 
1565 void
1567 {
1574 }
1575 
1576 void
1578  WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1579 {
1580  NS_LOG_FUNCTION (this << *psdu << rxSignalInfo << txVector);
1581  if (statusPerMpdu.empty ()) //wait for the whole A-MPDU
1582  {
1583  return;
1584  }
1585  NS_ABORT_MSG_IF (psdu->GetNMpdus () != statusPerMpdu.size (), "Should have one receive status per MPDU");
1586  auto rxOkForMpdu = statusPerMpdu.begin ();
1587  for (auto mpdu = psdu->begin (); mpdu != psdu->end (); ++mpdu)
1588  {
1589  if (*rxOkForMpdu)
1590  {
1591  IncrementSuccessBitmap ((*mpdu)->GetSize ());
1592  }
1593  else
1594  {
1595  IncrementFailureBitmap ((*mpdu)->GetSize ());
1596  }
1597  ++rxOkForMpdu;
1598  }
1599 }
1600 
1601 void
1603 {
1604  if (size == 1030) //A-MPDU 1 - MPDU #1
1605  {
1607  }
1608  else if (size == 1130) //A-MPDU 1 - MPDU #2
1609  {
1610  m_rxSuccessBitmapAmpdu1 |= (1 << 1);
1611  }
1612  else if (size == 1230) //A-MPDU 1 - MPDU #3
1613  {
1614  m_rxSuccessBitmapAmpdu1 |= (1 << 2);
1615  }
1616  else if (size == 1330) //A-MPDU 2 - MPDU #1
1617  {
1619  }
1620  else if (size == 1430) //A-MPDU 2 - MPDU #2
1621  {
1622  m_rxSuccessBitmapAmpdu2 |= (1 << 1);
1623  }
1624  else if (size == 1530) //A-MPDU 2 - MPDU #3
1625  {
1626  m_rxSuccessBitmapAmpdu2 |= (1 << 2);
1627  }
1628 }
1629 
1630 void
1632 {
1633  NS_LOG_FUNCTION (this << *psdu);
1634  for (auto mpdu = psdu->begin (); mpdu != psdu->end (); ++mpdu)
1635  {
1636  IncrementFailureBitmap ((*mpdu)->GetSize ());
1637  }
1638 }
1639 
1640 void
1642 {
1643  if (size == 1030) //A-MPDU 1 - MPDU #1
1644  {
1646  }
1647  else if (size == 1130) //A-MPDU 1 - MPDU #2
1648  {
1649  m_rxFailureBitmapAmpdu1 |= (1 << 1);
1650  }
1651  else if (size == 1230) //A-MPDU 1 - MPDU #3
1652  {
1653  m_rxFailureBitmapAmpdu1 |= (1 << 2);
1654  }
1655  else if (size == 1330) //A-MPDU 2 - MPDU #1
1656  {
1658  }
1659  else if (size == 1430) //A-MPDU 2 - MPDU #2
1660  {
1661  m_rxFailureBitmapAmpdu2 |= (1 << 1);
1662  }
1663  else if (size == 1530) //A-MPDU 2 - MPDU #3
1664  {
1665  m_rxFailureBitmapAmpdu2 |= (1 << 2);
1666  }
1667 }
1668 
1669 void
1671 {
1672  NS_LOG_FUNCTION (this << p << reason);
1673  if (p->GetSize () == 1030) //A-MPDU 1 - MPDU #1
1674  {
1676  }
1677  else if (p->GetSize () == 1130) //A-MPDU 1 - MPDU #2
1678  {
1679  m_rxDroppedBitmapAmpdu1 |= (1 << 1);
1680  }
1681  else if (p->GetSize () == 1230) //A-MPDU 1 - MPDU #3
1682  {
1683  m_rxDroppedBitmapAmpdu1 |= (1 << 2);
1684  }
1685  else if (p->GetSize () == 1330) //A-MPDU 2 - MPDU #1
1686  {
1688  }
1689  else if (p->GetSize () == 1430) //A-MPDU 2 - MPDU #2
1690  {
1691  m_rxDroppedBitmapAmpdu2 |= (1 << 1);
1692  }
1693  else if (p->GetSize () == 1530) //A-MPDU 2 - MPDU #3
1694  {
1695  m_rxDroppedBitmapAmpdu2 |= (1 << 2);
1696  }
1697 }
1698 
1699 void
1701 {
1702  NS_TEST_ASSERT_MSG_EQ (m_rxSuccessBitmapAmpdu1, expected, "RX success bitmap for A-MPDU 1 is not as expected");
1703 }
1704 
1705 void
1707 {
1708  NS_TEST_ASSERT_MSG_EQ (m_rxSuccessBitmapAmpdu2, expected, "RX success bitmap for A-MPDU 2 is not as expected");
1709 }
1710 
1711 void
1713 {
1714  NS_TEST_ASSERT_MSG_EQ (m_rxFailureBitmapAmpdu1, expected, "RX failure bitmap for A-MPDU 1 is not as expected");
1715 }
1716 
1717 void
1719 {
1720  NS_TEST_ASSERT_MSG_EQ (m_rxFailureBitmapAmpdu2, expected, "RX failure bitmap for A-MPDU 2 is not as expected");
1721 }
1722 
1723 void
1725 {
1726  NS_TEST_ASSERT_MSG_EQ (m_rxDroppedBitmapAmpdu1, expected, "RX dropped bitmap for A-MPDU 1 is not as expected");
1727 }
1728 
1729 void
1731 {
1732  NS_TEST_ASSERT_MSG_EQ (m_rxDroppedBitmapAmpdu2, expected, "RX dropped bitmap for A-MPDU 2 is not as expected");
1733 }
1734 
1735 void
1737 {
1738  WifiPhyState currentState;
1739  PointerValue ptr;
1740  m_phy->GetAttribute ("State", ptr);
1741  Ptr <WifiPhyStateHelper> state = DynamicCast <WifiPhyStateHelper> (ptr.Get<WifiPhyStateHelper> ());
1742  currentState = state->GetState ();
1743  NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ());
1744 }
1745 
1746 void
1747 TestAmpduReception::SendAmpduWithThreeMpdus (double rxPowerDbm, uint32_t referencePacketSize)
1748 {
1749  WifiTxVector txVector = WifiTxVector (HePhy::GetHeMcs0 (), 0, WIFI_PREAMBLE_HE_SU, 800, 1, 1, 0, 20, true);
1750 
1751  WifiMacHeader hdr;
1752  hdr.SetType (WIFI_MAC_QOSDATA);
1753  hdr.SetQosTid (0);
1754 
1755  std::vector<Ptr<WifiMacQueueItem>> mpduList;
1756  for (size_t i = 0; i < 3; ++i)
1757  {
1758  Ptr<Packet> p = Create<Packet> (referencePacketSize + i * 100);
1759  mpduList.push_back (Create<WifiMacQueueItem> (p, hdr));
1760  }
1761  Ptr<WifiPsdu> psdu = Create<WifiPsdu> (mpduList);
1762 
1763  Time txDuration = m_phy->CalculateTxDuration (psdu->GetSize (), txVector, m_phy->GetPhyBand ());
1764 
1765  Ptr<WifiPpdu> ppdu = Create<HePpdu> (psdu, txVector, txDuration, WIFI_PHY_BAND_5GHZ, m_uid++);
1766 
1767  Ptr<SpectrumValue> txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, DbmToW (rxPowerDbm), GUARD_WIDTH);
1768 
1769  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
1770  txParams->psd = txPowerSpectrum;
1771  txParams->txPhy = 0;
1772  txParams->duration = txDuration;
1773  txParams->ppdu = ppdu;
1774 
1775  m_phy->StartRx (txParams);
1776 }
1777 
1778 void
1780 {
1781  m_phy = CreateObject<SpectrumWifiPhy> ();
1783  Ptr<ErrorRateModel> error = CreateObject<NistErrorRateModel> ();
1784  m_phy->SetErrorRateModel (error);
1787 
1791 
1792  Ptr<ThresholdPreambleDetectionModel> preambleDetectionModel = CreateObject<ThresholdPreambleDetectionModel> ();
1793  preambleDetectionModel->SetAttribute ("Threshold", DoubleValue (2));
1794  m_phy->SetPreambleDetectionModel (preambleDetectionModel);
1795 
1796  Ptr<SimpleFrameCaptureModel> frameCaptureModel = CreateObject<SimpleFrameCaptureModel> ();
1797  frameCaptureModel->SetAttribute ("Margin", DoubleValue (5));
1798  frameCaptureModel->SetAttribute ("CaptureWindow", TimeValue (MicroSeconds (16)));
1799  m_phy->SetFrameCaptureModel (frameCaptureModel);
1800 }
1801 
1802 void
1804 {
1805  m_phy->Dispose ();
1806  m_phy = 0;
1807 }
1808 
1809 void
1811 {
1812  RngSeedManager::SetSeed (1);
1813  RngSeedManager::SetRun (2);
1814  int64_t streamNumber = 1;
1815  double rxPowerDbm = -30;
1816  m_phy->AssignStreams (streamNumber);
1817 
1819  // CASE 1: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity.
1820  // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection).
1822 
1823  // A-MPDU 1
1824  Simulator::Schedule (Seconds (1.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1000);
1825 
1826  // A-MPDU 2
1827  Simulator::Schedule (Seconds (1.0) + MicroSeconds (2), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
1828 
1829  // All MPDUs of A-MPDU 1 should have been ignored.
1830  Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
1831  Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1832  Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1833 
1834  // All MPDUs of A-MPDU 2 should have been successfully received.
1835  Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111);
1836  Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1837  Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1838 
1839  Simulator::Schedule (Seconds (1.2), &TestAmpduReception::ResetBitmaps, this);
1840 
1842  // CASE 2: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity.
1843  // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection).
1845 
1846  // A-MPDU 1
1847  Simulator::Schedule (Seconds (2.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
1848 
1849  // A-MPDU 2
1850  Simulator::Schedule (Seconds (2.0) + MicroSeconds (2), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1300);
1851 
1852  // All MPDUs of A-MPDU 1 should have been received.
1853  Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
1854  Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1855  Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1856 
1857  // All MPDUs of A-MPDU 2 should have been ignored.
1858  Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
1859  Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1860  Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1861 
1862  Simulator::Schedule (Seconds (2.2), &TestAmpduReception::ResetBitmaps, this);
1863 
1865  // CASE 3: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity.
1866  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
1868 
1869  // A-MPDU 1
1870  Simulator::Schedule (Seconds (3.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1000);
1871 
1872  // A-MPDU 2
1873  Simulator::Schedule (Seconds (3.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
1874 
1875  // All MPDUs of A-MPDU 1 should have been ignored.
1876  Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
1877  Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1878  Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1879 
1880  // All MPDUs of A-MPDU 2 should have been successfully received.
1881  Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111);
1882  Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1883  Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1884 
1885  Simulator::Schedule (Seconds (3.2), &TestAmpduReception::ResetBitmaps, this);
1886 
1888  // CASE 4: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity.
1889  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
1891 
1892  // A-MPDU 1
1893  Simulator::Schedule (Seconds (4.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
1894 
1895  // A-MPDU 2
1896  Simulator::Schedule (Seconds (4.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1300);
1897 
1898  // All MPDUs of A-MPDU 1 should have been received.
1899  Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
1900  Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1901  Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1902 
1903  // All MPDUs of A-MPDU 2 should have been ignored.
1904  Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
1905  Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1906  Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1907 
1908  Simulator::Schedule (Seconds (4.2), &TestAmpduReception::ResetBitmaps, this);
1909 
1911  // CASE 5: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity.
1912  // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. after the frame capture window, during the payload of MPDU #1).
1914 
1915  // A-MPDU 1
1916  Simulator::Schedule (Seconds (5.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1000);
1917 
1918  // A-MPDU 2
1919  Simulator::Schedule (Seconds (5.0) + MicroSeconds (100), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
1920 
1921  // All MPDUs of A-MPDU 1 should have been ignored.
1922  Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
1923  Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1924  Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1925 
1926  // All MPDUs of A-MPDU 2 should have been successfully received.
1927  Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111);
1928  Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1929  Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1930 
1931  Simulator::Schedule (Seconds (5.2), &TestAmpduReception::ResetBitmaps, this);
1932 
1934  // CASE 6: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity.
1935  // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. after the frame capture window, during the payload of MPDU #1).
1937 
1938  // A-MPDU 1
1939  Simulator::Schedule (Seconds (6.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
1940 
1941  // A-MPDU 2
1942  Simulator::Schedule (Seconds (6.0) + MicroSeconds (100), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1300);
1943 
1944  // All MPDUs of A-MPDU 1 should have been received.
1945  Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
1946  Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1947  Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1948 
1949  // All MPDUs of A-MPDU 2 should have been ignored.
1950  Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
1951  Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1952  Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1953 
1954  Simulator::Schedule (Seconds (6.2), &TestAmpduReception::ResetBitmaps, this);
1955 
1957  // CASE 7: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity.
1958  // The second A-MPDU is received during the payload of MPDU #2.
1960 
1961  // A-MPDU 1
1962  Simulator::Schedule (Seconds (7.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1000);
1963 
1964  // A-MPDU 2
1965  Simulator::Schedule (Seconds (7.0) + NanoSeconds (1100000), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
1966 
1967  // All MPDUs of A-MPDU 1 should have been ignored.
1968  Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
1969  Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1970  Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1971 
1972  // All MPDUs of A-MPDU 2 should have been successfully received.
1973  Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111);
1974  Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1975  Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1976 
1977  Simulator::Schedule (Seconds (7.2), &TestAmpduReception::ResetBitmaps, this);
1978 
1980  // CASE 8: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity.
1981  // The second A-MPDU is received during the payload of MPDU #2.
1983 
1984  // A-MPDU 1
1985  Simulator::Schedule (Seconds (8.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
1986 
1987  // A-MPDU 2
1988  Simulator::Schedule (Seconds (8.0) + NanoSeconds (1100000), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm - 100, 1300);
1989 
1990  // All MPDUs of A-MPDU 1 should have been received.
1991  Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
1992  Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
1993  Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
1994 
1995  // All MPDUs of A-MPDU 2 should have been ignored.
1996  Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
1997  Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
1998  Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
1999 
2000  Simulator::Schedule (Seconds (8.2), &TestAmpduReception::ResetBitmaps, this);
2001 
2003  // CASE 9: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 3 dB higher.
2004  // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection).
2006 
2007  // A-MPDU 1
2008  Simulator::Schedule (Seconds (9.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2009 
2010  // A-MPDU 2
2011  Simulator::Schedule (Seconds (9.0) + MicroSeconds (2), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 3, 1300);
2012 
2013  // All MPDUs of A-MPDU 1 should have been dropped.
2014  Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2015  Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2016  Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2017 
2018  // All MPDUs of A-MPDU 2 should have been received with errors.
2019  Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2020  Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000111);
2021  Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
2022 
2023  Simulator::Schedule (Seconds (9.2), &TestAmpduReception::ResetBitmaps, this);
2024 
2026  // CASE 10: receive two A-MPDUs (containing each 3 MPDUs) with the same power.
2027  // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection).
2029 
2030  // A-MPDU 1
2031  Simulator::Schedule (Seconds (10.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2032 
2033  // A-MPDU 2
2034  Simulator::Schedule (Seconds (10.0) + MicroSeconds (2), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2035 
2036  // All MPDUs of A-MPDU 1 should have been dropped (preamble detection failed).
2037  Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2038  Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2039  Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2040 
2041  // All MPDUs of A-MPDU 2 should have been dropped as well.
2042  Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2043  Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2044  Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2045 
2046  Simulator::Schedule (Seconds (10.2), &TestAmpduReception::ResetBitmaps, this);
2047 
2049  // CASE 11: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 3 dB higher.
2050  // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection).
2052 
2053  // A-MPDU 1
2054  Simulator::Schedule (Seconds (11.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 3, 1000);
2055 
2056  // A-MPDU 2
2057  Simulator::Schedule (Seconds (11.0) + MicroSeconds (2), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2058 
2059  // All MPDUs of A-MPDU 1 should have been received with errors.
2060  Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2061  Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111);
2062  Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2063 
2064  // All MPDUs of A-MPDU 2 should have been dropped.
2065  Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2066  Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2067  Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2068 
2069  Simulator::Schedule (Seconds (11.2), &TestAmpduReception::ResetBitmaps, this);
2070 
2072  // CASE 12: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 3 dB higher.
2073  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
2075 
2076  // A-MPDU 1
2077  Simulator::Schedule (Seconds (12.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2078 
2079  // A-MPDU 2
2080  Simulator::Schedule (Seconds (12.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 3, 1300);
2081 
2082  // All MPDUs of A-MPDU 1 should have been received with errors (PHY header reception failed and thus incorrect decoding of payload).
2083  Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2084  Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2085  Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2086 
2087  // All MPDUs of A-MPDU 2 should have been dropped (even though TX power is higher, it is not high enough to get the PHY reception switched)
2088  Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2089  Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2090  Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2091 
2092  Simulator::Schedule (Seconds (12.2), &TestAmpduReception::ResetBitmaps, this);
2093 
2095  // CASE 13: receive two A-MPDUs (containing each 3 MPDUs) with the same power.
2096  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
2098 
2099  // A-MPDU 1
2100  Simulator::Schedule (Seconds (13.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2101 
2102  // A-MPDU 2
2103  Simulator::Schedule (Seconds (13.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2104 
2105  // All MPDUs of A-MPDU 1 should have been received with errors (PHY header reception failed and thus incorrect decoding of payload).
2106  Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2107  Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2108  Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2109 
2110  // All MPDUs of A-MPDU 2 should have been dropped as well.
2111  Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2112  Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2113  Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2114 
2115  Simulator::Schedule (Seconds (13.2), &TestAmpduReception::ResetBitmaps, this);
2116 
2118  // CASE 14: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 3 dB higher.
2119  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
2121 
2122  // A-MPDU 1
2123  Simulator::Schedule (Seconds (14.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 3, 1000);
2124 
2125  // A-MPDU 2
2126  Simulator::Schedule (Seconds (14.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2127 
2128  // All MPDUs of A-MPDU 1 should have been received with errors.
2129  Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2130  Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111);
2131  Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2132 
2133  // All MPDUs of A-MPDU 2 should have been dropped.
2134  Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2135  Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2136  Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2137 
2138  Simulator::Schedule (Seconds (14.2), &TestAmpduReception::ResetBitmaps, this);
2139 
2141  // CASE 15: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 6 dB higher.
2142  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
2144 
2145  // A-MPDU 1
2146  Simulator::Schedule (Seconds (15.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2147 
2148  // A-MPDU 2
2149  Simulator::Schedule (Seconds (15.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 6, 1300);
2150 
2151  // All MPDUs of A-MPDU 1 should have been dropped because PHY reception switched to A-MPDU 2.
2152  Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2153  Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2154  Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2155 
2156  // All MPDUs of A-MPDU 2 should have been successfully received
2157  Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111);
2158  Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2159  Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000);
2160 
2161  Simulator::Schedule (Seconds (15.2), &TestAmpduReception::ResetBitmaps, this);
2162 
2164  // CASE 16: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 6 dB higher.
2165  // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window).
2167 
2168  // A-MPDU 1
2169  Simulator::Schedule (Seconds (16.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 6, 1000);
2170 
2171  // A-MPDU 2
2172  Simulator::Schedule (Seconds (16.0) + MicroSeconds (10), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2173 
2174  // All MPDUs of A-MPDU 1 should have been successfully received.
2175  Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
2176  Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2177  Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2178 
2179  // All MPDUs of A-MPDU 2 should have been dropped.
2180  Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2181  Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2182  Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2183 
2184  Simulator::Schedule (Seconds (16.2), &TestAmpduReception::ResetBitmaps, this);
2185 
2187  // CASE 17: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 6 dB higher.
2188  // The second A-MPDU is received 25 microseconds after the first A-MPDU (i.e. after the frame capture window, but still during PHY header).
2190 
2191  // A-MPDU 1
2192  Simulator::Schedule (Seconds (17.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2193 
2194  // A-MPDU 2
2195  Simulator::Schedule (Seconds (17.0) + MicroSeconds (25), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 6, 1300);
2196 
2197  // All MPDUs of A-MPDU 1 should have been received with errors.
2198  Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2199  Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2200  Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2201 
2202  // All MPDUs of A-MPDU 2 should have been dropped (no reception switch, MPDUs dropped because PHY is already in RX state).
2203  Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2204  Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2205  Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2206 
2207  Simulator::Schedule (Seconds (17.2), &TestAmpduReception::ResetBitmaps, this);
2208 
2210  // CASE 18: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 6 dB higher.
2211  // The second A-MPDU is received 25 microseconds after the first A-MPDU (i.e. after the frame capture window, but still during PHY header).
2213 
2214  // A-MPDU 1
2215  Simulator::Schedule (Seconds (18.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 6, 1000);
2216 
2217  // A-MPDU 2
2218  Simulator::Schedule (Seconds (18.0) + MicroSeconds (25), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2219 
2220  // All MPDUs of A-MPDU 1 should have been successfully received.
2221  Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
2222  Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2223  Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2224 
2225  // All MPDUs of A-MPDU 2 should have been dropped.
2226  Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2227  Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2228  Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2229 
2230  Simulator::Schedule (Seconds (18.2), &TestAmpduReception::ResetBitmaps, this);
2231 
2233  // CASE 19: receive two A-MPDUs (containing each 3 MPDUs) with the same power.
2234  // The second A-MPDU is received 25 microseconds after the first A-MPDU (i.e. after the frame capture window, but still during PHY header).
2236 
2237  // A-MPDU 1
2238  Simulator::Schedule (Seconds (19.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2239 
2240  // A-MPDU 2
2241  Simulator::Schedule (Seconds (19.0) + MicroSeconds (25), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2242 
2243  // All MPDUs of A-MPDU 1 should have been received with errors.
2244  Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2245  Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2246  Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111);
2247 
2248  // All MPDUs of A-MPDU 2 should have been dropped.
2249  Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2250  Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2251  Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2252 
2253  Simulator::Schedule (Seconds (19.2), &TestAmpduReception::ResetBitmaps, this);
2254 
2256  // CASE 20: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 6 dB higher.
2257  // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. during the payload of MPDU #1).
2259 
2260  // A-MPDU 1
2261  Simulator::Schedule (Seconds (20.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2262 
2263  // A-MPDU 2
2264  Simulator::Schedule (Seconds (20.0) + MicroSeconds (100), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 6, 1300);
2265 
2266  // All MPDUs of A-MPDU 1 should have been received with errors.
2267  Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2268  Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111);
2269  Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2270 
2271  // All MPDUs of A-MPDU 2 should have been dropped (no reception switch, MPDUs dropped because PHY is already in RX state).
2272  Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2273  Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2274  Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2275 
2276  Simulator::Schedule (Seconds (20.2), &TestAmpduReception::ResetBitmaps, this);
2277 
2279  // CASE 21: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 6 dB higher.
2280  // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. during the payload of MPDU #1).
2282 
2283  // A-MPDU 1
2284  Simulator::Schedule (Seconds (21.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm + 6, 1000);
2285 
2286  // A-MPDU 2
2287  Simulator::Schedule (Seconds (21.0) + MicroSeconds (100), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2288 
2289  // All MPDUs of A-MPDU 1 should have been successfully received.
2290  Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111);
2291  Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000);
2292  Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2293 
2294  // All MPDUs of A-MPDU 2 should have been dropped.
2295  Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2296  Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2297  Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2298 
2299  Simulator::Schedule (Seconds (21.2), &TestAmpduReception::ResetBitmaps, this);
2300 
2302  // CASE 22: receive two A-MPDUs (containing each 3 MPDUs) with the same power.
2303  // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. during the payload of MPDU #1).
2305 
2306  // A-MPDU 1
2307  Simulator::Schedule (Seconds (22.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2308 
2309  // A-MPDU 2
2310  Simulator::Schedule (Seconds (22.0) + MicroSeconds (100), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2311 
2312  // All MPDUs of A-MPDU 1 should have been received with errors.
2313  Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000);
2314  Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111);
2315  Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2316 
2317  // All MPDUs of A-MPDU 2 should have been dropped.
2318  Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2319  Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2320  Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2321 
2322  Simulator::Schedule (Seconds (22.2), &TestAmpduReception::ResetBitmaps, this);
2323 
2325  // CASE 23: receive two A-MPDUs (containing each 3 MPDUs) with the same power.
2326  // The second A-MPDU is received during the payload of MPDU #2.
2328 
2329  // A-MPDU 1
2330  Simulator::Schedule (Seconds (23.0), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1000);
2331 
2332  // A-MPDU 2
2333  Simulator::Schedule (Seconds (23.0) + NanoSeconds (1100000), &TestAmpduReception::SendAmpduWithThreeMpdus, this, rxPowerDbm, 1300);
2334 
2335  // The first MPDU of A-MPDU 1 should have been successfully received (no interference).
2336  // The two other MPDUs failed due to interference and are marked as failure (and dropped).
2337  Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000001);
2338  Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000110);
2339  Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000);
2340 
2341  // The two first MPDUs of A-MPDU 2 are dropped because PHY is already in RX state (receiving A-MPDU 1).
2342  // The last MPDU of A-MPDU 2 is interference free (A-MPDU 1 transmission is finished) but is dropped because its PHY preamble and header were not received.
2343  Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000);
2344  Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000);
2345  Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111);
2346 
2347  Simulator::Schedule (Seconds (23.2), &TestAmpduReception::ResetBitmaps, this);
2348 
2349  Simulator::Run ();
2350  Simulator::Destroy ();
2351 }
2352 
2374 {
2375 public:
2381 
2388  void Dropped (std::string context, Ptr<const Packet> packet, WifiPhyRxfailureReason reason);
2392  void CheckResults (void);
2393 
2394 private:
2395  void DoRun (void) override;
2396  uint16_t m_dropped;
2397 };
2398 
2400  : TestCase ("Check correct behavior when a STA is receiving a transmission using an unsupported modulation"),
2401  m_dropped (0)
2402 {
2403 }
2404 
2406 {
2407 }
2408 
2409 void
2411  WifiPhyRxfailureReason reason)
2412 {
2413  // Print if the test is executed through test-runner
2414  if (reason == RXING)
2415  {
2416  std::cout << "Dropped a packet because already receiving" << std::endl;
2417  m_dropped++;
2418  }
2419 }
2420 
2421 void
2423 {
2424  uint16_t m_nStations = 2;
2425  NetDeviceContainer m_staDevices;
2426  NetDeviceContainer m_apDevices;
2427 
2428  // RngSeedManager::SetSeed (1);
2429  // RngSeedManager::SetRun (40);
2430  int64_t streamNumber = 100;
2431 
2433  wifiApNode.Create (1);
2434 
2436  wifiStaNodes.Create (m_nStations);
2437 
2438  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
2439  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
2440  spectrumChannel->AddPropagationLossModel (lossModel);
2442  CreateObject<ConstantSpeedPropagationDelayModel> ();
2443  spectrumChannel->SetPropagationDelayModel (delayModel);
2444 
2446  phy.SetChannel (spectrumChannel);
2447 
2448  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", UintegerValue (65535));
2449 
2450  WifiHelper wifi;
2451  wifi.SetRemoteStationManager ("ns3::IdealWifiManager");
2452 
2454  mac.SetType ("ns3::StaWifiMac", "QosSupported", BooleanValue (true), "Ssid",
2455  SsidValue (Ssid ("non-existent-ssid")));
2456 
2457  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
2458  m_staDevices.Add (wifi.Install (phy, mac, wifiStaNodes.Get (0)));
2459  wifi.SetStandard (WIFI_STANDARD_80211ac);
2460  m_staDevices.Add (wifi.Install (phy, mac, wifiStaNodes.Get (1)));
2461 
2462  wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
2463  mac.SetType ("ns3::ApWifiMac", "QosSupported", BooleanValue (true), "Ssid",
2464  SsidValue (Ssid ("wifi-backoff-ssid")), "BeaconInterval",
2465  TimeValue (MicroSeconds (102400)), "EnableBeaconJitter", BooleanValue (false));
2466 
2467  m_apDevices = wifi.Install (phy, mac, wifiApNode);
2468 
2469  // schedule association requests at different times
2470  Time init = MilliSeconds (100);
2471  Ptr<WifiNetDevice> dev;
2472 
2473  for (uint16_t i = 0; i < m_nStations; i++)
2474  {
2475  dev = DynamicCast<WifiNetDevice> (m_staDevices.Get (i));
2476  Simulator::Schedule (init + i * MicroSeconds (102400), &WifiMac::SetSsid, dev->GetMac (),
2477  Ssid ("wifi-backoff-ssid"));
2478  }
2479 
2480  // Assign fixed streams to random variables in use
2481  wifi.AssignStreams (m_apDevices, streamNumber);
2482 
2484  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
2485 
2486  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
2487  positionAlloc->Add (Vector (1.0, 0.0, 0.0));
2488  positionAlloc->Add (Vector (0.0, 1.0, 0.0));
2489  positionAlloc->Add (Vector (-1.0, 0.0, 0.0));
2490  mobility.SetPositionAllocator (positionAlloc);
2491 
2492  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
2493  mobility.Install (wifiApNode);
2494  mobility.Install (wifiStaNodes);
2495 
2496  // set the TXOP limit on BE AC
2497  dev = DynamicCast<WifiNetDevice> (m_apDevices.Get (0));
2498  PointerValue ptr;
2499  dev->GetMac ()->GetAttribute ("BE_Txop", ptr);
2500 
2501  PacketSocketHelper packetSocket;
2502  packetSocket.Install (wifiApNode);
2503  packetSocket.Install (wifiStaNodes);
2504 
2505  // UL Traffic
2506  for (uint16_t i = 0; i < m_nStations; i++)
2507  {
2508  PacketSocketAddress socket;
2509  socket.SetSingleDevice (m_staDevices.Get (0)->GetIfIndex ());
2510  socket.SetPhysicalAddress (m_apDevices.Get (0)->GetAddress ());
2511  socket.SetProtocol (1);
2512  Ptr<PacketSocketClient> client = CreateObject<PacketSocketClient> ();
2513  client->SetAttribute ("PacketSize", UintegerValue (1500));
2514  client->SetAttribute ("MaxPackets", UintegerValue (200));
2515  client->SetAttribute ("Interval", TimeValue (MicroSeconds (0)));
2516  client->SetRemote (socket);
2517  wifiStaNodes.Get (i)->AddApplication (client);
2518  client->SetStartTime (MicroSeconds (400000));
2519  client->SetStopTime (Seconds (1.0));
2520  Ptr<PacketSocketClient> legacyStaClient = CreateObject<PacketSocketClient> ();
2521  legacyStaClient->SetAttribute ("PacketSize", UintegerValue (1500));
2522  legacyStaClient->SetAttribute ("MaxPackets", UintegerValue (200));
2523  legacyStaClient->SetAttribute ("Interval", TimeValue (MicroSeconds (0)));
2524  legacyStaClient->SetRemote (socket);
2525  wifiStaNodes.Get (i)->AddApplication (legacyStaClient);
2526  legacyStaClient->SetStartTime (MicroSeconds (400000));
2527  legacyStaClient->SetStopTime (Seconds (1.0));
2528  Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> ();
2529  server->SetLocal (socket);
2530  wifiApNode.Get (0)->AddApplication (server);
2531  server->SetStartTime (Seconds (0.0));
2532  server->SetStopTime (Seconds (1.0));
2533  }
2534 
2535  // Trace dropped packets
2536  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
2538 
2539  Simulator::Stop (Seconds (1));
2540  Simulator::Run ();
2541 
2542  CheckResults ();
2543 
2544  Simulator::Destroy ();
2545 }
2546 
2547 void
2549 {
2550  NS_TEST_EXPECT_MSG_EQ (m_dropped, 0, "Dropped some packets unexpectedly");
2551 }
2552 
2560 {
2561 public:
2563 };
2564 
2566  : TestSuite ("wifi-phy-reception", UNIT)
2567 {
2570  AddTestCase (new TestSimpleFrameCaptureModel, TestCase::QUICK);
2571  AddTestCase (new TestPhyHeadersReception, TestCase::QUICK);
2572  AddTestCase (new TestAmpduReception, TestCase::QUICK);
2573  AddTestCase (new TestUnsupportedModulationReception (), TestCase::QUICK);
2574 }
2575 
ns3::SpectrumChannel::SetPropagationDelayModel
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
Set the propagation delay model to be used.
Definition: spectrum-channel.cc:139
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition: net-device-container.h:42
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::SpectrumSignalParameters::psd
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
Definition: spectrum-signal-parameters.h:94
TestSimpleFrameCaptureModel::m_rxSuccess1500B
bool m_rxSuccess1500B
count received packets with 1500B payload
Definition: wifi-phy-reception-test.cc:995
TestThresholdPreambleDetectionWithFrameCapture::DoSetup
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:568
FREQUENCY
static const uint32_t FREQUENCY
Definition: wifi-phy-reception-test.cc:56
TestAmpduReception::DoSetup
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:1779
TestAmpduReception::DoTeardown
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:1803
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
TestSimpleFrameCaptureModel::SendPacket
void SendPacket(double rxPowerDbm, uint32_t packetSize)
Send packet function.
Definition: wifi-phy-reception-test.cc:1013
ns3::ListPositionAllocator::Add
void Add(Vector v)
Add a position to the list of positions.
Definition: position-allocator.cc:70
ns3::Object::Dispose
void Dispose(void)
Dispose of this Object.
Definition: object.cc:214
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
TestThresholdPreambleDetectionWithFrameCapture::TestThresholdPreambleDetectionWithFrameCapture
TestThresholdPreambleDetectionWithFrameCapture()
Definition: wifi-phy-reception-test.cc:486
ns3::BooleanValue
AttributeValue implementation for Boolean.
Definition: boolean.h:37
ns3::SpectrumChannel::AddPropagationLossModel
void AddPropagationLossModel(Ptr< PropagationLossModel > loss)
Add the single-frequency propagation loss model to be used.
Definition: spectrum-channel.cc:117
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
TestAmpduReception::~TestAmpduReception
virtual ~TestAmpduReception()
Definition: wifi-phy-reception-test.cc:1560
ns3::NetDevice::GetAddress
virtual Address GetAddress(void) const =0
ns3::SpectrumWifiPhy::StartRx
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
Definition: spectrum-wifi-phy.cc:283
TestPhyHeadersReception::DoSetup
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:1281
ns3::SpectrumWifiPhy::SetChannelNumber
void SetChannelNumber(uint8_t id) override
Set channel number.
Definition: spectrum-wifi-phy.cc:239
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
RX
@ RX
The PHY layer is receiving a packet.
Definition: wifi-phy-state.h:48
ns3::WifiPhy::CalculateTxDuration
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Definition: wifi-phy.cc:1610
ns3::WifiHelper
helps to create WifiNetDevice objects
Definition: wifi-helper.h:327
TestPhyHeadersReception::TestPhyHeadersReception
TestPhyHeadersReception()
Definition: wifi-phy-reception-test.cc:1222
TestAmpduReception::m_uid
uint64_t m_uid
UID.
Definition: wifi-phy-reception-test.cc:1545
ns3::WifiPsdu::end
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
Definition: wifi-psdu.cc:337
TestThresholdPreambleDetectionWithFrameCapture::CheckRxPacketCount
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
Definition: wifi-phy-reception-test.cc:541
ns3::MicroSeconds
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1305
TestAmpduReception::CheckRxDroppedBitmapAmpdu1
void CheckRxDroppedBitmapAmpdu1(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 1.
Definition: wifi-phy-reception-test.cc:1724
IDLE
@ IDLE
The PHY layer is IDLE.
Definition: wifi-phy-state.h:36
ns3::WifiPhyStateHelper::GetState
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
Definition: wifi-phy-state-helper.cc:196
TestSimpleFrameCaptureModel::DoSetup
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:1107
TestSimpleFrameCaptureModel::Expect1500BPacketDropped
void Expect1500BPacketDropped()
Verify whether 1500 bytes packet has been dropped.
Definition: wifi-phy-reception-test.cc:1096
WifiPhyReceptionTestSuite::WifiPhyReceptionTestSuite
WifiPhyReceptionTestSuite()
Definition: wifi-phy-reception-test.cc:2565
ns3::WIFI_PHY_BAND_5GHZ
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Definition: wifi-phy-band.h:37
TestSimpleFrameCaptureModel::Expect1000BPacketDropped
void Expect1000BPacketDropped()
Verify whether 1000 bytes packet has been dropped.
Definition: wifi-phy-reception-test.cc:1090
ns3::WIFI_STANDARD_80211ax_5GHZ
@ WIFI_STANDARD_80211ax_5GHZ
Definition: wifi-standards.h:135
TestSimpleFrameCaptureModel::RxDropped
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
Definition: wifi-phy-reception-test.cc:1056
TestThresholdPreambleDetectionWithoutFrameCapture::RxFailure
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
Definition: wifi-phy-reception-test.cc:191
TestThresholdPreambleDetectionWithoutFrameCapture::m_countRxFailure
uint32_t m_countRxFailure
count RX failure
Definition: wifi-phy-reception-test.cc:96
TestThresholdPreambleDetectionWithoutFrameCapture::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-phy-reception-test.cc:228
TestAmpduReception::CheckRxSuccessBitmapAmpdu2
void CheckRxSuccessBitmapAmpdu2(uint8_t expected)
Check the RX success bitmap for A-MPDU 2.
Definition: wifi-phy-reception-test.cc:1706
ns3::SpectrumSignalParameters::txPhy
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
Definition: spectrum-signal-parameters.h:107
TestThresholdPreambleDetectionWithFrameCapture
Preamble detection test w/o frame capture.
Definition: wifi-phy-reception-test.cc:432
TestAmpduReception::ResetBitmaps
void ResetBitmaps()
Reset bitmaps function.
Definition: wifi-phy-reception-test.cc:1566
ns3::PointerValue
Hold objects of type Ptr<T>.
Definition: pointer.h:37
ns3::PacketSocketAddress
an address for a packet socket
Definition: packet-socket-address.h:39
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
ns3::SpectrumWifiPhy::ConfigureStandardAndBand
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
Definition: spectrum-wifi-phy.cc:272
TestAmpduReception::CheckRxSuccessBitmapAmpdu1
void CheckRxSuccessBitmapAmpdu1(uint8_t expected)
Check the RX success bitmap for A-MPDU 1.
Definition: wifi-phy-reception-test.cc:1700
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition: wifi-tx-vector.h:71
third.mac
mac
Definition: third.py:99
TestThresholdPreambleDetectionWithoutFrameCapture::~TestThresholdPreambleDetectionWithoutFrameCapture
virtual ~TestThresholdPreambleDetectionWithoutFrameCapture()
Definition: wifi-phy-reception-test.cc:197
ns3::WifiPhy::SetReceiveOkCallback
void SetReceiveOkCallback(RxOkCallback callback)
Definition: wifi-phy.cc:635
ns3::PacketSocketClient::SetRemote
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
Definition: packet-socket-client.cc:91
ns3::WIFI_PREAMBLE_HE_SU
@ WIFI_PREAMBLE_HE_SU
Definition: wifi-phy-common.h:74
TestThresholdPreambleDetectionWithFrameCapture::~TestThresholdPreambleDetectionWithFrameCapture
virtual ~TestThresholdPreambleDetectionWithFrameCapture()
Definition: wifi-phy-reception-test.cc:562
TestUnsupportedModulationReception
Unsupported Modulation Reception Test This test creates a mixed network, in which an HE STA and a VHT...
Definition: wifi-phy-reception-test.cc:2374
TestThresholdPreambleDetectionWithoutFrameCapture::m_phy
Ptr< SpectrumWifiPhy > m_phy
Phy.
Definition: wifi-phy-reception-test.cc:75
CCA_BUSY
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
Definition: wifi-phy-state.h:40
TestPhyHeadersReception::~TestPhyHeadersReception
virtual ~TestPhyHeadersReception()
Definition: wifi-phy-reception-test.cc:1275
CHANNEL_WIDTH
static const uint16_t CHANNEL_WIDTH
Definition: wifi-phy-reception-test.cc:57
TestAmpduReception::TestAmpduReception
TestAmpduReception()
Definition: wifi-phy-reception-test.cc:1548
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
TestThresholdPreambleDetectionWithFrameCapture::m_uid
uint64_t m_uid
the UID to use for the PPDU
Definition: wifi-phy-reception-test.cc:483
TestPhyHeadersReception::m_uid
uint64_t m_uid
the UID to use for the PPDU
Definition: wifi-phy-reception-test.cc:1219
TestThresholdPreambleDetectionWithFrameCapture::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-phy-reception-test.cc:598
TestThresholdPreambleDetectionWithFrameCapture::RxSuccess
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
Definition: wifi-phy-reception-test.cc:548
ns3::SsidValue
AttributeValue implementation for Ssid.
Definition: ssid.h:105
ns3::Ssid
The IEEE 802.11 SSID Information Element.
Definition: ssid.h:36
ns3::RXING
@ RXING
Definition: wifi-phy-common.h:267
TestPhyHeadersReception::DoTeardown
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:1292
ns3::TestCase
encapsulates test code
Definition: test.h:1154
TestPhyHeadersReception
Test PHY state upon success or failure of L-SIG and SIG-A.
Definition: wifi-phy-reception-test.cc:1190
TestThresholdPreambleDetectionWithFrameCapture::SendPacket
void SendPacket(double rxPowerDbm)
Send packet function.
Definition: wifi-phy-reception-test.cc:495
TestThresholdPreambleDetectionWithoutFrameCapture::CheckRxPacketCount
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
Definition: wifi-phy-reception-test.cc:176
TestAmpduReception::CheckRxDroppedBitmapAmpdu2
void CheckRxDroppedBitmapAmpdu2(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 2.
Definition: wifi-phy-reception-test.cc:1730
ns3::WifiMacHeader
Implements the IEEE 802.11 MAC header.
Definition: wifi-mac-header.h:85
ns3::Application::SetStopTime
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
TestThresholdPreambleDetectionWithFrameCapture::DoTeardown
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:591
ns3::PacketSocketHelper::Install
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Definition: packet-socket-helper.cc:37
TestSimpleFrameCaptureModel::m_rxDropped1500B
bool m_rxDropped1500B
count dropped packets with 1500B payload
Definition: wifi-phy-reception-test.cc:997
TestUnsupportedModulationReception::TestUnsupportedModulationReception
TestUnsupportedModulationReception()
Constructor.
Definition: wifi-phy-reception-test.cc:2399
third.wifi
wifi
Definition: third.py:96
ns3::Ptr< SpectrumWifiPhy >
TestThresholdPreambleDetectionWithoutFrameCapture::DoTeardown
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:221
ns3::WIFI_PHY_STANDARD_80211ax
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
Definition: wifi-standards.h:49
ns3::WifiPhyStateHelper
This objects implements the PHY state machine of the Wifi device.
Definition: wifi-phy-state-helper.h:66
ns3::Application::SetStartTime
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
ns3::WifiPhyRxfailureReason
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
Definition: wifi-phy-common.h:263
TestSimpleFrameCaptureModel::DoTeardown
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:1130
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
TestThresholdPreambleDetectionWithFrameCapture::DoCheckPhyState
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
Definition: wifi-phy-reception-test.cc:529
TestPhyHeadersReception::CheckPhyState
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Definition: wifi-phy-reception-test.cc:1256
ns3::WifiPhy::SetReceiveErrorCallback
void SetReceiveErrorCallback(RxErrorCallback callback)
Definition: wifi-phy.cc:641
ns3::NanoSeconds
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1313
TestAmpduReception::IncrementFailureBitmap
void IncrementFailureBitmap(uint32_t size)
Increment reception failure bitmap.
Definition: wifi-phy-reception-test.cc:1641
TestThresholdPreambleDetectionWithoutFrameCapture::m_uid
uint64_t m_uid
the UID to use for the PPDU
Definition: wifi-phy-reception-test.cc:118
ns3::ObjectBase::GetAttribute
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:223
TestSimpleFrameCaptureModel::m_phy
Ptr< SpectrumWifiPhy > m_phy
Phy.
Definition: wifi-phy-reception-test.cc:992
TestThresholdPreambleDetectionWithoutFrameCapture
Preamble detection test w/o frame capture.
Definition: wifi-phy-reception-test.cc:67
TestAmpduReception::m_rxFailureBitmapAmpdu1
uint8_t m_rxFailureBitmapAmpdu1
bitmap of unsuccessfully received MPDUs in A-MPDU #1
Definition: wifi-phy-reception-test.cc:1539
ns3::MilliSeconds
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1297
TestThresholdPreambleDetectionWithFrameCapture::CheckPhyState
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Definition: wifi-phy-reception-test.cc:522
CHANNEL_NUMBER
static const uint8_t CHANNEL_NUMBER
Definition: wifi-phy-reception-test.cc:55
TestSimpleFrameCaptureModel::Expect1000BPacketReceived
void Expect1000BPacketReceived()
Verify whether 1000 bytes packet has been received.
Definition: wifi-phy-reception-test.cc:1079
TestUnsupportedModulationReception::~TestUnsupportedModulationReception
virtual ~TestUnsupportedModulationReception()
Definition: wifi-phy-reception-test.cc:2405
ns3::WifiPsdu::GetSize
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
Definition: wifi-psdu.cc:260
TestAmpduReception::SendAmpduWithThreeMpdus
void SendAmpduWithThreeMpdus(double rxPowerDbm, uint32_t referencePacketSize)
Send A-MPDU with 3 MPDUs of different size (i-th MSDU will have 100 bytes more than (i-1)-th).
Definition: wifi-phy-reception-test.cc:1747
SendPacket
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
Definition: wifi-trans-example.cc:48
ns3::PointerValue::Get
Ptr< T > Get(void) const
Definition: pointer.h:201
ns3::WifiPsdu::GetNMpdus
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Definition: wifi-psdu.cc:319
ns3::WifiPhy::GetPhyBand
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
Definition: wifi-phy.cc:1124
ns3::WifiSpectrumSignalParameters::ppdu
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
Definition: wifi-spectrum-signal-parameters.h:53
NS_TEST_EXPECT_MSG_EQ
#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
TestAmpduReception::m_rxSuccessBitmapAmpdu2
uint8_t m_rxSuccessBitmapAmpdu2
bitmap of successfully received MPDUs in A-MPDU #2
Definition: wifi-phy-reception-test.cc:1537
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
TestAmpduReception::m_rxSuccessBitmapAmpdu1
uint8_t m_rxSuccessBitmapAmpdu1
bitmap of successfully received MPDUs in A-MPDU #1
Definition: wifi-phy-reception-test.cc:1536
TestAmpduReception::m_rxFailureBitmapAmpdu2
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfully received MPDUs in A-MPDU #2
Definition: wifi-phy-reception-test.cc:1540
third.wifiApNode
wifiApNode
Definition: third.py:90
TestThresholdPreambleDetectionWithoutFrameCapture::CheckPhyState
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Definition: wifi-phy-reception-test.cc:157
NS_ABORT_MSG_IF
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
ns3::SpectrumSignalParameters::duration
Time duration
The duration of the packet transmission.
Definition: spectrum-signal-parameters.h:102
TestAmpduReception::CheckRxFailureBitmapAmpdu2
void CheckRxFailureBitmapAmpdu2(uint8_t expected)
Check the RX failure bitmap for A-MPDU 2.
Definition: wifi-phy-reception-test.cc:1718
TestUnsupportedModulationReception::CheckResults
void CheckResults(void)
Check correctness of transmitted frames.
Definition: wifi-phy-reception-test.cc:2548
ns3::PacketSocketAddress::SetSingleDevice
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Definition: packet-socket-address.cc:46
TestThresholdPreambleDetectionWithoutFrameCapture::DoCheckPhyState
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
Definition: wifi-phy-reception-test.cc:164
TestAmpduReception
A-MPDU reception test.
Definition: wifi-phy-reception-test.cc:1442
ns3::PacketSocketHelper
Give ns3::PacketSocket powers to ns3::Node.
Definition: packet-socket-helper.h:32
TestSimpleFrameCaptureModel::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-phy-reception-test.cc:1137
ns3::WIFI_STANDARD_80211ac
@ WIFI_STANDARD_80211ac
Definition: wifi-standards.h:133
ns3::MakeCallback
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
WifiPhyState
WifiPhyState
The state of the PHY layer.
Definition: wifi-phy-state.h:32
GUARD_WIDTH
static const uint16_t GUARD_WIDTH
Definition: wifi-phy-reception-test.cc:58
TestThresholdPreambleDetectionWithoutFrameCapture::TestThresholdPreambleDetectionWithoutFrameCapture
TestThresholdPreambleDetectionWithoutFrameCapture()
Definition: wifi-phy-reception-test.cc:121
TestSimpleFrameCaptureModel::m_rxSuccess1000B
bool m_rxSuccess1000B
count received packets with 1000B payload
Definition: wifi-phy-reception-test.cc:994
TestUnsupportedModulationReception::m_dropped
uint16_t m_dropped
number of packets dropped by the AP because it was already receiving
Definition: wifi-phy-reception-test.cc:2396
ns3::TestSuite
A suite of tests to run.
Definition: test.h:1344
TestAmpduReception::m_phy
Ptr< SpectrumWifiPhy > m_phy
Phy.
Definition: wifi-phy-reception-test.cc:1534
ns3::WifiPhy::SetFrameCaptureModel
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
Definition: wifi-phy.cc:822
TestPhyHeadersReception::m_phy
Ptr< SpectrumWifiPhy > m_phy
Phy.
Definition: wifi-phy-reception-test.cc:1198
TestAmpduReception::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-phy-reception-test.cc:1810
TestAmpduReception::m_rxDroppedBitmapAmpdu2
uint8_t m_rxDroppedBitmapAmpdu2
bitmap of dropped MPDUs in A-MPDU #2
Definition: wifi-phy-reception-test.cc:1543
NS_TEST_ASSERT_MSG_EQ
#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
ns3::Config::Connect
void Connect(std::string path, const CallbackBase &cb)
Definition: config.cc:920
ns3::WifiPsdu::IsAggregate
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
Definition: wifi-psdu.cc:81
ns3::WifiPhy::AssignStreams
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: wifi-phy.cc:2309
packetSize
static const uint32_t packetSize
Definition: wifi-power-adaptation-distance.cc:113
TestAmpduReception::m_rxDroppedBitmapAmpdu1
uint8_t m_rxDroppedBitmapAmpdu1
bitmap of dropped MPDUs in A-MPDU #1
Definition: wifi-phy-reception-test.cc:1542
ns3::DbmToW
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: wifi-utils.cc:37
TestPhyHeadersReception::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-phy-reception-test.cc:1299
TestAmpduReception::CheckRxFailureBitmapAmpdu1
void CheckRxFailureBitmapAmpdu1(uint8_t expected)
Check the RX failure bitmap for A-MPDU 1.
Definition: wifi-phy-reception-test.cc:1712
wifiPhyReceptionTestSuite
static WifiPhyReceptionTestSuite wifiPhyReceptionTestSuite
the test suite
Definition: wifi-phy-reception-test.cc:2576
TestSimpleFrameCaptureModel
Simple frame capture model test.
Definition: wifi-phy-reception-test.cc:937
ns3::RxSignalInfo
RxSignalInfo structure containing info on the received signal.
Definition: phy-entity.h:67
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
TestAmpduReception::CheckPhyState
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
Definition: wifi-phy-reception-test.cc:1736
TestThresholdPreambleDetectionWithFrameCapture::m_countRxSuccess
uint32_t m_countRxSuccess
count RX success
Definition: wifi-phy-reception-test.cc:460
TestAmpduReception::RxDropped
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
Definition: wifi-phy-reception-test.cc:1670
TestSimpleFrameCaptureModel::RxSuccess
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
Definition: wifi-phy-reception-test.cc:1040
TestSimpleFrameCaptureModel::m_uid
uint64_t m_uid
the UID to use for the PPDU
Definition: wifi-phy-reception-test.cc:999
ns3::WIFI_MAC_QOSDATA
@ WIFI_MAC_QOSDATA
Definition: wifi-mac-header.h:70
ns3::PacketSocketAddress::SetPhysicalAddress
void SetPhysicalAddress(const Address address)
Set the destination address.
Definition: packet-socket-address.cc:53
TestThresholdPreambleDetectionWithFrameCapture::m_phy
Ptr< SpectrumWifiPhy > m_phy
Phy.
Definition: wifi-phy-reception-test.cc:440
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
TestPhyHeadersReception::DoCheckPhyState
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
Definition: wifi-phy-reception-test.cc:1263
ns3::NodeContainer
keep track of a set of node pointers.
Definition: node-container.h:39
third.wifiStaNodes
wifiStaNodes
Definition: third.py:88
ns3::SpectrumWifiPhy::SetFrequency
void SetFrequency(uint16_t freq) override
If the operating channel for this object has not been set yet, the given center frequency is saved an...
Definition: spectrum-wifi-phy.cc:250
TestAmpduReception::IncrementSuccessBitmap
void IncrementSuccessBitmap(uint32_t size)
Increment reception success bitmap.
Definition: wifi-phy-reception-test.cc:1602
ns3::WifiMacHeader::SetType
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
Definition: wifi-mac-header.cc:132
ns3::PacketSocketAddress::SetProtocol
void SetProtocol(uint16_t protocol)
Set the protocol.
Definition: packet-socket-address.cc:33
TestAmpduReception::RxSuccess
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
Definition: wifi-phy-reception-test.cc:1577
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
TestSimpleFrameCaptureModel::m_rxDropped1000B
bool m_rxDropped1000B
count dropped packets with 1000B payload
Definition: wifi-phy-reception-test.cc:996
ns3::WifiMacHelper
create MAC layers for a ns3::WifiNetDevice.
Definition: wifi-mac-helper.h:48
ns3::Config::SetDefault
void SetDefault(std::string name, const AttributeValue &value)
Definition: config.cc:849
TestThresholdPreambleDetectionWithFrameCapture::RxFailure
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
Definition: wifi-phy-reception-test.cc:556
ns3::ObjectBase::TraceConnectWithoutContext
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
Definition: object-base.cc:293
TestThresholdPreambleDetectionWithoutFrameCapture::RxSuccess
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
Definition: wifi-phy-reception-test.cc:183
ns3::WifiPsdu::begin
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
Definition: wifi-psdu.cc:325
TestAmpduReception::RxFailure
void RxFailure(Ptr< WifiPsdu > psdu)
RX failure function.
Definition: wifi-phy-reception-test.cc:1631
ns3::PacketSocketServer::SetLocal
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
Definition: packet-socket-server.cc:102
ns3::WifiMacHeader::SetQosTid
void SetQosTid(uint8_t tid)
Set the TID for the QoS header.
Definition: wifi-mac-header.cc:352
TestThresholdPreambleDetectionWithoutFrameCapture::SendPacket
void SendPacket(double rxPowerDbm)
Send packet function.
Definition: wifi-phy-reception-test.cc:130
TestPhyHeadersReception::SendPacket
void SendPacket(double rxPowerDbm)
Send packet function.
Definition: wifi-phy-reception-test.cc:1229
ns3::NetDeviceContainer::Get
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Definition: net-device-container.cc:62
ns3::WifiPsdu::IsSingle
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
Definition: wifi-psdu.cc:75
ns3::NetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const =0
TestThresholdPreambleDetectionWithoutFrameCapture::DoSetup
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
Definition: wifi-phy-reception-test.cc:203
ns3::NetDeviceContainer::Add
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Definition: net-device-container.cc:67
ns3::WifiPhy::SetErrorRateModel
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
Definition: wifi-phy.cc:808
TestSimpleFrameCaptureModel::Expect1500BPacketReceived
void Expect1500BPacketReceived()
Verify whether 1500 bytes packet has been received.
Definition: wifi-phy-reception-test.cc:1085
TestThresholdPreambleDetectionWithFrameCapture::m_countRxFailure
uint32_t m_countRxFailure
count RX failure
Definition: wifi-phy-reception-test.cc:461
TestSimpleFrameCaptureModel::TestSimpleFrameCaptureModel
TestSimpleFrameCaptureModel()
Definition: wifi-phy-reception-test.cc:1002
ns3::MobilityHelper
Helper class used to assign positions and mobility models to nodes.
Definition: mobility-helper.h:43
TestUnsupportedModulationReception::DoRun
void DoRun(void) override
Implementation to actually run this TestCase.
Definition: wifi-phy-reception-test.cc:2422
ns3::SpectrumWifiPhyHelper
Make it easy to create and manage PHY objects for the spectrum model.
Definition: spectrum-wifi-helper.h:38
TestUnsupportedModulationReception::Dropped
void Dropped(std::string context, Ptr< const Packet > packet, WifiPhyRxfailureReason reason)
Callback invoked when PHY drops an incoming packet.
Definition: wifi-phy-reception-test.cc:2410
third.mobility
mobility
Definition: third.py:108
ns3::WifiPhy::SetPreambleDetectionModel
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
Definition: wifi-phy.cc:828
third.phy
phy
Definition: third.py:93
WifiPhyReceptionTestSuite
wifi PHY reception Test Suite
Definition: wifi-phy-reception-test.cc:2560
TestSimpleFrameCaptureModel::Reset
void Reset(void)
Reset function.
Definition: wifi-phy-reception-test.cc:1070
TestThresholdPreambleDetectionWithoutFrameCapture::m_countRxSuccess
uint32_t m_countRxSuccess
count RX success
Definition: wifi-phy-reception-test.cc:95
ns3::WifiNetDevice::GetMac
Ptr< WifiMac > GetMac(void) const
Definition: wifi-net-device.cc:201
TestSimpleFrameCaptureModel::~TestSimpleFrameCaptureModel
virtual ~TestSimpleFrameCaptureModel()
Definition: wifi-phy-reception-test.cc:1101