26 #include <ns3/fatal-error.h>
34 NS_LOG_COMPONENT_DEFINE(
"SatLookUpTable");
39 NS_OBJECT_ENSURE_REGISTERED(SatLookUpTable);
43 NS_LOG_FUNCTION(
this << linkResultPath);
49 NS_LOG_FUNCTION(
this);
55 NS_LOG_FUNCTION(
this);
77 static TypeId tid = TypeId(
"ns3::SatLookUpTable").SetParent<Object>();
84 NS_LOG_FUNCTION(
this << esNoDb);
89 NS_ASSERT(
m_bler.size() == n);
94 NS_LOG_INFO(
this <<
" Very low SINR -> BLER = 1.0");
100 while ((i < n) && (esNoDb >
m_esNoDb[i]))
105 NS_LOG_DEBUG(
this <<
" i=" << i <<
" esno[i]=" <<
m_esNoDb[i] <<
" bler[i]=" <<
m_bler[i]);
112 NS_LOG_INFO(
this <<
" Very high SINR -> BLER = " <<
m_bler[0]);
117 NS_LOG_INFO(
this <<
" Very high SINR -> BLER = 0.0");
127 double esno = esNoDb;
131 NS_LOG_INFO(
this <<
" Interpolate: " << esno <<
" to BLER = " << bler <<
"(sinr0: " << esno0
132 <<
", sinr1: " << esno1 <<
", bler0: " <<
m_bler[i - 1]
133 <<
", bler1: " <<
m_bler[i] <<
")");
143 NS_LOG_FUNCTION(
this << blerTarget);
145 uint16_t n =
m_bler.size();
152 if (blerTarget <=
m_bler[n - 1])
159 if (blerTarget >
m_bler[0])
161 NS_FATAL_ERROR(
"The BLER target is set to be too high!");
166 for (uint32_t i = 0; i < n; ++i)
168 if (blerTarget >=
m_bler[i])
175 NS_LOG_INFO(
this <<
" Interpolate: " << blerTarget <<
" to SINR = " << sinr
176 <<
"(bler0: " <<
m_bler[i - 1] <<
", bler1: " <<
m_bler[i]
189 NS_LOG_FUNCTION(
this << linkResultPath);
193 m_ifs =
new std::ifstream(linkResultPath.c_str(), std::ifstream::in);
195 if (!
m_ifs->is_open())
199 linkResultPath =
"../../" + linkResultPath;
200 m_ifs =
new std::ifstream(linkResultPath.c_str(), std::ifstream::in);
202 if (!
m_ifs->is_open())
204 NS_FATAL_ERROR(
"The file " << linkResultPath <<
" is not found.");
208 double lastEsNoDb = -100.0;
209 double lastBler = 1.0;
212 *
m_ifs >> esNoDb >> bler;
214 while (
m_ifs->good())
216 NS_LOG_DEBUG(
this <<
" sinrDb=" << esNoDb <<
", bler=" << bler);
219 if ((esNoDb <= lastEsNoDb) || (bler > lastBler))
221 NS_FATAL_ERROR(
"The file " << linkResultPath <<
" is not properly sorted.");
231 *
m_ifs >> esNoDb >> bler;
243 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.