23 #include "ns3/snr-to-block-error-rate-manager.h"
24 #include "ns3/snr-to-block-error-rate-record.h"
27 #include "ns3/assert.h"
38 for (
int i = 0; i < 7; i++)
49 for (
int i = 0; i < 7; i++)
58 for (
int i = 0; i < 7; i++)
61 for (std::vector<SNRToBlockErrorRateRecord*>::iterator iter =
m_recordModulation[i]->begin (); iter
83 std::ifstream traceFile;
85 double snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2;
87 for (
int i = 0; i < 7; i++)
89 std::stringstream traceFilePath;
92 traceFile.open (traceFilePath.str ().c_str (), std::ifstream::in);
93 if (traceFile.good () ==
false)
95 NS_LOG_INFO (
"Unable to load " << traceFilePath.str () <<
"!! Loading default traces...");
99 while (traceFile.good ())
101 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
119 double snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2;
121 for (
unsigned int j = 0; j <
sizeof(
modulation0[0]) /
sizeof(
double); j++)
137 for (
unsigned int j = 0; j <
sizeof(
modulation1[0]) /
sizeof(
double); j++)
153 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++)
185 for (
unsigned int j = 0; j <
sizeof(
modulation4[0]) /
sizeof(
double); j++)
201 for (
unsigned int j = 0; j <
sizeof(
modulation5[0]) /
sizeof(
double); j++)
217 for (
unsigned int j = 0; j <
sizeof(
modulation6[0]) /
sizeof(
double); j++)
239 double snrValue, bitErrorRate, burstErrorRate, sigma2, I1, I2;
243 std::ifstream traceFile;
245 for (
int i = 0; i < 7; i++)
247 std::stringstream traceFilePath;
250 traceFile.open (traceFilePath.str ().c_str (), std::ifstream::in);
251 if (traceFile.good () ==
false)
253 NS_LOG_INFO (
"Unable to load " << traceFilePath.str () <<
"!!Loading default traces...");
257 while (traceFile.good ())
259 traceFile >> snrValue >> bitErrorRate >> burstErrorRate >> sigma2 >> I1 >> I2;
296 std::vector<SNRToBlockErrorRateRecord *> *record = 0;
300 if (SNR <= (record->at (0)->GetSNRValue ()))
304 if (SNR >= (record->at (record->size () - 1)->GetSNRValue ()))
310 for (i = 0; i < record->size (); i++)
312 if (SNR < record->at (i)->GetSNRValue ())
317 double intervalSize = (record->at (i)->GetSNRValue () - record->at (i - 1)->GetSNRValue ());
318 double coeff1 = (SNR - record->at (i - 1)->GetSNRValue ()) / intervalSize;
319 double coeff2 = -1 * (SNR - record->at (i)->GetSNRValue ()) / intervalSize;
320 double BlockErrorRate = coeff2 * (record->at (i - 1)->GetBlockErrorRate ()) + coeff1 * (record->at (i)->GetBlockErrorRate ());
321 return BlockErrorRate;
334 std::vector<SNRToBlockErrorRateRecord *> *record = 0;
337 if (SNR <= (record->at (0)->GetSNRValue ()))
340 record->at (0)->Copy ();
342 if (SNR >= (record->at (record->size () - 1)->GetSNRValue ()))
345 record->at (record->size () - 1)->Copy ();
349 for (i = 0; i < record->size (); i++)
351 if (SNR < record->at (i)->GetSNRValue ())
356 double intervalSize = (record->at (i)->GetSNRValue ()
357 - record->at (i - 1)->GetSNRValue ());
358 double coeff1 = (SNR - record->at (i - 1)->GetSNRValue ()) / intervalSize;
359 double coeff2 = -1 * (SNR - record->at (i)->GetSNRValue ()) / intervalSize;
360 double BER = coeff2 * (record->at (i - 1)->GetBitErrorRate ()) + coeff1 * (record->at (i)->GetBitErrorRate ());
361 double BlcER = coeff2 * (record->at (i - 1)->GetBlockErrorRate ()) + coeff1 * (record->at (i)->GetBlockErrorRate ());
362 double sigma2 = coeff2 * (record->at (i - 1)->GetSigma2 ()) + coeff1 * (record->at (i)->GetSigma2 ());
363 double I1 = coeff2 * (record->at (i - 1)->GetI1 ()) + coeff1 * (record->at (i)->GetI1 ());
364 double I2 = coeff2 * (record->at (i - 1)->GetI2 ()) + coeff1 * (record->at (i)->GetI2 ());
367 return SNRToBlockErrorRate;
void ClearRecords(void)
Clear records function.
void ActivateLoss(bool loss)
If activate loss is called with false, all the returned BlcER will be 0 (no losses)
static const double modulation5[6][547]
These represent default traces, providing a number of parameters for each SNR value.
SNRToBlockErrorRateManager()
void LoadDefaultTraces(void)
Loads the default traces from default-traces.h file.
void ReLoadTraces(void)
Reloads the trace.
std::string GetTraceFilePath(void)
static const double modulation1[6][42]
These represent default traces, providing a number of parameters for each SNR value.
SNRToBlockErrorRateRecord * GetSNRToBlockErrorRateRecord(double SNR, uint8_t modulation)
returns a record of type SNRToBlockErrorRateRecord corresponding to a given modulation and SNR value
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.
uint8_t m_activateLoss
activate loss
~SNRToBlockErrorRateManager(void)
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.
void LoadTraces(void)
Loads the traces form the repository specified in the constructor or set by SetTraceFilePath function...
std::vector< SNRToBlockErrorRateRecord * > * m_recordModulation[7]
record modulation
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.