13#include "ns3/string.h"
15#include <ns3/simulator.h>
25 : m_RsrpSinrFirstWrite(true),
26 m_UeSinrFirstWrite(true),
27 m_InterferenceFirstWrite(true)
55 TypeId(
"ns3::PhyStatsCalculator")
59 .AddAttribute(
"DlRsrpSinrFilename",
60 "Name of the file where the RSRP/SINR statistics will be saved.",
64 .AddAttribute(
"UlSinrFilename",
65 "Name of the file where the UE SINR statistics will be saved.",
69 .AddAttribute(
"UlInterferenceFilename",
70 "Name of the file where the interference statistics will be saved.",
119 uint8_t componentCarrierId)
133 m_rsrpOutFile <<
"% time\tcellId\tIMSI\tRNTI\trsrp\tsinr\tComponentCarrierId";
151 uint8_t componentCarrierId)
165 m_ueSinrOutFile <<
"% time\tcellId\tIMSI\tRNTI\tsinrLinear\tcomponentCarrierId";
207 uint8_t componentCarrierId)
211 std::string pathUePhy = path.substr(0, path.find(
"/ComponentCarrierMapUe"));
212 if (phyStats->ExistsImsiPath(pathUePhy))
214 imsi = phyStats->GetImsiPath(pathUePhy);
219 phyStats->SetImsiPath(pathUePhy, imsi);
222 phyStats->ReportCurrentCellRsrpSinr(cellId, imsi, rnti, rsrp, sinr, componentCarrierId);
231 uint8_t componentCarrierId)
236 std::ostringstream pathAndRnti;
237 pathAndRnti << path <<
"/" << rnti;
238 std::string pathEnbMac = path.substr(0, path.find(
"/ComponentCarrierMap"));
239 pathEnbMac +=
"/LteEnbMac/DlScheduling";
240 if (phyStats->ExistsImsiPath(pathAndRnti.str()))
242 imsi = phyStats->GetImsiPath(pathAndRnti.str());
247 phyStats->SetImsiPath(pathAndRnti.str(), imsi);
250 phyStats->ReportUeSinr(cellId, imsi, rnti, sinrLinear, componentCarrierId);
260 phyStats->ReportInterference(cellId, interference);
Base class for ***StatsCalculator classes.
static uint64_t FindImsiFromLteNetDevice(std::string path)
Retrieves IMSI from LteNetDevice path in the attribute system.
static uint64_t FindImsiFromEnbMac(std::string path, uint16_t rnti)
Retrieves IMSI from Enb MAC path in the attribute system.
Takes care of storing the information generated at PHY layer.
bool m_UeSinrFirstWrite
When writing UE SINR statistics first time to file, columns description is added.
bool m_InterferenceFirstWrite
When writing interference statistics first time to file, columns description is added.
std::string GetInterferenceFilename()
Get the name of the file where the interference statistics will be stored.
std::string GetUeSinrFilename()
Get the name of the file where the UE SINR statistics will be stored.
void SetInterferenceFilename(std::string filename)
Set the name of the file where the interference statistics will be stored.
void ReportUeSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double sinrLinear, uint8_t componentCarrierId)
Notifies the stats calculator that an UE SINR report has occurred.
bool m_RsrpSinrFirstWrite
When writing RSRP SINR statistics first time to file, columns description is added.
std::string m_interferenceFilename
Name of the file where the interference statistics will be saved.
std::string m_ueSinrFilename
Name of the file where the UE SINR statistics will be saved.
void SetCurrentCellRsrpSinrFilename(std::string filename)
Set the name of the file where the RSRP/SINR statistics will be stored.
PhyStatsCalculator()
Constructor.
void ReportCurrentCellRsrpSinr(uint16_t cellId, uint64_t imsi, uint16_t rnti, double rsrp, double sinr, uint8_t componentCarrierId)
Notifies the stats calculator that an RSRP and SINR report has occurred.
void SetUeSinrFilename(std::string filename)
Set the name of the file where the UE SINR statistics will be stored.
std::ofstream m_interferenceOutFile
Interference statistics output trace file.
std::string GetCurrentCellRsrpSinrFilename()
Get the name of the file where the RSRP/SINR statistics will be stored.
static TypeId GetTypeId()
Register this type.
std::ofstream m_ueSinrOutFile
UE SINR statistics output trace file.
std::string m_RsrpSinrFilename
Name of the file where the RSRP/SINR statistics will be saved.
std::ofstream m_rsrpOutFile
RSRP statistics output trace file.
void ReportInterference(uint16_t cellId, Ptr< SpectrumValue > interference)
Notifies the stats calculator that an interference report has occurred.
static void ReportCurrentCellRsrpSinrCallback(Ptr< PhyStatsCalculator > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double rsrp, double sinr, uint8_t componentCarrierId)
trace sink
~PhyStatsCalculator() override
Destructor.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Hold variables of type string.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< const AttributeChecker > MakeStringChecker()
Ptr< const AttributeAccessor > MakeStringAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.