22 #include "ns3/string.h"
23 #include <ns3/simulator.h>
33 : m_dlFirstWrite (true),
50 .AddConstructor<MacStatsCalculator> ()
51 .AddAttribute (
"DlOutputFilename",
52 "Name of the file where the downlink results will be saved.",
56 .AddAttribute (
"UlOutputFilename",
57 "Name of the file where the uplink results will be saved.",
91 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
93 NS_LOG_FUNCTION (
this << cellId << imsi << frameNo << subframeNo << rnti << (uint32_t) mcsTb1 << sizeTb1 << (uint32_t) mcsTb2 << sizeTb2);
96 std::ofstream outFile;
100 if (!outFile.is_open ())
106 outFile <<
"% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2";
107 outFile << std::endl;
112 if (!outFile.is_open ())
120 outFile << (uint32_t) cellId <<
"\t";
121 outFile << imsi <<
"\t";
122 outFile << frameNo <<
"\t";
123 outFile << subframeNo <<
"\t";
124 outFile << rnti <<
"\t";
125 outFile << (uint32_t) mcsTb1 <<
"\t";
126 outFile << sizeTb1 <<
"\t";
127 outFile << (uint32_t) mcsTb2 <<
"\t";
128 outFile << sizeTb2 << std::endl;
134 uint32_t subframeNo, uint16_t rnti,uint8_t mcsTb, uint16_t size)
136 NS_LOG_FUNCTION (
this << cellId << imsi << frameNo << subframeNo << rnti << (uint32_t) mcsTb << size);
139 std::ofstream outFile;
143 if (!outFile.is_open ())
149 outFile <<
"% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcs\tsize";
150 outFile << std::endl;
155 if (!outFile.is_open ())
163 outFile << (uint32_t) cellId <<
"\t";
164 outFile << imsi <<
"\t";
165 outFile << frameNo <<
"\t";
166 outFile << subframeNo <<
"\t";
167 outFile << rnti <<
"\t";
168 outFile << (uint32_t) mcsTb <<
"\t";
169 outFile << size << std::endl;
175 std::string path, uint32_t frameNo, uint32_t subframeNo,
176 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1,
177 uint8_t mcsTb2, uint16_t sizeTb2)
181 std::ostringstream pathAndRnti;
182 pathAndRnti << path <<
"/" << rnti;
183 if (macStats->ExistsImsiPath (pathAndRnti.str ()) ==
true)
185 imsi = macStats->GetImsiPath (pathAndRnti.str ());
190 macStats->SetImsiPath (pathAndRnti.str (), imsi);
194 if (macStats->ExistsCellIdPath (pathAndRnti.str ()) ==
true)
196 cellId = macStats->GetCellIdPath (pathAndRnti.str ());
201 macStats->SetCellIdPath (pathAndRnti.str (), cellId);
204 macStats->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
209 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
210 uint8_t mcs, uint16_t size)
215 std::ostringstream pathAndRnti;
216 pathAndRnti << path <<
"/" << rnti;
217 if (macStats->ExistsImsiPath (pathAndRnti.str ()) ==
true)
219 imsi = macStats->GetImsiPath (pathAndRnti.str ());
224 macStats->SetImsiPath (pathAndRnti.str (), imsi);
227 if (macStats->ExistsCellIdPath (pathAndRnti.str ()) ==
true)
229 cellId = macStats->GetCellIdPath (pathAndRnti.str ());
234 macStats->SetCellIdPath (pathAndRnti.str (), cellId);
237 macStats->UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size);
Ptr< const AttributeChecker > MakeStringChecker(void)
Base class for ***StatsCalculator classes.
Smart pointer class similar to boost::intrusive_ptr.
#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.
static void DlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
Trace sink for the ns3::LteEnbMac::DlScheduling trace source.
#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.
MacStatsCalculator()
Constructor.
static uint16_t FindCellIdFromEnbMac(std::string path, uint16_t rnti)
Retrieves CellId from Enb MAC path in the attribute system.
bool m_ulFirstWrite
When writing UL MAC statistics first time to file, columns description is added.
void SetUlOutputFilename(std::string outputFilename)
Set the name of the file where the uplink statistics will be stored.
void SetDlOutputFilename(std::string outputFilename)
Set the name of the file where the downlink statistics will be stored.
static TypeId GetTypeId(void)
Register this type.
std::string GetUlOutputFilename(void)
Get the name of the file where the uplink statistics will be stored.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void DlScheduling(uint16_t cellId, uint64_t imsi, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
Notifies the stats calculator that an downlink scheduling has occurred.
void SetDlOutputFilename(std::string outputFilename)
Set the name of the file where the downlink statistics will be stored.
std::string GetDlOutputFilename(void)
Get the name of the file where the downlink statistics will be stored.
bool m_dlFirstWrite
When writing DL MAC statistics first time to file, columns description is added.
static Time Now(void)
Return the current simulation virtual time.
static void UlSchedulingCallback(Ptr< MacStatsCalculator > macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t size)
Trace sink for the ns3::LteEnbMac::UlScheduling trace source.
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
std::string GetUlOutputFilename(void)
Get the name of the file where the uplink statistics will be stored.
void UlScheduling(uint16_t cellId, uint64_t imsi, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcsTb, uint16_t sizeTb)
Notifies the stats calculator that an uplink scheduling has occurred.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
virtual ~MacStatsCalculator()
Destructor.
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.
void SetUlOutputFilename(std::string outputFilename)
Set the name of the file where the uplink statistics will be stored.
TypeId SetParent(TypeId tid)
std::string GetDlOutputFilename(void)
Get the name of the file where the downlink statistics will be stored.