5#include "nr-mac-scheduling-stats.h"
9#include <ns3/simulator.h>
14NS_LOG_COMPONENT_DEFINE(
"NrMacSchedulingStats");
16NS_OBJECT_ENSURE_REGISTERED(NrMacSchedulingStats);
20 NS_LOG_FUNCTION(
this);
27 NS_LOG_FUNCTION(
this);
28 if (outDlFile.is_open())
32 if (outUlFile.is_open())
42 TypeId(
"ns3::NrMacSchedulingStats")
46 .AddAttribute(
"DlOutputFilename",
47 "Name of the file where the downlink results will be saved.",
48 StringValue(
"NrDlMacStats.txt"),
51 .AddAttribute(
"UlOutputFilename",
52 "Name of the file where the uplink results will be saved.",
53 StringValue(
"NrUlMacStats.txt"),
63 if (outUlFile.is_open())
68 if (!outUlFile.is_open())
75 "\tcellId\tbwpId\tIMSI\tRNTI\tframe\tsframe\tslot\tsymStart\tnumSym\thar"
76 "qId\tndi\trv\tmcs\ttbSize";
77 outUlFile << std::endl;
90 if (outDlFile.is_open())
95 if (!outDlFile.is_open())
102 "\tcellId\tbwpId\tIMSI\tRNTI\tframe\tsframe\tslot\tsymStart\tnumSym\thar"
103 "qId\tndi\trv\tmcs\ttbSize";
104 outDlFile << std::endl;
122 outDlFile << Simulator::Now().GetSeconds() <<
"\t";
123 outDlFile << (uint32_t)cellId <<
"\t";
124 outDlFile << (uint32_t)traceInfo.
m_bwpId <<
"\t";
125 outDlFile << imsi <<
"\t";
126 outDlFile << traceInfo.
m_rnti <<
"\t";
129 outDlFile << traceInfo.
m_slotNum <<
"\t";
130 outDlFile << (uint32_t)traceInfo.
m_symStart <<
"\t";
131 outDlFile << (uint32_t)traceInfo.
m_numSym <<
"\t";
132 outDlFile << (uint32_t)traceInfo.
m_harqId <<
"\t";
133 outDlFile << (uint32_t)traceInfo.
m_ndi <<
"\t";
134 outDlFile << (uint32_t)traceInfo.
m_rv <<
"\t";
135 outDlFile << (uint32_t)traceInfo.
m_mcs <<
"\t";
136 outDlFile << traceInfo.
m_tbSize << std::endl;
148 outUlFile << Simulator::Now().GetSeconds() <<
"\t";
149 outUlFile << (uint32_t)cellId <<
"\t";
150 outUlFile << (uint32_t)traceInfo.
m_bwpId <<
"\t";
151 outUlFile << imsi <<
"\t";
152 outUlFile << traceInfo.
m_rnti <<
"\t";
155 outUlFile << traceInfo.
m_slotNum <<
"\t";
156 outUlFile << (uint32_t)traceInfo.
m_symStart <<
"\t";
157 outUlFile << (uint32_t)traceInfo.
m_numSym <<
"\t";
158 outUlFile << (uint32_t)traceInfo.
m_harqId <<
"\t";
159 outUlFile << (uint32_t)traceInfo.
m_ndi <<
"\t";
160 outUlFile << (uint32_t)traceInfo.
m_rv <<
"\t";
161 outUlFile << (uint32_t)traceInfo.
m_mcs <<
"\t";
162 outUlFile << traceInfo.
m_tbSize << std::endl;
170 NS_LOG_FUNCTION(macStats << path);
172 std::ostringstream pathAndRnti;
173 std::string pathGnb = path.substr(0, path.find(
"/BandwidthPartMap"));
174 pathAndRnti << pathGnb <<
"/NrGnbRrc/UeMap/" << traceInfo.
m_rnti;
175 if (macStats->ExistsImsiPath(pathAndRnti.str()))
177 imsi = macStats->GetImsiPath(pathAndRnti.str());
182 macStats->SetImsiPath(pathAndRnti.str(), imsi);
185 if (macStats->ExistsCellIdPath(pathAndRnti.str()))
187 cellId = macStats->GetCellIdPath(pathAndRnti.str());
192 macStats->SetCellIdPath(pathAndRnti.str(), cellId);
195 macStats->DlScheduling(cellId, imsi, traceInfo);
203 NS_LOG_FUNCTION(macStats << path);
206 std::ostringstream pathAndRnti;
207 std::string pathGnb = path.substr(0, path.find(
"/BandwidthPartMap"));
208 pathAndRnti << pathGnb <<
"/NrGnbRrc/UeMap/" << traceInfo.
m_rnti;
209 if (macStats->ExistsImsiPath(pathAndRnti.str()))
211 imsi = macStats->GetImsiPath(pathAndRnti.str());
216 macStats->SetImsiPath(pathAndRnti.str(), imsi);
219 if (macStats->ExistsCellIdPath(pathAndRnti.str()))
221 cellId = macStats->GetCellIdPath(pathAndRnti.str());
226 macStats->SetCellIdPath(pathAndRnti.str(), cellId);
229 macStats->UlScheduling(cellId, imsi, traceInfo);
void DlScheduling(uint16_t cellId, uint64_t imsi, const NrSchedulingCallbackInfo &traceInfo)
void SetDlOutputFilename(std::string outputFilename)
std::string GetUlOutputFilename()
void SetUlOutputFilename(std::string outputFilename)
std::string GetDlOutputFilename()
~NrMacSchedulingStats() override
void UlScheduling(uint16_t cellId, uint64_t imsi, const NrSchedulingCallbackInfo &traceInfo)
static TypeId GetTypeId()
static void UlSchedulingCallback(Ptr< NrMacSchedulingStats > macStats, std::string path, NrSchedulingCallbackInfo traceInfo)
static void DlSchedulingCallback(Ptr< NrMacSchedulingStats > macStats, std::string path, NrSchedulingCallbackInfo traceInfo)
std::string GetUlOutputFilename()
static uint64_t FindImsiFromGnbRlcPath(std::string path)
static uint16_t FindCellIdFromGnbRlcPath(std::string path)
std::string GetDlOutputFilename()
void SetDlOutputFilename(std::string outputFilename)
void SetUlOutputFilename(std::string outputFilename)
NrSchedulingCallbackInfo structure.
uint32_t m_tbSize
TB size.
uint8_t m_ndi
New data indicator.
uint8_t m_symStart
starting symbol index
uint8_t m_subframeNum
subframe number
uint16_t m_frameNum
frame number
uint8_t m_bwpId
Bandwidth Part ID.
uint16_t m_slotNum
slot number
uint8_t m_numSym
number of symbols