22 #include "ns3/string.h"
23 #include <ns3/simulator.h>
33 : m_RsrpSinrFirstWrite (true),
34 m_UeSinrFirstWrite (true),
35 m_InterferenceFirstWrite (true)
51 .AddConstructor<PhyStatsCalculator> ()
52 .AddAttribute (
"DlRsrpSinrFilename",
53 "Name of the file where the RSRP/SINR statistics will be saved.",
57 .AddAttribute (
"UlSinrFilename",
58 "Name of the file where the UE SINR statistics will be saved.",
62 .AddAttribute (
"UlInterferenceFilename",
63 "Name of the file where the interference statistics will be saved.",
111 double rsrp,
double sinr)
116 std::ofstream outFile;
120 if (!outFile.is_open ())
126 outFile <<
"% time\tcellId\tIMSI\tRNTI\trsrp\tsinr";
127 outFile << std::endl;
132 if (!outFile.is_open ())
140 outFile << cellId <<
"\t";
141 outFile << imsi <<
"\t";
142 outFile << rnti <<
"\t";
143 outFile << rsrp <<
"\t";
144 outFile << sinr << std::endl;
154 std::ofstream outFile;
158 if (!outFile.is_open ())
164 outFile <<
"% time\tcellId\tIMSI\tRNTI\tsinrLinear";
165 outFile << std::endl;
170 if (!outFile.is_open ())
178 outFile << cellId <<
"\t";
179 outFile << imsi <<
"\t";
180 outFile << rnti <<
"\t";
181 outFile << sinrLinear << std::endl;
191 std::ofstream outFile;
195 if (!outFile.is_open ())
201 outFile <<
"% time\tcellId\tInterference";
202 outFile << std::endl;
207 if (!outFile.is_open ())
215 outFile << cellId <<
"\t";
216 outFile << *interference;
223 std::string path, uint16_t cellId, uint16_t rnti,
224 double rsrp,
double sinr)
228 std::string pathUePhy = path.substr (0, path.find (
"/ReportCurrentCellRsrpSinr"));
229 if (phyStats->ExistsImsiPath (pathUePhy) ==
true)
231 imsi = phyStats->GetImsiPath (pathUePhy);
236 phyStats->SetImsiPath (pathUePhy, imsi);
239 phyStats->ReportCurrentCellRsrpSinr (cellId, imsi, rnti, rsrp,sinr);
244 uint16_t cellId, uint16_t rnti,
double sinrLinear)
249 std::ostringstream pathAndRnti;
250 pathAndRnti << path <<
"/" << rnti;
251 std::string pathEnbMac = path.substr (0, path.find (
"LteEnbPhy/ReportUeSinr"));
252 pathEnbMac +=
"LteEnbMac/DlScheduling";
253 if (phyStats->ExistsImsiPath (pathAndRnti.str ()) ==
true)
255 imsi = phyStats->GetImsiPath (pathAndRnti.str ());
260 phyStats->SetImsiPath (pathAndRnti.str (), imsi);
263 phyStats->ReportUeSinr (cellId, imsi, rnti, sinrLinear);
271 phyStats->ReportInterference (cellId, interference);
Ptr< const AttributeChecker > MakeStringChecker(void)
Base class for ***StatsCalculator classes.
static uint64_t FindImsiFromUePhy(std::string path)
Retrieves IMSI from Ue PHY path in the attribute system.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
static uint64_t FindImsiFromEnbMac(std::string path, uint16_t rnti)
Retrieves IMSI from Enb MAC path in the attribute system.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Hold variables of type string.
std::string GetInterferenceFilename(void)
Get the name of the file where the interference statistics will be stored.
std::string m_ueSinrFilename
Name of the file where the UE SINR statistics will be saved.
void ReportUeSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double sinrLinear)
Notifies the stats calculator that an UE SINR report has occurred.
#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.
void SetCurrentCellRsrpSinrFilename(std::string filename)
Set the name of the file where the RSRP/SINR statistics will be stored.
bool m_RsrpSinrFirstWrite
When writing RSRP SINR statistics first time to file, columns description is added.
static TypeId GetTypeId(void)
Register this type.
static void ReportCurrentCellRsrpSinrCallback(Ptr< PhyStatsCalculator > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double rsrp, double sinr)
trace sink
std::string m_interferenceFilename
Name of the file where the interference statistics will be saved.
bool m_InterferenceFirstWrite
When writing interference statistics first time to file, columns description is added.
void SetUeSinrFilename(std::string filename)
Set the name of the file where the UE SINR statistics will be stored.
virtual ~PhyStatsCalculator()
Destructor.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Time Now(void)
Return the current simulation virtual time.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
std::string m_RsrpSinrFilename
Name of the file where the RSRP/SINR statistics will be saved.
void SetInterferenceFilename(std::string filename)
Set the name of the file where the interference statistics will be stored.
std::string GetUeSinrFilename(void)
Get the name of the file where the UE SINR statistics will be stored.
void ReportInterference(uint16_t cellId, Ptr< SpectrumValue > interference)
Notifies the stats calculator that an interference report has occurred.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
std::string GetCurrentCellRsrpSinrFilename(void)
Get the name of the file where the RSRP/SINR statistics will be stored.
PhyStatsCalculator()
Constructor.
bool m_UeSinrFirstWrite
When writing UE SINR statistics first time to file, columns description is added. ...
void ReportCurrentCellRsrpSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double rsrp, double sinr)
Notifies the stats calculator that an RSRP and SINR report has occurred.