15#include "ns3/assert.h"
29 for (
int i = 0; i < 7; i++)
40 for (
int i = 0; i < 7; i++)
49 for (
int i = 0; i < 7; i++)
73 std::ifstream traceFile;
77 double burstErrorRate;
82 for (
int i = 0; i < 7; i++)
84 std::stringstream traceFilePath;
87 traceFile.open(traceFilePath.str(), std::ifstream::in);
88 if (!traceFile.good())
90 NS_LOG_INFO(
"Unable to load " << traceFilePath.str() <<
"!! Loading default traces...");
94 while (traceFile.good())
96 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
115 double burstErrorRate;
120 for (
unsigned int j = 0; j <
sizeof(
modulation0[0]) /
sizeof(
double); j++)
132 for (
unsigned int j = 0; j <
sizeof(
modulation1[0]) /
sizeof(
double); j++)
144 for (
unsigned int j = 0; j <
sizeof(
modulation2[0]) /
sizeof(
double); j++)
156 for (
unsigned int j = 0; j <
sizeof(
modulation3[0]) /
sizeof(
double); j++)
168 for (
unsigned int j = 0; j <
sizeof(
modulation4[0]) /
sizeof(
double); j++)
180 for (
unsigned int j = 0; j <
sizeof(
modulation5[0]) /
sizeof(
double); j++)
192 for (
unsigned int j = 0; j <
sizeof(
modulation6[0]) /
sizeof(
double); j++)
212 double burstErrorRate;
219 std::ifstream traceFile;
221 for (
int i = 0; i < 7; i++)
223 std::stringstream traceFilePath;
226 traceFile.open(traceFilePath.str(), std::ifstream::in);
227 if (!traceFile.good())
229 NS_LOG_INFO(
"Unable to load " << traceFilePath.str() <<
"!!Loading default traces...");
233 while (traceFile.good())
235 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
270 std::vector<SNRToBlockErrorRateRecord*>* record =
nullptr;
274 if (SNR <= (record->at(0)->GetSNRValue()))
278 if (SNR >= (record->at(record->size() - 1)->GetSNRValue()))
284 for (i = 0; i < record->size(); i++)
286 if (SNR < record->at(i)->GetSNRValue())
291 double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue());
292 double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize;
293 double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize;
294 double BlockErrorRate = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) +
295 coeff1 * (record->at(i)->GetBlockErrorRate());
296 return BlockErrorRate;
307 std::vector<SNRToBlockErrorRateRecord*>* record =
nullptr;
310 if (SNR <= (record->at(0)->GetSNRValue()))
312 return record->at(0)->Copy();
314 if (SNR >= (record->at(record->size() - 1)->GetSNRValue()))
316 return record->at(record->size() - 1)->Copy();
320 for (i = 0; i < record->size(); i++)
322 if (SNR < record->at(i)->GetSNRValue())
327 double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue());
328 double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize;
329 double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize;
330 double BER = coeff2 * (record->at(i - 1)->GetBitErrorRate()) +
331 coeff1 * (record->at(i)->GetBitErrorRate());
332 double BlcER = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) +
333 coeff1 * (record->at(i)->GetBlockErrorRate());
335 coeff2 * (record->at(i - 1)->GetSigma2()) + coeff1 * (record->at(i)->GetSigma2());
336 double I1 = coeff2 * (record->at(i - 1)->GetI1()) + coeff1 * (record->at(i)->GetI1());
337 double I2 = coeff2 * (record->at(i - 1)->GetI2()) + coeff1 * (record->at(i)->GetI2());
340 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.