21#include "ns3/snr-to-block-error-rate-manager.h"
25#include "ns3/assert.h"
27#include "ns3/snr-to-block-error-rate-record.h"
40 for (
int i = 0; i < 7; i++)
51 for (
int i = 0; i < 7; i++)
60 for (
int i = 0; i < 7; i++)
62 for (std::vector<SNRToBlockErrorRateRecord*>::iterator iter =
86 std::ifstream traceFile;
90 double burstErrorRate;
95 for (
int i = 0; i < 7; i++)
97 std::stringstream traceFilePath;
100 traceFile.open(traceFilePath.str(), std::ifstream::in);
101 if (!traceFile.good())
103 NS_LOG_INFO(
"Unable to load " << traceFilePath.str() <<
"!! Loading default traces...");
107 while (traceFile.good())
109 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
128 double burstErrorRate;
133 for (
unsigned int j = 0; j <
sizeof(
modulation0[0]) /
sizeof(
double); j++)
145 for (
unsigned int j = 0; j <
sizeof(
modulation1[0]) /
sizeof(
double); j++)
157 for (
unsigned int j = 0; j <
sizeof(
modulation2[0]) /
sizeof(
double); j++)
169 for (
unsigned int j = 0; j <
sizeof(
modulation3[0]) /
sizeof(
double); j++)
181 for (
unsigned int j = 0; j <
sizeof(
modulation4[0]) /
sizeof(
double); j++)
193 for (
unsigned int j = 0; j <
sizeof(
modulation5[0]) /
sizeof(
double); j++)
205 for (
unsigned int j = 0; j <
sizeof(
modulation6[0]) /
sizeof(
double); j++)
225 double burstErrorRate;
232 std::ifstream traceFile;
234 for (
int i = 0; i < 7; i++)
236 std::stringstream traceFilePath;
239 traceFile.open(traceFilePath.str(), std::ifstream::in);
240 if (!traceFile.good())
242 NS_LOG_INFO(
"Unable to load " << traceFilePath.str() <<
"!!Loading default traces...");
246 while (traceFile.good())
248 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
283 std::vector<SNRToBlockErrorRateRecord*>* record =
nullptr;
287 if (SNR <= (record->at(0)->GetSNRValue()))
291 if (SNR >= (record->at(record->size() - 1)->GetSNRValue()))
297 for (i = 0; i < record->size(); i++)
299 if (SNR < record->at(i)->GetSNRValue())
304 double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue());
305 double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize;
306 double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize;
307 double BlockErrorRate = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) +
308 coeff1 * (record->at(i)->GetBlockErrorRate());
309 return BlockErrorRate;
320 std::vector<SNRToBlockErrorRateRecord*>* record =
nullptr;
323 if (SNR <= (record->at(0)->GetSNRValue()))
325 return record->at(0)->Copy();
327 if (SNR >= (record->at(record->size() - 1)->GetSNRValue()))
329 return record->at(record->size() - 1)->Copy();
333 for (i = 0; i < record->size(); i++)
335 if (SNR < record->at(i)->GetSNRValue())
340 double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue());
341 double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize;
342 double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize;
343 double BER = coeff2 * (record->at(i - 1)->GetBitErrorRate()) +
344 coeff1 * (record->at(i)->GetBitErrorRate());
345 double BlcER = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) +
346 coeff1 * (record->at(i)->GetBlockErrorRate());
348 coeff2 * (record->at(i - 1)->GetSigma2()) + coeff1 * (record->at(i)->GetSigma2());
349 double I1 = coeff2 * (record->at(i - 1)->GetI1()) + coeff1 * (record->at(i)->GetI1());
350 double I2 = coeff2 * (record->at(i - 1)->GetI2()) + coeff1 * (record->at(i)->GetI2());
354 return SNRToBlockErrorRate;
void ActivateLoss(bool loss)
If activate loss is called with false, all the returned BlcER will be 0 (no losses)
void ClearRecords()
Clear records function.
static const double modulation5[6][547]
These represent default traces, providing a number of parameters for each SNR value.
SNRToBlockErrorRateManager()
bool m_activateLoss
activate loss
static const double modulation1[6][42]
These represent default traces, providing a number of parameters for each SNR value.
void ReLoadTraces()
Reloads the trace.
void LoadTraces()
Loads the traces form the repository specified in the constructor or set by SetTraceFilePath function...
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value
std::string GetTraceFilePath()
std::string m_traceFilePath
trace file path
static const double modulation0[6][29]
These represent default traces, providing a number of parameters for each SNR value.
static const double modulation6[6][626]
These represent default traces, providing a number of parameters for each SNR value.
static const double modulation3[6][117]
These represent default traces, providing a number of parameters for each SNR value.
double GetBlockErrorRate(double SNR, uint8_t modulation)
returns the Block Error Rate for a given modulation and SNR value
void SetTraceFilePath(char *traceFilePath)
Set the path of the repository containing the traces.
static const double modulation2[6][96]
These represent default traces, providing a number of parameters for each SNR value.
std::vector< SNRToBlockErrorRateRecord * > * m_recordModulation[7]
record modulation
void LoadDefaultTraces()
Loads the default traces from default-traces.h file.
~SNRToBlockErrorRateManager()
static const double modulation4[6][331]
These represent default traces, providing a number of parameters for each SNR value.
This class represents a record (handled by SnrToBlockErrorRate manager) that keeps a mapping between ...
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.