From 103d8f702c8a051916e7eb3d50497bda9ff5cfd2 Mon Sep 17 00:00:00 2001 From: jnin Date: Mon, 27 Jun 2011 15:32:49 +0200 Subject: [PATCH] Added cellId and IMSI output to mac stats --- src/lte/examples/lena-rlc-calculator.cc | 6 +- src/lte/helper/lena-helper.cc | 106 ++++++++++++++++-------- src/lte/helper/mac-stats-calculator.cc | 16 ++-- src/lte/helper/mac-stats-calculator.h | 12 ++- 4 files changed, 91 insertions(+), 49 deletions(-) diff --git a/src/lte/examples/lena-rlc-calculator.cc b/src/lte/examples/lena-rlc-calculator.cc index 6f0b4f9f7..48bbe5fca 100644 --- a/src/lte/examples/lena-rlc-calculator.cc +++ b/src/lte/examples/lena-rlc-calculator.cc @@ -24,7 +24,7 @@ #include "ns3/mobility-module.h" #include "ns3/lte-module.h" #include "ns3/config-store.h" -#include "ns3/gtk-config-store.h" +//#include "ns3/gtk-config-store.h" using namespace ns3; @@ -91,8 +91,8 @@ int main (int argc, char *argv[]) Simulator::Run (); // Uncomment to show available paths - GtkConfigStore config; - config.ConfigureAttributes (); + /*GtkConfigStore config; + config.ConfigureAttributes ();*/ Simulator::Destroy (); diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index 972aaf7c2..70aaeba3d 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -43,6 +43,9 @@ #include +#include + + NS_LOG_COMPONENT_DEFINE ("LenaHelper"); namespace ns3 { @@ -370,42 +373,7 @@ LenaHelper::EnableLogComponents (void) LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL); } -void -LenaHelper::EnableMacTraces (void) -{ - EnableDlMacTraces (); - EnableUlMacTraces (); -} -void -DlSchedulingCallback (Ptr mac, std::string path, - uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) -{ - mac->DlScheduling (frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); -} - -void -LenaHelper::EnableDlMacTraces (void) -{ - Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling", - MakeBoundCallback (&DlSchedulingCallback, m_macStats)); -} - -void -UlSchedulingCallback (Ptr mac, std::string path, - uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcs, uint16_t size) -{ - mac->UlScheduling (frameNo, subframeNo, rnti, mcs, size); -} - -void -LenaHelper::EnableUlMacTraces (void) -{ - Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/UlScheduling", - MakeBoundCallback (&UlSchedulingCallback, m_macStats)); -} void LenaHelper::EnableRlcTraces (void) @@ -415,6 +383,9 @@ LenaHelper::EnableRlcTraces (void) } + + + uint64_t FindImsiFromEnbRlcPath (std::string path) { @@ -479,6 +450,29 @@ FindImsiFromUeRlcPath (std::string path) } +uint64_t +FindImsiFromEnbMac (std::string path, uint16_t rnti) +{ + // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbMac/DlScheduling + std::ostringstream oss; + std::string p = path.substr (0, path.find ("/LteEnbMac")); + oss << rnti; + p += "\\/LteEnbRrc/UeMap/" + oss.str (); + return FindImsiFromEnbRlcPath (p); +} + +uint16_t +FindCellIdFromEnbMac (std::string path, uint16_t rnti) +{ + // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbMac/DlScheduling + std::ostringstream oss; + std::string p = path.substr (0, path.find ("/LteEnbMac")); + oss << rnti; + p += "\\/LteEnbRrc/UeMap/" + oss.str (); + return FindCellIdFromEnbRlcPath (p); +} + + void DlTxPduCallback (Ptr m_rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize) @@ -522,7 +516,15 @@ UlRxPduCallback (Ptr m_rlcStats, std::string path, m_rlcStats->UlRxPdu (cellId, imsi, rnti, lcid, packetSize, delay); } - +void +DlSchedulingCallback (Ptr mac, std::string path, + uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) +{ + uint64_t imsi = FindImsiFromEnbMac (path, rnti); + uint16_t cellId = FindCellIdFromEnbMac (path, rnti); + mac->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); +} void LenaHelper::EnableUlRlcTraces (void) @@ -533,6 +535,38 @@ LenaHelper::EnableUlRlcTraces (void) MakeBoundCallback (&UlRxPduCallback, m_rlcStats)); } +void +LenaHelper::EnableMacTraces (void) +{ + EnableDlMacTraces (); + EnableUlMacTraces (); +} + + +void +LenaHelper::EnableDlMacTraces (void) +{ + Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling", + MakeBoundCallback (&DlSchedulingCallback, m_macStats)); +} + +void +UlSchedulingCallback (Ptr mac, std::string path, + uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcs, uint16_t size) +{ + uint64_t imsi = FindImsiFromEnbMac (path, rnti); + uint16_t cellId = FindCellIdFromEnbMac (path, rnti); + mac->UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size); +} + +void +LenaHelper::EnableUlMacTraces (void) +{ + Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/UlScheduling", + MakeBoundCallback (&UlSchedulingCallback, m_macStats)); +} + Ptr LenaHelper::GetRlcStats (void) { diff --git a/src/lte/helper/mac-stats-calculator.cc b/src/lte/helper/mac-stats-calculator.cc index de9f24532..3e3a8568f 100644 --- a/src/lte/helper/mac-stats-calculator.cc +++ b/src/lte/helper/mac-stats-calculator.cc @@ -77,8 +77,8 @@ MacStatsCalculator::SetDlOutputFilename (std::string outputFilename) } void -MacStatsCalculator::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2) +MacStatsCalculator::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) { NS_LOG_FUNCTION (this); NS_LOG_INFO ("Write DL Mac Stats in " << m_dlOutputFilename.c_str ()); @@ -93,7 +93,7 @@ MacStatsCalculator::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_ return; } m_dlFirstWrite = false; - outFile << "# time\tframe\tsframe\tRNTI\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2"; + outFile << "# time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcsTb1\tsizeTb1\tmcsTb2\tsizeTb2"; outFile << std::endl; } else @@ -107,6 +107,8 @@ MacStatsCalculator::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_ } outFile << Simulator::Now ().GetNanoSeconds () / (double) 1e9 << "\t"; + outFile << (uint32_t) cellId << "\t"; + outFile << imsi << "\t"; outFile << frameNo << "\t"; outFile << subframeNo << "\t"; outFile << rnti << "\t"; @@ -118,8 +120,8 @@ MacStatsCalculator::DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_ } void -MacStatsCalculator::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcs, uint16_t size) +MacStatsCalculator::UlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frameNo, + uint32_t subframeNo, uint16_t rnti,uint8_t mcs, uint16_t size) { NS_LOG_FUNCTION (this); NS_LOG_INFO ("Write UL Mac Stats in " << m_ulOutputFilename.c_str ()); @@ -134,7 +136,7 @@ MacStatsCalculator::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_ return; } m_ulFirstWrite = false; - outFile << "# time\tframe\tsframe\tRNTI\tmcs\tsize"; + outFile << "# time\tcellId\tIMSI\tframe\tsframe\tRNTI\tmcs\tsize"; outFile << std::endl; } else @@ -148,6 +150,8 @@ MacStatsCalculator::UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_ } outFile << Simulator::Now ().GetNanoSeconds () / (double) 1e9 << "\t"; + outFile << (uint32_t) cellId << "\t"; + outFile << imsi << "\t"; outFile << frameNo << "\t"; outFile << subframeNo << "\t"; outFile << rnti << "\t"; diff --git a/src/lte/helper/mac-stats-calculator.h b/src/lte/helper/mac-stats-calculator.h index cb835158d..04be0fef0 100644 --- a/src/lte/helper/mac-stats-calculator.h +++ b/src/lte/helper/mac-stats-calculator.h @@ -75,6 +75,8 @@ public: /** * Notifies the stats calculator that an downlink scheduling has occurred. + * @param cellId Cell ID of the attached Enb + * @param imsi IMSI of the scheduled UE * @param frameNo Frame number * @param subframeNo Subframe number * @param rnti C-RNTI scheduled @@ -83,19 +85,21 @@ public: * @param mcsTb2 MCS for transport block 2 (0 if not used) * @param sizeTb2 Size of transport block 2 (0 if not used) */ - void DlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcsTb1, uint16_t sizeTb1, uint8_t mcsTb2, uint16_t sizeTb2); + 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 uplink scheduling has occurred. + * @param cellId Cell ID of the attached Enb + * @param imsi IMSI of the scheduled UE * @param frameNo Frame number * @param subframeNo Subframe number * @param rnti C-RNTI scheduled * @param mcsTb MCS for transport block * @param sizeTb Size of transport block */ - void UlScheduling (uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcs, uint16_t sizeTb); + void UlScheduling (uint16_t cellId, uint64_t imsi,uint32_t frameNo, uint32_t subframeNo, + uint16_t rnti, uint8_t mcs, uint16_t sizeTb); private: