From 57e69a5366ea614b2939dc2bb161ef69dc0c1616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Mon, 31 Dec 2018 13:53:15 +0100 Subject: [PATCH] wifi: Add tests for A-MPDU reception --- src/wifi/model/mac-low.cc | 6 +- src/wifi/model/mac-low.h | 4 +- src/wifi/model/wifi-phy-state-helper.cc | 2 +- src/wifi/model/wifi-phy-state-helper.h | 4 +- src/wifi/test/spectrum-wifi-phy-test.cc | 9 +- src/wifi/test/wifi-phy-reception-test.cc | 1003 ++++++++++++++++++++- src/wifi/test/wifi-phy-thresholds-test.cc | 7 +- 7 files changed, 1015 insertions(+), 20 deletions(-) diff --git a/src/wifi/model/mac-low.cc b/src/wifi/model/mac-low.cc index 80bb8730d..662cf2ec4 100644 --- a/src/wifi/model/mac-low.cc +++ b/src/wifi/model/mac-low.cc @@ -269,7 +269,7 @@ void MacLow::ResetPhy (void) { m_phy->SetReceiveOkCallback (MakeNullCallback, double, WifiTxVector> ()); - m_phy->SetReceiveErrorCallback (MakeNullCallback ()); + m_phy->SetReceiveErrorCallback (MakeNullCallback> ()); RemovePhyMacLowListener (m_phy); m_phy = 0; } @@ -651,9 +651,9 @@ MacLow::NeedCtsToSelf (void) const } void -MacLow::ReceiveError (void) +MacLow::ReceiveError (Ptr packet) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << packet); NS_LOG_DEBUG ("rx failed"); if (IsCfPeriod () && m_currentHdr.IsCfPoll ()) { diff --git a/src/wifi/model/mac-low.h b/src/wifi/model/mac-low.h index f4ff70693..f69b3c681 100644 --- a/src/wifi/model/mac-low.h +++ b/src/wifi/model/mac-low.h @@ -334,10 +334,12 @@ public: */ void ReceiveOk (Ptr packet, double rxSnr, WifiTxVector txVector, bool ampduSubframe); /** + * \param packet packet received. + * * This method is typically invoked by the lower PHY layer to notify * the MAC layer that a packet was unsuccessfully received. */ - void ReceiveError (void); + void ReceiveError (Ptr packet); /** * \param duration switching delay duration. * diff --git a/src/wifi/model/wifi-phy-state-helper.cc b/src/wifi/model/wifi-phy-state-helper.cc index db7895464..1b2d14a06 100644 --- a/src/wifi/model/wifi-phy-state-helper.cc +++ b/src/wifi/model/wifi-phy-state-helper.cc @@ -480,7 +480,7 @@ WifiPhyStateHelper::SwitchFromRxEndError (Ptr packet, double snr) DoSwitchFromRx (); if (!m_rxErrorCallback.IsNull ()) { - m_rxErrorCallback (); + m_rxErrorCallback (packet); } } diff --git a/src/wifi/model/wifi-phy-state-helper.h b/src/wifi/model/wifi-phy-state-helper.h index 498bcadc1..6818c4f28 100644 --- a/src/wifi/model/wifi-phy-state-helper.h +++ b/src/wifi/model/wifi-phy-state-helper.h @@ -46,8 +46,10 @@ class Packet; typedef Callback, double, WifiTxVector> RxOkCallback; /** * Callback if packet unsuccessfully received + * + * arg1: packet received unsuccessfully */ -typedef Callback RxErrorCallback; +typedef Callback> RxErrorCallback; /** * \ingroup wifi diff --git a/src/wifi/test/spectrum-wifi-phy-test.cc b/src/wifi/test/spectrum-wifi-phy-test.cc index f0f0a3f64..688c88f71 100644 --- a/src/wifi/test/spectrum-wifi-phy-test.cc +++ b/src/wifi/test/spectrum-wifi-phy-test.cc @@ -79,8 +79,9 @@ protected: void SpectrumWifiPhyRxSuccess (Ptr p, double snr, WifiTxVector txVector); /** * Spectrum wifi receive failure function - */ - void SpectrumWifiPhyRxFailure (void); + * \param p the packet +- */ + void SpectrumWifiPhyRxFailure (Ptr p); uint32_t m_count; ///< count private: @@ -144,9 +145,9 @@ SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxSuccess (Ptr p, double snr, W } void -SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxFailure (void) +SpectrumWifiPhyBasicTest::SpectrumWifiPhyRxFailure (Ptr p) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << p); m_count++; } diff --git a/src/wifi/test/wifi-phy-reception-test.cc b/src/wifi/test/wifi-phy-reception-test.cc index eeeb94536..27cd3de42 100644 --- a/src/wifi/test/wifi-phy-reception-test.cc +++ b/src/wifi/test/wifi-phy-reception-test.cc @@ -21,12 +21,14 @@ #include "ns3/log.h" #include "ns3/test.h" #include "ns3/pointer.h" +#include "ns3/rng-seed-manager.h" #include "ns3/spectrum-wifi-helper.h" #include "ns3/wifi-spectrum-value-helper.h" #include "ns3/spectrum-wifi-phy.h" #include "ns3/nist-error-rate-model.h" #include "ns3/wifi-mac-header.h" #include "ns3/wifi-mac-trailer.h" +#include "ns3/ampdu-tag.h" #include "ns3/wifi-phy-tag.h" #include "ns3/wifi-spectrum-signal-parameters.h" #include "ns3/wifi-utils.h" @@ -71,8 +73,9 @@ protected: void RxSuccess (Ptr p, double snr, WifiTxVector txVector); /** * Spectrum wifi receive failure function + * \param p the packet */ - void RxFailure (void); + void RxFailure (Ptr p); uint32_t m_countRxSuccess; ///< count RX success uint32_t m_countRxFailure; ///< count RX failure @@ -155,14 +158,15 @@ TestThresholdPreambleDetectionWithoutFrameCapture::RxSuccess (Ptr p, dou } void -TestThresholdPreambleDetectionWithoutFrameCapture::RxFailure (void) +TestThresholdPreambleDetectionWithoutFrameCapture::RxFailure (Ptr p) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << p); m_countRxFailure++; } TestThresholdPreambleDetectionWithoutFrameCapture::~TestThresholdPreambleDetectionWithoutFrameCapture () { + m_phy = 0; } void @@ -185,7 +189,11 @@ TestThresholdPreambleDetectionWithoutFrameCapture::DoSetup (void) void TestThresholdPreambleDetectionWithoutFrameCapture::DoRun (void) { + RngSeedManager::SetSeed (1); + RngSeedManager::SetRun (1); + int64_t streamNumber = 0; double txPowerDbm = -30; + m_phy->AssignStreams (streamNumber); //CASE 1: send one packet and check PHY state: packet reception should succeed @@ -263,8 +271,9 @@ protected: void RxSuccess (Ptr p, double snr, WifiTxVector txVector); /** * Spectrum wifi receive failure function + * \param p the packet */ - void RxFailure (void); + void RxFailure (Ptr p); uint32_t m_countRxSuccess; ///< count RX success uint32_t m_countRxFailure; ///< count RX failure @@ -347,14 +356,15 @@ TestThresholdPreambleDetectionWithFrameCapture::RxSuccess (Ptr p, double } void -TestThresholdPreambleDetectionWithFrameCapture::RxFailure (void) +TestThresholdPreambleDetectionWithFrameCapture::RxFailure (Ptr p) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << p); m_countRxFailure++; } TestThresholdPreambleDetectionWithFrameCapture::~TestThresholdPreambleDetectionWithFrameCapture () { + m_phy = 0; } void @@ -380,7 +390,11 @@ TestThresholdPreambleDetectionWithFrameCapture::DoSetup (void) void TestThresholdPreambleDetectionWithFrameCapture::DoRun (void) { + RngSeedManager::SetSeed (1); + RngSeedManager::SetRun (1); + int64_t streamNumber = 1; double txPowerDbm = -30; + m_phy->AssignStreams (streamNumber); //CASE 1: send one packet and check PHY state: packet reception should succeed @@ -461,7 +475,6 @@ private: * Spectrum wifi receive success function * \param p the packet * \param snr the SNR - * \param rxPower the rx power (W) * \param txVector the transmit vector */ void RxSuccess (Ptr p, double snr, WifiTxVector txVector); @@ -585,6 +598,7 @@ TestSimpleFrameCaptureModel::Expect1500BPacketDropped () TestSimpleFrameCaptureModel::~TestSimpleFrameCaptureModel () { + m_phy = 0; } void @@ -611,7 +625,11 @@ TestSimpleFrameCaptureModel::DoSetup (void) void TestSimpleFrameCaptureModel::DoRun (void) { + RngSeedManager::SetSeed (1); + RngSeedManager::SetRun (1); + int64_t streamNumber = 2; double txPowerDbm = -30; + m_phy->AssignStreams (streamNumber); //CASE 1: send two packets with same power within the capture window: should not switch reception because they have same power Simulator::Schedule (Seconds (1.0), &TestSimpleFrameCaptureModel::SendPacket, this, txPowerDbm, 1000); @@ -643,6 +661,976 @@ TestSimpleFrameCaptureModel::DoRun (void) Simulator::Destroy (); } +/** + * \ingroup wifi-test + * \ingroup tests + * + * \brief A-MPDU reception test + */ +class TestAmpduReception : public TestCase +{ +public: + TestAmpduReception (); + virtual ~TestAmpduReception (); + +protected: + virtual void DoSetup (void); + +private: + virtual void DoRun (void); + + /** + * RX success function + * \param p the packet + * \param snr the SNR + * \param txVector the transmit vector + */ + void RxSuccess (Ptr p, double snr, WifiTxVector txVector); + /** + * RX failure function + * \param p the packet + */ + void RxFailure (Ptr p); + /** + * RX dropped function + * \param p the packet + */ + void RxDropped (Ptr p); + + /** + * Reset bitmaps function + */ + void ResetBitmaps(); + + /** + * schedule send MPDU function + * \param txPowerDbm the transmit power in dBm + * \param packetSize the size of the packet in bytes + * \param preamble the preamble + * \param mpdutype the MPDU type + * \param remainingNbOfMpdus the remaining number of MPDUs to send after this MPDU + */ + void ScheduleSendMpdu (double txPowerDbm, uint32_t packetSize, WifiPreamble preamble, MpduType mpdutype, uint8_t remainingNbOfMpdus); + /** + * Send MPDU function + * \param txPowerDbm the transmit power in dBm + * \param packetSize the size of the packet in bytes + * \param preamble the preamble + * \param mpdutype the MPDU type + * \param remainingNbOfMpdus the remaining number of MPDUs to send after this MPDU + */ + void SendMpdu (double txPowerDbm, uint32_t packetSize, WifiPreamble preamble, MpduType mpdutype, uint8_t remainingNbOfMpdus); + + /** + * Check the RX success bitmap for A-MPDU 1 + * \param expected the expected bitmap + */ + void CheckRxSuccessBitmapAmpdu1 (uint8_t expected); + /** + * Check the RX success bitmap for A-MPDU 2 + * \param expected the expected bitmap + */ + void CheckRxSuccessBitmapAmpdu2 (uint8_t expected); + /** + * Check the RX failure bitmap for A-MPDU 1 + * \param expected the expected bitmap + */ + void CheckRxFailureBitmapAmpdu1 (uint8_t expected); + /** + * Check the RX failure bitmap for A-MPDU 2 + * \param expected the expected bitmap + */ + void CheckRxFailureBitmapAmpdu2 (uint8_t expected); + /** + * Check the RX dropped bitmap for A-MPDU 1 + * \param expected the expected bitmap + */ + void CheckRxDroppedBitmapAmpdu1 (uint8_t expected); + /** + * Check the RX dropped bitmap for A-MPDU 2 + * \param expected the expected bitmap + */ + void CheckRxDroppedBitmapAmpdu2 (uint8_t expected); + + /** + * Check the PHY state + * \param expectedState the expected PHY state + */ + void CheckPhyState (WifiPhyState expectedState); + + Ptr m_phy; ///< Phy + + uint8_t m_rxSuccessBitmapAmpdu1; + uint8_t m_rxSuccessBitmapAmpdu2; + + uint8_t m_rxFailureBitmapAmpdu1; + uint8_t m_rxFailureBitmapAmpdu2; + + uint8_t m_rxDroppedBitmapAmpdu1; + uint8_t m_rxDroppedBitmapAmpdu2; +}; + +TestAmpduReception::TestAmpduReception () +: TestCase ("A-MPDU reception test"), + m_rxSuccessBitmapAmpdu1 (0), + m_rxSuccessBitmapAmpdu2 (0), + m_rxFailureBitmapAmpdu1 (0), + m_rxFailureBitmapAmpdu2 (0), + m_rxDroppedBitmapAmpdu1 (0), + m_rxDroppedBitmapAmpdu2 (0) +{ +} + +TestAmpduReception::~TestAmpduReception () +{ + m_phy = 0; +} + +void +TestAmpduReception::ResetBitmaps() +{ + m_rxSuccessBitmapAmpdu1 = 0; + m_rxSuccessBitmapAmpdu2 = 0; + m_rxFailureBitmapAmpdu1 = 0; + m_rxFailureBitmapAmpdu2 = 0; + m_rxDroppedBitmapAmpdu1 = 0; + m_rxDroppedBitmapAmpdu2 = 0; +} + +void +TestAmpduReception::RxSuccess (Ptr p, double snr, WifiTxVector txVector) +{ + NS_LOG_FUNCTION (this << p << snr << txVector); + if (p->GetSize () == 1030) //A-MPDU 1 - MPDU #1 + { + m_rxSuccessBitmapAmpdu1 |= 1; + } + else if (p->GetSize () == 1130) //A-MPDU 1 - MPDU #2 + { + m_rxSuccessBitmapAmpdu1 |= (1 << 1); + } + else if (p->GetSize () == 1230) //A-MPDU 1 - MPDU #3 + { + m_rxSuccessBitmapAmpdu1 |= (1 << 2); + } + else if (p->GetSize () == 1330) //A-MPDU 2 - MPDU #1 + { + m_rxSuccessBitmapAmpdu2 |= 1; + } + else if (p->GetSize () == 1430) //A-MPDU 2 - MPDU #2 + { + m_rxSuccessBitmapAmpdu2 |= (1 << 1); + } + else if (p->GetSize () == 1530) //A-MPDU 2 - MPDU #3 + { + m_rxSuccessBitmapAmpdu2 |= (1 << 2); + } +} + +void +TestAmpduReception::RxFailure (Ptr p) +{ + NS_LOG_FUNCTION (this << p); + if (p->GetSize () == 1030) //A-MPDU 1 - MPDU #1 + { + m_rxFailureBitmapAmpdu1 |= 1; + } + else if (p->GetSize () == 1130) //A-MPDU 1 - MPDU #2 + { + m_rxFailureBitmapAmpdu1 |= (1 << 1); + } + else if (p->GetSize () == 1230) //A-MPDU 1 - MPDU #3 + { + m_rxFailureBitmapAmpdu1 |= (1 << 2); + } + else if (p->GetSize () == 1330) //A-MPDU 2 - MPDU #1 + { + m_rxFailureBitmapAmpdu2 |= 1; + } + else if (p->GetSize () == 1430) //A-MPDU 2 - MPDU #2 + { + m_rxFailureBitmapAmpdu2 |= (1 << 1); + } + else if (p->GetSize () == 1530) //A-MPDU 2 - MPDU #3 + { + m_rxFailureBitmapAmpdu2 |= (1 << 2); + } +} + +void +TestAmpduReception::RxDropped (Ptr p) +{ + NS_LOG_FUNCTION (this << p); + if (p->GetSize () == 1030) //A-MPDU 1 - MPDU #1 + { + m_rxDroppedBitmapAmpdu1 |= 1; + } + else if (p->GetSize () == 1130) //A-MPDU 1 - MPDU #2 + { + m_rxDroppedBitmapAmpdu1 |= (1 << 1); + } + else if (p->GetSize () == 1230) //A-MPDU 1 - MPDU #3 + { + m_rxDroppedBitmapAmpdu1 |= (1 << 2); + } + else if (p->GetSize () == 1330) //A-MPDU 2 - MPDU #1 + { + m_rxDroppedBitmapAmpdu2 |= 1; + } + else if (p->GetSize () == 1430) //A-MPDU 2 - MPDU #2 + { + m_rxDroppedBitmapAmpdu2 |= (1 << 1); + } + else if (p->GetSize () == 1530) //A-MPDU 2 - MPDU #3 + { + m_rxDroppedBitmapAmpdu2 |= (1 << 2); + } +} + +void +TestAmpduReception::CheckRxSuccessBitmapAmpdu1 (uint8_t expected) +{ + NS_TEST_ASSERT_MSG_EQ (m_rxSuccessBitmapAmpdu1, expected, "RX success bitmap for A-MPDU 1 is not as expected"); +} + +void +TestAmpduReception::CheckRxSuccessBitmapAmpdu2 (uint8_t expected) +{ + NS_TEST_ASSERT_MSG_EQ (m_rxSuccessBitmapAmpdu2, expected, "RX success bitmap for A-MPDU 2 is not as expected"); +} + +void +TestAmpduReception::CheckRxFailureBitmapAmpdu1 (uint8_t expected) +{ + NS_TEST_ASSERT_MSG_EQ (m_rxFailureBitmapAmpdu1, expected, "RX failure bitmap for A-MPDU 1 is not as expected"); +} + +void +TestAmpduReception::CheckRxFailureBitmapAmpdu2 (uint8_t expected) +{ + NS_TEST_ASSERT_MSG_EQ (m_rxFailureBitmapAmpdu2, expected, "RX failure bitmap for A-MPDU 2 is not as expected"); +} + +void +TestAmpduReception::CheckRxDroppedBitmapAmpdu1 (uint8_t expected) +{ + NS_TEST_ASSERT_MSG_EQ (m_rxDroppedBitmapAmpdu1, expected, "RX dropped bitmap for A-MPDU 1 is not as expected"); +} + +void +TestAmpduReception::CheckRxDroppedBitmapAmpdu2 (uint8_t expected) +{ + NS_TEST_ASSERT_MSG_EQ (m_rxDroppedBitmapAmpdu2, expected, "RX dropped bitmap for A-MPDU 2 is not as expected"); +} + +void +TestAmpduReception::CheckPhyState (WifiPhyState expectedState) +{ + WifiPhyState currentState; + PointerValue ptr; + m_phy->GetAttribute ("State", ptr); + Ptr state = DynamicCast (ptr.Get ()); + currentState = state->GetState (); + NS_TEST_ASSERT_MSG_EQ (currentState, expectedState, "PHY State " << currentState << " does not match expected state " << expectedState << " at " << Simulator::Now ()); +} + +void +TestAmpduReception::ScheduleSendMpdu (double txPowerDbm, uint32_t packetSize, WifiPreamble preamble, MpduType mpdutype, uint8_t remainingNbOfMpdus) +{ + //This is needed to make sure this is the last scheduled event and to avoid the start of an MPDU is triggered before the end of the previous MPDU. + Simulator::ScheduleNow (&TestAmpduReception::SendMpdu, this, txPowerDbm, packetSize, preamble, mpdutype, remainingNbOfMpdus); +} + +void +TestAmpduReception::SendMpdu (double txPowerDbm, uint32_t packetSize, WifiPreamble preamble, MpduType mpdutype, uint8_t remainingNbOfMpdus) +{ + WifiTxVector txVector = WifiTxVector (WifiPhy::GetHeMcs0 (), 0, preamble, 800, 1, 1, 0, 20, false, false); + + Ptr pkt = Create (packetSize); + WifiMacHeader hdr; + WifiMacTrailer trailer; + + hdr.SetType (WIFI_MAC_QOSDATA); + hdr.SetQosTid (0); + uint32_t size = pkt->GetSize () + hdr.GetSize () + trailer.GetSerializedSize (); + Time txDuration = m_phy->CalculateTxDuration (size, txVector, m_phy->GetFrequency (), mpdutype, 0); + hdr.SetDuration (txDuration); + + pkt->AddHeader (hdr); + pkt->AddTrailer (trailer); + AmpduTag ampdutag; + ampdutag.SetRemainingNbOfMpdus (remainingNbOfMpdus); + pkt->AddPacketTag (ampdutag); + WifiPhyTag tag (txVector, mpdutype, 1); + pkt->AddPacketTag (tag); + Ptr txPowerSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (FREQUENCY, CHANNEL_WIDTH, DbmToW (txPowerDbm), GUARD_WIDTH); + Ptr txParams = Create (); + txParams->psd = txPowerSpectrum; + txParams->txPhy = 0; + txParams->duration = txDuration; + txParams->packet = pkt; + + m_phy->StartRx (txParams); +} + +void +TestAmpduReception::DoSetup (void) +{ + m_phy = CreateObject (); + m_phy->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ); + Ptr error = CreateObject (); + m_phy->SetErrorRateModel (error); + m_phy->SetChannelNumber (CHANNEL_NUMBER); + m_phy->SetFrequency (FREQUENCY); + + m_phy->SetReceiveOkCallback (MakeCallback (&TestAmpduReception::RxSuccess, this)); + m_phy->SetReceiveErrorCallback (MakeCallback (&TestAmpduReception::RxFailure, this)); + m_phy->TraceConnectWithoutContext ("PhyRxDrop", MakeCallback (&TestAmpduReception::RxDropped, this)); + + Ptr preambleDetectionModel = CreateObject (); + m_phy->SetPreambleDetectionModel (preambleDetectionModel); + + Ptr frameCaptureModel = CreateObject (); + m_phy->SetFrameCaptureModel (frameCaptureModel); +} + +// Test that the expected number of packet receptions occur. +void +TestAmpduReception::DoRun (void) +{ + RngSeedManager::SetSeed (1); + RngSeedManager::SetRun (1); + int64_t streamNumber = 3; + double txPowerDbm = -30; + m_phy->AssignStreams (streamNumber); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 1: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity. + // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection). + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (1.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (1.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (1.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (1.0) + MicroSeconds (2), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (1.0) + MicroSeconds (2) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (1.0) + MicroSeconds (2) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been ignored. + Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been received. + Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111); + Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (1.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (1.2), &TestAmpduReception::ResetBitmaps, this); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 2: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity. + // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection). + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (2.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (2.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (2.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (2.0) + MicroSeconds (2), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (2.0) + MicroSeconds (2) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (2.0) + MicroSeconds (2) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received. + Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been ignored. + Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (2.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (2.2), &TestAmpduReception::ResetBitmaps, this); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 3: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (3.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (3.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (3.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (3.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (3.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (3.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been ignored. + Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been received. + Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111); + Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (3.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (3.2), &TestAmpduReception::ResetBitmaps, this); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 4: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (4.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (4.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (4.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (4.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (4.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (4.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received. + Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been ignored. + Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (4.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (4.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 5: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity. + // 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). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (5.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (5.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (5.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (5.0) + MicroSeconds (100), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (5.0) + MicroSeconds (100) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (5.0) + MicroSeconds (100) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been ignored. + Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been received. + Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111); + Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (5.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (5.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 6: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity. + // 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). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (6.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (6.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (6.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (6.0) + MicroSeconds (100), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (6.0) + MicroSeconds (100) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (6.0) + MicroSeconds (100) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received. + Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been ignored. + Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (6.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (6.2), &TestAmpduReception::ResetBitmaps, this); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 7: receive two A-MPDUs (containing each 3 MPDUs) where the first A-MPDU is received with power under RX sensitivity. + // The second A-MPDU is received during the payload of MPDU #2. + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (7.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (7.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (7.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (7.0) + NanoSeconds (1100000), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (7.0) + NanoSeconds (1100000) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (7.0) + NanoSeconds (1100000) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been ignored. + Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been received. + Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111); + Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (7.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (7.2), &TestAmpduReception::ResetBitmaps, this); + + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 8: receive two A-MPDUs (containing each 3 MPDUs) where the second A-MPDU is received with power under RX sensitivity. + // The second A-MPDU is received during the payload of MPDU #2. + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (8.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (8.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (8.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (8.0) + NanoSeconds (1100000), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (8.0) + NanoSeconds (1100000) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (8.0) + NanoSeconds (1100000) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm - 100, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received. + Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been ignored. + Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (8.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (8.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 9: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 3 dB higher. + // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection). + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (9.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (9.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (9.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (9.0) + MicroSeconds (2), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (9.0) + MicroSeconds (2) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (9.0) + MicroSeconds (2) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been dropped. + Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been received with errors. + Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000111); + Simulator::Schedule (Seconds (9.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (9.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 10: receive two A-MPDUs (containing each 3 MPDUs) with the same power. + // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection). + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (10.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (10.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (10.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (10.0) + MicroSeconds (2), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (10.0) + MicroSeconds (2) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (10.0) + MicroSeconds (2) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been dropped (preamble detection failed). + Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped as well. + Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (10.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (10.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 11: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 3 dB higher. + // The second A-MPDU is received 2 microseconds after the first A-MPDU (i.e. during preamble detection). + /////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (11.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (11.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (11.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (11.0) + MicroSeconds (2), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (11.0) + MicroSeconds (2) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (11.0) + MicroSeconds (2) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been dropped (PHY header reception failed). + Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000001); + Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (11.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (11.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 12: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 3 dB higher. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (12.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (12.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (12.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (12.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (12.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (12.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been dropped (PHY header reception failed). + Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000001); + Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // 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) + Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (12.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (12.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 13: receive two A-MPDUs (containing each 3 MPDUs) with the same power. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (13.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (13.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (13.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (13.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (13.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (13.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been dropped (PHY header reception failed). + Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000001); + Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped as well. + Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (13.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (13.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 14: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 3 dB higher. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (14.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (14.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (14.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 3, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (14.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (14.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (14.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received with errors. + Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (14.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (14.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 15: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 6 dB higher. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (15.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (15.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (15.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (15.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (15.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (15.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been dropped because PHY reception switched to A-MPDU 2. + Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been successfully received + Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000111); + Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (15.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000000); + + Simulator::Schedule (Seconds (15.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 16: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 6 dB higher. + // The second A-MPDU is received 10 microseconds after the first A-MPDU (i.e. during the frame capture window). + /////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (16.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (16.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (16.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (16.0) + MicroSeconds (10), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (16.0) + MicroSeconds (10) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (16.0) + MicroSeconds (10) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been successfully received. + Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (16.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (16.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 17: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 6 dB higher. + // 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). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (17.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (17.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (17.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (17.0) + MicroSeconds (25), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (17.0) + MicroSeconds (25) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (17.0) + MicroSeconds (25) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received with errors. + Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + //Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111); //TODO: PHY should stay in RX if L-SIG was successfully decoded + Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped (no reception switch, MPDUs dropped because PHY is already in RX state). + Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (17.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (17.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 18: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 6 dB higher. + // 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). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (18.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (18.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (18.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (18.0) + MicroSeconds (25), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (18.0) + MicroSeconds (25) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (18.0) + MicroSeconds (25) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been successfully received. + Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (18.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (18.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 19: receive two A-MPDUs (containing each 3 MPDUs) with the same power. + // 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). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (19.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (19.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (19.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (19.0) + MicroSeconds (25), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (19.0) + MicroSeconds (25) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (19.0) + MicroSeconds (25) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received with errors. + Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + //Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111); //TODO: PHY should stay in RX if L-SIG was successfully decoded + Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (19.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (19.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 20: receive two A-MPDUs (containing each 3 MPDUs) with the second A-MPDU having a power 6 dB higher. + // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. during the payload of MPDU #1). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (20.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (20.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (20.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (20.0) + MicroSeconds (100), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (20.0) + MicroSeconds (100) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (20.0) + MicroSeconds (100) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received with errors. + Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped (no reception switch, MPDUs dropped because PHY is already in RX state). + Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (20.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (20.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 21: receive two A-MPDUs (containing each 3 MPDUs) with the first A-MPDU having a power 6 dB higher. + // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. during the payload of MPDU #1). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (21.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (21.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (21.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm + 6, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (21.0) + MicroSeconds (100), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (21.0) + MicroSeconds (100) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (21.0) + MicroSeconds (100) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been successfully received. + Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000000); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (21.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (21.2), &TestAmpduReception::ResetBitmaps, this); + + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // CASE 22: receive two A-MPDUs (containing each 3 MPDUs) with the same power. + // The second A-MPDU is received 100 microseconds after the first A-MPDU (i.e. during the payload of MPDU #1). + ////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (22.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (22.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (22.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (22.0) + MicroSeconds (100), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (22.0) + MicroSeconds (100) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (22.0) + MicroSeconds (100) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // All MPDUs of A-MPDU 1 should have been received with errors. + Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000000); + Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000111); + Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000111); + + // All MPDUs of A-MPDU 2 should have been dropped. + Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (22.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (22.2), &TestAmpduReception::ResetBitmaps, this); + + /////////////////////////////////////////////////////////////////////////////// + // CASE 23: receive two A-MPDUs (containing each 3 MPDUs) with the same power. + // The second A-MPDU is received during the payload of MPDU #2. + /////////////////////////////////////////////////////////////////////////////// + + // A-MPDU 1 + Simulator::Schedule (Seconds (23.0), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1000, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (23.0) + NanoSeconds (1004369), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1100, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (23.0) + NanoSeconds (2055172), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1200, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // A-MPDU 2 + Simulator::Schedule (Seconds (23.0) + NanoSeconds (1100000), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1300, WIFI_PREAMBLE_HE_SU, MPDU_IN_AGGREGATE, 2); + Simulator::Schedule (Seconds (23.0) + NanoSeconds (1100000) + NanoSeconds (1283343), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1400, WIFI_PREAMBLE_NONE, MPDU_IN_AGGREGATE, 1); + Simulator::Schedule (Seconds (23.0) + NanoSeconds (1100000) + NanoSeconds (2613120), &TestAmpduReception::ScheduleSendMpdu, this, txPowerDbm, 1500, WIFI_PREAMBLE_NONE, LAST_MPDU_IN_AGGREGATE, 0); + + // The first MPDU of A-MPDU 1 should have been successfully received (no interference). + // The two other MPDUs failed due to interference and are marked as failure (and dropped). + Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu1, this, 0b00000001); + Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu1, this, 0b00000110); + Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu1, this, 0b00000110); + + // The two first MPDUs of A-MPDU 2 are dropped because PHY is already in RX state (receiving A-MPDU 1). + // 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. + Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxSuccessBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxFailureBitmapAmpdu2, this, 0b00000000); + Simulator::Schedule (Seconds (23.1), &TestAmpduReception::CheckRxDroppedBitmapAmpdu2, this, 0b00000111); + + Simulator::Schedule (Seconds (23.2), &TestAmpduReception::ResetBitmaps, this); + + Simulator::Run (); + Simulator::Destroy (); +} + /** * \ingroup wifi-test * \ingroup tests @@ -661,6 +1649,7 @@ WifiPhyReceptionTestSuite::WifiPhyReceptionTestSuite () AddTestCase (new TestThresholdPreambleDetectionWithoutFrameCapture, TestCase::QUICK); AddTestCase (new TestThresholdPreambleDetectionWithFrameCapture, TestCase::QUICK); AddTestCase (new TestSimpleFrameCaptureModel, TestCase::QUICK); + AddTestCase (new TestAmpduReception, TestCase::QUICK); } static WifiPhyReceptionTestSuite wifiPhyReceptionTestSuite; ///< the test suite diff --git a/src/wifi/test/wifi-phy-thresholds-test.cc b/src/wifi/test/wifi-phy-thresholds-test.cc index 58f0484a2..db80c5faf 100644 --- a/src/wifi/test/wifi-phy-thresholds-test.cc +++ b/src/wifi/test/wifi-phy-thresholds-test.cc @@ -78,8 +78,9 @@ protected: virtual void RxSuccess (Ptr p, double snr, WifiTxVector txVector); /** * PHY receive failure callback function + * \param p the packet */ - virtual void RxFailure (void); + virtual void RxFailure (Ptr p); /** * PHY dropped packet callback function * \param p the packet @@ -183,9 +184,9 @@ WifiPhyThresholdsTest::RxSuccess (Ptr p, double snr, WifiTxVector txVect } void -WifiPhyThresholdsTest::RxFailure (void) +WifiPhyThresholdsTest::RxFailure (Ptr p) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << p); m_rxFailure++; }