24 #include "ns3/nist-error-rate-model.h"
25 #include "ns3/yans-error-rate-model.h"
26 #include "ns3/dsss-error-rate-model.h"
27 #include "ns3/wifi-phy.h"
28 #include "ns3/wifi-utils.h"
29 #include "ns3/table-based-error-rate-model.h"
30 #include "ns3/he-phy.h"
41 double noisePowerDbw = -100.5522786 + 7;
43 double sinrDb = rssDbw - noisePowerDbw;
45 return pow (10.0, sinrDb / 10.0);
61 void DoRun (
void)
override;
65 :
TestCase (
"WifiErrorRateModel test case DSSS")
77 uint64_t size = (1024 + 40 + 14) * 8;
82 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-105.0), size);
84 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-100.0), size);
86 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-99.0), size);
88 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-98.0), size);
90 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-97.0), size);
92 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-96.0), size);
94 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-95.0), size);
96 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-90.0), size);
101 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-96.0), size);
103 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-95.0), size);
105 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-94.0), size);
107 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-93.0), size);
109 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-92.0), size);
111 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-91.0), size);
113 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-90.0), size);
115 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-89.0), size);
120 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-94.0), size);
122 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-93.0), size);
124 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-92.0), size);
126 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-91.0), size);
128 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-90.0), size);
130 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-89.0), size);
132 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-88.0), size);
134 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-87.0), size);
138 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-91.0), size);
140 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-90.0), size);
142 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-89.0), size);
144 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-88.0), size);
146 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-87.0), size);
148 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-86.0), size);
150 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-85.0), size);
152 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-84.0), size);
170 void DoRun (
void)
override;
174 :
TestCase (
"WifiErrorRateModel test case NIST")
185 uint32_t frameSize = 2000;
195 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
198 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
201 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
204 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
208 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
211 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
214 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
217 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
221 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
224 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
227 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
230 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
234 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
237 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
240 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
243 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
247 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
250 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
253 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
256 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
260 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
263 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
266 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
269 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
273 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
276 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
279 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
282 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
286 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
289 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
292 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
295 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
302 using InterferenceHelper::InterferenceHelper;
303 using InterferenceHelper::CalculatePayloadChunkSuccessRate;
304 using InterferenceHelper::CalculateSnr;
320 void DoRun (
void)
override;
324 :
TestCase (
"WifiErrorRateModel test case MIMO")
337 WifiMode mode = HtPhy::GetHtMcs0 ();
351 double initialSnr = 4.0;
357 double sisoChunkSuccess = chunkSuccess;
464 {std::make_pair (0, 1458), {
604 {std::make_pair (0, 32), {
744 {std::make_pair (0, 1000), {
884 {std::make_pair (0, 1), {
1024 {std::make_pair (0, 2000), {
1164 {std::make_pair (7, 1500), {
1304 {std::make_pair (8, 1500), {
1465 void DoRun (
void)
override;
1474 m_testName (testName),
1496 for (
double snr = -4; snr <= 30; snr += 0.25)
1498 double expectedValue = 0;
1502 expectedValue = 1 - yans->GetChunkSuccessRate (
m_mode, txVector, std::pow (10, snr / 10),
m_size * 8);
1509 auto itValue = it->second.find (snr);
1510 if (itValue != it->second.end ())
1512 expectedValue = itValue->second;
1524 double per = 1 - table->GetChunkSuccessRate (
m_mode, txVector, std::pow (10, snr / 10),
m_size * 8);
1525 NS_LOG_INFO (
m_testName <<
": snr=" << snr <<
"dB per=" << per <<
" expectedPER=" << expectedValue);
1543 :
TestSuite (
"wifi-error-rate-models", UNIT)
Wifi Table-based Error Rate Models Test Case.
WifiMode m_mode
The WifiMode to test.
uint32_t m_size
The size (in bytes) to test.
TableBasedErrorRateTestCase(const std::string &testName, WifiMode mode, uint32_t size)
Constructor.
std::string m_testName
The name of the test to run.
void DoRun(void) override
Implementation to actually run this TestCase.
virtual ~TableBasedErrorRateTestCase()
Wifi Error Rate Models Test Case Dsss.
virtual ~WifiErrorRateModelsTestCaseDsss()
void DoRun(void) override
Implementation to actually run this TestCase.
WifiErrorRateModelsTestCaseDsss()
Wifi Error Rate Models Test Case MIMO.
WifiErrorRateModelsTestCaseMimo()
virtual ~WifiErrorRateModelsTestCaseMimo()
void DoRun(void) override
Implementation to actually run this TestCase.
Wifi Error Rate Models Test Case Nist.
void DoRun(void) override
Implementation to actually run this TestCase.
virtual ~WifiErrorRateModelsTestCaseNist()
WifiErrorRateModelsTestCaseNist()
Wifi Error Rate Models Test Suite.
WifiErrorRateModelsTestSuite()
handles interference calculations
void SetNoiseFigure(double value)
Set the noise figure.
void SetErrorRateModel(const Ptr< ErrorRateModel > rate)
Set the error rate model for this interference helper.
double CalculatePayloadChunkSuccessRate(double snir, Time duration, const WifiTxVector &txVector, uint16_t staId=SU_STA_ID) const
Calculate the success rate of the payload chunk given the SINR, duration, and TXVECTOR.
double CalculateSnr(Ptr< Event > event, uint16_t channelWidth, uint8_t nss, WifiSpectrumBand band) const
Calculate the SNIR for the event (starting from now until the event end).
void SetNumberOfReceiveAntennas(uint8_t rx)
Set the number of RX antennas in the receiver corresponding to this interference helper.
Smart pointer class similar to boost::intrusive_ptr.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
represent a single transmission mode
uint8_t GetMcsValue(void) const
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
void SetTxPowerLevel(uint8_t powerlevel)
Sets the selected transmission power level.
void SetChannelWidth(uint16_t channelWidth)
Sets the selected channelWidth (in MHz)
uint8_t GetNss(uint16_t staId=SU_STA_ID) const
If this TX vector is associated with an SU PPDU, return the number of spatial streams.
void SetNTx(uint8_t nTx)
Sets the number of TX antennas.
uint16_t GetChannelWidth(void) const
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
void SetNss(uint8_t nss)
Sets the number of Nss.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_TEST_ASSERT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report and abort if not.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double RatioToDb(double ratio)
Convert from ratio to dB.
const uint8_t ERROR_TABLE_BCC_MAX_NUM_MCS
maximum number of MCSs for BCC
double DbToRatio(double dB)
Convert from dB to ratio.
std::map< std::pair< uint8_t, uint32_t >, std::map< double, double > > expectedTableValues
map of PER values that have been manually computed for a given MCS, size (in bytes) and SNR (in dB) i...
static double FromRss(double rssDbw)
static WifiErrorRateModelsTestSuite wifiErrorRateModelsTestSuite
the test suite