23 #include "ns3/double.h"
24 #include "ns3/pointer.h"
25 #include "ns3/rng-seed-manager.h"
26 #include "ns3/spectrum-wifi-helper.h"
27 #include "ns3/wifi-spectrum-value-helper.h"
28 #include "ns3/spectrum-wifi-phy.h"
29 #include "ns3/nist-error-rate-model.h"
30 #include "ns3/wifi-mac-header.h"
31 #include "ns3/ampdu-tag.h"
32 #include "ns3/wifi-spectrum-signal-parameters.h"
33 #include "ns3/wifi-utils.h"
34 #include "ns3/threshold-preamble-detection-model.h"
35 #include "ns3/simple-frame-capture-model.h"
36 #include "ns3/wifi-mac-queue-item.h"
37 #include "ns3/mpdu-aggregator.h"
38 #include "ns3/wifi-psdu.h"
39 #include "ns3/he-ppdu.h"
40 #include "ns3/he-phy.h"
64 void DoSetup (
void)
override;
65 void DoTeardown (
void)
override;
90 void DoRun (
void)
override;
107 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
113 :
TestCase (
"Threshold preamble detection model test when no frame capture model is applied"),
114 m_countRxSuccess (0),
115 m_countRxFailure (0),
139 txParams->psd = txPowerSpectrum;
141 txParams->duration = txDuration;
142 txParams->ppdu = ppdu;
161 currentState = state->GetState ();
196 m_phy = CreateObject<SpectrumWifiPhy> ();
206 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (4));
207 preambleDetectionModel->SetAttribute (
"MinimumRssi",
DoubleValue (-82));
221 RngSeedManager::SetSeed (1);
222 RngSeedManager::SetRun (1);
223 int64_t streamNumber = 0;
227 double rxPowerDbm = -50;
413 Simulator::Destroy ();
445 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
455 void DoRun (
void)
override;
472 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
478 :
TestCase (
"Threshold preamble detection model test when simple frame capture model is applied"),
479 m_countRxSuccess (0),
480 m_countRxFailure (0),
504 txParams->psd = txPowerSpectrum;
506 txParams->duration = txDuration;
507 txParams->ppdu = ppdu;
526 currentState = state->GetState ();
561 m_phy = CreateObject<SpectrumWifiPhy> ();
571 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (4));
572 preambleDetectionModel->SetAttribute (
"MinimumRssi",
DoubleValue (-82));
576 frameCaptureModel->SetAttribute (
"Margin",
DoubleValue (5));
591 RngSeedManager::SetSeed (1);
592 RngSeedManager::SetRun (1);
593 int64_t streamNumber = 1;
597 double rxPowerDbm = -50;
918 Simulator::Destroy ();
938 void DoRun (
void)
override;
958 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
994 :
TestCase (
"Simple frame capture model test"),
995 m_rxSuccess1000B (false),
996 m_rxSuccess1500B (false),
997 m_rxDropped1000B (false),
998 m_rxDropped1500B (false),
1022 txParams->psd = txPowerSpectrum;
1023 txParams->txPhy = 0;
1024 txParams->duration = txDuration;
1025 txParams->ppdu = ppdu;
1032 WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1040 else if (psdu->
GetSize () == 1530)
1054 else if (p->
GetSize () == 1530)
1100 m_phy = CreateObject<SpectrumWifiPhy> ();
1111 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (2));
1115 frameCaptureModel->SetAttribute (
"Margin",
DoubleValue (5));
1130 RngSeedManager::SetSeed (1);
1131 RngSeedManager::SetRun (1);
1132 int64_t streamNumber = 2;
1133 double rxPowerDbm = -30;
1171 Simulator::Destroy ();
1197 void DoRun (
void)
override;
1214 :
TestCase (
"PHY headers reception test"),
1238 txParams->psd = txPowerSpectrum;
1239 txParams->txPhy = 0;
1240 txParams->duration = txDuration;
1241 txParams->ppdu = ppdu;
1260 currentState = state->GetState ();
1274 m_phy = CreateObject<SpectrumWifiPhy> ();
1292 RngSeedManager::SetSeed (1);
1293 RngSeedManager::SetRun (1);
1294 int64_t streamNumber = 0;
1298 double rxPowerDbm = -50;
1423 Simulator::Destroy ();
1443 void DoRun (
void)
override;
1453 WifiTxVector txVector, std::vector<bool> statusPerMpdu);
1540 :
TestCase (
"A-MPDU reception test"),
1541 m_rxSuccessBitmapAmpdu1 (0),
1542 m_rxSuccessBitmapAmpdu2 (0),
1543 m_rxFailureBitmapAmpdu1 (0),
1544 m_rxFailureBitmapAmpdu2 (0),
1545 m_rxDroppedBitmapAmpdu1 (0),
1546 m_rxDroppedBitmapAmpdu2 (0),
1569 WifiTxVector txVector, std::vector<bool> statusPerMpdu)
1572 if (statusPerMpdu.empty ())
1577 auto rxOkForMpdu = statusPerMpdu.begin ();
1578 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1599 else if (size == 1130)
1603 else if (size == 1230)
1607 else if (size == 1330)
1611 else if (size == 1430)
1615 else if (size == 1530)
1625 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1638 else if (size == 1130)
1642 else if (size == 1230)
1646 else if (size == 1330)
1650 else if (size == 1430)
1654 else if (size == 1530)
1668 else if (p->
GetSize () == 1130)
1672 else if (p->
GetSize () == 1230)
1676 else if (p->
GetSize () == 1330)
1680 else if (p->
GetSize () == 1430)
1684 else if (p->
GetSize () == 1530)
1733 currentState = state->GetState ();
1746 std::vector<Ptr<WifiMacQueueItem>> mpduList;
1747 for (
size_t i = 0; i < 3; ++i)
1749 Ptr<Packet> p = Create<Packet> (referencePacketSize + i * 100);
1750 mpduList.push_back (Create<WifiMacQueueItem> (p, hdr));
1761 txParams->psd = txPowerSpectrum;
1762 txParams->txPhy = 0;
1763 txParams->duration = txDuration;
1764 txParams->ppdu = ppdu;
1772 m_phy = CreateObject<SpectrumWifiPhy> ();
1784 preambleDetectionModel->SetAttribute (
"Threshold",
DoubleValue (2));
1788 frameCaptureModel->SetAttribute (
"Margin",
DoubleValue (5));
1803 RngSeedManager::SetSeed (1);
1804 RngSeedManager::SetRun (2);
1805 int64_t streamNumber = 1;
1806 double rxPowerDbm = -30;
2341 Simulator::Destroy ();
2357 :
TestSuite (
"wifi-phy-reception", UNIT)
void IncrementSuccessBitmap(uint32_t size)
Increment reception success bitmap.
uint8_t m_rxDroppedBitmapAmpdu2
bitmap of dropped MPDUs in A-MPDU #2
void CheckRxSuccessBitmapAmpdu2(uint8_t expected)
Check the RX success bitmap for A-MPDU 2.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
void CheckRxDroppedBitmapAmpdu1(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 1.
uint8_t m_rxSuccessBitmapAmpdu1
bitmap of successfully received MPDUs in A-MPDU #1
uint8_t m_rxFailureBitmapAmpdu1
bitmap of unsuccessfully received MPDUs in A-MPDU #1
void RxFailure(Ptr< WifiPsdu > psdu)
RX failure function.
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfully received MPDUs in A-MPDU #2
void DoRun(void) override
Implementation to actually run this TestCase.
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
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).
void CheckRxFailureBitmapAmpdu2(uint8_t expected)
Check the RX failure bitmap for A-MPDU 2.
uint8_t m_rxDroppedBitmapAmpdu1
bitmap of dropped MPDUs in A-MPDU #1
void IncrementFailureBitmap(uint32_t size)
Increment reception failure bitmap.
void ResetBitmaps()
Reset bitmaps function.
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
virtual ~TestAmpduReception()
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
void CheckRxSuccessBitmapAmpdu1(uint8_t expected)
Check the RX success bitmap for A-MPDU 1.
void CheckRxFailureBitmapAmpdu1(uint8_t expected)
Check the RX failure bitmap for A-MPDU 1.
uint8_t m_rxSuccessBitmapAmpdu2
bitmap of successfully received MPDUs in A-MPDU #2
Ptr< SpectrumWifiPhy > m_phy
Phy.
void CheckRxDroppedBitmapAmpdu2(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 2.
Simple frame capture model test.
void Expect1000BPacketReceived()
Verify whether 1000 bytes packet has been received.
bool m_rxDropped1500B
count dropped packets with 1500B payload
void Expect1500BPacketDropped()
Verify whether 1500 bytes packet has been dropped.
void Expect1000BPacketDropped()
Verify whether 1000 bytes packet has been dropped.
void DoRun(void) override
Implementation to actually run this TestCase.
void Reset(void)
Reset function.
void SendPacket(double rxPowerDbm, uint32_t packetSize)
Send packet function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
bool m_rxSuccess1000B
count received packets with 1000B payload
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
bool m_rxSuccess1500B
count received packets with 1500B payload
void Expect1500BPacketReceived()
Verify whether 1500 bytes packet has been received.
uint64_t m_uid
the UID to use for the PPDU
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
TestSimpleFrameCaptureModel()
bool m_rxDropped1000B
count dropped packets with 1000B payload
virtual ~TestSimpleFrameCaptureModel()
Preamble detection test w/o frame capture.
TestThresholdPreambleDetectionWithFrameCapture()
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void SendPacket(double rxPowerDbm)
Send packet function.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxSuccess
count RX success
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
uint32_t m_countRxFailure
count RX failure
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void DoRun(void) override
Implementation to actually run this TestCase.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
virtual ~TestThresholdPreambleDetectionWithFrameCapture()
uint64_t m_uid
the UID to use for the PPDU
Preamble detection test w/o frame capture.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
TestThresholdPreambleDetectionWithoutFrameCapture()
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxFailure
count RX failure
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
uint64_t m_uid
the UID to use for the PPDU
virtual ~TestThresholdPreambleDetectionWithoutFrameCapture()
void DoRun(void) override
Implementation to actually run this TestCase.
void SendPacket(double rxPowerDbm)
Send packet function.
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
Ptr< SpectrumWifiPhy > m_phy
Phy.
uint32_t m_countRxSuccess
count RX success
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
wifi PHY reception Test Suite
WifiPhyReceptionTestSuite()
This class can be used to hold variables of floating point type such as 'double' or 'float'.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
void Dispose(void)
Dispose of this Object.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Hold objects of type Ptr<T>.
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
void SetChannelNumber(uint8_t id) override
Set channel number.
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
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...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
AttributeValue implementation for Time.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
void SetReceiveErrorCallback(RxErrorCallback callback)
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
void SetReceiveOkCallback(RxOkCallback callback)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
This objects implements the PHY state machine of the Wifi device.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
#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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
@ WIFI_PHY_STANDARD_80211ax
HE PHY (clause 26)
@ WIFI_PHY_BAND_5GHZ
The 5 GHz band.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double DbmToW(double dBm)
Convert from dBm to Watts.
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...
RxSignalInfo structure containing info on the received signal.
static const uint8_t CHANNEL_NUMBER
static const uint16_t GUARD_WIDTH
static const uint16_t CHANNEL_WIDTH
static WifiPhyReceptionTestSuite wifiPhyReceptionTestSuite
the test suite
static const uint32_t FREQUENCY
WifiPhyState
The state of the PHY layer.
@ CCA_BUSY
The PHY layer has sense the medium busy through the CCA mechanism.
@ RX
The PHY layer is receiving a packet.
@ IDLE
The PHY layer is IDLE.
static const uint32_t packetSize
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...