26 #include <ns3/fatal-error.h>
31 NS_LOG_COMPONENT_DEFINE(
"SatLookUpTable");
36 NS_OBJECT_ENSURE_REGISTERED(SatLookUpTable);
40 NS_LOG_FUNCTION(
this << linkResultPath);
46 NS_LOG_FUNCTION(
this);
52 NS_LOG_FUNCTION(
this);
74 static TypeId tid = TypeId(
"ns3::SatLookUpTable").SetParent<Object>();
81 NS_LOG_FUNCTION(
this << esNoDb);
86 NS_ASSERT(
m_bler.size() == n);
91 NS_LOG_INFO(
this <<
" Very low SINR -> BLER = 1.0");
97 while ((i < n) && (esNoDb >
m_esNoDb[i]))
102 NS_LOG_DEBUG(
this <<
" i=" << i <<
" esno[i]=" <<
m_esNoDb[i] <<
" bler[i]=" <<
m_bler[i]);
109 NS_LOG_INFO(
this <<
" Very high SINR -> BLER = " <<
m_bler[0]);
114 NS_LOG_INFO(
this <<
" Very high SINR -> BLER = 0.0");
124 double esno = esNoDb;
128 NS_LOG_INFO(
this <<
" Interpolate: " << esno <<
" to BLER = " << bler <<
"(sinr0: " << esno0
129 <<
", sinr1: " << esno1 <<
", bler0: " <<
m_bler[i - 1]
130 <<
", bler1: " <<
m_bler[i] <<
")");
140 NS_LOG_FUNCTION(
this << blerTarget);
142 uint16_t n =
m_bler.size();
149 if (blerTarget <=
m_bler[n - 1])
156 if (blerTarget >
m_bler[0])
158 NS_FATAL_ERROR(
"The BLER target is set to be too high!");
163 for (uint32_t i = 0; i < n; ++i)
165 if (blerTarget >=
m_bler[i])
172 NS_LOG_INFO(
this <<
" Interpolate: " << blerTarget <<
" to SINR = " << sinr
173 <<
"(bler0: " <<
m_bler[i - 1] <<
", bler1: " <<
m_bler[i]
186 NS_LOG_FUNCTION(
this << linkResultPath);
190 m_ifs =
new std::ifstream(linkResultPath.c_str(), std::ifstream::in);
192 if (!
m_ifs->is_open())
196 linkResultPath =
"../../" + linkResultPath;
197 m_ifs =
new std::ifstream(linkResultPath.c_str(), std::ifstream::in);
199 if (!
m_ifs->is_open())
201 NS_FATAL_ERROR(
"The file " << linkResultPath <<
" is not found.");
205 double lastEsNoDb = -100.0;
206 double lastBler = 1.0;
209 *
m_ifs >> esNoDb >> bler;
211 while (
m_ifs->good())
213 NS_LOG_DEBUG(
this <<
" sinrDb=" << esNoDb <<
", bler=" << bler);
216 if ((esNoDb <= lastEsNoDb) || (bler > lastBler))
218 NS_FATAL_ERROR(
"The file " << linkResultPath <<
" is not properly sorted.");
228 *
m_ifs >> esNoDb >> bler;
240 NS_FATAL_ERROR(
"Error reading data from file " << linkResultPath <<
".");
virtual ~SatLookUpTable()
Destructor for SatLookUpTable.
double GetBler(double sinrDb) const
Get the BLER corresponding to a given SINR.
std::vector< double > m_bler
static TypeId GetTypeId()
Get the type ID.
double GetEsNoDb(double blerTarget) const
Get Es/No in dB for a given BLER target.
std::vector< double > m_esNoDb
void Load(std::string linkResultPath)
Load the link results.
SatLookUpTable(std::string linkResultPath)
Constructor with initialization parameters.
static double Interpolate(double x, double x0, double x1, double y0, double y1)
Simple linear interpolation.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.