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/wifi-ppdu.h" 63 virtual void DoSetup (
void);
87 virtual void DoRun (
void);
104 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
108 :
TestCase (
"Threshold preamble detection model test when no frame capture model is applied"),
109 m_countRxSuccess (0),
133 txParams->
psd = txPowerSpectrum;
136 txParams->
ppdu = ppdu;
189 m_phy = CreateObject<SpectrumWifiPhy> ();
207 RngSeedManager::SetSeed (1);
208 RngSeedManager::SetRun (1);
209 int64_t streamNumber = 0;
213 double rxPowerDbm = -50;
399 Simulator::Destroy ();
439 virtual void DoRun (
void);
456 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
460 :
TestCase (
"Threshold preamble detection model test when simple frame capture model is applied"),
461 m_countRxSuccess (0),
485 txParams->
psd = txPowerSpectrum;
488 txParams->
ppdu = ppdu;
541 m_phy = CreateObject<SpectrumWifiPhy> ();
564 RngSeedManager::SetSeed (1);
565 RngSeedManager::SetRun (1);
566 int64_t streamNumber = 1;
570 double rxPowerDbm = -50;
891 Simulator::Destroy ();
910 virtual void DoRun (
void);
963 :
TestCase (
"Simple frame capture model test"),
964 m_rxSuccess1000B (false),
965 m_rxSuccess1500B (false),
966 m_rxDropped1000B (false),
967 m_rxDropped1500B (false)
990 txParams->
psd = txPowerSpectrum;
993 txParams->
ppdu = ppdu;
1007 else if (psdu->
GetSize () == 1530)
1021 else if (p->
GetSize () == 1530)
1067 m_phy = CreateObject<SpectrumWifiPhy> ();
1090 RngSeedManager::SetSeed (1);
1091 RngSeedManager::SetRun (1);
1092 int64_t streamNumber = 2;
1093 double rxPowerDbm = -30;
1131 Simulator::Destroy ();
1156 virtual void DoRun (
void);
1171 :
TestCase (
"PHY headers reception test")
1194 txParams->
psd = txPowerSpectrum;
1195 txParams->
txPhy = 0;
1197 txParams->
ppdu = ppdu;
1230 m_phy = CreateObject<SpectrumWifiPhy> ();
1241 RngSeedManager::SetSeed (1);
1242 RngSeedManager::SetRun (1);
1243 int64_t streamNumber = 0;
1247 double rxPowerDbm = -50;
1372 Simulator::Destroy ();
1391 virtual void DoRun (
void);
1485 :
TestCase (
"A-MPDU reception test"),
1486 m_rxSuccessBitmapAmpdu1 (0),
1487 m_rxSuccessBitmapAmpdu2 (0),
1488 m_rxFailureBitmapAmpdu1 (0),
1489 m_rxFailureBitmapAmpdu2 (0),
1490 m_rxDroppedBitmapAmpdu1 (0),
1491 m_rxDroppedBitmapAmpdu2 (0)
1515 if (statusPerMpdu.empty ())
1520 auto rxOkForMpdu = statusPerMpdu.begin ();
1521 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1542 else if (size == 1130)
1546 else if (size == 1230)
1550 else if (size == 1330)
1554 else if (size == 1430)
1558 else if (size == 1530)
1568 for (
auto mpdu = psdu->
begin (); mpdu != psdu->
end (); ++mpdu)
1581 else if (size == 1130)
1585 else if (size == 1230)
1589 else if (size == 1330)
1593 else if (size == 1430)
1597 else if (size == 1530)
1611 else if (p->
GetSize () == 1130)
1615 else if (p->
GetSize () == 1230)
1619 else if (p->
GetSize () == 1330)
1623 else if (p->
GetSize () == 1430)
1627 else if (p->
GetSize () == 1530)
1689 std::vector<Ptr<WifiMacQueueItem>> mpduList;
1690 for (
size_t i = 0; i < 3; ++i)
1692 Ptr<Packet> p = Create<Packet> (referencePacketSize + i * 100);
1693 mpduList.push_back (Create<WifiMacQueueItem> (p, hdr));
1704 txParams->
psd = txPowerSpectrum;
1705 txParams->
txPhy = 0;
1707 txParams->
ppdu = ppdu;
1715 m_phy = CreateObject<SpectrumWifiPhy> ();
1739 RngSeedManager::SetSeed (1);
1740 RngSeedManager::SetRun (2);
1741 int64_t streamNumber = 1;
1742 double rxPowerDbm = -30;
2277 Simulator::Destroy ();
2293 :
TestSuite (
"wifi-phy-reception", UNIT)
uint32_t m_countRxSuccess
count RX success
uint8_t m_rxSuccessBitmapAmpdu1
bitmap of successfully received MPDUs in A-MPDU #1
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 "...
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
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 RxSuccess(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.
void DoCheckPhyState(WifiPhyState expectedState)
Check the PHY state now.
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 RxSuccess(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
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
#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.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void SetChannelNumber(uint8_t id)
Set channel number.
static const uint16_t GUARD_WIDTH
void RxSuccess(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
virtual void DoRun(void)
Implementation to actually run this TestCase.
uint32_t GetSize(void) const
Return the size of the PSDU in bytes.
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.
void CheckRxPacketCount(uint32_t expectedSuccessCount, uint32_t expectedFailureCount)
Check the number of received packets.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SendPacket(double rxPowerDbm)
Send packet function.
WifiPhyReceptionTestSuite()
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
AttributeValue implementation for Time.
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
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.
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
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()
virtual void SetFrequency(uint16_t freq)
virtual void ConfigureStandardAndBand(WifiPhyStandard standard, WifiPhyBand band)
Configure the PHY-level parameters for different Wi-Fi standard.
uint32_t m_countRxFailure
count RX failure
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Sets the error rate model.
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.
virtual void DoSetup(void)
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.
#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.
WifiPhyRxfailureReason
Enumeration of the possible reception failure reasons.
The PHY layer is receiving a packet.
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 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.
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxSuccess
count RX success
static Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, WifiPhyBand band, uint16_t staId=SU_STA_ID)
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 RxSuccess(Ptr< WifiPsdu > psdu, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
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 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
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 CheckRxDroppedBitmapAmpdu1(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 1.
bool IsAggregate(void) const
Return true if the PSDU is an S-MPDU or A-MPDU.