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/wifi-mac-trailer.h" 32 #include "ns3/ampdu-tag.h" 33 #include "ns3/wifi-phy-tag.h" 34 #include "ns3/wifi-spectrum-signal-parameters.h" 35 #include "ns3/wifi-utils.h" 36 #include "ns3/threshold-preamble-detection-model.h" 37 #include "ns3/simple-frame-capture-model.h" 38 #include "ns3/wifi-psdu.h" 39 #include "ns3/wifi-mac-queue-item.h" 40 #include "ns3/mpdu-aggregator.h" 41 #include "ns3/wifi-phy-header.h" 65 virtual void DoSetup (
void);
89 virtual void DoRun (
void);
102 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
106 :
TestCase (
"Threshold preamble detection model test when no frame capture model is applied"),
107 m_countRxSuccess (0),
125 hdr.SetDuration (txDuration);
145 txParams->
psd = txPowerSpectrum;
201 m_phy = CreateObject<SpectrumWifiPhy> ();
219 RngSeedManager::SetSeed (1);
220 RngSeedManager::SetRun (1);
221 int64_t streamNumber = 0;
225 double rxPowerDbm = -50;
396 Simulator::Destroy ();
436 virtual void DoRun (
void);
449 void CheckRxPacketCount (uint32_t expectedSuccessCount, uint32_t expectedFailureCount);
453 :
TestCase (
"Threshold preamble detection model test when simple frame capture model is applied"),
454 m_countRxSuccess (0),
472 hdr.SetDuration (txDuration);
492 txParams->
psd = txPowerSpectrum;
548 m_phy = CreateObject<SpectrumWifiPhy> ();
571 RngSeedManager::SetSeed (1);
572 RngSeedManager::SetRun (1);
573 int64_t streamNumber = 1;
577 double rxPowerDbm = -50;
766 Simulator::Destroy ();
785 virtual void DoRun (
void);
826 :
TestCase (
"Simple frame capture model test"),
827 m_rxSuccess1000B (false),
828 m_rxSuccess1500B (false),
829 m_rxDropped1000B (false),
830 m_rxDropped1500B (false)
847 hdr.SetDuration (txDuration);
867 txParams->
psd = txPowerSpectrum;
883 else if (p->
GetSize () == 1530)
897 else if (p->
GetSize () == 1530)
943 m_phy = CreateObject<SpectrumWifiPhy> ();
966 RngSeedManager::SetSeed (1);
967 RngSeedManager::SetRun (1);
968 int64_t streamNumber = 2;
969 double rxPowerDbm = -30;
1007 Simulator::Destroy ();
1032 virtual void DoRun (
void);
1043 :
TestCase (
"PHY headers reception test")
1061 hdr.SetDuration (txDuration);
1081 txParams->
psd = txPowerSpectrum;
1082 txParams->
txPhy = 0;
1117 m_phy = CreateObject<SpectrumWifiPhy> ();
1128 RngSeedManager::SetSeed (1);
1129 RngSeedManager::SetRun (1);
1130 int64_t streamNumber = 0;
1134 double rxPowerDbm = -50;
1244 Simulator::Destroy ();
1263 virtual void DoRun (
void);
1357 :
TestCase (
"A-MPDU reception test"),
1358 m_rxSuccessBitmapAmpdu1 (0),
1359 m_rxSuccessBitmapAmpdu2 (0),
1360 m_rxFailureBitmapAmpdu1 (0),
1361 m_rxFailureBitmapAmpdu2 (0),
1362 m_rxDroppedBitmapAmpdu1 (0),
1363 m_rxDroppedBitmapAmpdu2 (0)
1389 std::list<Ptr<const Packet>> mpdus = MpduAggregator::PeekMpdus (p);
1390 NS_ABORT_MSG_IF (mpdus.size () != statusPerMpdu.size (),
"Should have one receive status per MPDU");
1391 auto rxOkForMpdu = statusPerMpdu.begin ();
1392 for (
const auto & mpdu : mpdus)
1418 else if (size == 1130)
1422 else if (size == 1230)
1426 else if (size == 1330)
1430 else if (size == 1430)
1434 else if (size == 1530)
1446 std::list<Ptr<const Packet>> mpdus = MpduAggregator::PeekMpdus (p);
1447 for (
const auto & mpdu : mpdus)
1465 else if (size == 1130)
1469 else if (size == 1230)
1473 else if (size == 1330)
1477 else if (size == 1430)
1481 else if (size == 1530)
1495 else if (p->
GetSize () == 1130)
1499 else if (p->
GetSize () == 1230)
1503 else if (p->
GetSize () == 1330)
1507 else if (p->
GetSize () == 1430)
1511 else if (p->
GetSize () == 1530)
1573 std::vector<Ptr<WifiMacQueueItem>> mpduList;
1574 for (
size_t i = 0; i < 3; ++i)
1576 Ptr<Packet> p = Create<Packet> (referencePacketSize + i * 100);
1577 mpduList.push_back (Create<WifiMacQueueItem> (p, hdr));
1593 uint16_t length = ((ceil ((static_cast<double> (txDuration.GetNanoSeconds () - (20 * 1000)) / 1000) / 4.0) * 3) - 3 - 2);
1602 txParams->
psd = txPowerSpectrum;
1603 txParams->
txPhy = 0;
1613 m_phy = CreateObject<SpectrumWifiPhy> ();
1637 RngSeedManager::SetSeed (1);
1638 RngSeedManager::SetRun (1);
1639 int64_t streamNumber = 1;
1640 double rxPowerDbm = -30;
2175 Simulator::Destroy ();
2191 :
TestSuite (
"wifi-phy-reception", UNIT)
uint32_t m_countRxSuccess
count RX success
uint8_t m_rxSuccessBitmapAmpdu1
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...
void SetDuration(Time duration)
Set the Duration/ID field on all the MPDUs.
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()
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()
double DbmToW(double dBm)
Convert from dBm to Watts.
void ResetBitmaps()
Reset bitmaps function.
void DoCheckPhyState(WifiPhyState expectedState)
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)
void RxSuccess(Ptr< Packet > p, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
void Expect1500BPacketReceived()
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.
uint16_t GetGuardInterval(void) const
Ptr< SpectrumWifiPhy > m_phy
Phy.
void DoCheckPhyState(WifiPhyState expectedState)
void SetFrameCaptureModel(const Ptr< FrameCaptureModel > frameCaptureModel)
Sets the frame capture model.
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
virtual void DoRun(void)
Implementation to actually run this TestCase.
MpduType
The type of an MPDU.
void RxFailure(Ptr< Packet > p)
Spectrum wifi receive failure function.
uint32_t GetSize(void) const
Return the size of the PSDU.
void RxSuccess(Ptr< Packet > p, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
WifiPreamble GetPreambleType(void) const
Time CalculateTxDuration(uint32_t size, WifiTxVector txVector, uint16_t frequency)
Ptr< SpectrumWifiPhy > m_phy
Phy.
The MPDU is not part of an A-MPDU.
void CheckPhyState(WifiPhyState expectedState)
Check the PHY state.
Preamble detection test w/o frame capture.
Preamble detection test w/o frame capture.
Ptr< const Packet > GetPacket(void) const
Get the PSDU as a single packet.
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.
HE PHY for the 5 GHz band (clause 26)
WifiPhyReceptionTestSuite()
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
AttributeValue implementation for Time.
virtual void ConfigureStandard(WifiPhyStandard standard)
Configure the PHY-level parameters for different Wi-Fi standard.
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.
uint32_t GetSerializedSize(void) const
#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()
void SetPreambleDetectionModel(const Ptr< PreambleDetectionModel > preambleDetectionModel)
Sets the preamble detection model.
bool m_rxSuccess1000B
count received packets with 1000B payload
void RxFailure(Ptr< Packet > p)
Spectrum wifi receive failure function.
uint8_t m_rxFailureBitmapAmpdu1
WifiMode GetMode(void) const
The PHY layer has sense the medium busy through the CCA mechanism.
Ptr< SpectrumPhy > txPhy
The SpectrumPhy instance that is making the transmission.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
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
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)...
WifiModulationClass GetModulationClass() const
void RxDropped(Ptr< const Packet > p, WifiPhyRxfailureReason reason)
RX dropped function.
virtual ~TestThresholdPreambleDetectionWithFrameCapture()
virtual void SetFrequency(uint16_t freq)
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.
bool IsAmpdu(Ptr< const Packet > packet)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
uint16_t GetFrequency(void) const
WifiPhyState
The state of the PHY layer.
bool m_rxDropped1500B
count dropped packets with 1500B payload
void CheckRxSuccessBitmapAmpdu2(uint8_t expected)
Check the RX success bitmap for A-MPDU 2.
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
virtual ~TestAmpduReception()
Ptr< Packet > packet
The packet being transmitted with this signal.
uint8_t m_rxSuccessBitmapAmpdu2
uint8_t m_rxFailureBitmapAmpdu2
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.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Ptr< SpectrumValue > psd
The Power Spectral Density of the waveform, in linear units.
uint8_t GetBssColor(void) const
Get the BSS color.
TestThresholdPreambleDetectionWithFrameCapture()
TestSimpleFrameCaptureModel()
Time Seconds(double value)
Construct a Time in the indicated unit.
The PHY layer is receiving a packet.
bool m_rxSuccess1500B
count received packets with 1500B payload
Tag for WifiTxVector and WifiPreamble information to be embedded in outgoing transmissions as a Packe...
Time duration
The duration of the packet transmission.
static const uint16_t CHANNEL_WIDTH
void RxFailure(Ptr< Packet > p)
RX failure function.
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()
static const uint32_t packetSize
uint16_t GetChannelWidth(void) const
virtual void DoSetup(void)
Implementation to do any local setup required for this TestCase.
uint32_t m_countRxSuccess
count RX success
uint8_t m_rxDroppedBitmapAmpdu1
void RxSuccess(Ptr< Packet > p, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
Spectrum wifi receive success function.
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)
Check the PHY state.
uint8_t GetMcsValue(void) const
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
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 AddHeader(const Header &header)
Add header to this packet.
void CheckRxDroppedBitmapAmpdu1(uint8_t expected)
Check the RX dropped bitmap for A-MPDU 1.
Implements the IEEE 802.11 MAC trailer.
void RxSuccess(Ptr< Packet > p, double snr, WifiTxVector txVector, std::vector< bool > statusPerMpdu)
RX success function.