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;
142 txParams->
ppdu = ppdu;
196 m_phy = CreateObject<SpectrumWifiPhy> ();
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;
507 txParams->
ppdu = ppdu;
561 m_phy = CreateObject<SpectrumWifiPhy> ();
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;
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> ();
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;
1241 txParams->
ppdu = ppdu;
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)
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;
1764 txParams->
ppdu = ppdu;
1772 m_phy = CreateObject<SpectrumWifiPhy> ();
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)
uint32_t m_countRxSuccess
count RX success
uint64_t m_uid
the UID to use for the PPDU
void DoRun(void) override
Implementation to actually run this TestCase.
void Dispose(void)
Dispose of this Object.
uint8_t m_rxSuccessBitmapAmpdu1
bitmap of successfully received MPDUs in A-MPDU #1
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
bool IsSingle(void) const
Return true if the PSDU is an S-MPDU.
void CheckRxFailureBitmapAmpdu2(uint8_t expected)
Check the RX failure bitmap for A-MPDU 2.
Simulation virtual time values and global simulation resolution.
Ptr< SpectrumWifiPhy > m_phy
Phy.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void SendPacket(double rxPowerDbm)
Send packet function.
void Expect1000BPacketDropped()
Verify whether 1000 bytes packet has been dropped.
Ptr< WifiPpdu > ppdu
The PPDU being transmitted.
static const uint32_t packetSize
void StartRx(Ptr< SpectrumSignalParameters > rxParams)
Input method for delivering a signal from the spectrum channel and low-level PHY interface to this Sp...
void SendPacket(double rxPowerDbm, uint32_t packetSize)
Send packet function.
void IncrementFailureBitmap(uint32_t size)
Increment reception failure bitmap.
virtual ~TestThresholdPreambleDetectionWithoutFrameCapture()
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
double DbmToW(double dBm)
Convert from dBm to Watts.
void ResetBitmaps()
Reset bitmaps function.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void Reset(void)
Reset function.
void CheckRxSuccessBitmapAmpdu1(uint8_t expected)
Check the RX success bitmap for A-MPDU 1.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void SetReceiveErrorCallback(RxErrorCallback callback)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void Expect1500BPacketReceived()
Verify whether 1500 bytes packet has been received.
static WifiPhyReceptionTestSuite wifiPhyReceptionTestSuite
the test suite
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Simple frame capture model test.
Ptr< SpectrumWifiPhy > m_phy
Phy.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
std::vector< Ptr< WifiMacQueueItem > >::const_iterator end(void) const
Return a const iterator to past-the-last MPDU.
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
static const uint16_t GUARD_WIDTH
void DoRun(void) override
Implementation to actually run this TestCase.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
uint64_t m_uid
the UID to use for the PPDU
static Time CalculateTxDuration(uint32_t size, const WifiTxVector &txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
Ptr< SpectrumWifiPhy > m_phy
Phy.
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
Preamble detection test w/o frame capture.
Preamble detection test w/o frame capture.
RxSignalInfo structure containing info on the received signal.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void SendPacket(double rxPowerDbm)
Send packet function.
WifiPhyReceptionTestSuite()
AttributeValue implementation for Time.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
#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.
void Expect1000BPacketReceived()
Verify whether 1000 bytes packet has been received.
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
bool m_rxSuccess1000B
count received packets with 1000B payload
void DoRun(void) override
Implementation to actually run this TestCase.
uint8_t m_rxFailureBitmapAmpdu1
bitmap of unsuccessfully received MPDUs in A-MPDU #1
The PHY layer has sense the medium busy through the CCA mechanism.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
static const uint32_t FREQUENCY
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
void IncrementSuccessBitmap(uint32_t size)
Increment reception success bitmap.
uint8_t m_rxDroppedBitmapAmpdu2
bitmap of dropped MPDUs in A-MPDU #2
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 RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
virtual ~TestThresholdPreambleDetectionWithFrameCapture()
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxFailure
count RX failure
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
uint64_t m_uid
the UID to use for the PPDU
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
void CheckRxDroppedBitmapAmpdu2(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 2.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
std::size_t GetNMpdus(void) const
Return the number of MPDUs constituting the PSDU.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
WifiPhyState
The state of the PHY layer.
bool m_rxDropped1500B
count dropped packets with 1500B payload
void RxFailure(Ptr< WifiPsdu > psdu)
Spectrum wifi receive failure function.
void CheckRxSuccessBitmapAmpdu2(uint8_t expected)
Check the RX success bitmap for A-MPDU 2.
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
void DoTeardown(void) override
Implementation to do any local setup required for this TestCase.
virtual ~TestAmpduReception()
uint8_t m_rxSuccessBitmapAmpdu2
bitmap of successfully received MPDUs in A-MPDU #2
uint8_t m_rxFailureBitmapAmpdu2
bitmap of unsuccessfully received MPDUs in A-MPDU #2
virtual ~TestSimpleFrameCaptureModel()
void SendPacket(Ptr< NetDevice > sourceDevice, Address &destination)
This example (inspired from tv-trans-example) enables to generate the transmitted spectra of Wi-Fi st...
uint32_t m_countRxFailure
count RX failure
void SetReceiveOkCallback(RxOkCallback callback)
This objects implements the PHY state machine of the Wifi device.
WifiPhyState GetState(void) const
Return the current state of WifiPhy.
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...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
TestThresholdPreambleDetectionWithFrameCapture()
TestSimpleFrameCaptureModel()
Time Seconds(double value)
Construct a Time in the indicated unit.
The PHY layer is receiving a packet.
void SetChannelNumber(uint8_t id) override
Set channel number.
bool m_rxSuccess1500B
count received packets with 1500B payload
std::vector< Ptr< WifiMacQueueItem > >::const_iterator begin(void) const
Return a const iterator to the first MPDU.
void DoSetup(void) override
Implementation to do any local setup required for this TestCase.
void RxFailure(Ptr< WifiPsdu > psdu)
RX failure function.
Time duration
The duration of the packet transmission.
static const uint16_t CHANNEL_WIDTH
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
void Expect1500BPacketDropped()
Verify whether 1500 bytes packet has been dropped.
uint32_t m_countRxSuccess
count RX success
uint8_t m_rxDroppedBitmapAmpdu1
bitmap of dropped MPDUs in A-MPDU #1
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void CheckRxFailureBitmapAmpdu1(uint8_t expected)
Check the RX failure bitmap for A-MPDU 1.
bool m_rxDropped1000B
count dropped packets with 1000B payload
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void CheckPhyState(WifiPhyState expectedState)
Schedule now to check the PHY state.
void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band) override
Configure the PHY-level parameters for different Wi-Fi standard.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
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...
wifi PHY reception Test Suite
void RxSuccess(Ptr< WifiPsdu > psdu, RxSignalInfo rxSignalInfo, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
static const uint8_t CHANNEL_NUMBER
TestThresholdPreambleDetectionWithoutFrameCapture()
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
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.
void DoRun(void) override
Implementation to actually run this TestCase.
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.