From 59c4f97e8069c8c8f4be4af244cb9c5ceb368b65 Mon Sep 17 00:00:00 2001 From: mrequena Date: Fri, 1 Apr 2011 12:02:18 +0200 Subject: [PATCH] refactoring lteFlowId_t struct --- src/lte/helper/rlc-stats-calculator.cc | 24 +++++++-------- src/lte/model/lte-enb-mac.cc | 34 +++++---------------- src/lte/model/lte-enb-mac.h | 11 ++----- src/lte/model/pf-ff-mac-scheduler.cc | 41 ++++++++------------------ src/lte/model/pf-ff-mac-scheduler.h | 11 ++----- 5 files changed, 36 insertions(+), 85 deletions(-) diff --git a/src/lte/helper/rlc-stats-calculator.cc b/src/lte/helper/rlc-stats-calculator.cc index f3d09d99c..3d6e25f00 100644 --- a/src/lte/helper/rlc-stats-calculator.cc +++ b/src/lte/helper/rlc-stats-calculator.cc @@ -67,7 +67,7 @@ void RlcStatsCalculator::TxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize) { NS_LOG_FUNCTION (this << "TxPDU" << rnti << (uint32_t) lcid << packetSize); - lteFlowId_t pair = lteFlowId_t(rnti, lcid); + lteFlowId_t pair (rnti, lcid); m_txPackets[pair]++; } @@ -76,7 +76,7 @@ void RlcStatsCalculator::RxPdu (uint16_t rnti, uint8_t lcid, uint32_t packetSize, uint64_t delay) { NS_LOG_FUNCTION (this << "RxPDU" << rnti << (uint32_t) lcid << packetSize << delay); - lteFlowId_t pair = lteFlowId_t(rnti, lcid); + lteFlowId_t pair (rnti, lcid); m_rxPackets [pair]++; m_rxData [pair] += packetSize; @@ -183,36 +183,36 @@ RlcStatsCalculator::GetThroughput (lteFlowId_t p) uint32_t RlcStatsCalculator::GetTxPackets (uint16_t rnti, uint8_t lcid) { - lteFlowId_t p = lteFlowId_t (rnti, lcid); - return GetTxPackets(p); + lteFlowId_t p (rnti, lcid); + return GetTxPackets (p); } uint32_t RlcStatsCalculator::GetRxPackets (uint16_t rnti, uint8_t lcid) { - lteFlowId_t p = lteFlowId_t (rnti, lcid); - return GetRxPackets(p); + lteFlowId_t p (rnti, lcid); + return GetRxPackets (p); } uint64_t RlcStatsCalculator::GetRxData (uint16_t rnti, uint8_t lcid) { - lteFlowId_t p = lteFlowId_t (rnti, lcid); - return GetRxData(p); + lteFlowId_t p (rnti, lcid); + return GetRxData (p); } uint64_t RlcStatsCalculator::GetDelay (uint16_t rnti, uint8_t lcid) { - lteFlowId_t p = lteFlowId_t (rnti, lcid); - return GetDelay(p); + lteFlowId_t p (rnti, lcid); + return GetDelay (p); } double RlcStatsCalculator::GetThroughput (uint16_t rnti, uint8_t lcid) { - lteFlowId_t p = lteFlowId_t (rnti, lcid); - return GetThroughput(p); + lteFlowId_t p (rnti, lcid); + return GetThroughput (p); } } // namespace ns3 diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index a399319cc..a5e78f719 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -41,19 +41,6 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (LteEnbMac); -bool -operator< (const flowId_t& lhs, const flowId_t& rhs) -{ - if (lhs.m_rnti == rhs.m_rnti) - { - return (lhs.m_lcId < rhs.m_lcId); - } - else - { - return (lhs.m_rnti < rhs.m_rnti); - } -} - // ////////////////////////////////////// @@ -571,10 +558,8 @@ LteEnbMac::DoReceivePhyPdu (Ptr p) // forward the packet to the correspondent RLC - flowId_t flow; - flow.m_rnti = tag.GetRnti (); - flow.m_lcId = tag.GetLcid (); - std::map ::iterator it2; + lteFlowId_t flow ( tag.GetRnti (), tag.GetLcid () ); + std::map ::iterator it2; it2 = m_rlcAttached.find (flow); NS_ASSERT_MSG (it2 != m_rlcAttached.end (), "UE not attached rnti=" << flow.m_rnti << " lcid=" << (uint32_t) flow.m_lcId); (*it2).second->ReceivePdu (p); @@ -615,16 +600,14 @@ void LteEnbMac::DoAddLc (LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser* msu) { NS_LOG_FUNCTION (this); - std::map ::iterator it; + std::map ::iterator it; - flowId_t flow; - flow.m_rnti = lcinfo.rnti; - flow.m_lcId = lcinfo.lcId; + lteFlowId_t flow (lcinfo.rnti, lcinfo.lcId); it = m_rlcAttached.find (flow); if (it == m_rlcAttached.end ()) { - m_rlcAttached.insert (std::pair (flow, msu)); + m_rlcAttached.insert (std::pair (flow, msu)); } else { @@ -711,15 +694,14 @@ LteEnbMac::DoSchedDlConfigInd (FfMacSchedSapUser::SchedDlConfigIndParameters ind NS_LOG_FUNCTION (this); // Create DL PHY PDU Ptr pb = CreateObject (); - std::map ::iterator it; + std::map ::iterator it; for (unsigned int i = 0; i < ind.m_buildDataList.size (); i++) { for (unsigned int j = 0; j < ind.m_buildDataList.at (i).m_rlcPduList.size (); j++) { - flowId_t flow; - flow.m_rnti = ind.m_buildDataList.at (i).m_rnti; - flow.m_lcId = ind.m_buildDataList.at (i).m_rlcPduList.at (j).at (0).m_logicalChannelIdentity; + lteFlowId_t flow (ind.m_buildDataList.at (i).m_rnti, + ind.m_buildDataList.at (i).m_rlcPduList.at (j).at (0).m_logicalChannelIdentity); it = m_rlcAttached.find (flow); NS_ASSERT_MSG (it != m_rlcAttached.end (), "rnti=" << flow.m_rnti << " lcid=" << (uint32_t) flow.m_lcId); (*it).second->NotifyTxOpportunity (ind.m_buildDataList.at (i).m_rlcPduList.at (j).at (0).m_size); // second [] is for TB diff --git a/src/lte/model/lte-enb-mac.h b/src/lte/model/lte-enb-mac.h index 06cacd72e..db4a77e83 100644 --- a/src/lte/model/lte-enb-mac.h +++ b/src/lte/model/lte-enb-mac.h @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -38,14 +39,6 @@ class UlCqiIdealControlMessage; class PdcchMapIdealControlMessage; -struct flowId_t -{ - uint16_t m_rnti; - uint8_t m_lcId; -}; - -bool operator< (const flowId_t& lhs, const flowId_t& rhs); - /** * This class implements the MAC layer of the eNodeB device @@ -192,7 +185,7 @@ public: private: private: // std::map > > m_rlcAttached; - std::map m_rlcAttached; + std::map m_rlcAttached; std::vector m_dlCqiReceived; // CQI received std::vector m_ulCeReceived; // CE received (BSR up to now) diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index 618e66356..f78a49395 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -40,19 +40,6 @@ int PfType0AllocationRbg[4] = { NS_OBJECT_ENSURE_REGISTERED (PfFfMacScheduler); -bool -operator< (const pfsFlowId_t& lhs, const pfsFlowId_t& rhs) -{ - if (lhs.m_rnti == rhs.m_rnti) - { - return (lhs.m_lcId < rhs.m_lcId); - } - else - { - return (lhs.m_rnti < rhs.m_rnti); - } -} - class PfSchedulerMemberCschedSapProvider : public FfMacCschedSapProvider { @@ -302,12 +289,10 @@ PfFfMacScheduler::DoCschedLcConfigReq (const struct FfMacCschedSapProvider::Csch { NS_LOG_FUNCTION (this << " New LC, rnti: " << params.m_rnti); - std::map ::iterator it; + std::map ::iterator it; for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++) { - pfsFlowId_t flow; - flow.m_rnti = params.m_rnti; - flow.m_lcId = params.m_logicalChannelConfigList.at (i).m_logicalChannelIdentity; + lteFlowId_t flow (params.m_rnti, params.m_logicalChannelConfigList.at (i).m_logicalChannelIdentity); it = m_flowStats.find (flow); @@ -321,7 +306,7 @@ PfFfMacScheduler::DoCschedLcConfigReq (const struct FfMacCschedSapProvider::Csch flowStats.rlcBufferReq.m_rlcTransmissionQueueSize = 0; flowStats.rlcBufferReq.m_rlcRetransmissionQueueSize = 0; flowStats.rlcBufferReq.m_rlcStatusPduSize = 0; - m_flowStats.insert (std::pair (flow, flowStats)); + m_flowStats.insert (std::pair (flow, flowStats)); } else { @@ -356,11 +341,9 @@ PfFfMacScheduler::DoSchedDlRlcBufferReq (const struct FfMacSchedSapProvider::Sch // API generated by RLC for updating RLC parameters on a LC (tx and retx queues) - std::map ::iterator it; + std::map ::iterator it; - pfsFlowId_t flow; - flow.m_rnti = params.m_rnti; - flow.m_lcId = params.m_logicalChannelIdentity; + lteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity); it = m_flowStats.find (flow); @@ -419,12 +402,12 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched // Resource allocation type 0 (see sec 7.1.6.1 of 36.213) int rbgSize = GetRbgSize (m_cschedCellConfig.m_dlBandwidth); int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize; - std::vector rbgAllocationMap; + std::vector rbgAllocationMap; for (int i = 0; i < rbgNum; i++) { //NS_LOG_DEBUG (this << " ALLOCATION for RBG " << i << " of " << rbgNum); - std::map ::iterator it; - std::map ::iterator itMax = m_flowStats.begin (); + std::map ::iterator it; + std::map ::iterator itMax = m_flowStats.begin (); double rcqiMax = 0.0; for (it = m_flowStats.begin (); it != m_flowStats.end (); it++) { @@ -466,7 +449,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched { // no UE available for this RB //NS_LOG_DEBUG (this << " no UE found"); - pfsFlowId_t nullFlow; + lteFlowId_t nullFlow; nullFlow.m_rnti = 0; rbgAllocationMap.push_back (nullFlow); } @@ -480,7 +463,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched // generate the transmission opportunities by grouping the adjacent RBGs and // creating the correspondent DCIs FfMacSchedSapUser::SchedDlConfigIndParameters ret; - std::vector :: iterator flowIt = rbgAllocationMap.begin (); + std::vector :: iterator flowIt = rbgAllocationMap.begin (); int rbgAllocated = 0; while (flowIt != rbgAllocationMap.end ()) { @@ -557,7 +540,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched ret.m_buildDataList.push_back (newEl); // update UE-LC stats - std::map ::iterator it; + std::map ::iterator it; it = m_flowStats.find ((*flowIt)); if (it != m_flowStats.end()) { @@ -587,7 +570,7 @@ PfFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched ret.m_nrOfPdcchOfdmSymbols = 1; // TODO: check correct value according the DCIs txed // update the UE-LC stats - std::map ::iterator it; + std::map ::iterator it; for (it = m_flowStats.begin (); it != m_flowStats.end (); it++) { (*it).second.totalBytesTransmitted += (*it).second.lastTtiBytesTrasmitted; diff --git a/src/lte/model/pf-ff-mac-scheduler.h b/src/lte/model/pf-ff-mac-scheduler.h index f86399f4e..f0cda833f 100644 --- a/src/lte/model/pf-ff-mac-scheduler.h +++ b/src/lte/model/pf-ff-mac-scheduler.h @@ -21,6 +21,7 @@ #ifndef PF_FF_MAC_SCHEDULER_H #define PF_FF_MAC_SCHEDULER_H +#include #include #include #include @@ -30,15 +31,7 @@ namespace ns3 { - - -struct pfsFlowId_t -{ - uint16_t m_rnti; - uint8_t m_lcId; -}; -bool operator< (const pfsFlowId_t& lhs, const pfsFlowId_t& rhs); struct pfsFlowPerf_t { @@ -145,7 +138,7 @@ private: /* * Map of UE-LC statistics */ - std::map m_flowStats; + std::map m_flowStats; /*