26 #include "ns3/assert.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++)
84 std::ifstream traceFile;
88 double burstErrorRate;
93 for (
int i = 0; i < 7; i++)
95 std::stringstream traceFilePath;
98 traceFile.open(traceFilePath.str(), std::ifstream::in);
99 if (!traceFile.good())
101 NS_LOG_INFO(
"Unable to load " << traceFilePath.str() <<
"!! Loading default traces...");
105 while (traceFile.good())
107 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
126 double burstErrorRate;
131 for (
unsigned int j = 0; j <
sizeof(
modulation0[0]) /
sizeof(
double); j++)
143 for (
unsigned int j = 0; j <
sizeof(
modulation1[0]) /
sizeof(
double); j++)
155 for (
unsigned int j = 0; j <
sizeof(
modulation2[0]) /
sizeof(
double); j++)
167 for (
unsigned int j = 0; j <
sizeof(
modulation3[0]) /
sizeof(
double); j++)
179 for (
unsigned int j = 0; j <
sizeof(
modulation4[0]) /
sizeof(
double); j++)
191 for (
unsigned int j = 0; j <
sizeof(
modulation5[0]) /
sizeof(
double); j++)
203 for (
unsigned int j = 0; j <
sizeof(
modulation6[0]) /
sizeof(
double); j++)
223 double burstErrorRate;
230 std::ifstream traceFile;
232 for (
int i = 0; i < 7; i++)
234 std::stringstream traceFilePath;
237 traceFile.open(traceFilePath.str(), std::ifstream::in);
238 if (!traceFile.good())
240 NS_LOG_INFO(
"Unable to load " << traceFilePath.str() <<
"!!Loading default traces...");
244 while (traceFile.good())
246 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
281 std::vector<SNRToBlockErrorRateRecord*>* record =
nullptr;
285 if (SNR <= (record->at(0)->GetSNRValue()))
289 if (SNR >= (record->at(record->size() - 1)->GetSNRValue()))
295 for (i = 0; i < record->size(); i++)
297 if (SNR < record->at(i)->GetSNRValue())
302 double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue());
303 double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize;
304 double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize;
305 double BlockErrorRate = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) +
306 coeff1 * (record->at(i)->GetBlockErrorRate());
307 return BlockErrorRate;
318 std::vector<SNRToBlockErrorRateRecord*>* record =
nullptr;
321 if (SNR <= (record->at(0)->GetSNRValue()))
323 return record->at(0)->Copy();
325 if (SNR >= (record->at(record->size() - 1)->GetSNRValue()))
327 return record->at(record->size() - 1)->Copy();
331 for (i = 0; i < record->size(); i++)
333 if (SNR < record->at(i)->GetSNRValue())
338 double intervalSize = (record->at(i)->GetSNRValue() - record->at(i - 1)->GetSNRValue());
339 double coeff1 = (SNR - record->at(i - 1)->GetSNRValue()) / intervalSize;
340 double coeff2 = -1 * (SNR - record->at(i)->GetSNRValue()) / intervalSize;
341 double BER = coeff2 * (record->at(i - 1)->GetBitErrorRate()) +
342 coeff1 * (record->at(i)->GetBitErrorRate());
343 double BlcER = coeff2 * (record->at(i - 1)->GetBlockErrorRate()) +
344 coeff1 * (record->at(i)->GetBlockErrorRate());
346 coeff2 * (record->at(i - 1)->GetSigma2()) + coeff1 * (record->at(i)->GetSigma2());
347 double I1 = coeff2 * (record->at(i - 1)->GetI1()) + coeff1 * (record->at(i)->GetI1());
348 double I2 = coeff2 * (record->at(i - 1)->GetI2()) + coeff1 * (record->at(i)->GetI2());
351 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.