diff --git a/src/lte/helper/mac-stats-calculator.cc b/src/lte/helper/mac-stats-calculator.cc index d05b2f032..7188dbf98 100644 --- a/src/lte/helper/mac-stats-calculator.cc +++ b/src/lte/helper/mac-stats-calculator.cc @@ -42,6 +42,15 @@ MacStatsCalculator::MacStatsCalculator () MacStatsCalculator::~MacStatsCalculator () { NS_LOG_FUNCTION (this); + if (m_dlOutFile.is_open()) + { + m_dlOutFile.close(); + } + + if (m_ulOutFile.is_open()) + { + m_ulOutFile.close(); + } } TypeId @@ -96,41 +105,30 @@ MacStatsCalculator::DlScheduling (uint16_t cellId, uint64_t imsi, DlSchedulingCa dlSchedulingCallbackInfo.rnti << (uint32_t) dlSchedulingCallbackInfo.mcsTb1 << dlSchedulingCallbackInfo.sizeTb1 << (uint32_t) dlSchedulingCallbackInfo.mcsTb2 << dlSchedulingCallbackInfo.sizeTb2); NS_LOG_INFO ("Write DL Mac Stats in " << GetDlOutputFilename ().c_str ()); - std::ofstream outFile; if ( m_dlFirstWrite == true ) { - outFile.open (GetDlOutputFilename ().c_str ()); - if (!outFile.is_open ()) + m_dlOutFile.open (GetDlOutputFilename ().c_str ()); + if (!m_dlOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ()); return; } m_dlFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2\tccId"; - outFile << std::endl; - } - else - { - outFile.open (GetDlOutputFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ()); - return; - } + m_dlOutFile << "% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2\tccId"; + m_dlOutFile << "\n"; } - outFile << Simulator::Now ().GetSeconds () << "\t"; - outFile << (uint32_t) cellId << "\t"; - outFile << imsi << "\t"; - outFile << dlSchedulingCallbackInfo.frameNo << "\t"; - outFile << dlSchedulingCallbackInfo.subframeNo << "\t"; - outFile << dlSchedulingCallbackInfo.rnti << "\t"; - outFile << (uint32_t) dlSchedulingCallbackInfo.mcsTb1 << "\t"; - outFile << dlSchedulingCallbackInfo.sizeTb1 << "\t"; - outFile << (uint32_t) dlSchedulingCallbackInfo.mcsTb2 << "\t"; - outFile << dlSchedulingCallbackInfo.sizeTb2 << "\t"; - outFile << (uint32_t) dlSchedulingCallbackInfo.componentCarrierId << std::endl; - outFile.close (); + m_dlOutFile << Simulator::Now ().GetSeconds () << "\t"; + m_dlOutFile << (uint32_t) cellId << "\t"; + m_dlOutFile << imsi << "\t"; + m_dlOutFile << dlSchedulingCallbackInfo.frameNo << "\t"; + m_dlOutFile << dlSchedulingCallbackInfo.subframeNo << "\t"; + m_dlOutFile << dlSchedulingCallbackInfo.rnti << "\t"; + m_dlOutFile << (uint32_t) dlSchedulingCallbackInfo.mcsTb1 << "\t"; + m_dlOutFile << dlSchedulingCallbackInfo.sizeTb1 << "\t"; + m_dlOutFile << (uint32_t) dlSchedulingCallbackInfo.mcsTb2 << "\t"; + m_dlOutFile << dlSchedulingCallbackInfo.sizeTb2 << "\t"; + m_dlOutFile << (uint32_t) dlSchedulingCallbackInfo.componentCarrierId << std::endl; } void @@ -140,39 +138,28 @@ MacStatsCalculator::UlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frame NS_LOG_FUNCTION (this << cellId << imsi << frameNo << subframeNo << rnti << (uint32_t) mcsTb << size); NS_LOG_INFO ("Write UL Mac Stats in " << GetUlOutputFilename ().c_str ()); - std::ofstream outFile; if ( m_ulFirstWrite == true ) { - outFile.open (GetUlOutputFilename ().c_str ()); - if (!outFile.is_open ()) + m_ulOutFile.open (GetUlOutputFilename ().c_str ()); + if (!m_ulOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ()); return; } m_ulFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcs\tsize\tccId"; - outFile << std::endl; - } - else - { - outFile.open (GetUlOutputFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ()); - return; - } + m_ulOutFile << "% time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcs\tsize\tccId"; + m_ulOutFile << "\n"; } - outFile << Simulator::Now ().GetSeconds () << "\t"; - outFile << (uint32_t) cellId << "\t"; - outFile << imsi << "\t"; - outFile << frameNo << "\t"; - outFile << subframeNo << "\t"; - outFile << rnti << "\t"; - outFile << (uint32_t) mcsTb << "\t"; - outFile << size << "\t"; - outFile << (uint32_t) componentCarrierId << std::endl; - outFile.close (); + m_ulOutFile << Simulator::Now ().GetSeconds () << "\t"; + m_ulOutFile << (uint32_t) cellId << "\t"; + m_ulOutFile << imsi << "\t"; + m_ulOutFile << frameNo << "\t"; + m_ulOutFile << subframeNo << "\t"; + m_ulOutFile << rnti << "\t"; + m_ulOutFile << (uint32_t) mcsTb << "\t"; + m_ulOutFile << size << "\t"; + m_ulOutFile << (uint32_t) componentCarrierId << std::endl; } void diff --git a/src/lte/helper/mac-stats-calculator.h b/src/lte/helper/mac-stats-calculator.h index da1669580..815a40396 100644 --- a/src/lte/helper/mac-stats-calculator.h +++ b/src/lte/helper/mac-stats-calculator.h @@ -166,6 +166,15 @@ private: */ bool m_ulFirstWrite; + /** + * Downlink output trace file + */ + std::ofstream m_dlOutFile; + + /** + * Uplink output trace file + */ + std::ofstream m_ulOutFile; }; } // namespace ns3 diff --git a/src/lte/helper/phy-rx-stats-calculator.cc b/src/lte/helper/phy-rx-stats-calculator.cc index a93391665..4b13b3e19 100644 --- a/src/lte/helper/phy-rx-stats-calculator.cc +++ b/src/lte/helper/phy-rx-stats-calculator.cc @@ -42,6 +42,15 @@ PhyRxStatsCalculator::PhyRxStatsCalculator () PhyRxStatsCalculator::~PhyRxStatsCalculator () { NS_LOG_FUNCTION (this); + if (m_dlRxOutFile.is_open()) + { + m_dlRxOutFile.close(); + } + + if (m_ulRxOutFile.is_open()) + { + m_ulRxOutFile.close(); + } } TypeId @@ -95,42 +104,31 @@ PhyRxStatsCalculator::DlPhyReception (PhyReceptionStatParameters params) NS_LOG_FUNCTION (this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi << params.m_correctness); NS_LOG_INFO ("Write DL Rx Phy Stats in " << GetDlRxOutputFilename ().c_str ()); - std::ofstream outFile; if ( m_dlRxFirstWrite == true ) { - outFile.open (GetDlRxOutputFilename ().c_str ()); - if (!outFile.is_open ()) + m_dlRxOutFile.open (GetDlRxOutputFilename ().c_str ()); + if (!m_dlRxOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetDlRxOutputFilename ().c_str ()); return; } m_dlRxFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tRNTI\ttxMode\tlayer\tmcs\tsize\trv\tndi\tcorrect\tccId"; - outFile << std::endl; - } - else - { - outFile.open (GetDlRxOutputFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetDlRxOutputFilename ().c_str ()); - return; - } + m_dlRxOutFile << "% time\tcellId\tIMSI\tRNTI\ttxMode\tlayer\tmcs\tsize\trv\tndi\tcorrect\tccId"; + m_dlRxOutFile << "\n"; } - outFile << params.m_timestamp << "\t"; - outFile << (uint32_t) params.m_cellId << "\t"; - outFile << params.m_imsi << "\t"; - outFile << params.m_rnti << "\t"; - outFile << (uint32_t) params.m_txMode << "\t"; - outFile << (uint32_t) params.m_layer << "\t"; - outFile << (uint32_t) params.m_mcs << "\t"; - outFile << params.m_size << "\t"; - outFile << (uint32_t) params.m_rv << "\t"; - outFile << (uint32_t) params.m_ndi << "\t"; - outFile << (uint32_t) params.m_correctness << "\t"; - outFile << (uint32_t) params.m_ccId << std::endl; - outFile.close (); + m_dlRxOutFile << params.m_timestamp << "\t"; + m_dlRxOutFile << (uint32_t) params.m_cellId << "\t"; + m_dlRxOutFile << params.m_imsi << "\t"; + m_dlRxOutFile << params.m_rnti << "\t"; + m_dlRxOutFile << (uint32_t) params.m_txMode << "\t"; + m_dlRxOutFile << (uint32_t) params.m_layer << "\t"; + m_dlRxOutFile << (uint32_t) params.m_mcs << "\t"; + m_dlRxOutFile << params.m_size << "\t"; + m_dlRxOutFile << (uint32_t) params.m_rv << "\t"; + m_dlRxOutFile << (uint32_t) params.m_ndi << "\t"; + m_dlRxOutFile << (uint32_t) params.m_correctness << "\t"; + m_dlRxOutFile << (uint32_t) params.m_ccId << std::endl; } void @@ -139,41 +137,30 @@ PhyRxStatsCalculator::UlPhyReception (PhyReceptionStatParameters params) NS_LOG_FUNCTION (this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi << params.m_correctness); NS_LOG_INFO ("Write UL Rx Phy Stats in " << GetUlRxOutputFilename ().c_str ()); - std::ofstream outFile; if ( m_ulRxFirstWrite == true ) { - outFile.open (GetUlRxOutputFilename ().c_str ()); - if (!outFile.is_open ()) + m_ulRxOutFile.open (GetUlRxOutputFilename ().c_str ()); + if (!m_ulRxOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetUlRxOutputFilename ().c_str ()); return; } m_ulRxFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tcorrect\tccId"; - outFile << std::endl; - } - else - { - outFile.open (GetUlRxOutputFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetUlRxOutputFilename ().c_str ()); - return; - } + m_ulRxOutFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tcorrect\tccId"; + m_ulRxOutFile << "\n"; } - outFile << params.m_timestamp << "\t"; - outFile << (uint32_t) params.m_cellId << "\t"; - outFile << params.m_imsi << "\t"; - outFile << params.m_rnti << "\t"; - outFile << (uint32_t) params.m_layer << "\t"; - outFile << (uint32_t) params.m_mcs << "\t"; - outFile << params.m_size << "\t"; - outFile << (uint32_t) params.m_rv << "\t"; - outFile << (uint32_t) params.m_ndi << "\t"; - outFile << (uint32_t) params.m_correctness << "\t"; - outFile << (uint32_t) params.m_ccId << std::endl; - outFile.close (); + m_ulRxOutFile << params.m_timestamp << "\t"; + m_ulRxOutFile << (uint32_t) params.m_cellId << "\t"; + m_ulRxOutFile << params.m_imsi << "\t"; + m_ulRxOutFile << params.m_rnti << "\t"; + m_ulRxOutFile << (uint32_t) params.m_layer << "\t"; + m_ulRxOutFile << (uint32_t) params.m_mcs << "\t"; + m_ulRxOutFile << params.m_size << "\t"; + m_ulRxOutFile << (uint32_t) params.m_rv << "\t"; + m_ulRxOutFile << (uint32_t) params.m_ndi << "\t"; + m_ulRxOutFile << (uint32_t) params.m_correctness << "\t"; + m_ulRxOutFile << (uint32_t) params.m_ccId << std::endl; } void diff --git a/src/lte/helper/phy-rx-stats-calculator.h b/src/lte/helper/phy-rx-stats-calculator.h index 63ac9546c..8736d52cb 100644 --- a/src/lte/helper/phy-rx-stats-calculator.h +++ b/src/lte/helper/phy-rx-stats-calculator.h @@ -142,6 +142,15 @@ private: */ bool m_ulRxFirstWrite; + /** + * DL RX PHY output trace file + */ + std::ofstream m_dlRxOutFile; + + /** + * UL RX PHY output trace file + */ + std::ofstream m_ulRxOutFile; }; } // namespace ns3 diff --git a/src/lte/helper/phy-stats-calculator.cc b/src/lte/helper/phy-stats-calculator.cc index 47ba3474e..05576a293 100644 --- a/src/lte/helper/phy-stats-calculator.cc +++ b/src/lte/helper/phy-stats-calculator.cc @@ -42,6 +42,20 @@ PhyStatsCalculator::PhyStatsCalculator () PhyStatsCalculator::~PhyStatsCalculator () { NS_LOG_FUNCTION (this); + if (m_interferenceOutFile.is_open()) + { + m_interferenceOutFile.close(); + } + + if (m_rsrpOutFile.is_open()) + { + m_rsrpOutFile.close(); + } + + if (m_ueSinrOutFile.is_open()) + { + m_ueSinrOutFile.close(); + } } TypeId @@ -115,37 +129,26 @@ PhyStatsCalculator::ReportCurrentCellRsrpSinr (uint16_t cellId, uint64_t imsi, u NS_LOG_FUNCTION (this << cellId << imsi << rnti << rsrp << sinr); NS_LOG_INFO ("Write RSRP/SINR Phy Stats in " << GetCurrentCellRsrpSinrFilename ().c_str ()); - std::ofstream outFile; if ( m_RsrpSinrFirstWrite == true ) { - outFile.open (GetCurrentCellRsrpSinrFilename ().c_str ()); - if (!outFile.is_open ()) + m_rsrpOutFile.open (GetCurrentCellRsrpSinrFilename ().c_str ()); + if (!m_rsrpOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetCurrentCellRsrpSinrFilename ().c_str ()); return; } m_RsrpSinrFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tRNTI\trsrp\tsinr\tComponentCarrierId"; - outFile << std::endl; - } - else - { - outFile.open (GetCurrentCellRsrpSinrFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetCurrentCellRsrpSinrFilename ().c_str ()); - return; - } + m_rsrpOutFile << "% time\tcellId\tIMSI\tRNTI\trsrp\tsinr\tComponentCarrierId"; + m_rsrpOutFile << "\n"; } - outFile << Simulator::Now ().GetSeconds () << "\t"; - outFile << cellId << "\t"; - outFile << imsi << "\t"; - outFile << rnti << "\t"; - outFile << rsrp << "\t"; - outFile << sinr << "\t"; - outFile << (uint32_t)componentCarrierId << std::endl; - outFile.close (); + m_rsrpOutFile << Simulator::Now ().GetSeconds () << "\t"; + m_rsrpOutFile << cellId << "\t"; + m_rsrpOutFile << imsi << "\t"; + m_rsrpOutFile << rnti << "\t"; + m_rsrpOutFile << rsrp << "\t"; + m_rsrpOutFile << sinr << "\t"; + m_rsrpOutFile << (uint32_t)componentCarrierId << std::endl; } void @@ -154,36 +157,24 @@ PhyStatsCalculator::ReportUeSinr (uint16_t cellId, uint64_t imsi, uint16_t rnti, NS_LOG_FUNCTION (this << cellId << imsi << rnti << sinrLinear); NS_LOG_INFO ("Write SINR Linear Phy Stats in " << GetUeSinrFilename ().c_str ()); - std::ofstream outFile; if ( m_UeSinrFirstWrite == true ) { - outFile.open (GetUeSinrFilename ().c_str ()); - if (!outFile.is_open ()) + m_ueSinrOutFile.open (GetUeSinrFilename ().c_str ()); + if (!m_ueSinrOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetUeSinrFilename ().c_str ()); return; } m_UeSinrFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tRNTI\tsinrLinear\tcomponentCarrierId"; - outFile << std::endl; + m_ueSinrOutFile << "% time\tcellId\tIMSI\tRNTI\tsinrLinear\tcomponentCarrierId"; + m_ueSinrOutFile << "\n"; } - else - { - outFile.open (GetUeSinrFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetUeSinrFilename ().c_str ()); - return; - } - } - - outFile << Simulator::Now ().GetSeconds () << "\t"; - outFile << cellId << "\t"; - outFile << imsi << "\t"; - outFile << rnti << "\t"; - outFile << sinrLinear << "\t"; - outFile << (uint32_t)componentCarrierId << std::endl; - outFile.close (); + m_ueSinrOutFile << Simulator::Now ().GetSeconds () << "\t"; + m_ueSinrOutFile << cellId << "\t"; + m_ueSinrOutFile << imsi << "\t"; + m_ueSinrOutFile << rnti << "\t"; + m_ueSinrOutFile << sinrLinear << "\t"; + m_ueSinrOutFile << (uint32_t)componentCarrierId << std::endl; } void @@ -192,33 +183,22 @@ PhyStatsCalculator::ReportInterference (uint16_t cellId, Ptr inte NS_LOG_FUNCTION (this << cellId << interference); NS_LOG_INFO ("Write Interference Phy Stats in " << GetInterferenceFilename ().c_str ()); - std::ofstream outFile; if ( m_InterferenceFirstWrite == true ) { - outFile.open (GetInterferenceFilename ().c_str ()); - if (!outFile.is_open ()) + m_interferenceOutFile.open (GetInterferenceFilename ().c_str ()); + if (!m_interferenceOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetInterferenceFilename ().c_str ()); return; } m_InterferenceFirstWrite = false; - outFile << "% time\tcellId\tInterference"; - outFile << std::endl; - } - else - { - outFile.open (GetInterferenceFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetInterferenceFilename ().c_str ()); - return; - } + m_interferenceOutFile << "% time\tcellId\tInterference"; + m_interferenceOutFile << "\n"; } - outFile << Simulator::Now ().GetSeconds () << "\t"; - outFile << cellId << "\t"; - outFile << *interference; - outFile.close (); + m_interferenceOutFile << Simulator::Now ().GetSeconds () << "\t"; + m_interferenceOutFile << cellId << "\t"; + m_interferenceOutFile << *interference; } diff --git a/src/lte/helper/phy-stats-calculator.h b/src/lte/helper/phy-stats-calculator.h index ae9e067af..1060fefd3 100644 --- a/src/lte/helper/phy-stats-calculator.h +++ b/src/lte/helper/phy-stats-calculator.h @@ -221,6 +221,20 @@ private: */ std::string m_interferenceFilename; + /** + * RSRP statistics output trace file + */ + std::ofstream m_rsrpOutFile; + + /** + * UE SINR statistics output trace file + */ + std::ofstream m_ueSinrOutFile; + + /** + * Interference statistics output trace file + */ + std::ofstream m_interferenceOutFile; }; } // namespace ns3 diff --git a/src/lte/helper/phy-tx-stats-calculator.cc b/src/lte/helper/phy-tx-stats-calculator.cc index 973fd1d71..0046d8f7a 100644 --- a/src/lte/helper/phy-tx-stats-calculator.cc +++ b/src/lte/helper/phy-tx-stats-calculator.cc @@ -42,8 +42,16 @@ PhyTxStatsCalculator::PhyTxStatsCalculator () PhyTxStatsCalculator::~PhyTxStatsCalculator () { NS_LOG_FUNCTION (this); -} + if (m_dlTxOutFile.is_open()) + { + m_dlTxOutFile.close(); + } + if (m_ulTxOutFile.is_open()) + { + m_ulTxOutFile.close(); + } +} TypeId PhyTxStatsCalculator::GetTypeId (void) { @@ -95,41 +103,30 @@ PhyTxStatsCalculator::DlPhyTransmission (PhyTransmissionStatParameters params) NS_LOG_FUNCTION (this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi); NS_LOG_INFO ("Write DL Tx Phy Stats in " << GetDlTxOutputFilename ().c_str ()); - std::ofstream outFile; if ( m_dlTxFirstWrite == true ) { - outFile.open (GetDlOutputFilename ().c_str ()); - if (!outFile.is_open ()) + m_dlTxOutFile.open (GetDlOutputFilename ().c_str ()); + if (!m_dlTxOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetDlTxOutputFilename ().c_str ()); return; } m_dlTxFirstWrite = false; - outFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tccId"; - outFile << std::endl; - } - else - { - outFile.open (GetDlTxOutputFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetDlTxOutputFilename ().c_str ()); - return; - } + m_dlTxOutFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tccId"; + m_dlTxOutFile << "\n"; } - outFile << params.m_timestamp << "\t"; - outFile << (uint32_t) params.m_cellId << "\t"; - outFile << params.m_imsi << "\t"; - outFile << params.m_rnti << "\t"; - //outFile << (uint32_t) params.m_txMode << "\t"; // txMode is not available at dl tx side - outFile << (uint32_t) params.m_layer << "\t"; - outFile << (uint32_t) params.m_mcs << "\t"; - outFile << params.m_size << "\t"; - outFile << (uint32_t) params.m_rv << "\t"; - outFile << (uint32_t) params.m_ndi << "\t"; - outFile << (uint32_t) params.m_ccId << std::endl; - outFile.close (); + m_dlTxOutFile << params.m_timestamp << "\t"; + m_dlTxOutFile << (uint32_t) params.m_cellId << "\t"; + m_dlTxOutFile << params.m_imsi << "\t"; + m_dlTxOutFile << params.m_rnti << "\t"; + //m_dlTxOutFile << (uint32_t) params.m_txMode << "\t"; // txMode is not available at dl tx side + m_dlTxOutFile << (uint32_t) params.m_layer << "\t"; + m_dlTxOutFile << (uint32_t) params.m_mcs << "\t"; + m_dlTxOutFile << params.m_size << "\t"; + m_dlTxOutFile << (uint32_t) params.m_rv << "\t"; + m_dlTxOutFile << (uint32_t) params.m_ndi << "\t"; + m_dlTxOutFile << (uint32_t) params.m_ccId << std::endl; } void @@ -138,42 +135,31 @@ PhyTxStatsCalculator::UlPhyTransmission (PhyTransmissionStatParameters params) NS_LOG_FUNCTION (this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi); NS_LOG_INFO ("Write UL Tx Phy Stats in " << GetUlTxOutputFilename ().c_str ()); - std::ofstream outFile; if ( m_ulTxFirstWrite == true ) { - outFile.open (GetUlTxOutputFilename ().c_str ()); - if (!outFile.is_open ()) + m_ulTxOutFile.open (GetUlTxOutputFilename ().c_str ()); + if (!m_ulTxOutFile.is_open ()) { NS_LOG_ERROR ("Can't open file " << GetUlTxOutputFilename ().c_str ()); return; } m_ulTxFirstWrite = false; -// outFile << "% time\tcellId\tIMSI\tRNTI\ttxMode\tlayer\tmcs\tsize\trv\tndi"; - outFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tccId"; - outFile << std::endl; - } - else - { - outFile.open (GetUlTxOutputFilename ().c_str (), std::ios_base::app); - if (!outFile.is_open ()) - { - NS_LOG_ERROR ("Can't open file " << GetUlTxOutputFilename ().c_str ()); - return; - } + //m_ulTxOutFile << "% time\tcellId\tIMSI\tRNTI\ttxMode\tlayer\tmcs\tsize\trv\tndi"; + m_ulTxOutFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tccId"; + m_ulTxOutFile << "\n"; } - outFile << params.m_timestamp << "\t"; - outFile << (uint32_t) params.m_cellId << "\t"; - outFile << params.m_imsi << "\t"; - outFile << params.m_rnti << "\t"; - //outFile << (uint32_t) params.m_txMode << "\t"; - outFile << (uint32_t) params.m_layer << "\t"; - outFile << (uint32_t) params.m_mcs << "\t"; - outFile << params.m_size << "\t"; - outFile << (uint32_t) params.m_rv << "\t"; - outFile << (uint32_t) params.m_ndi << "\t"; - outFile << (uint32_t) params.m_ccId << std::endl; - outFile.close (); + m_ulTxOutFile << params.m_timestamp << "\t"; + m_ulTxOutFile << (uint32_t) params.m_cellId << "\t"; + m_ulTxOutFile << params.m_imsi << "\t"; + m_ulTxOutFile << params.m_rnti << "\t"; + //m_ulTxOutFile << (uint32_t) params.m_txMode << "\t"; + m_ulTxOutFile << (uint32_t) params.m_layer << "\t"; + m_ulTxOutFile << (uint32_t) params.m_mcs << "\t"; + m_ulTxOutFile << params.m_size << "\t"; + m_ulTxOutFile << (uint32_t) params.m_rv << "\t"; + m_ulTxOutFile << (uint32_t) params.m_ndi << "\t"; + m_ulTxOutFile << (uint32_t) params.m_ccId << std::endl; } void diff --git a/src/lte/helper/phy-tx-stats-calculator.h b/src/lte/helper/phy-tx-stats-calculator.h index aa4bcdde1..f0fc23bad 100644 --- a/src/lte/helper/phy-tx-stats-calculator.h +++ b/src/lte/helper/phy-tx-stats-calculator.h @@ -143,6 +143,15 @@ private: */ bool m_ulTxFirstWrite; + /** + * DL TX PHY statistics output trace file + */ + std::ofstream m_dlTxOutFile; + + /** + * UL TX PHY statistics output trace file + */ + std::ofstream m_ulTxOutFile; }; } // namespace ns3