22 #include "ns3/string.h"
23 #include <ns3/simulator.h>
33 : m_dlFirstWrite (true),
52 .AddAttribute (
"DlOutputFilename",
53 "Name of the file where the downlink results will be saved.",
57 .AddAttribute (
"UlOutputFilename",
58 "Name of the file where the uplink results will be saved.",
92 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2)
94 NS_LOG_FUNCTION (
this << cellId << imsi << frameNo << subframeNo << rnti << (uint32_t) mcsTb1 << sizeTb1 << (uint32_t) mcsTb2 << sizeTb2);
97 std::ofstream outFile;
101 if (!outFile.is_open ())
107 outFile <<
"% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2";
108 outFile << std::endl;
113 if (!outFile.is_open ())
121 outFile << (uint32_t) cellId <<
"\t";
122 outFile << imsi <<
"\t";
123 outFile << frameNo <<
"\t";
124 outFile << subframeNo <<
"\t";
125 outFile << rnti <<
"\t";
126 outFile << (uint32_t) mcsTb1 <<
"\t";
127 outFile << sizeTb1 <<
"\t";
128 outFile << (uint32_t) mcsTb2 <<
"\t";
129 outFile << sizeTb2 << std::endl;
135 uint32_t subframeNo, uint16_t rnti,uint8_t mcsTb, uint16_t size)
137 NS_LOG_FUNCTION (
this << cellId << imsi << frameNo << subframeNo << rnti << (uint32_t) mcsTb << size);
140 std::ofstream outFile;
144 if (!outFile.is_open ())
150 outFile <<
"% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcs\tsize";
151 outFile << std::endl;
156 if (!outFile.is_open ())
164 outFile << (uint32_t) cellId <<
"\t";
165 outFile << imsi <<
"\t";
166 outFile << frameNo <<
"\t";
167 outFile << subframeNo <<
"\t";
168 outFile << rnti <<
"\t";
169 outFile << (uint32_t) mcsTb <<
"\t";
170 outFile << size << std::endl;
176 std::string path, uint32_t frameNo, uint32_t subframeNo,
177 uint16_t rnti, uint8_t mcsTb1, uint16_t sizeTb1,
178 uint8_t mcsTb2, uint16_t sizeTb2)
182 std::ostringstream pathAndRnti;
183 pathAndRnti << path <<
"/" << rnti;
184 if (macStats->ExistsImsiPath (pathAndRnti.str ()) ==
true)
186 imsi = macStats->GetImsiPath (pathAndRnti.str ());
191 macStats->SetImsiPath (pathAndRnti.str (), imsi);
195 if (macStats->ExistsCellIdPath (pathAndRnti.str ()) ==
true)
197 cellId = macStats->GetCellIdPath (pathAndRnti.str ());
202 macStats->SetCellIdPath (pathAndRnti.str (), cellId);
205 macStats->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2);
210 uint32_t frameNo, uint32_t subframeNo, uint16_t rnti,
211 uint8_t mcs, uint16_t size)
216 std::ostringstream pathAndRnti;
217 pathAndRnti << path <<
"/" << rnti;
218 if (macStats->ExistsImsiPath (pathAndRnti.str ()) ==
true)
220 imsi = macStats->GetImsiPath (pathAndRnti.str ());
225 macStats->SetImsiPath (pathAndRnti.str (), imsi);
228 if (macStats->ExistsCellIdPath (pathAndRnti.str ()) ==
true)
230 cellId = macStats->GetCellIdPath (pathAndRnti.str ());
235 macStats->SetCellIdPath (pathAndRnti.str (), cellId);
238 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.
Takes care of storing the information generated at MAC layer.
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.