25 #include "ns3/string.h"
26 #include "ns3/pointer.h"
27 #include "ns3/uinteger.h"
31 #include "ns3/dsss-error-rate-model.h"
46 static TypeId tid =
TypeId (
"ns3::TableBasedErrorRateModel")
48 .SetGroupName (
"Wifi")
50 .AddAttribute (
"FallbackErrorRateModel",
51 "Ptr to the fallback error rate model to be used when no matching value is found in a table",
54 MakePointerChecker <ErrorRateModel> ())
55 .AddAttribute (
"SizeThreshold",
56 "Threshold in bytes over which the table for large size frames is used",
59 MakeUintegerChecker<uint64_t> ())
80 double multiplier = std::round (std::pow (10.0, precision));
81 return std::floor (snr * multiplier + 0.5) / multiplier;
146 NS_LOG_FUNCTION (
this << mode << txVector << snr << nbits << +numRxAntennas << field << staId);
147 uint64_t size = std::max<uint64_t> (1, (nbits / 8));
150 bool ldpc = txVector.
IsLdpc ();
161 NS_LOG_WARN (
"Table missing for MCS: " << +mcs <<
" in TableBasedErrorRateModel: use fallback error rate model");
166 auto itVector = errorTable[mcs];
167 auto itTable = std::find_if (itVector.begin(), itVector.end(),
168 [&roundedSnr](
const std::pair<double, double>& element) {
169 return element.first == roundedSnr;
171 double minSnr = itVector.begin ()->first;
172 double maxSnr = (--itVector.end ())->
first;
174 if (itTable == itVector.end ())
176 if (roundedSnr < minSnr)
180 else if (roundedSnr > maxSnr)
186 double a = 0.0, b = 0.0, previousSnr = 0.0, nextSnr = 0.0;
187 for (
auto i = itVector.begin (); i != itVector.end (); ++i)
189 if (i->first < roundedSnr)
191 previousSnr = i->first;
201 per = a + (roundedSnr - previousSnr) * (b - a) / (nextSnr - previousSnr);
206 per = itTable->second;
210 if (size != tableSize)
213 per = (1.0 - std::pow ((1 - per), (
static_cast<double> (size) / tableSize)));
the interface for Wifi's error models
Hold objects of type Ptr<T>.
Introspection did not find any typical Config paths.
Ptr< ErrorRateModel > m_fallbackErrorModel
Error rate model to fallback to if no value is found in the table.
double DoGetChunkSuccessRate(WifiMode mode, const WifiTxVector &txVector, double snr, uint64_t nbits, uint8_t numRxAntennas, WifiPpduField field, uint16_t staId) const override
A pure virtual method that must be implemented in the subclass.
TableBasedErrorRateModel()
static uint8_t GetMcsForMode(WifiMode mode)
Utility function to convert WifiMode to an MCS value.
static TypeId GetTypeId(void)
Get the type ID.
~TableBasedErrorRateModel()
double RoundSnr(double snr, double precision) const
Round SNR (in dB) to the specified precision.
uint64_t m_threshold
Threshold in bytes over which the table for large size frames is used.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
represent a single transmission mode
uint16_t GetConstellationSize(void) const
uint8_t GetMcsValue(void) const
WifiModulationClass GetModulationClass() const
WifiCodeRate GetCodeRate(void) const
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
bool IsLdpc(void) const
Check if LDPC FEC coding is used or not.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
WifiPpduField
The type of PPDU field (grouped for convenience)
@ WIFI_MOD_CLASS_OFDM
OFDM (Clause 17)
@ WIFI_MOD_CLASS_HT
HT (Clause 19)
@ WIFI_MOD_CLASS_VHT
VHT (Clause 22)
@ WIFI_MOD_CLASS_HE
HE (Clause 27)
@ WIFI_MOD_CLASS_ERP_OFDM
ERP-OFDM (18.4)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double RatioToDb(double ratio)
Convert from ratio to dB.
const uint16_t WIFI_CODE_RATE_3_4
3/4 coding rate
static const SnrPerTable AwgnErrorTableBcc1458[ERROR_TABLE_BCC_MAX_NUM_MCS+1]
AWGN error table for BCC with reference size of 1458 bytes.
const uint16_t WIFI_CODE_RATE_1_2
1/2 coding rate
const uint8_t ERROR_TABLE_BCC_MAX_NUM_MCS
maximum number of MCSs for BCC
const uint16_t WIFI_CODE_RATE_2_3
2/3 coding rate
const uint8_t ERROR_TABLE_LDPC_MAX_NUM_MCS
maximum number of MCSs for LDPC
const uint16_t ERROR_TABLE_BCC_LARGE_FRAME_SIZE
reference size (bytes) of large frames for BCC
static const SnrPerTable AwgnErrorTableLdpc1458[ERROR_TABLE_LDPC_MAX_NUM_MCS+1]
AWGN error table for LDPC with reference size of 1458 bytes.
const uint16_t ERROR_TABLE_BCC_SMALL_FRAME_SIZE
reference size (bytes) of small frames for BCC
static const double TABLED_BASED_ERROR_MODEL_PRECISION
precision for PER
static const double SNR_PRECISION
precision for SNR
const uint16_t ERROR_TABLE_LDPC_FRAME_SIZE
reference size (bytes) for LDPC
static const SnrPerTable AwgnErrorTableBcc32[ERROR_TABLE_BCC_MAX_NUM_MCS+1]
AWGN error table for BCC with reference size of 32 bytes.