6#include "nr-phy-rx-trace.h"
9#include <ns3/nr-gnb-net-device.h>
10#include <ns3/nr-ue-net-device.h>
11#include <ns3/simulator.h>
12#include <ns3/string.h>
20NS_LOG_COMPONENT_DEFINE(
"NrPhyRxTrace");
22NS_OBJECT_ENSURE_REGISTERED(NrPhyRxTrace);
24std::ofstream NrPhyRxTrace::m_dlDataSinrFile;
25std::string NrPhyRxTrace::m_dlDataSinrFileName;
27std::ofstream NrPhyRxTrace::m_dlCtrlSinrFile;
28std::string NrPhyRxTrace::m_dlCtrlSinrFileName;
30std::ofstream NrPhyRxTrace::m_rxPacketTraceFile;
31std::string NrPhyRxTrace::m_rxPacketTraceFilename;
32std::string NrPhyRxTrace::m_simTag;
33std::string NrPhyRxTrace::m_resultsFolder;
35std::ofstream NrPhyRxTrace::m_rxedGnbPhyCtrlMsgsFile;
36std::string NrPhyRxTrace::m_rxedGnbPhyCtrlMsgsFileName;
37std::ofstream NrPhyRxTrace::m_txedGnbPhyCtrlMsgsFile;
38std::string NrPhyRxTrace::m_txedGnbPhyCtrlMsgsFileName;
40std::ofstream NrPhyRxTrace::m_rxedUePhyCtrlMsgsFile;
41std::string NrPhyRxTrace::m_rxedUePhyCtrlMsgsFileName;
42std::ofstream NrPhyRxTrace::m_txedUePhyCtrlMsgsFile;
43std::string NrPhyRxTrace::m_txedUePhyCtrlMsgsFileName;
44std::ofstream NrPhyRxTrace::m_rxedUePhyDlDciFile;
45std::string NrPhyRxTrace::m_rxedUePhyDlDciFileName;
47std::ofstream NrPhyRxTrace::m_dlPathlossFile;
48std::string NrPhyRxTrace::m_dlPathlossFileName;
49std::ofstream NrPhyRxTrace::m_ulPathlossFile;
50std::string NrPhyRxTrace::m_ulPathlossFileName;
52std::ofstream NrPhyRxTrace::m_dlCtrlPathlossFile;
53std::string NrPhyRxTrace::m_dlCtrlPathlossFileName;
54std::ofstream NrPhyRxTrace::m_dlDataPathlossFile;
55std::string NrPhyRxTrace::m_dlDataPathlossFileName;
57NrPhyRxTrace::NrPhyRxTrace()
61NrPhyRxTrace::~NrPhyRxTrace()
63 if (m_dlDataSinrFile.is_open())
65 m_dlDataSinrFile.close();
68 if (m_dlCtrlSinrFile.is_open())
70 m_dlCtrlSinrFile.close();
73 if (m_rxPacketTraceFile.is_open())
75 m_rxPacketTraceFile.close();
78 if (m_rxedGnbPhyCtrlMsgsFile.is_open())
80 m_rxedGnbPhyCtrlMsgsFile.close();
83 if (m_txedGnbPhyCtrlMsgsFile.is_open())
85 m_txedGnbPhyCtrlMsgsFile.close();
88 if (m_rxedUePhyCtrlMsgsFile.is_open())
90 m_rxedUePhyCtrlMsgsFile.close();
93 if (m_txedUePhyCtrlMsgsFile.is_open())
95 m_txedUePhyCtrlMsgsFile.close();
98 if (m_rxedUePhyDlDciFile.is_open())
100 m_rxedUePhyDlDciFile.close();
103 if (m_dlPathlossFile.is_open())
105 m_dlPathlossFile.close();
108 if (m_ulPathlossFile.is_open())
110 m_ulPathlossFile.close();
113 if (m_dlCtrlPathlossFile.is_open())
115 m_dlCtrlPathlossFile.close();
118 if (m_dlDataPathlossFile.is_open())
120 m_dlDataPathlossFile.close();
125NrPhyRxTrace::GetTypeId()
128 TypeId(
"ns3::NrPhyRxTrace")
130 .AddConstructor<NrPhyRxTrace>()
133 "simulation tag that will be concatenated to output file names"
134 "in order to distinguish them, for example: RxPacketTrace-${SimTag}.out. ",
137 MakeStringChecker());
150 m_resultsFolder = resultsFolder;
155 [[maybe_unused]] std::string path,
161 NS_LOG_INFO(
"UE" << rnti <<
"of " << cellId <<
" over bwp ID " << bwpId
162 <<
"->Generate RsrpSinrTrace");
163 if (!m_dlDataSinrFile.is_open())
165 std::ostringstream oss;
166 oss << m_resultsFolder <<
"DlDataSinr" << m_simTag.c_str() <<
".txt";
167 m_dlDataSinrFileName = oss.str();
168 m_dlDataSinrFile.open(m_dlDataSinrFileName.c_str());
170 m_dlDataSinrFile <<
"Time"
178 <<
"SINR(dB)" << std::endl;
180 if (!m_dlDataSinrFile.is_open())
182 NS_FATAL_ERROR(
"Could not open tracefile");
186 m_dlDataSinrFile << Simulator::Now().GetSeconds() <<
"\t" << cellId <<
"\t" << rnti <<
"\t"
187 << bwpId <<
"\t" << 10 * log10(avgSinr) << std::endl;
192 [[maybe_unused]] std::string path,
198 NS_LOG_INFO(
"UE" << rnti <<
"of " << cellId <<
" over bwp ID " << bwpId
199 <<
"->Generate DlCtrlSinrTrace");
201 if (!m_dlCtrlSinrFile.is_open())
203 std::ostringstream oss;
204 oss << m_resultsFolder <<
"DlCtrlSinr" << m_simTag.c_str() <<
".txt";
205 m_dlCtrlSinrFileName = oss.str();
206 m_dlCtrlSinrFile.open(m_dlCtrlSinrFileName.c_str());
208 m_dlCtrlSinrFile <<
"Time"
216 <<
"SINR(dB)" << std::endl;
218 if (!m_dlCtrlSinrFile.is_open())
220 NS_FATAL_ERROR(
"Could not open tracefile");
224 m_dlCtrlSinrFile << Simulator::Now().GetSeconds() <<
"\t" << cellId <<
"\t" << rnti <<
"\t"
225 << bwpId <<
"\t" << 10 * log10(avgSinr) << std::endl;
229NrPhyRxTrace::UlSinrTraceCallback(Ptr<NrPhyRxTrace> phyStats,
233 SpectrumValue& power)
235 NS_LOG_INFO(
"UE" << imsi <<
"->Generate UlSinrTrace");
236 uint64_t tti_count = Now().GetMicroSeconds() / 125;
237 uint32_t rb_count = 1;
239 std::string fname =
"UE_" + std::to_string(imsi) +
"_UL_SINR_dB.txt";
240 log_file = fopen(fname.c_str(),
"a");
241 Values::iterator it = sinr.ValuesBegin();
242 while (it != sinr.ValuesEnd())
246 "%llu\t%llu\t%d\t%f\t \n",
247 (
long long unsigned)tti_count / 8 + 1,
248 (
long long unsigned)tti_count % 8 + 1,
267 Ptr<const NrControlMessage> msg)
269 if (!m_rxedGnbPhyCtrlMsgsFile.is_open())
271 std::ostringstream oss;
272 oss << m_resultsFolder <<
"RxedGnbPhyCtrlMsgsTrace" << m_simTag.c_str() <<
".txt";
273 m_rxedGnbPhyCtrlMsgsFileName = oss.str();
274 m_rxedGnbPhyCtrlMsgsFile.open(m_rxedGnbPhyCtrlMsgsFileName.c_str());
276 m_rxedGnbPhyCtrlMsgsFile <<
"Time"
292 <<
"MsgType" << std::endl;
294 if (!m_rxedGnbPhyCtrlMsgsFile.is_open())
296 NS_FATAL_ERROR(
"Could not open tracefile");
300 m_rxedGnbPhyCtrlMsgsFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
303 <<
static_cast<uint32_t
>(sfn.
GetSubframe()) <<
"\t"
304 <<
static_cast<uint32_t
>(sfn.
GetSlot()) <<
"\t" << nodeId <<
"\t"
305 << rnti <<
"\t" <<
static_cast<uint32_t
>(bwpId) <<
"\t";
309 m_rxedGnbPhyCtrlMsgsFile <<
"DL_CQI";
313 m_rxedGnbPhyCtrlMsgsFile <<
"SR";
317 m_rxedGnbPhyCtrlMsgsFile <<
"BSR";
321 m_rxedGnbPhyCtrlMsgsFile <<
"RACH_PREAMBLE";
325 m_rxedGnbPhyCtrlMsgsFile <<
"DL_HARQ";
329 m_rxedGnbPhyCtrlMsgsFile <<
"SRS";
333 m_rxedGnbPhyCtrlMsgsFile <<
"Other";
335 m_rxedGnbPhyCtrlMsgsFile << std::endl;
345 Ptr<const NrControlMessage> msg)
347 if (!m_txedGnbPhyCtrlMsgsFile.is_open())
349 std::ostringstream oss;
350 oss << m_resultsFolder <<
"TxedGnbPhyCtrlMsgsTrace" << m_simTag.c_str() <<
".txt";
351 m_txedGnbPhyCtrlMsgsFileName = oss.str();
352 m_txedGnbPhyCtrlMsgsFile.open(m_txedGnbPhyCtrlMsgsFileName.c_str());
354 m_txedGnbPhyCtrlMsgsFile <<
"Time"
370 <<
"MsgType" << std::endl;
372 if (!m_txedGnbPhyCtrlMsgsFile.is_open())
374 NS_FATAL_ERROR(
"Could not open tracefile");
378 m_txedGnbPhyCtrlMsgsFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
381 <<
static_cast<uint32_t
>(sfn.
GetSubframe()) <<
"\t"
382 <<
static_cast<uint32_t
>(sfn.
GetSlot()) <<
"\t" << nodeId <<
"\t"
383 << rnti <<
"\t" <<
static_cast<uint32_t
>(bwpId) <<
"\t";
387 m_txedGnbPhyCtrlMsgsFile <<
"MIB";
391 m_txedGnbPhyCtrlMsgsFile <<
"SIB1";
395 m_txedGnbPhyCtrlMsgsFile <<
"RAR";
399 m_txedGnbPhyCtrlMsgsFile <<
"DL_DCI";
403 m_txedGnbPhyCtrlMsgsFile <<
"UL_UCI";
407 m_txedGnbPhyCtrlMsgsFile <<
"Other";
409 m_txedGnbPhyCtrlMsgsFile << std::endl;
419 Ptr<const NrControlMessage> msg)
421 if (!m_rxedUePhyCtrlMsgsFile.is_open())
423 std::ostringstream oss;
424 oss << m_resultsFolder <<
"RxedUePhyCtrlMsgsTrace" << m_simTag.c_str() <<
".txt";
425 m_rxedUePhyCtrlMsgsFileName = oss.str();
426 m_rxedUePhyCtrlMsgsFile.open(m_rxedUePhyCtrlMsgsFileName.c_str());
428 m_rxedUePhyCtrlMsgsFile <<
"Time"
444 <<
"MsgType" << std::endl;
446 if (!m_rxedUePhyCtrlMsgsFile.is_open())
448 NS_FATAL_ERROR(
"Could not open tracefile");
452 m_rxedUePhyCtrlMsgsFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
455 <<
static_cast<uint32_t
>(sfn.
GetSubframe()) <<
"\t"
456 <<
static_cast<uint32_t
>(sfn.
GetSlot()) <<
"\t" << nodeId <<
"\t"
457 << rnti <<
"\t" <<
static_cast<uint32_t
>(bwpId) <<
"\t";
461 m_rxedUePhyCtrlMsgsFile <<
"UL_DCI";
465 m_rxedUePhyCtrlMsgsFile <<
"DL_DCI";
469 m_rxedUePhyCtrlMsgsFile <<
"MIB";
473 m_rxedUePhyCtrlMsgsFile <<
"SIB1";
477 m_rxedUePhyCtrlMsgsFile <<
"RAR";
481 m_rxedUePhyCtrlMsgsFile <<
"Other";
483 m_rxedUePhyCtrlMsgsFile << std::endl;
493 Ptr<const NrControlMessage> msg)
495 if (!m_txedUePhyCtrlMsgsFile.is_open())
497 std::ostringstream oss;
498 oss << m_resultsFolder <<
"TxedUePhyCtrlMsgsTrace" << m_simTag.c_str() <<
".txt";
499 m_txedUePhyCtrlMsgsFileName = oss.str();
500 m_txedUePhyCtrlMsgsFile.open(m_txedUePhyCtrlMsgsFileName.c_str());
502 m_txedUePhyCtrlMsgsFile <<
"Time"
518 <<
"MsgType" << std::endl;
520 if (!m_txedUePhyCtrlMsgsFile.is_open())
522 NS_FATAL_ERROR(
"Could not open tracefile");
526 m_txedUePhyCtrlMsgsFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
529 <<
static_cast<uint32_t
>(sfn.
GetSubframe()) <<
"\t"
530 <<
static_cast<uint32_t
>(sfn.
GetSlot()) <<
"\t" << nodeId <<
"\t"
531 << rnti <<
"\t" <<
static_cast<uint32_t
>(bwpId) <<
"\t";
535 m_txedUePhyCtrlMsgsFile <<
"RACH_PREAMBLE";
539 m_txedUePhyCtrlMsgsFile <<
"SR";
543 m_txedUePhyCtrlMsgsFile <<
"BSR";
547 m_txedUePhyCtrlMsgsFile <<
"DL_CQI";
551 m_txedUePhyCtrlMsgsFile <<
"DL_HARQ";
555 m_txedUePhyCtrlMsgsFile <<
"SRS";
559 m_txedUePhyCtrlMsgsFile <<
"Other";
561 m_txedUePhyCtrlMsgsFile << std::endl;
574 if (!m_rxedUePhyDlDciFile.is_open())
576 std::ostringstream oss;
577 oss << m_resultsFolder <<
"RxedUePhyDlDciTrace" << m_simTag.c_str() <<
".txt";
578 m_rxedUePhyDlDciFileName = oss.str();
579 m_rxedUePhyDlDciFile.open(m_rxedUePhyDlDciFileName.c_str());
581 m_rxedUePhyDlDciFile <<
"Time"
599 <<
"K1 Delay" << std::endl;
601 if (!m_rxedUePhyDlDciFile.is_open())
603 NS_FATAL_ERROR(
"Could not open tracefile");
607 m_rxedUePhyDlDciFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
610 <<
static_cast<uint32_t
>(sfn.
GetSubframe()) <<
"\t"
611 <<
static_cast<uint32_t
>(sfn.
GetSlot()) <<
"\t" << nodeId <<
"\t" << rnti
612 <<
"\t" <<
static_cast<uint32_t
>(bwpId) <<
"\t"
613 <<
static_cast<uint32_t
>(harqId) <<
"\t" << k1Delay << std::endl;
626 if (!m_rxedUePhyDlDciFile.is_open())
628 std::ostringstream oss;
629 oss << m_resultsFolder <<
"RxedUePhyDlDciTrace" << m_simTag.c_str() <<
".txt";
630 m_rxedUePhyDlDciFileName = oss.str();
631 m_rxedUePhyDlDciFile.open(m_rxedUePhyDlDciFileName.c_str());
633 m_rxedUePhyDlDciFile <<
"Time"
651 <<
"K1 Delay" << std::endl;
653 if (!m_rxedUePhyDlDciFile.is_open())
655 NS_FATAL_ERROR(
"Could not open tracefile");
659 m_rxedUePhyDlDciFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
662 <<
static_cast<uint32_t
>(sfn.
GetSubframe()) <<
"\t"
663 <<
static_cast<uint32_t
>(sfn.
GetSlot()) <<
"\t" << nodeId <<
"\t" << rnti
664 <<
"\t" <<
static_cast<uint32_t
>(bwpId) <<
"\t"
665 <<
static_cast<uint32_t
>(harqId) <<
"\t" << k1Delay << std::endl;
669NrPhyRxTrace::ReportInterferenceTrace(uint64_t imsi, SpectrumValue& sinr)
671 uint64_t tti_count = Now().GetMicroSeconds() / 125;
672 uint32_t rb_count = 1;
674 std::string fname =
"UE_" + std::to_string(imsi) +
"_SINR_dB.txt";
675 log_file = fopen(fname.c_str(),
"a");
676 Values::iterator it = sinr.ValuesBegin();
677 while (it != sinr.ValuesEnd())
681 "%llu\t%llu\t%d\t%f\t \n",
682 (
long long unsigned)tti_count / 8 + 1,
683 (
long long unsigned)tti_count % 8 + 1,
694NrPhyRxTrace::ReportPowerTrace(uint64_t imsi, SpectrumValue& power)
696 uint32_t tti_count = Now().GetMicroSeconds() / 125;
697 uint32_t rb_count = 1;
699 std::string fname =
"UE_" + std::to_string(imsi) +
"_ReceivedPower_dB.txt";
700 log_file = fopen(fname.c_str(),
"a");
701 Values::iterator it = power.ValuesBegin();
702 while (it != power.ValuesEnd())
705 "%llu\t%llu\t%d\t%f\t \n",
706 (
long long unsigned)tti_count / 8 + 1,
707 (
long long unsigned)tti_count % 8 + 1,
718NrPhyRxTrace::ReportPacketCountUeCallback(Ptr<NrPhyRxTrace> phyStats,
720 UePhyPacketCountParameter param)
722 phyStats->ReportPacketCountUe(param);
726NrPhyRxTrace::ReportPacketCountGnbCallback(Ptr<NrPhyRxTrace> phyStats,
728 GnbPhyPacketCountParameter param)
730 phyStats->ReportPacketCountGnb(param);
734NrPhyRxTrace::ReportDownLinkTBSize(Ptr<NrPhyRxTrace> phyStats,
739 phyStats->ReportDLTbSize(imsi, tbSize);
743NrPhyRxTrace::ReportPacketCountUe(UePhyPacketCountParameter param)
746 std::string fname =
"UE_" + std::to_string(param.m_imsi) +
"_Packet_Trace.txt";
747 log_file = fopen(fname.c_str(),
"a");
750 fprintf(log_file,
"%d\t%d\t%d\n", param.m_subframeno, param.m_noBytes, 0);
754 fprintf(log_file,
"%d\t%d\t%d\n", param.m_subframeno, 0, param.m_noBytes);
762NrPhyRxTrace::ReportPacketCountGnb(GnbPhyPacketCountParameter param)
765 std::string fname =
"BS_" + std::to_string(param.m_cellId) +
"_Packet_Trace.txt";
766 log_file = fopen(fname.c_str(),
"a");
769 fprintf(log_file,
"%d\t%d\t%d\n", param.m_subframeno, param.m_noBytes, 0);
773 fprintf(log_file,
"%d\t%d\t%d\n", param.m_subframeno, 0, param.m_noBytes);
781NrPhyRxTrace::ReportDLTbSize(uint64_t imsi, uint64_t tbSize)
784 std::string fname =
"UE_" + std::to_string(imsi) +
"_Tb_Size.txt";
785 log_file = fopen(fname.c_str(),
"a");
789 (
long long unsigned)Now().GetMicroSeconds(),
790 (
long long unsigned)tbSize);
793 (
long long int)Now().GetMicroSeconds(),
794 (
long long unsigned)tbSize);
800NrPhyRxTrace::RxPacketTraceUeCallback(Ptr<NrPhyRxTrace> phyStats,
802 RxPacketTraceParams params)
804 if (!m_rxPacketTraceFile.is_open())
806 std::ostringstream oss;
807 oss << m_resultsFolder <<
"RxPacketTrace" << m_simTag.c_str() <<
".txt";
808 m_rxPacketTraceFilename = oss.str();
809 m_rxPacketTraceFile.open(m_rxPacketTraceFilename.c_str());
811 m_rxPacketTraceFile <<
"Time"
845 <<
"TBler" << std::endl;
847 if (!m_rxPacketTraceFile.is_open())
849 NS_FATAL_ERROR(
"Could not open tracefile");
853 m_rxPacketTraceFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
855 <<
"\t" << params.m_frameNum <<
"\t" << (
unsigned)params.m_subframeNum
856 <<
"\t" << (unsigned)params.m_slotNum <<
"\t" << (
unsigned)params.m_symStart
857 <<
"\t" << (unsigned)params.m_numSym <<
"\t" << params.m_cellId <<
"\t"
858 << (
unsigned)params.m_bwpId <<
"\t" << params.m_rnti <<
"\t"
859 << params.m_tbSize <<
"\t" << (unsigned)params.m_mcs <<
"\t"
860 << (
unsigned)params.m_rank <<
"\t" << (unsigned)params.m_rv <<
"\t"
861 << 10 * log10(params.m_sinr) <<
"\t" << std::to_string(params.m_cqi) <<
"\t"
862 << params.m_corrupt <<
"\t" << params.m_tbler << std::endl;
864 if (params.m_corrupt)
866 NS_LOG_DEBUG(
"DL TB error\t"
867 << params.m_frameNum <<
"\t" << (
unsigned)params.m_subframeNum <<
"\t"
868 << (
unsigned)params.m_slotNum <<
"\t" << (
unsigned)params.m_symStart <<
"\t"
869 << (
unsigned)params.m_numSym <<
"\t" << params.m_rnti <<
"\t"
870 << params.m_tbSize <<
"\t" << (
unsigned)params.m_mcs <<
"\t"
871 << (
unsigned)params.m_rank <<
"\t" << (
unsigned)params.m_rv <<
"\t"
872 << params.m_sinr <<
"\t" << params.m_tbler <<
"\t"
873 << std::to_string(params.m_cqi) <<
"\t" << params.m_corrupt <<
"\t"
874 << (
unsigned)params.m_bwpId);
879NrPhyRxTrace::RxPacketTraceGnbCallback(Ptr<NrPhyRxTrace> phyStats,
881 RxPacketTraceParams params)
883 if (!m_rxPacketTraceFile.is_open())
885 std::ostringstream oss;
886 oss << m_resultsFolder <<
"RxPacketTrace" << m_simTag.c_str() <<
".txt";
887 m_rxPacketTraceFilename = oss.str();
888 m_rxPacketTraceFile.open(m_rxPacketTraceFilename.c_str());
890 m_rxPacketTraceFile <<
"Time"
924 <<
"TBler" << std::endl;
926 if (!m_rxPacketTraceFile.is_open())
928 NS_FATAL_ERROR(
"Could not open tracefile");
931 m_rxPacketTraceFile << Simulator::Now().GetNanoSeconds() / (double)1e9 <<
"\t"
933 <<
"\t" << params.m_frameNum <<
"\t" << (
unsigned)params.m_subframeNum
934 <<
"\t" << (unsigned)params.m_slotNum <<
"\t" << (
unsigned)params.m_symStart
935 <<
"\t" << (unsigned)params.m_numSym <<
"\t" << params.m_cellId <<
"\t"
936 << (
unsigned)params.m_bwpId <<
"\t" << params.m_rnti <<
"\t"
937 << params.m_tbSize <<
"\t" << (unsigned)params.m_mcs <<
"\t"
938 << (
unsigned)params.m_rank <<
"\t" << (unsigned)params.m_rv <<
"\t"
939 << 10 * log10(params.m_sinr) <<
"\t" << std::to_string(params.m_cqi) <<
"\t"
940 << params.m_corrupt <<
"\t" << params.m_tbler << std::endl;
942 if (params.m_corrupt)
944 NS_LOG_DEBUG(
"UL TB error\t"
945 << params.m_frameNum <<
"\t" << (
unsigned)params.m_subframeNum <<
"\t"
946 << (
unsigned)params.m_slotNum <<
"\t" << (
unsigned)params.m_symStart <<
"\t"
947 << (
unsigned)params.m_numSym <<
"\t" << params.m_rnti <<
"\t"
948 << params.m_tbSize <<
"\t" << (
unsigned)params.m_mcs <<
"\t"
949 << (
unsigned)params.m_rank <<
"\t" << (
unsigned)params.m_rv <<
"\t"
950 << params.m_sinr <<
"\t" << params.m_tbler <<
"\t"
951 << std::to_string(params.m_cqi) <<
"\t" << params.m_corrupt <<
"\t"
952 << params.m_sinrMin <<
"\t" << params.m_bwpId);
959 Ptr<const SpectrumPhy> txPhy,
960 Ptr<const SpectrumPhy> rxPhy,
963 Ptr<NrSpectrumPhy> txNrSpectrumPhy = txPhy->GetObject<
NrSpectrumPhy>();
964 Ptr<NrSpectrumPhy> rxNrSpectrumPhy = rxPhy->GetObject<
NrSpectrumPhy>();
965 if (DynamicCast<NrGnbNetDevice>(txNrSpectrumPhy->GetDevice()) !=
nullptr)
970 if (DynamicCast<NrUeNetDevice>(rxNrSpectrumPhy->GetDevice()) !=
nullptr)
973 txNrSpectrumPhy->GetDevice()->GetObject<
NrGnbNetDevice>()->GetCellId();
975 rxNrSpectrumPhy->GetDevice()->GetObject<
NrUeNetDevice>()->GetCellId();
976 uint16_t txBwpId = txNrSpectrumPhy->GetBwpId();
977 uint16_t rxBwpId = rxNrSpectrumPhy->GetBwpId();
978 if (txCellId == rxCellId && txBwpId == rxBwpId)
982 phyStats->WriteDlPathlossTrace(txNrSpectrumPhy, rxNrSpectrumPhy, lossDb * -1);
991 if (DynamicCast<NrGnbNetDevice>(rxNrSpectrumPhy->GetDevice()) !=
nullptr)
994 txNrSpectrumPhy->GetDevice()->GetObject<
NrUeNetDevice>()->GetCellId();
996 rxNrSpectrumPhy->GetDevice()->GetObject<
NrGnbNetDevice>()->GetCellId();
997 uint16_t txBwpId = txNrSpectrumPhy->GetBwpId();
998 uint16_t rxBwpId = rxNrSpectrumPhy->GetBwpId();
999 if (txCellId == rxCellId && txBwpId == rxBwpId)
1003 phyStats->WriteUlPathlossTrace(txNrSpectrumPhy, rxNrSpectrumPhy, lossDb * -1);
1010NrPhyRxTrace::WriteDlPathlossTrace(Ptr<NrSpectrumPhy> txNrSpectrumPhy,
1011 Ptr<NrSpectrumPhy> rxNrSpectrumPhy,
1014 if (!m_dlPathlossFile.is_open())
1016 std::ostringstream oss;
1017 oss << m_resultsFolder <<
"DlPathlossTrace" << m_simTag.c_str() <<
".txt";
1018 m_dlPathlossFileName = oss.str();
1019 m_dlPathlossFile.open(m_dlPathlossFileName.c_str());
1021 m_dlPathlossFile <<
"Time(sec)"
1029 <<
"pathLoss(dB)" << std::endl;
1031 if (!m_dlPathlossFile.is_open())
1033 NS_FATAL_ERROR(
"Could not open DL pathloss tracefile");
1037 m_dlPathlossFile << Simulator::Now().GetSeconds() <<
"\t"
1038 << txNrSpectrumPhy->GetDevice()->GetObject<NrGnbNetDevice>()->GetCellId()
1039 <<
"\t" << txNrSpectrumPhy->GetBwpId() <<
"\t"
1040 << rxNrSpectrumPhy->GetDevice()->GetObject<NrUeNetDevice>()->GetImsi() <<
"\t"
1041 << lossDb << std::endl;
1045NrPhyRxTrace::WriteUlPathlossTrace(Ptr<NrSpectrumPhy> txNrSpectrumPhy,
1046 Ptr<NrSpectrumPhy> rxNrSpectrumPhy,
1049 if (!m_ulPathlossFile.is_open())
1051 std::ostringstream oss;
1052 oss << m_resultsFolder <<
"UlPathlossTrace" << m_simTag.c_str() <<
".txt";
1053 m_ulPathlossFileName = oss.str();
1054 m_ulPathlossFile.open(m_ulPathlossFileName.c_str());
1056 m_ulPathlossFile <<
"Time(sec)"
1064 <<
"pathLoss(dB)" << std::endl;
1066 if (!m_ulPathlossFile.is_open())
1068 NS_FATAL_ERROR(
"Could not open UL pathloss tracefile");
1072 m_ulPathlossFile << Simulator::Now().GetSeconds() <<
"\t"
1073 << txNrSpectrumPhy->GetDevice()->GetObject<NrUeNetDevice>()->GetCellId()
1074 <<
"\t" << txNrSpectrumPhy->GetBwpId() <<
"\t"
1075 << txNrSpectrumPhy->GetDevice()->GetObject<NrUeNetDevice>()->GetImsi() <<
"\t"
1076 << lossDb << std::endl;
1081 [[maybe_unused]] std::string path,
1087 NS_LOG_INFO(
"UE node id:" << ueNodeId <<
"of " << cellId <<
" over bwp ID " << bwpId
1088 <<
"->Generate DL CTRL pathloss record: " << lossDb);
1090 if (!m_dlCtrlPathlossFile.is_open())
1092 std::ostringstream oss;
1093 oss << m_resultsFolder <<
"DlCtrlPathlossTrace" << m_simTag.c_str() <<
".txt";
1094 m_dlCtrlPathlossFileName = oss.str();
1095 m_dlCtrlPathlossFile.open(m_dlCtrlPathlossFileName.c_str());
1097 m_dlCtrlPathlossFile <<
"Time(sec)"
1105 <<
"pathLoss(dB)" << std::endl;
1107 if (!m_dlCtrlPathlossFile.is_open())
1109 NS_FATAL_ERROR(
"Could not open DL CTRL pathloss tracefile");
1113 m_dlCtrlPathlossFile << Simulator::Now().GetSeconds() <<
"\t" << cellId <<
"\t" << +bwpId
1114 <<
"\t" << ueNodeId <<
"\t" << lossDb << std::endl;
1119 [[maybe_unused]] std::string path,
1126 NS_LOG_INFO(
"UE node id:" << ueNodeId <<
"of " << cellId <<
" over bwp ID " << bwpId
1127 <<
"->Generate DL DATA pathloss record: " << lossDb);
1129 if (!m_dlDataPathlossFile.is_open())
1131 std::ostringstream oss;
1132 oss << m_resultsFolder <<
"DlDataPathlossTrace" << m_simTag.c_str() <<
".txt";
1133 m_dlDataPathlossFileName = oss.str();
1134 m_dlDataPathlossFile.open(m_dlDataPathlossFileName.c_str());
1136 m_dlDataPathlossFile <<
"Time(sec)"
1146 <<
"CQI" << std::endl;
1148 if (!m_dlDataPathlossFile.is_open())
1150 NS_FATAL_ERROR(
"Could not open DL DATA pathloss tracefile");
1154 m_dlDataPathlossFile << Simulator::Now().GetSeconds() <<
"\t" << cellId <<
"\t" << +bwpId
1155 <<
"\t" << ueNodeId <<
"\t" << lossDb <<
"\t" << +cqi << std::endl;
@ UL_DCI
The resources allocation map from the BS to the attached UEs (UL)
@ DL_HARQ
DL HARQ feedback.
@ RACH_PREAMBLE
Random Access Preamble.
@ MIB
Master Information Block.
@ SR
Scheduling Request: asking for space.
@ BSR
Buffer Status Report.
@ RAR
Random Access Response.
@ SIB1
System Information Block Type 1.
@ DL_DCI
The resources allocation map from the BS to the attached UEs (DL)
The NrGnbNetDevice class.
static void RxedGnbPhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void ReportDlDataPathloss(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint8_t bwpId, uint32_t ueNodeId, double lossDb, uint8_t cqi)
Write DL DATA pathloss values in a file.
static void PathlossTraceCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, Ptr< const SpectrumPhy > txPhy, Ptr< const SpectrumPhy > rxPhy, double lossDb)
Trace sink for spectrum channel pathloss trace.
static void TxedGnbPhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
void SetResultsFolder(const std::string &resultsFolder)
Set results folder.
static void TxedUePhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void TxedUePhyHarqFeedbackCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, uint8_t harqId, uint32_t k1Delay)
static void RxedUePhyCtrlMsgsCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, Ptr< const NrControlMessage > msg)
static void DlCtrlSinrCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double avgSinr, uint16_t bwpId)
Trace sink for DL Average SINR of CTRL (in dB).
static void RxedUePhyDlDciCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, SfnSf sfn, uint16_t nodeId, uint16_t rnti, uint8_t bwpId, uint8_t harqId, uint32_t k1Delay)
void SetSimTag(const std::string &simTag)
Set simTag that will be concatenated to output file names.
static void DlDataSinrCallback(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint16_t rnti, double avgSinr, uint16_t bwpId)
Trace sink for DL Average SINR of DATA (in dB).
static void ReportDlCtrlPathloss(Ptr< NrPhyRxTrace > phyStats, std::string path, uint16_t cellId, uint8_t bwpId, uint32_t ueNodeId, double lossDb)
Write DL CTRL pathloss values in a file.
Interface between the physical layer and the channel.
The User Equipment NetDevice.
uint8_t GetSubframe() const
GetSubframe.
uint8_t GetSlot() const
GetSlot.
uint32_t GetFrame() const
GetFrame.