25 #include "ns3/string.h" 26 #include "ns3/pointer.h" 27 #include "ns3/uinteger.h" 45 static TypeId tid =
TypeId (
"ns3::TableBasedErrorRateModel")
47 .SetGroupName (
"Wifi")
49 .AddAttribute (
"FallbackErrorRateModel",
50 "Ptr to the fallback error rate model to be used when no matching value is found in a table",
53 MakePointerChecker <ErrorRateModel> ())
54 .AddAttribute (
"SizeThreshold",
55 "Threshold in bytes over which the table for large size frames is used",
58 MakeUintegerChecker<uint64_t> ())
79 double multiplier = std::round (std::pow (10.0, precision));
80 return std::floor (snr * multiplier + 0.5) / multiplier;
146 uint64_t size = std::max<uint64_t> (1, (nbits / 8));
149 bool ldpc = txVector.
IsLdpc ();
160 NS_LOG_WARN (
"Table missing for MCS: " << +mcs <<
" in TableBasedErrorRateModel: use fallback error rate model");
165 auto itVector = errorTable[mcs];
166 auto itTable = std::find_if (itVector.begin(), itVector.end(),
167 [&roundedSnr](
const std::pair<double, double>& element) {
168 return element.first == roundedSnr;
170 double minSnr = itVector.begin ()->first;
171 double maxSnr = (--itVector.end ())->
first;
173 if (itTable == itVector.end ())
175 if (roundedSnr < minSnr)
179 else if (roundedSnr > maxSnr)
185 double a = 0.0, b = 0.0, previousSnr = 0.0, nextSnr = 0.0;
186 for (
auto i = itVector.begin (); i != itVector.end (); ++i)
188 if (i->first < roundedSnr)
190 previousSnr = i->first;
200 per = a + (roundedSnr - previousSnr) * (b - a) / (nextSnr - previousSnr);
205 per = itTable->second;
209 if (size != tableSize)
212 per = (1.0 - std::pow ((1 - per), (static_cast<double> (size) / tableSize)));
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
const uint8_t ERROR_TABLE_LDPC_MAX_NUM_MCS
const uint8_t ERROR_TABLE_BCC_MAX_NUM_MCS
Ptr< ErrorRateModel > m_fallbackErrorModel
Error rate model to fallback to if no value is found in the table.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
const uint16_t ERROR_TABLE_LDPC_FRAME_SIZE
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
bool IsLdpc(void) const
Check if LDPC FEC coding is used or not.
~TableBasedErrorRateModel()
the interface for Wifi's error models
uint64_t m_threshold
Threshold in bytes over which the table for large size frames is used.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static const std::vector< std::pair< double, double > > AwgnErrorTableBcc32[ERROR_TABLE_BCC_MAX_NUM_MCS+1]
double DoGetChunkSuccessRate(WifiMode mode, WifiTxVector txVector, double snr, uint64_t nbits) const
A pure virtual method that must be implemented in the subclass.
Introspection did not find any typical Config paths.
Hold an unsigned integer type.
double RoundSnr(double snr, double precision) const
Round SNR (in dB) to the specified precision.
static const std::vector< std::pair< double, double > > AwgnErrorTableBcc1458[ERROR_TABLE_BCC_MAX_NUM_MCS+1]
static const std::vector< std::pair< double, double > > AwgnErrorTableLdpc1458[ERROR_TABLE_LDPC_MAX_NUM_MCS+1]
static TypeId GetTypeId(void)
Get the type ID.
WifiModulationClass GetModulationClass() const
TableBasedErrorRateModel()
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
const uint16_t ERROR_TABLE_BCC_SMALL_FRAME_SIZE
static const double SNR_PRECISION
uint16_t GetConstellationSize(void) const
double RatioToDb(double ratio)
Convert from ratio to dB.
static uint8_t GetMcsForMode(WifiMode mode)
Utility function to convert WifiMode to an MCS value.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
const uint16_t ERROR_TABLE_BCC_LARGE_FRAME_SIZE
WifiCodeRate GetCodeRate(void) const
uint8_t GetMcsValue(void) const
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.