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"
31 #include "ns3/interference-helper.h"
42 double noisePowerDbw = -100.5522786 + 7;
44 double sinrDb = rssDbw - noisePowerDbw;
46 return pow (10.0, sinrDb / 10.0);
62 void DoRun (
void)
override;
66 :
TestCase (
"WifiErrorRateModel test case DSSS")
78 uint64_t size = (1024 + 40 + 14) * 8;
83 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-105.0), size);
85 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-100.0), size);
87 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-99.0), size);
89 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-98.0), size);
91 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-97.0), size);
93 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-96.0), size);
95 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-95.0), size);
97 value = DsssErrorRateModel::GetDsssDbpskSuccessRate (
FromRss (-90.0), size);
102 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-96.0), size);
104 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-95.0), size);
106 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-94.0), size);
108 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-93.0), size);
110 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-92.0), size);
112 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-91.0), size);
114 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-90.0), size);
116 value = DsssErrorRateModel::GetDsssDqpskSuccessRate (
FromRss (-89.0), size);
121 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-94.0), size);
123 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-93.0), size);
125 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-92.0), size);
127 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-91.0), size);
129 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-90.0), size);
131 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-89.0), size);
133 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-88.0), size);
135 value = DsssErrorRateModel::GetDsssDqpskCck5_5SuccessRate (
FromRss (-87.0), size);
139 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-91.0), size);
141 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-90.0), size);
143 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-89.0), size);
145 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-88.0), size);
147 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-87.0), size);
149 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-86.0), size);
151 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-85.0), size);
153 value = DsssErrorRateModel::GetDsssDqpskCck11SuccessRate (
FromRss (-84.0), size);
171 void DoRun (
void)
override;
175 :
TestCase (
"WifiErrorRateModel test case NIST")
186 uint32_t frameSize = 2000;
196 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
199 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
202 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
205 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate6Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
209 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
212 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
215 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
218 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate9Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
222 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
225 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
228 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
231 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate12Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
235 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
238 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
241 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
244 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate18Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
248 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
251 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
254 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
257 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate24Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
261 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
264 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
267 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
270 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate36Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
274 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
277 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
280 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
283 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate48Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
287 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
290 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
293 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
296 ps = nist->GetChunkSuccessRate (
WifiMode (
"OfdmRate54Mbps"), txVector, std::pow (10.0, snr / 10.0), frameSize * 8);
303 using InterferenceHelper::InterferenceHelper;
304 using InterferenceHelper::CalculatePayloadChunkSuccessRate;
305 using InterferenceHelper::CalculateSnr;
321 void DoRun (
void)
override;
325 :
TestCase (
"WifiErrorRateModel test case MIMO")
338 WifiMode mode = HtPhy::GetHtMcs0 ();
352 double initialSnr = 4.0;
358 double sisoChunkSuccess = chunkSuccess;
465 {std::make_pair (0, 1458), {
605 {std::make_pair (0, 32), {
745 {std::make_pair (0, 1000), {
885 {std::make_pair (0, 1), {
1025 {std::make_pair (0, 2000), {
1165 {std::make_pair (7, 1500), {
1305 {std::make_pair (8, 1500), {
1466 void DoRun (
void)
override;
1475 m_testName (testName),
1497 for (
double snr = -4; snr <= 30; snr += 0.25)
1499 double expectedValue = 0;
1503 expectedValue = 1 - yans->GetChunkSuccessRate (
m_mode, txVector, std::pow (10, snr / 10),
m_size * 8);
1510 auto itValue = it->second.find (snr);
1511 if (itValue != it->second.end ())
1513 expectedValue = itValue->second;
1525 double per = 1 - table->GetChunkSuccessRate (
m_mode, txVector, std::pow (10, snr / 10),
m_size * 8);
1526 NS_LOG_INFO (
m_testName <<
": snr=" << snr <<
"dB per=" << per <<
" expectedPER=" << expectedValue);
1544 :
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