From 186893dc202a0f24e9beec9ebb1654e4c4af4f6c Mon Sep 17 00:00:00 2001 From: Nicola Baldo Date: Wed, 19 Jun 2013 17:52:18 +0200 Subject: [PATCH] moved stats-related callbacks from LteHelper to the appropriate StatsCalculator --- src/lte/helper/lte-helper.cc | 405 +--------------------- src/lte/helper/lte-stats-calculator.cc | 178 ++++++++++ src/lte/helper/lte-stats-calculator.h | 11 + src/lte/helper/mac-stats-calculator.cc | 68 ++++ src/lte/helper/mac-stats-calculator.h | 35 ++ src/lte/helper/phy-rx-stats-calculator.cc | 44 +++ src/lte/helper/phy-rx-stats-calculator.h | 18 + src/lte/helper/phy-stats-calculator.cc | 55 +++ src/lte/helper/phy-stats-calculator.h | 38 ++ src/lte/helper/phy-tx-stats-calculator.cc | 45 +++ src/lte/helper/phy-tx-stats-calculator.h | 20 ++ 11 files changed, 525 insertions(+), 392 deletions(-) diff --git a/src/lte/helper/lte-helper.cc b/src/lte/helper/lte-helper.cc index f6280a676..db6e186d8 100644 --- a/src/lte/helper/lte-helper.cc +++ b/src/lte/helper/lte-helper.cc @@ -49,7 +49,10 @@ #include #include #include - +#include +#include +#include +#include #include #include #include @@ -889,265 +892,6 @@ LteHelper::AssignStreams (NetDeviceContainer c, int64_t stream) return (currentStream - stream); } -uint64_t -FindImsiFromEnbRlcPath (std::string path) -{ - NS_LOG_FUNCTION (path); - // Sample path input: - // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/DataRadioBearerMap/#LCID/LteRlc/RxPDU - - // We retrieve the UeManager associated to the C-RNTI and perform the IMSI lookup - std::string ueMapPath = path.substr (0, path.find ("/DataRadioBearerMap")); - Config::MatchContainer match = Config::LookupMatches (ueMapPath); - - if (match.GetN () != 0) - { - Ptr ueInfo = match.Get (0); - NS_LOG_LOGIC ("FindImsiFromEnbRlcPath: " << path << ", " << ueInfo->GetObject ()->GetImsi ()); - return ueInfo->GetObject ()->GetImsi (); - } - else - { - NS_FATAL_ERROR ("Lookup " << ueMapPath << " got no matches"); - } -} - -uint64_t -FindImsiFromUePhy (std::string path) -{ - NS_LOG_FUNCTION (path); - // Sample path input: - // /NodeList/#NodeId/DeviceList/#DeviceId/LteUePhy - - // We retrieve the UeInfo associated to the C-RNTI and perform the IMSI lookup - std::string ueRlcPath = path.substr (0, path.find ("/LteUePhy")); - ueRlcPath += "/LteUeRrc"; - Config::MatchContainer match = Config::LookupMatches (ueRlcPath); - - if (match.GetN () != 0) - { - Ptr ueRrc = match.Get (0); - return ueRrc->GetObject ()->GetImsi (); - } - else - { - NS_FATAL_ERROR ("Lookup " << ueRlcPath << " got no matches"); - } - return 0; -} - - -uint64_t -FindImsiFromLteNetDevice (std::string path) -{ - NS_LOG_FUNCTION (path); - // Sample path input: - // /NodeList/#NodeId/DeviceList/#DeviceId/ - - // We retrieve the Imsi associated to the LteUeNetDevice - Config::MatchContainer match = Config::LookupMatches (path); - - if (match.GetN () != 0) - { - Ptr ueNetDevice = match.Get (0); - NS_LOG_LOGIC ("FindImsiFromLteNetDevice: " << path << ", " << ueNetDevice->GetObject ()->GetImsi ()); - return ueNetDevice->GetObject ()->GetImsi (); - } - else - { - NS_FATAL_ERROR ("Lookup " << path << " got no matches"); - } -} - -uint16_t -FindCellIdFromEnbRlcPath (std::string path) -{ - NS_LOG_FUNCTION (path); - // Sample path input: - // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/DataRadioBearerMap/#LCID/LteRlc/RxPDU - - // We retrieve the CellId associated to the Enb - std::string enbNetDevicePath = path.substr (0, path.find ("/LteEnbRrc")); - Config::MatchContainer match = Config::LookupMatches (enbNetDevicePath); - if (match.GetN () != 0) - { - Ptr enbNetDevice = match.Get (0); - NS_LOG_LOGIC ("FindCellIdFromEnbRlcPath: " << path << ", " << enbNetDevice->GetObject ()->GetCellId ()); - return enbNetDevice->GetObject ()->GetCellId (); - } - else - { - NS_FATAL_ERROR ("Lookup " << enbNetDevicePath << " got no matches"); - } -} - -uint64_t -FindImsiFromEnbMac (std::string path, uint16_t rnti) -{ - NS_LOG_FUNCTION (path << 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 (); - uint64_t imsi = FindImsiFromEnbRlcPath (p); - NS_LOG_LOGIC ("FindImsiFromEnbMac: " << path << ", " << rnti << ", " << imsi); - return imsi; -} - -uint16_t -FindCellIdFromEnbMac (std::string path, uint16_t rnti) -{ - NS_LOG_FUNCTION (path << 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 (); - uint16_t cellId = FindCellIdFromEnbRlcPath (p); - NS_LOG_LOGIC ("FindCellIdFromEnbMac: " << path << ", "<< rnti << ", " << cellId); - return cellId; -} - - -uint64_t -FindImsiForEnb (std::string path, uint16_t rnti) -{ - NS_LOG_FUNCTION (path << rnti); - uint64_t imsi = 0; - if (path.find ("/DlPhyTransmission")) - { - // /NodeList/0/DeviceList/0/LteEnbPhy/DlPhyTransmission/LteEnbRrc/UeMap/1 - std::ostringstream oss; - std::string p = path.substr (0, path.find ("/LteEnbPhy")); - oss << rnti; - p += "/LteEnbRrc/UeMap/" + oss.str (); - imsi = FindImsiFromEnbRlcPath (p); - NS_LOG_LOGIC ("FindImsiForEnb[Tx]: " << path << ", " << rnti << ", " << imsi); - } - else if (path.find ("/UlPhyReception")) - { - std::string p = path.substr (0, path.find ("/LteUePhy")); - imsi = FindImsiFromLteNetDevice (p); - NS_LOG_LOGIC ("FindImsiForEnb[Rx]: " << path << ", " << rnti << ", " << imsi); - } - return imsi; -} - - -uint64_t -FindImsiForUe (std::string path, uint16_t rnti) -{ - NS_LOG_FUNCTION (path << rnti); - uint64_t imsi = 0; - if (path.find ("/UlPhyTransmission")) - { - std::string p = path.substr (0, path.find ("/LteUePhy")); - imsi = FindImsiFromLteNetDevice (p); - NS_LOG_LOGIC ("FindImsiForUe[Tx]: " << path << ", " << rnti << ", " << imsi); - } - else if (path.find ("/DlPhyReception")) - { - // /NodeList/0/DeviceList/0/LteEnbPhy/LteSpectrumPhy - std::ostringstream oss; - std::string p = path.substr (0, path.find ("/LteEnbPhy")); - oss << rnti; - p += "/LteEnbRrc/UeMap/" + oss.str (); - imsi = FindImsiFromEnbRlcPath (p); - NS_LOG_LOGIC ("FindImsiForUe[Rx]: " << path << ", " << rnti << ", " << imsi); - } - return imsi; -} - -void -DlPhyTransmissionCallback (Ptr phyTxStats, - std::string path, PhyTransmissionStatParameters params) -{ - NS_LOG_FUNCTION (phyTxStats << path); - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << params.m_rnti; - if (phyTxStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = phyTxStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiForEnb (path, params.m_rnti); - phyTxStats->SetImsiPath (pathAndRnti.str (), imsi); - } - - params.m_imsi = imsi; - phyTxStats->DlPhyTransmission (params); -} - -void -UlPhyTransmissionCallback (Ptr phyTxStats, - std::string path, PhyTransmissionStatParameters params) -{ - NS_LOG_FUNCTION (phyTxStats << path); - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << params.m_rnti; - if (phyTxStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = phyTxStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiForUe (path, params.m_rnti); - phyTxStats->SetImsiPath (pathAndRnti.str (), imsi); - } - - params.m_imsi = imsi; - phyTxStats->UlPhyTransmission (params); -} - - -void -DlPhyReceptionCallback (Ptr phyRxStats, - std::string path, PhyReceptionStatParameters params) -{ - NS_LOG_FUNCTION (phyRxStats << path); - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << params.m_rnti; - if (phyRxStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = phyRxStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiForUe (path, params.m_rnti); - phyRxStats->SetImsiPath (pathAndRnti.str (), imsi); - } - - params.m_imsi = imsi; - phyRxStats->DlPhyReception (params); -} - -void -UlPhyReceptionCallback (Ptr phyRxStats, - std::string path, PhyReceptionStatParameters params) -{ - NS_LOG_FUNCTION (phyRxStats << path); - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << params.m_rnti; - if (phyRxStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = phyRxStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiForEnb (path, params.m_rnti); - phyRxStats->SetImsiPath (pathAndRnti.str (), imsi); - } - - params.m_imsi = imsi; - phyRxStats->UlPhyReception (params); -} void LteHelper::EnablePhyTraces (void) @@ -1164,68 +908,31 @@ void LteHelper::EnableDlTxPhyTraces (void) { Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/DlPhyTransmission", - MakeBoundCallback (&DlPhyTransmissionCallback, m_phyTxStats)); + MakeBoundCallback (&PhyTxStatsCalculator::DlPhyTransmissionCallback, m_phyTxStats)); } void LteHelper::EnableUlTxPhyTraces (void) { Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/UlPhyTransmission", - MakeBoundCallback (&UlPhyTransmissionCallback, m_phyTxStats)); + MakeBoundCallback (&PhyTxStatsCalculator::UlPhyTransmissionCallback, m_phyTxStats)); } void LteHelper::EnableDlRxPhyTraces (void) { Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/DlSpectrumPhy/DlPhyReception", - MakeBoundCallback (&DlPhyReceptionCallback, m_phyRxStats)); + MakeBoundCallback (&PhyRxStatsCalculator::DlPhyReceptionCallback, m_phyRxStats)); } void LteHelper::EnableUlRxPhyTraces (void) { Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/UlSpectrumPhy/UlPhyReception", - MakeBoundCallback (&UlPhyReceptionCallback, m_phyRxStats)); + MakeBoundCallback (&PhyRxStatsCalculator::UlPhyReceptionCallback, m_phyRxStats)); } - -void -DlSchedulingCallback (Ptr 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) -{ - NS_LOG_FUNCTION (macStats << path); - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << rnti; - if (macStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = macStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiFromEnbMac (path, rnti); - macStats->SetImsiPath (pathAndRnti.str (), imsi); - } - - uint16_t cellId = 0; - if (macStats->ExistsCellIdPath (pathAndRnti.str ()) == true) - { - cellId = macStats->GetCellIdPath (pathAndRnti.str ()); - } - else - { - cellId = FindCellIdFromEnbMac (path, rnti); - macStats->SetCellIdPath (pathAndRnti.str (), cellId); - } - - macStats->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); -} - - - void LteHelper::EnableMacTraces (void) { @@ -1239,40 +946,7 @@ LteHelper::EnableDlMacTraces (void) { NS_LOG_FUNCTION_NOARGS (); Config::Connect ("/NodeList/*/DeviceList/*/LteEnbMac/DlScheduling", - MakeBoundCallback (&DlSchedulingCallback, m_macStats)); -} - -void -UlSchedulingCallback (Ptr macStats, std::string path, - uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, - uint8_t mcs, uint16_t size) -{ - NS_LOG_FUNCTION (macStats << path); - - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << rnti; - if (macStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = macStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiFromEnbMac (path, rnti); - macStats->SetImsiPath (pathAndRnti.str (), imsi); - } - uint16_t cellId = 0; - if (macStats->ExistsCellIdPath (pathAndRnti.str ()) == true) - { - cellId = macStats->GetCellIdPath (pathAndRnti.str ()); - } - else - { - cellId = FindCellIdFromEnbMac (path, rnti); - macStats->SetCellIdPath (pathAndRnti.str (), cellId); - } - - macStats->UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size); + MakeBoundCallback (&MacStatsCalculator::DlSchedulingCallback, m_macStats)); } void @@ -1280,28 +954,7 @@ LteHelper::EnableUlMacTraces (void) { NS_LOG_FUNCTION_NOARGS (); Config::Connect ("/NodeList/*/DeviceList/*/LteEnbMac/UlScheduling", - MakeBoundCallback (&UlSchedulingCallback, m_macStats)); -} - -void -ReportCurrentCellRsrpSinrCallback (Ptr phyStats, - std::string path, uint16_t cellId, uint16_t rnti, - double rsrp, double sinr) -{ - NS_LOG_FUNCTION (phyStats << path); - uint64_t imsi = 0; - std::string pathUePhy = path.substr (0, path.find ("/ReportCurrentCellRsrpSinr")); - if (phyStats->ExistsImsiPath (pathUePhy) == true) - { - imsi = phyStats->GetImsiPath (pathUePhy); - } - else - { - imsi = FindImsiFromUePhy (pathUePhy); - phyStats->SetImsiPath (pathUePhy, imsi); - } - - phyStats->ReportCurrentCellRsrpSinr (cellId, imsi, rnti, rsrp,sinr); + MakeBoundCallback (&MacStatsCalculator::UlSchedulingCallback, m_macStats)); } void @@ -1309,39 +962,7 @@ LteHelper::EnableDlPhyTraces (void) { NS_LOG_FUNCTION_NOARGS (); Config::Connect ("/NodeList/*/DeviceList/*/LteUePhy/ReportCurrentCellRsrpSinr", - MakeBoundCallback (&ReportCurrentCellRsrpSinrCallback, m_phyStats)); -} - -void -ReportUeSinr (Ptr phyStats, std::string path, - uint16_t cellId, uint16_t rnti, double sinrLinear) -{ - NS_LOG_FUNCTION (phyStats << path); - - uint64_t imsi = 0; - std::ostringstream pathAndRnti; - pathAndRnti << path << "/" << rnti; - std::string pathEnbMac = path.substr (0, path.find ("LteEnbPhy/ReportUeSinr")); - pathEnbMac += "LteEnbMac/DlScheduling"; - if (phyStats->ExistsImsiPath (pathAndRnti.str ()) == true) - { - imsi = phyStats->GetImsiPath (pathAndRnti.str ()); - } - else - { - imsi = FindImsiFromEnbMac (pathEnbMac, rnti); - phyStats->SetImsiPath (pathAndRnti.str (), imsi); - } - - phyStats->ReportUeSinr (cellId, imsi, rnti, sinrLinear); -} - -void -ReportInterference (Ptr phyStats, std::string path, - uint16_t cellId, Ptr interference) -{ - NS_LOG_FUNCTION (phyStats << path); - phyStats->ReportInterference (cellId, interference); + MakeBoundCallback (&PhyStatsCalculator::ReportCurrentCellRsrpSinrCallback, m_phyStats)); } void @@ -1349,9 +970,9 @@ LteHelper::EnableUlPhyTraces (void) { NS_LOG_FUNCTION_NOARGS (); Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/ReportUeSinr", - MakeBoundCallback (&ReportUeSinr, m_phyStats)); + MakeBoundCallback (&PhyStatsCalculator::ReportUeSinr, m_phyStats)); Config::Connect ("/NodeList/*/DeviceList/*/LteEnbPhy/ReportInterference", - MakeBoundCallback (&ReportInterference, m_phyStats)); + MakeBoundCallback (&PhyStatsCalculator::ReportInterference, m_phyStats)); } diff --git a/src/lte/helper/lte-stats-calculator.cc b/src/lte/helper/lte-stats-calculator.cc index cf1418eef..3a4e48c52 100644 --- a/src/lte/helper/lte-stats-calculator.cc +++ b/src/lte/helper/lte-stats-calculator.cc @@ -19,7 +19,13 @@ */ #include "lte-stats-calculator.h" + #include +#include +#include +#include +#include +#include namespace ns3 { @@ -128,4 +134,176 @@ LteStatsCalculator::GetCellIdPath (std::string path) } +uint64_t +LteStatsCalculator::FindImsiFromEnbRlcPath (std::string path) +{ + NS_LOG_FUNCTION (path); + // Sample path input: + // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/DataRadioBearerMap/#LCID/LteRlc/RxPDU + + // We retrieve the UeManager associated to the C-RNTI and perform the IMSI lookup + std::string ueMapPath = path.substr (0, path.find ("/DataRadioBearerMap")); + Config::MatchContainer match = Config::LookupMatches (ueMapPath); + + if (match.GetN () != 0) + { + Ptr ueInfo = match.Get (0); + NS_LOG_LOGIC ("FindImsiFromEnbRlcPath: " << path << ", " << ueInfo->GetObject ()->GetImsi ()); + return ueInfo->GetObject ()->GetImsi (); + } + else + { + NS_FATAL_ERROR ("Lookup " << ueMapPath << " got no matches"); + } +} + +uint64_t +LteStatsCalculator::FindImsiFromUePhy (std::string path) +{ + NS_LOG_FUNCTION (path); + // Sample path input: + // /NodeList/#NodeId/DeviceList/#DeviceId/LteUePhy + + // We retrieve the UeInfo associated to the C-RNTI and perform the IMSI lookup + std::string ueRlcPath = path.substr (0, path.find ("/LteUePhy")); + ueRlcPath += "/LteUeRrc"; + Config::MatchContainer match = Config::LookupMatches (ueRlcPath); + + if (match.GetN () != 0) + { + Ptr ueRrc = match.Get (0); + return ueRrc->GetObject ()->GetImsi (); + } + else + { + NS_FATAL_ERROR ("Lookup " << ueRlcPath << " got no matches"); + } + return 0; +} + + +uint64_t +LteStatsCalculator::FindImsiFromLteNetDevice (std::string path) +{ + NS_LOG_FUNCTION (path); + // Sample path input: + // /NodeList/#NodeId/DeviceList/#DeviceId/ + + // We retrieve the Imsi associated to the LteUeNetDevice + Config::MatchContainer match = Config::LookupMatches (path); + + if (match.GetN () != 0) + { + Ptr ueNetDevice = match.Get (0); + NS_LOG_LOGIC ("FindImsiFromLteNetDevice: " << path << ", " << ueNetDevice->GetObject ()->GetImsi ()); + return ueNetDevice->GetObject ()->GetImsi (); + } + else + { + NS_FATAL_ERROR ("Lookup " << path << " got no matches"); + } +} + +uint16_t +LteStatsCalculator::FindCellIdFromEnbRlcPath (std::string path) +{ + NS_LOG_FUNCTION (path); + // Sample path input: + // /NodeList/#NodeId/DeviceList/#DeviceId/LteEnbRrc/UeMap/#C-RNTI/DataRadioBearerMap/#LCID/LteRlc/RxPDU + + // We retrieve the CellId associated to the Enb + std::string enbNetDevicePath = path.substr (0, path.find ("/LteEnbRrc")); + Config::MatchContainer match = Config::LookupMatches (enbNetDevicePath); + if (match.GetN () != 0) + { + Ptr enbNetDevice = match.Get (0); + NS_LOG_LOGIC ("FindCellIdFromEnbRlcPath: " << path << ", " << enbNetDevice->GetObject ()->GetCellId ()); + return enbNetDevice->GetObject ()->GetCellId (); + } + else + { + NS_FATAL_ERROR ("Lookup " << enbNetDevicePath << " got no matches"); + } +} + +uint64_t +LteStatsCalculator::FindImsiFromEnbMac (std::string path, uint16_t rnti) +{ + NS_LOG_FUNCTION (path << 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 (); + uint64_t imsi = FindImsiFromEnbRlcPath (p); + NS_LOG_LOGIC ("FindImsiFromEnbMac: " << path << ", " << rnti << ", " << imsi); + return imsi; +} + +uint16_t +LteStatsCalculator::FindCellIdFromEnbMac (std::string path, uint16_t rnti) +{ + NS_LOG_FUNCTION (path << 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 (); + uint16_t cellId = FindCellIdFromEnbRlcPath (p); + NS_LOG_LOGIC ("FindCellIdFromEnbMac: " << path << ", "<< rnti << ", " << cellId); + return cellId; +} + + +uint64_t +LteStatsCalculator::FindImsiForEnb (std::string path, uint16_t rnti) +{ + NS_LOG_FUNCTION (path << rnti); + uint64_t imsi = 0; + if (path.find ("/DlPhyTransmission")) + { + // /NodeList/0/DeviceList/0/LteEnbPhy/DlPhyTransmission/LteEnbRrc/UeMap/1 + std::ostringstream oss; + std::string p = path.substr (0, path.find ("/LteEnbPhy")); + oss << rnti; + p += "/LteEnbRrc/UeMap/" + oss.str (); + imsi = FindImsiFromEnbRlcPath (p); + NS_LOG_LOGIC ("FindImsiForEnb[Tx]: " << path << ", " << rnti << ", " << imsi); + } + else if (path.find ("/UlPhyReception")) + { + std::string p = path.substr (0, path.find ("/LteUePhy")); + imsi = FindImsiFromLteNetDevice (p); + NS_LOG_LOGIC ("FindImsiForEnb[Rx]: " << path << ", " << rnti << ", " << imsi); + } + return imsi; +} + + +uint64_t +LteStatsCalculator::FindImsiForUe (std::string path, uint16_t rnti) +{ + NS_LOG_FUNCTION (path << rnti); + uint64_t imsi = 0; + if (path.find ("/UlPhyTransmission")) + { + std::string p = path.substr (0, path.find ("/LteUePhy")); + imsi = FindImsiFromLteNetDevice (p); + NS_LOG_LOGIC ("FindImsiForUe[Tx]: " << path << ", " << rnti << ", " << imsi); + } + else if (path.find ("/DlPhyReception")) + { + // /NodeList/0/DeviceList/0/LteEnbPhy/LteSpectrumPhy + std::ostringstream oss; + std::string p = path.substr (0, path.find ("/LteEnbPhy")); + oss << rnti; + p += "/LteEnbRrc/UeMap/" + oss.str (); + imsi = FindImsiFromEnbRlcPath (p); + NS_LOG_LOGIC ("FindImsiForUe[Rx]: " << path << ", " << rnti << ", " << imsi); + } + return imsi; +} + + } // namespace ns3 diff --git a/src/lte/helper/lte-stats-calculator.h b/src/lte/helper/lte-stats-calculator.h index 55b0504d1..5c2a108c2 100644 --- a/src/lte/helper/lte-stats-calculator.h +++ b/src/lte/helper/lte-stats-calculator.h @@ -104,6 +104,17 @@ public: */ uint16_t GetCellIdPath (std::string path); +protected: + + static uint64_t FindImsiFromEnbRlcPath (std::string path); + static uint64_t FindImsiFromUePhy (std::string path); + static uint64_t FindImsiFromLteNetDevice (std::string path); + static uint16_t FindCellIdFromEnbRlcPath (std::string path); + static uint64_t FindImsiFromEnbMac (std::string path, uint16_t rnti); + static uint16_t FindCellIdFromEnbMac (std::string path, uint16_t rnti); + static uint64_t FindImsiForEnb (std::string path, uint16_t rnti); + static uint64_t FindImsiForUe (std::string path, uint16_t rnti); + private: std::map m_pathImsiMap; diff --git a/src/lte/helper/mac-stats-calculator.cc b/src/lte/helper/mac-stats-calculator.cc index eb96abbaf..8efd5d928 100644 --- a/src/lte/helper/mac-stats-calculator.cc +++ b/src/lte/helper/mac-stats-calculator.cc @@ -170,4 +170,72 @@ MacStatsCalculator::UlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frame outFile.close (); } +void +MacStatsCalculator::DlSchedulingCallback (Ptr 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) +{ + NS_LOG_FUNCTION (macStats << path); + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << rnti; + if (macStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = macStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiFromEnbMac (path, rnti); + macStats->SetImsiPath (pathAndRnti.str (), imsi); + } + + uint16_t cellId = 0; + if (macStats->ExistsCellIdPath (pathAndRnti.str ()) == true) + { + cellId = macStats->GetCellIdPath (pathAndRnti.str ()); + } + else + { + cellId = FindCellIdFromEnbMac (path, rnti); + macStats->SetCellIdPath (pathAndRnti.str (), cellId); + } + + macStats->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); +} + +void +MacStatsCalculator::UlSchedulingCallback (Ptr macStats, std::string path, + uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcs, uint16_t size) +{ + NS_LOG_FUNCTION (macStats << path); + + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << rnti; + if (macStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = macStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiFromEnbMac (path, rnti); + macStats->SetImsiPath (pathAndRnti.str (), imsi); + } + uint16_t cellId = 0; + if (macStats->ExistsCellIdPath (pathAndRnti.str ()) == true) + { + cellId = macStats->GetCellIdPath (pathAndRnti.str ()); + } + else + { + cellId = FindCellIdFromEnbMac (path, rnti); + macStats->SetCellIdPath (pathAndRnti.str (), cellId); + } + + macStats->UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size); +} + + } // namespace ns3 diff --git a/src/lte/helper/mac-stats-calculator.h b/src/lte/helper/mac-stats-calculator.h index 98c57dbe0..24760a850 100644 --- a/src/lte/helper/mac-stats-calculator.h +++ b/src/lte/helper/mac-stats-calculator.h @@ -110,6 +110,41 @@ public: void UlScheduling (uint16_t cellId, uint64_t imsi,uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t sizeTb); + + /** + * Trace sink for the ns3::LteEnbMac::DlScheduling trace source + * + * \param macStats + * \param path + * \param frameNo + * \param subframeNo + * \param rnti + * \param mcsTb1 + * \param sizeTb1 + * \param mcsTb2 + * \param sizeTb2 + */ + static void DlSchedulingCallback (Ptr 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::UlScheduling trace source + * + * \param macStats + * \param path + * \param frameNo + * \param subframeNo + * \param rnti + * \param mcs + * \param size + */ + static void UlSchedulingCallback (Ptr macStats, std::string path, + uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, + uint8_t mcs, uint16_t size); + + private: bool m_dlFirstWrite; diff --git a/src/lte/helper/phy-rx-stats-calculator.cc b/src/lte/helper/phy-rx-stats-calculator.cc index 5d20b6b6d..908b7b5ab 100644 --- a/src/lte/helper/phy-rx-stats-calculator.cc +++ b/src/lte/helper/phy-rx-stats-calculator.cc @@ -175,4 +175,48 @@ PhyRxStatsCalculator::UlPhyReception (PhyReceptionStatParameters params) outFile.close (); } +void +PhyRxStatsCalculator::DlPhyReceptionCallback (Ptr phyRxStats, + std::string path, PhyReceptionStatParameters params) +{ + NS_LOG_FUNCTION (phyRxStats << path); + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << params.m_rnti; + if (phyRxStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = phyRxStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiForUe (path, params.m_rnti); + phyRxStats->SetImsiPath (pathAndRnti.str (), imsi); + } + + params.m_imsi = imsi; + phyRxStats->DlPhyReception (params); +} + +void +PhyRxStatsCalculator::UlPhyReceptionCallback (Ptr phyRxStats, + std::string path, PhyReceptionStatParameters params) +{ + NS_LOG_FUNCTION (phyRxStats << path); + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << params.m_rnti; + if (phyRxStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = phyRxStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiForEnb (path, params.m_rnti); + phyRxStats->SetImsiPath (pathAndRnti.str (), imsi); + } + + params.m_imsi = imsi; + phyRxStats->UlPhyReception (params); +} + } // namespace ns3 diff --git a/src/lte/helper/phy-rx-stats-calculator.h b/src/lte/helper/phy-rx-stats-calculator.h index 3728fc171..d2ca316f6 100644 --- a/src/lte/helper/phy-rx-stats-calculator.h +++ b/src/lte/helper/phy-rx-stats-calculator.h @@ -121,7 +121,25 @@ public: */ void UlPhyReception (PhyReceptionStatParameters params); + /** + * trace sink + * + * \param phyRxStats + * \param path + * \param params + */ + static void DlPhyReceptionCallback (Ptr phyRxStats, + std::string path, PhyReceptionStatParameters params); + /** + * trace sink + * + * \param phyRxStats + * \param path + * \param params + */ + static void UlPhyReceptionCallback (Ptr phyRxStats, + std::string path, PhyReceptionStatParameters params); private: bool m_dlRxFirstWrite; diff --git a/src/lte/helper/phy-stats-calculator.cc b/src/lte/helper/phy-stats-calculator.cc index fe873e749..15fdf32a6 100644 --- a/src/lte/helper/phy-stats-calculator.cc +++ b/src/lte/helper/phy-stats-calculator.cc @@ -217,4 +217,59 @@ PhyStatsCalculator::ReportInterference (uint16_t cellId, Ptr inte outFile.close (); } + +void +PhyStatsCalculator::ReportCurrentCellRsrpSinrCallback (Ptr phyStats, + std::string path, uint16_t cellId, uint16_t rnti, + double rsrp, double sinr) +{ + NS_LOG_FUNCTION (phyStats << path); + uint64_t imsi = 0; + std::string pathUePhy = path.substr (0, path.find ("/ReportCurrentCellRsrpSinr")); + if (phyStats->ExistsImsiPath (pathUePhy) == true) + { + imsi = phyStats->GetImsiPath (pathUePhy); + } + else + { + imsi = FindImsiFromUePhy (pathUePhy); + phyStats->SetImsiPath (pathUePhy, imsi); + } + + phyStats->ReportCurrentCellRsrpSinr (cellId, imsi, rnti, rsrp,sinr); +} + +void +PhyStatsCalculator::ReportUeSinr (Ptr phyStats, std::string path, + uint16_t cellId, uint16_t rnti, double sinrLinear) +{ + NS_LOG_FUNCTION (phyStats << path); + + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << rnti; + std::string pathEnbMac = path.substr (0, path.find ("LteEnbPhy/ReportUeSinr")); + pathEnbMac += "LteEnbMac/DlScheduling"; + if (phyStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = phyStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiFromEnbMac (pathEnbMac, rnti); + phyStats->SetImsiPath (pathAndRnti.str (), imsi); + } + + phyStats->ReportUeSinr (cellId, imsi, rnti, sinrLinear); +} + +void +PhyStatsCalculator::ReportInterference (Ptr phyStats, std::string path, + uint16_t cellId, Ptr interference) +{ + NS_LOG_FUNCTION (phyStats << path); + phyStats->ReportInterference (cellId, interference); +} + + } // namespace ns3 diff --git a/src/lte/helper/phy-stats-calculator.h b/src/lte/helper/phy-stats-calculator.h index 433c9ddcc..a0401e4d1 100644 --- a/src/lte/helper/phy-stats-calculator.h +++ b/src/lte/helper/phy-stats-calculator.h @@ -130,6 +130,44 @@ public: */ void ReportInterference (uint16_t cellId, Ptr interference); + /** + * trace sink + * + * \param phyStats + * \param path + * \param cellId + * \param rnti + * \param rsrp + * \param sinr + */ + static void ReportCurrentCellRsrpSinrCallback (Ptr phyStats, + std::string path, uint16_t cellId, uint16_t rnti, + double rsrp, double sinr); + + /** + * trace sink + * + * \param phyStats + * \param path + * \param cellId + * \param rnti + * \param sinrLinear + */ + static void ReportUeSinr (Ptr phyStats, std::string path, + uint16_t cellId, uint16_t rnti, double sinrLinear); + + /** + * trace sink + * + * \param phyStats + * \param path + * \param cellId + * \param interference + */ + static void ReportInterference (Ptr phyStats, std::string path, + uint16_t cellId, Ptr interference); + + private: bool m_RsrpSinrFirstWrite; bool m_UeSinrFirstWrite; diff --git a/src/lte/helper/phy-tx-stats-calculator.cc b/src/lte/helper/phy-tx-stats-calculator.cc index 76b591a0d..4c7c43c8c 100644 --- a/src/lte/helper/phy-tx-stats-calculator.cc +++ b/src/lte/helper/phy-tx-stats-calculator.cc @@ -176,5 +176,50 @@ PhyTxStatsCalculator::UlPhyTransmission (PhyTransmissionStatParameters params) outFile.close (); } +void +PhyTxStatsCalculator::DlPhyTransmissionCallback (Ptr phyTxStats, + std::string path, PhyTransmissionStatParameters params) +{ + NS_LOG_FUNCTION (phyTxStats << path); + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << params.m_rnti; + if (phyTxStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = phyTxStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiForEnb (path, params.m_rnti); + phyTxStats->SetImsiPath (pathAndRnti.str (), imsi); + } + + params.m_imsi = imsi; + phyTxStats->DlPhyTransmission (params); +} + +void +PhyTxStatsCalculator::UlPhyTransmissionCallback (Ptr phyTxStats, + std::string path, PhyTransmissionStatParameters params) +{ + NS_LOG_FUNCTION (phyTxStats << path); + uint64_t imsi = 0; + std::ostringstream pathAndRnti; + pathAndRnti << path << "/" << params.m_rnti; + if (phyTxStats->ExistsImsiPath (pathAndRnti.str ()) == true) + { + imsi = phyTxStats->GetImsiPath (pathAndRnti.str ()); + } + else + { + imsi = FindImsiForUe (path, params.m_rnti); + phyTxStats->SetImsiPath (pathAndRnti.str (), imsi); + } + + params.m_imsi = imsi; + phyTxStats->UlPhyTransmission (params); +} + + } // namespace ns3 diff --git a/src/lte/helper/phy-tx-stats-calculator.h b/src/lte/helper/phy-tx-stats-calculator.h index 99b3ac633..6b7ff241f 100644 --- a/src/lte/helper/phy-tx-stats-calculator.h +++ b/src/lte/helper/phy-tx-stats-calculator.h @@ -121,6 +121,26 @@ public: */ void UlPhyTransmission (PhyTransmissionStatParameters params); + + /** + * trace sink + * + * \param phyTxStats + * \param path + * \param params + */ + static void DlPhyTransmissionCallback (Ptr phyTxStats, + std::string path, PhyTransmissionStatParameters params); + + /** + * trace sink + * + * \param phyTxStats + * \param path + * \param params + */ + static void UlPhyTransmissionCallback (Ptr phyTxStats, + std::string path, PhyTransmissionStatParameters params); private: