From 0aeb3bf8d52ead35891c7bcca7fe0d860c301af0 Mon Sep 17 00:00:00 2001 From: jaumenin Date: Mon, 7 Nov 2011 17:47:12 +0100 Subject: [PATCH] Refactoring of the statistics classes to avoid continious calls to the attribute system. Moved common attributes from Rlc and MacStats calculator to generic LteStatsCalculator. --- src/lte/examples/lena-runtime-profiler.cc | 2 +- src/lte/helper/lena-helper.cc | 137 +++++++++++++++++++--- src/lte/helper/lena-helper.h | 3 - src/lte/helper/mac-stats-calculator.cc | 61 ++-------- src/lte/helper/mac-stats-calculator.h | 26 +--- src/lte/helper/rlc-stats-calculator.cc | 135 ++++++--------------- src/lte/helper/rlc-stats-calculator.h | 49 ++------ src/lte/model/lte-common.cc | 23 ++++ src/lte/model/lte-common.h | 13 ++ src/lte/wscript | 2 + 10 files changed, 219 insertions(+), 232 deletions(-) diff --git a/src/lte/examples/lena-runtime-profiler.cc b/src/lte/examples/lena-runtime-profiler.cc index 5d544a56a..af91f0882 100644 --- a/src/lte/examples/lena-runtime-profiler.cc +++ b/src/lte/examples/lena-runtime-profiler.cc @@ -67,7 +67,7 @@ main (int argc, char *argv[]) uint32_t nEnb; Ptr < LenaHelper > lena = CreateObject (); - lena->EnableLogComponents (); + //lena->EnableLogComponents (); if (nFloors == 0) { lena->SetAttribute("PropagationModel", diff --git a/src/lte/helper/lena-helper.cc b/src/lte/helper/lena-helper.cc index 9605a98bf..88c53cc03 100644 --- a/src/lte/helper/lena-helper.cc +++ b/src/lte/helper/lena-helper.cc @@ -101,7 +101,11 @@ LenaHelper::DoStart (void) } m_macStats = CreateObject (); + m_macStats->SetDlOutputFilename("DlMacStats.csv"); + m_macStats->SetUlOutputFilename("UlMacStats.csv"); m_rlcStats = CreateObject (); + m_rlcStats->SetDlOutputFilename("DlRlcStats.csv"); + m_rlcStats->SetUlOutputFilename("UlRlcStats.csv"); Object::DoStart (); } @@ -432,6 +436,7 @@ LenaHelper::EnableLogComponents (void) LogComponentEnable ("LteEnbNetDevice", LOG_LEVEL_ALL); LogComponentEnable ("RlcStatsCalculator", LOG_LEVEL_ALL); + LogComponentEnable ("MacStatsCalculator", LOG_LEVEL_ALL); } @@ -441,7 +446,6 @@ LenaHelper::EnableRlcTraces (void) { EnableDlRlcTraces (); EnableUlRlcTraces (); - } @@ -547,8 +551,26 @@ DlTxPduCallback (Ptr rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize) { NS_LOG_FUNCTION (rlcStats << path << rnti << lcid << packetSize); - uint64_t imsi = FindImsiFromEnbRlcPath (path); - uint16_t cellId = FindCellIdFromEnbRlcPath (path); + uint64_t imsi = 0; + if (rlcStats->ExistsImsiPath(path) == true) + { + imsi = rlcStats->GetImsiPath (path); + } + else + { + imsi = FindImsiFromEnbRlcPath (path); + rlcStats->SetImsiPath (path, imsi); + } + uint16_t cellId = 0; + if (rlcStats->ExistsCellIdPath(path) == true) + { + cellId = rlcStats->GetCellIdPath (path); + } + else + { + cellId = FindCellIdFromEnbRlcPath (path); + rlcStats->SetCellIdPath (path, cellId); + } rlcStats->DlTxPdu (cellId, imsi, rnti, lcid, packetSize); } @@ -557,7 +579,16 @@ DlRxPduCallback (Ptr rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) { NS_LOG_FUNCTION (rlcStats << path << rnti << lcid << packetSize << delay); - uint64_t imsi = FindImsiFromUeRlcPath (path); + uint64_t imsi = 0; + if (rlcStats->ExistsImsiPath(path) == true) + { + imsi = rlcStats->GetImsiPath (path); + } + else + { + imsi = FindImsiFromUeRlcPath (path); + rlcStats->SetImsiPath (path, imsi); + } rlcStats->DlRxPdu (imsi, rnti, lcid, packetSize, delay); } @@ -576,7 +607,16 @@ UlTxPduCallback (Ptr rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize) { NS_LOG_FUNCTION (rlcStats << path << rnti << lcid << packetSize); - uint64_t imsi = FindImsiFromUeRlcPath (path); + uint64_t imsi = 0; + if (rlcStats->ExistsImsiPath(path) == true) + { + imsi = rlcStats->GetImsiPath (path); + } + else + { + imsi = FindImsiFromUeRlcPath (path); + rlcStats->SetImsiPath (path, imsi); + } rlcStats->UlTxPdu (imsi, rnti, lcid, packetSize); } @@ -585,20 +625,59 @@ UlRxPduCallback (Ptr rlcStats, std::string path, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) { NS_LOG_FUNCTION (rlcStats << path << rnti << lcid << packetSize << delay); - uint64_t imsi = FindImsiFromEnbRlcPath (path); - uint16_t cellId = FindCellIdFromEnbRlcPath (path); + uint64_t imsi = 0; + if (rlcStats->ExistsImsiPath(path) == true) + { + imsi = rlcStats->GetImsiPath (path); + } + else + { + imsi = FindImsiFromEnbRlcPath(path); + rlcStats->SetImsiPath (path, imsi); + } + uint16_t cellId = 0; + if (rlcStats->ExistsCellIdPath(path) == true) + { + cellId = rlcStats->GetCellIdPath (path); + } + else + { + cellId = FindCellIdFromEnbRlcPath (path); + rlcStats->SetCellIdPath (path, cellId); + } 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) +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 (mac << path); - uint64_t imsi = FindImsiFromEnbMac (path, rnti); - uint16_t cellId = FindCellIdFromEnbMac (path, rnti); - mac->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); + NS_LOG_FUNCTION (macStats << path); + uint64_t imsi = 0; + if (macStats->ExistsImsiPath(path) == true) + { + imsi = macStats->GetImsiPath (path); + } + else + { + imsi = FindImsiFromEnbMac (path, rnti); + macStats->SetImsiPath (path, imsi); + } + + uint16_t cellId = 0; + if (macStats->ExistsCellIdPath(path) == true) + { + cellId = macStats->GetCellIdPath (path); + } + else + { + cellId = FindCellIdFromEnbMac (path, rnti); + macStats->SetCellIdPath (path, cellId); + } + + macStats->DlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcsTb1, sizeTb1, mcsTb2, sizeTb2); } void @@ -626,14 +705,34 @@ LenaHelper::EnableDlMacTraces (void) } void -UlSchedulingCallback (Ptr mac, std::string path, +UlSchedulingCallback (Ptr macStats, std::string path, uint32_t frameNo, uint32_t subframeNo, uint16_t rnti, uint8_t mcs, uint16_t size) { - NS_LOG_FUNCTION (mac << path); - uint64_t imsi = FindImsiFromEnbMac (path, rnti); - uint16_t cellId = FindCellIdFromEnbMac (path, rnti); - mac->UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size); + NS_LOG_FUNCTION (macStats << path); + + uint64_t imsi = 0; + if (macStats->ExistsImsiPath(path) == true) + { + imsi = macStats->GetImsiPath (path); + } + else + { + imsi = FindImsiFromEnbMac (path, rnti); + macStats->SetImsiPath (path, imsi); + } + uint16_t cellId = 0; + if (macStats->ExistsCellIdPath(path) == true) + { + cellId = macStats->GetCellIdPath (path); + } + else + { + cellId = FindCellIdFromEnbMac (path, rnti); + macStats->SetCellIdPath (path, cellId); + } + + macStats->UlScheduling (cellId, imsi, frameNo, subframeNo, rnti, mcs, size); } void diff --git a/src/lte/helper/lena-helper.h b/src/lte/helper/lena-helper.h index 5db9ba9ec..4922f8320 100644 --- a/src/lte/helper/lena-helper.h +++ b/src/lte/helper/lena-helper.h @@ -198,8 +198,6 @@ private: Ptr InstallSingleEnbDevice (Ptr n); Ptr InstallSingleUeDevice (Ptr n); - //uint64_t FindImsiFromEnbRlcPath(std::string path); - Ptr m_downlinkChannel; Ptr m_uplinkChannel; @@ -215,7 +213,6 @@ private: Ptr m_macStats; Ptr m_rlcStats; - }; diff --git a/src/lte/helper/mac-stats-calculator.cc b/src/lte/helper/mac-stats-calculator.cc index a45c39494..c360b70e5 100644 --- a/src/lte/helper/mac-stats-calculator.cc +++ b/src/lte/helper/mac-stats-calculator.cc @@ -30,9 +30,7 @@ NS_LOG_COMPONENT_DEFINE ("MacStatsCalculator"); NS_OBJECT_ENSURE_REGISTERED (MacStatsCalculator); MacStatsCalculator::MacStatsCalculator () - : m_dlOutputFilename (""), - m_dlFirstWrite (true), - m_ulOutputFilename (""), + : m_dlFirstWrite (true), m_ulFirstWrite (true) { NS_LOG_FUNCTION (this); @@ -48,60 +46,26 @@ TypeId MacStatsCalculator::GetTypeId (void) { static TypeId tid = TypeId ("ns3::MacStatsCalculator") - .SetParent () + .SetParent () .AddConstructor () - .AddAttribute ("DlOutputFilename", - "Name of the file where the downlink results will be saved.", - StringValue ("DlMacStats.csv"), - MakeStringAccessor (&MacStatsCalculator::SetDlOutputFilename), - MakeStringChecker ()) - .AddAttribute ("UlOutputFilename", - "Name of the file where the uplink results will be saved.", - StringValue ("UlMacStats.csv"), - MakeStringAccessor (&MacStatsCalculator::SetUlOutputFilename), - MakeStringChecker ()) ; return tid; } -void -MacStatsCalculator::SetUlOutputFilename (std::string outputFilename) -{ - m_ulOutputFilename = outputFilename; -} - -std::string -MacStatsCalculator::GetUlOutputFilename (void) -{ - return m_ulOutputFilename; -} - -void -MacStatsCalculator::SetDlOutputFilename (std::string outputFilename) -{ - m_dlOutputFilename = outputFilename; -} - -std::string -MacStatsCalculator::GetDlOutputFilename (void) -{ - return m_dlOutputFilename; -} - void 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 ()); + NS_LOG_INFO ("Write DL Mac Stats in " << GetDlOutputFilename ().c_str ()); std::ofstream outFile; if ( m_dlFirstWrite == true ) { - outFile.open (m_dlOutputFilename.c_str ()); + outFile.open (GetDlOutputFilename ().c_str ()); if (!outFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_dlOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ()); return; } m_dlFirstWrite = false; @@ -110,10 +74,10 @@ MacStatsCalculator::DlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frame } else { - outFile.open (m_dlOutputFilename.c_str (), std::ios_base::app); + outFile.open (GetDlOutputFilename ().c_str (), std::ios_base::app); if (!outFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_dlOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ()); return; } } @@ -136,15 +100,15 @@ MacStatsCalculator::UlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frame 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 ()); + NS_LOG_INFO ("Write UL Mac Stats in " << GetUlOutputFilename ().c_str ()); std::ofstream outFile; if ( m_ulFirstWrite == true ) { - outFile.open (m_ulOutputFilename.c_str ()); + outFile.open (GetUlOutputFilename ().c_str ()); if (!outFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_ulOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ()); return; } m_ulFirstWrite = false; @@ -153,10 +117,10 @@ MacStatsCalculator::UlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frame } else { - outFile.open (m_ulOutputFilename.c_str (), std::ios_base::app); + outFile.open (GetUlOutputFilename ().c_str (), std::ios_base::app); if (!outFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_ulOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ()); return; } } @@ -172,5 +136,4 @@ MacStatsCalculator::UlScheduling (uint16_t cellId, uint64_t imsi, uint32_t frame outFile.close (); } - } // namespace ns3 diff --git a/src/lte/helper/mac-stats-calculator.h b/src/lte/helper/mac-stats-calculator.h index 89ca69fa4..5306e946e 100644 --- a/src/lte/helper/mac-stats-calculator.h +++ b/src/lte/helper/mac-stats-calculator.h @@ -21,9 +21,9 @@ #ifndef MAC_STATS_CALCULATOR_H_ #define MAC_STATS_CALCULATOR_H_ +#include "ns3/lte-stats-calculator.h" #include "ns3/nstime.h" #include "ns3/uinteger.h" -#include "ns3/object.h" #include #include @@ -41,7 +41,7 @@ namespace ns3 { * - MCS for transport block 2 (0 if not used) * - Size of transport block 2 (0 if not used) */ -class MacStatsCalculator : public Object +class MacStatsCalculator : public LteStatsCalculator { public: /** @@ -59,24 +59,6 @@ public: */ static TypeId GetTypeId (void); - /** - * Set the name of the file where the uplink statistics will be stored. - * - * \param outputFilename string with the name of the file - */ - void SetUlOutputFilename (std::string outputFilename); - - std::string GetUlOutputFilename (void); - - /** - * Set the name of the file where the downlink statistics will be stored. - * - * \param outputFilename string with the name of the file - */ - void SetDlOutputFilename (std::string outputFilename); - - std::string GetDlOutputFilename (void); - /** * Notifies the stats calculator that an downlink scheduling has occurred. * @param cellId Cell ID of the attached Enb @@ -107,10 +89,8 @@ public: private: - std::string m_dlOutputFilename; - bool m_dlFirstWrite; - std::string m_ulOutputFilename; + bool m_dlFirstWrite; bool m_ulFirstWrite; }; diff --git a/src/lte/helper/rlc-stats-calculator.cc b/src/lte/helper/rlc-stats-calculator.cc index 9e0a25d43..f1632228a 100644 --- a/src/lte/helper/rlc-stats-calculator.cc +++ b/src/lte/helper/rlc-stats-calculator.cc @@ -27,37 +27,12 @@ namespace ns3 { -ImsiLcidPair::ImsiLcidPair () -{ -} - -ImsiLcidPair::ImsiLcidPair (const uint64_t a, const uint8_t b) - : m_imsi (a), - m_lcId (b) -{ -} - -bool -operator == (const ImsiLcidPair &a, const ImsiLcidPair &b) -{ - return ((a.m_imsi == b.m_imsi) && (a.m_lcId == b.m_lcId)); -} - -bool -operator < (const ImsiLcidPair& a, const ImsiLcidPair& b) -{ - return ((a.m_imsi < b.m_imsi) || ((a.m_imsi == b.m_imsi) && (a.m_lcId - < b.m_lcId))); -} - NS_LOG_COMPONENT_DEFINE ("RlcStatsCalculator"); NS_OBJECT_ENSURE_REGISTERED (RlcStatsCalculator); RlcStatsCalculator::RlcStatsCalculator () - : m_dlOutputFilename (""), - m_ulOutputFilename (""), - m_firstWrite (true) + : m_firstWrite (true) { NS_LOG_FUNCTION (this); @@ -76,16 +51,6 @@ RlcStatsCalculator::GetTypeId (void) TypeId ("ns3::RlcStatsCalculator") .SetParent () .AddConstructor () - .AddAttribute ("DlOutputFilename", - "Name of the file where the downlink results will be saved.", - StringValue ("DlRlcStats.csv"), - MakeStringAccessor (&RlcStatsCalculator::SetDlOutputFilename), - MakeStringChecker ()) - .AddAttribute ("UlOutputFilename", - "Name of the file where the uplink results will be saved.", - StringValue ("UlRlcStats.csv"), - MakeStringAccessor (&RlcStatsCalculator::SetUlOutputFilename), - MakeStringChecker ()) .AddAttribute ("StartTime", "Start time of the on going epoch.", TimeValue (Seconds (0.)), @@ -99,36 +64,12 @@ RlcStatsCalculator::GetTypeId (void) return tid; } -void -RlcStatsCalculator::SetUlOutputFilename (std::string outputFilename) -{ - m_ulOutputFilename = outputFilename; -} - -std::string -RlcStatsCalculator::GetUlOutputFilename (void) -{ - return m_ulOutputFilename; -} - -void -RlcStatsCalculator::SetDlOutputFilename (std::string outputFilename) -{ - m_dlOutputFilename = outputFilename; -} - -std::string -RlcStatsCalculator::GetDlOutputFilename (void) -{ - return m_dlOutputFilename; -} - void RlcStatsCalculator::UlTxPdu (uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize) { NS_LOG_FUNCTION (this << "UlTxPDU" << imsi << rnti << (uint32_t) lcid << packetSize); - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); if (Simulator::Now () > m_startTime) { m_flowId[p] = LteFlowId_t (rnti, lcid); @@ -143,7 +84,7 @@ RlcStatsCalculator::DlTxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize) { NS_LOG_FUNCTION (this << "DlTxPDU" << imsi << rnti << (uint32_t) lcid << packetSize); - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); bool forceEpoch = false; if (Simulator::Now () > m_startTime) { @@ -169,7 +110,7 @@ RlcStatsCalculator::UlRxPdu (uint16_t cellId, uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) { NS_LOG_FUNCTION (this << "UlRxPDU" << imsi << rnti << (uint32_t) lcid << packetSize << delay); - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); bool forceEpoch = false; if (Simulator::Now () > m_startTime) @@ -206,7 +147,7 @@ RlcStatsCalculator::DlRxPdu (uint64_t imsi, uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) { NS_LOG_FUNCTION (this << "DlRxPDU" << imsi << rnti << (uint32_t) lcid << packetSize << delay); - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); if (Simulator::Now () > m_startTime) { m_dlRxPackets[p]++; @@ -229,26 +170,26 @@ void RlcStatsCalculator::ShowResults (void) { - NS_LOG_FUNCTION (this << m_ulOutputFilename.c_str () << m_dlOutputFilename.c_str () ); - NS_LOG_INFO ("Write Rlc Stats in " << m_ulOutputFilename.c_str () << - " and in " << m_dlOutputFilename.c_str ()); + NS_LOG_FUNCTION (this << GetUlOutputFilename ().c_str () << GetDlOutputFilename ().c_str () ); + NS_LOG_INFO ("Write Rlc Stats in " << GetUlOutputFilename ().c_str () << + " and in " << GetDlOutputFilename ().c_str ()); std::ofstream ulOutFile; std::ofstream dlOutFile; if (m_firstWrite == true) { - ulOutFile.open (m_ulOutputFilename.c_str ()); + ulOutFile.open (GetUlOutputFilename ().c_str ()); if (!ulOutFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_ulOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ()); return; } - dlOutFile.open (m_dlOutputFilename.c_str ()); + dlOutFile.open (GetDlOutputFilename ().c_str ()); if (!dlOutFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_dlOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ()); return; } m_firstWrite = false; @@ -265,17 +206,17 @@ RlcStatsCalculator::ShowResults (void) } else { - ulOutFile.open (m_ulOutputFilename.c_str (), std::ios_base::app); + ulOutFile.open (GetUlOutputFilename ().c_str (), std::ios_base::app); if (!ulOutFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_ulOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetUlOutputFilename ().c_str ()); return; } - dlOutFile.open (m_dlOutputFilename.c_str (), std::ios_base::app); + dlOutFile.open (GetDlOutputFilename ().c_str (), std::ios_base::app); if (!dlOutFile.is_open ()) { - NS_LOG_ERROR ("Can't open file " << m_dlOutputFilename.c_str ()); + NS_LOG_ERROR ("Can't open file " << GetDlOutputFilename ().c_str ()); return; } } @@ -290,7 +231,7 @@ RlcStatsCalculator::WriteUlResults (std::ofstream& outFile) { // Get the unique IMSI / LCID list - std::vector pairVector; + std::vector pairVector; for (Uint32Map::iterator it = m_ulTxPackets.begin (); it != m_ulTxPackets.end (); ++it) { @@ -302,10 +243,10 @@ RlcStatsCalculator::WriteUlResults (std::ofstream& outFile) } Time endTime = m_startTime + m_epochDuration; - for (std::vector::iterator it = pairVector.begin (); it + for (std::vector::iterator it = pairVector.begin (); it != pairVector.end (); ++it) { - ImsiLcidPair p = *it; + ImsiLcidPair_t p = *it; outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t"; outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t"; outFile << GetUlCellId (p.m_imsi, p.m_lcId) << "\t"; @@ -336,7 +277,7 @@ void RlcStatsCalculator::WriteDlResults (std::ofstream& outFile) { // Get the unique IMSI list - std::vector pairVector; + std::vector pairVector; for (Uint32Map::iterator it = m_dlTxPackets.begin (); it != m_dlTxPackets.end (); ++it) { @@ -348,10 +289,10 @@ RlcStatsCalculator::WriteDlResults (std::ofstream& outFile) } Time endTime = m_startTime + m_epochDuration; - for (std::vector::iterator pair = pairVector.begin (); pair + for (std::vector::iterator pair = pairVector.begin (); pair != pairVector.end (); ++pair) { - ImsiLcidPair p = *pair; + ImsiLcidPair_t p = *pair; outFile << m_startTime.GetNanoSeconds () / 1.0e9 << "\t"; outFile << endTime.GetNanoSeconds () / 1.0e9 << "\t"; outFile << GetDlCellId (p.m_imsi, p.m_lcId) << "\t"; @@ -417,35 +358,35 @@ RlcStatsCalculator::StartEpoch (void) uint32_t RlcStatsCalculator::GetUlTxPackets (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_ulTxPackets[p]; } uint32_t RlcStatsCalculator::GetUlRxPackets (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_ulRxPackets[p]; } uint64_t RlcStatsCalculator::GetUlTxData (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_ulTxData[p]; } uint64_t RlcStatsCalculator::GetUlRxData (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_ulRxData[p]; } double RlcStatsCalculator::GetUlDelay (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); Uint64StatsMap::iterator it = m_ulDelay.find (p); if (it == m_ulDelay.end ()) { @@ -459,7 +400,7 @@ RlcStatsCalculator::GetUlDelay (uint64_t imsi, uint8_t lcid) std::vector RlcStatsCalculator::GetUlDelayStats (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); std::vector stats; Uint64StatsMap::iterator it = m_ulDelay.find (p); if (it == m_ulDelay.end ()) @@ -478,7 +419,7 @@ RlcStatsCalculator::GetUlDelayStats (uint64_t imsi, uint8_t lcid) std::vector RlcStatsCalculator::GetUlPduSizeStats (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); std::vector stats; Uint32StatsMap::iterator it = m_ulPduSize.find (p); if (it == m_ulPduSize.end ()) @@ -497,49 +438,49 @@ RlcStatsCalculator::GetUlPduSizeStats (uint64_t imsi, uint8_t lcid) uint32_t RlcStatsCalculator::GetDlTxPackets (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_dlTxPackets[p]; } uint32_t RlcStatsCalculator::GetDlRxPackets (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_dlRxPackets[p]; } uint64_t RlcStatsCalculator::GetDlTxData (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_dlTxData[p]; } uint64_t RlcStatsCalculator::GetDlRxData (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_dlRxData[p]; } uint32_t RlcStatsCalculator::GetUlCellId (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_ulCellId[p]; } uint32_t RlcStatsCalculator::GetDlCellId (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); return m_dlCellId[p]; } double RlcStatsCalculator::GetDlDelay (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); Uint64StatsMap::iterator it = m_dlDelay.find (p); if (it == m_dlDelay.end ()) { @@ -552,7 +493,7 @@ RlcStatsCalculator::GetDlDelay (uint64_t imsi, uint8_t lcid) std::vector RlcStatsCalculator::GetDlDelayStats (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); std::vector stats; Uint64StatsMap::iterator it = m_dlDelay.find (p); if (it == m_dlDelay.end ()) @@ -572,7 +513,7 @@ RlcStatsCalculator::GetDlDelayStats (uint64_t imsi, uint8_t lcid) std::vector RlcStatsCalculator::GetDlPduSizeStats (uint64_t imsi, uint8_t lcid) { - ImsiLcidPair p (imsi, lcid); + ImsiLcidPair_t p (imsi, lcid); std::vector stats; Uint32StatsMap::iterator it = m_dlPduSize.find (p); if (it == m_dlPduSize.end ()) diff --git a/src/lte/helper/rlc-stats-calculator.h b/src/lte/helper/rlc-stats-calculator.h index 53993da9d..5699df281 100644 --- a/src/lte/helper/rlc-stats-calculator.h +++ b/src/lte/helper/rlc-stats-calculator.h @@ -21,6 +21,8 @@ #ifndef RLC_STATS_CALCULATOR_H_ #define RLC_STATS_CALCULATOR_H_ +#include "ns3/lte-stats-calculator.h" +#include "ns3/lte-common.h" #include "ns3/uinteger.h" #include "ns3/object.h" #include "ns3/basic-data-calculators.h" @@ -32,25 +34,12 @@ namespace ns3 { -struct ImsiLcidPair -{ - uint64_t m_imsi; - uint8_t m_lcId; - -public: - ImsiLcidPair (); - ImsiLcidPair (const uint64_t a, const uint8_t b); - - friend bool operator == (const ImsiLcidPair &a, const ImsiLcidPair &b); - friend bool operator < (const ImsiLcidPair &a, const ImsiLcidPair &b); -}; - -typedef std::map Uint32Map; -typedef std::map Uint64Map; -typedef std::map > > Uint32StatsMap; -typedef std::map > > Uint64StatsMap; -typedef std::map DoubleMap; -typedef std::map FlowIdMap; +typedef std::map Uint32Map; +typedef std::map Uint64Map; +typedef std::map > > Uint32StatsMap; +typedef std::map > > Uint64StatsMap; +typedef std::map DoubleMap; +typedef std::map FlowIdMap; @@ -63,7 +52,7 @@ typedef std::map FlowIdMap; * - Average, min, max and standard deviation of RLC to RLC delay * - Average, min, max and standard deviation of RLC PDU size */ -class RlcStatsCalculator : public Object +class RlcStatsCalculator : public LteStatsCalculator { public: /** @@ -81,24 +70,6 @@ public: */ static TypeId GetTypeId (void); - /** - * Set the name of the file where the uplink statistics will be stored. - * - * \param outputFilename string with the name of the file - */ - void SetUlOutputFilename (std::string outputFilename); - - std::string GetUlOutputFilename (void); - - /** - * Set the name of the file where the downlink statistics will be stored. - * - * \param outputFilename string with the name of the file - */ - void SetDlOutputFilename (std::string outputFilename); - - std::string GetDlOutputFilename (void); - /** * Notifies the stats calculator that an uplink transmission has occurred. * @param imsi IMSI of the UE who transmitted the PDU @@ -278,7 +249,6 @@ private: FlowIdMap m_flowId; - std::string m_dlOutputFilename; Uint32Map m_dlCellId; Uint32Map m_dlTxPackets; Uint32Map m_dlRxPackets; @@ -287,7 +257,6 @@ private: Uint64StatsMap m_dlDelay; Uint32StatsMap m_dlPduSize; - std::string m_ulOutputFilename; Uint32Map m_ulCellId; Uint32Map m_ulTxPackets; Uint32Map m_ulRxPackets; diff --git a/src/lte/model/lte-common.cc b/src/lte/model/lte-common.cc index db3bf2e49..cf018fa01 100644 --- a/src/lte/model/lte-common.cc +++ b/src/lte/model/lte-common.cc @@ -49,6 +49,29 @@ operator < (const LteFlowId_t& a, const LteFlowId_t& b) return ( (a.m_rnti < b.m_rnti) || ( (a.m_rnti == b.m_rnti) && (a.m_lcId < b.m_lcId) ) ); } +ImsiLcidPair_t::ImsiLcidPair_t () +{ +} + +ImsiLcidPair_t::ImsiLcidPair_t (const uint64_t a, const uint8_t b) + : m_imsi (a), + m_lcId (b) +{ +} + +bool +operator == (const ImsiLcidPair_t &a, const ImsiLcidPair_t &b) +{ + return ((a.m_imsi == b.m_imsi) && (a.m_lcId == b.m_lcId)); +} + +bool +operator < (const ImsiLcidPair_t& a, const ImsiLcidPair_t& b) +{ + return ((a.m_imsi < b.m_imsi) || ((a.m_imsi == b.m_imsi) && (a.m_lcId + < b.m_lcId))); +} + uint16_t LteFfConverter::double2fpS11dot3 (double val) diff --git a/src/lte/model/lte-common.h b/src/lte/model/lte-common.h index 0fc2d9a42..9326572e7 100644 --- a/src/lte/model/lte-common.h +++ b/src/lte/model/lte-common.h @@ -40,6 +40,19 @@ public: friend bool operator < (const LteFlowId_t &a, const LteFlowId_t &b); }; +struct ImsiLcidPair_t +{ + uint64_t m_imsi; + uint8_t m_lcId; + +public: + ImsiLcidPair_t (); + ImsiLcidPair_t (const uint64_t a, const uint8_t b); + + friend bool operator == (const ImsiLcidPair_t &a, const ImsiLcidPair_t &b); + friend bool operator < (const ImsiLcidPair_t &a, const ImsiLcidPair_t &b); +}; + class LteFfConverter { diff --git a/src/lte/wscript b/src/lte/wscript index 0cdd2e79f..3968ec9dd 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -28,6 +28,7 @@ def build(bld): 'model/lte-ue-net-device.cc', 'model/ideal-control-messages.cc', 'helper/lena-helper.cc', + 'helper/lte-stats-calculator.cc', 'helper/rlc-stats-calculator.cc', 'helper/mac-stats-calculator.cc', 'model/ff-mac-csched-sap.cc', @@ -93,6 +94,7 @@ def build(bld): 'model/lte-ue-net-device.h', 'model/ideal-control-messages.h', 'helper/lena-helper.h', + 'helper/lte-stats-calculator.h', 'helper/mac-stats-calculator.h', 'helper/rlc-stats-calculator.h', 'model/ff-mac-common.h',