diff --git a/src/lte/examples/lena-first-sim.cc b/src/lte/examples/lena-first-sim.cc index c1f51d00e..a0149bb6d 100644 --- a/src/lte/examples/lena-first-sim.cc +++ b/src/lte/examples/lena-first-sim.cc @@ -64,7 +64,7 @@ int main (int argc, char *argv[]) Simulator::Stop (Seconds (0.005)); - //Simulator::Run (); + Simulator::Run (); //GtkConfigStore config; //config.ConfigureAttributes (); diff --git a/src/lte/model/lte-enb-mac.cc b/src/lte/model/lte-enb-mac.cc index a5e78f719..b9a2f837e 100644 --- a/src/lte/model/lte-enb-mac.cc +++ b/src/lte/model/lte-enb-mac.cc @@ -402,18 +402,18 @@ LteEnbMac::DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo) // --- DOWNLINK --- - // Send CQI info to the scheduler - FfMacSchedSapProvider::SchedDlCqiInfoReqParameters cqiInfoReq; - cqiInfoReq.m_sfnSf = ((0xFF & frameNo) << 4) | (0xF & subframeNo); + // Send Dl-CQI info to the scheduler + FfMacSchedSapProvider::SchedDlCqiInfoReqParameters dlcqiInfoReq; + dlcqiInfoReq.m_sfnSf = ((0xFF & frameNo) << 4) | (0xF & subframeNo); int cqiNum = m_dlCqiReceived.size (); if (cqiNum > MAX_CQI_LIST) { cqiNum = MAX_CQI_LIST; } - cqiInfoReq.m_cqiList.insert (cqiInfoReq.m_cqiList.begin (), m_dlCqiReceived.begin (), m_dlCqiReceived.end ()); + dlcqiInfoReq.m_cqiList.insert (dlcqiInfoReq.m_cqiList.begin (), m_dlCqiReceived.begin (), m_dlCqiReceived.end ()); m_dlCqiReceived.erase (m_dlCqiReceived.begin (), m_dlCqiReceived.end ()); - m_schedSapProvider->SchedDlCqiInfoReq (cqiInfoReq); + m_schedSapProvider->SchedDlCqiInfoReq (dlcqiInfoReq); // Get downlink transmission opportunities @@ -422,6 +422,23 @@ LteEnbMac::DoSubframeIndication (uint32_t frameNo, uint32_t subframeNo) // --- UPLINK --- + // Send UL-CQI info to the scheduler + FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqiInfoReq; + ulcqiInfoReq.m_sfnSf = ((0xFF & frameNo) << 4) | (0xF & subframeNo); + cqiNum = m_ulCqiReceived.size (); + if (cqiNum >= 1) + { + ulcqiInfoReq.m_ulCqi = m_ulCqiReceived.at (cqiNum -1); + if (cqiNum > 1) + { + // empty old ul cqi + while (m_ulCqiReceived.size () > 0) + { + m_ulCqiReceived.pop_back (); + } + } + m_schedSapProvider->SchedUlCqiInfoReq (ulcqiInfoReq); + } // Send BSR reports to the scheduler FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters ulMacReq; @@ -481,8 +498,13 @@ LteEnbMac::DoReceiveIdealControlMessage (Ptr msg) void LteEnbMac::DoUlCqiReport (UlCqi_s ulcqi) -{ - NS_LOG_FUNCTION (this << " eNB UL-CQI received"); +{ + if (ulcqi.m_type == UlCqi_s::PUSCH) + { + NS_LOG_DEBUG(this << " eNB rxed an PUSCH UL-CQI"); + } + // TODO store UL-CQI to send them to scheduler + m_ulCqiReceived.push_back (ulcqi); } @@ -499,21 +521,6 @@ LteEnbMac::ReceiveDlCqiIdealControlMessage (Ptr msg) } -void -LteEnbMac::ReceiveUlCqiIdealControlMessage (Ptr msg) -{ - NS_LOG_FUNCTION (this << msg); - - UlCqi_s ulcqi = msg->GetUlCqi (); - if (ulcqi.m_type == UlCqi_s::PUSCH) - { - NS_LOG_DEBUG(this << " eNB rxed an PUSCH UL-CQI"); - } - // TODO store UL-CQI to send them to scheduler - //m_dlCqiReceived.push_back (dlcqi); - -} - void LteEnbMac::ReceiveBsrMessage (MacCeListElement_s bsr) { diff --git a/src/lte/model/lte-enb-mac.h b/src/lte/model/lte-enb-mac.h index db4a77e83..e03dee5e0 100644 --- a/src/lte/model/lte-enb-mac.h +++ b/src/lte/model/lte-enb-mac.h @@ -122,11 +122,7 @@ public: * \param msg the DL CQI message */ void ReceiveDlCqiIdealControlMessage (Ptr msg); - /** - * \brief Receive a UL CQI ideal control message - * \param msg the UL CQI message - */ - void ReceiveUlCqiIdealControlMessage (Ptr msg); + void DoReceiveIdealControlMessage (Ptr msg); /** @@ -187,7 +183,8 @@ private: // std::map > > m_rlcAttached; std::map m_rlcAttached; - std::vector m_dlCqiReceived; // CQI received + std::vector m_dlCqiReceived; // DL-CQI received + std::vector m_ulCqiReceived; // UL-CQI received std::vector m_ulCeReceived; // CE received (BSR up to now) diff --git a/src/lte/model/lte-enb-phy.cc b/src/lte/model/lte-enb-phy.cc index f45e87004..f10b93212 100644 --- a/src/lte/model/lte-enb-phy.cc +++ b/src/lte/model/lte-enb-phy.cc @@ -398,7 +398,7 @@ LteEnbPhy::CreateUlCqiReport (const SpectrumValue& sinr) for (it = sinr.ConstValuesBegin (); it != sinr.ConstValuesEnd (); it++) { ulcqi.m_sinr.push_back ((*it)); - NS_LOG_DEBUG(this << " RB " << i << " SINR " << (*it)); + //NS_LOG_DEBUG(this << " RB " << i << " SINR " << (*it)); i++; } return (ulcqi); diff --git a/src/lte/model/pf-ff-mac-scheduler.cc b/src/lte/model/pf-ff-mac-scheduler.cc index f78a49395..113547105 100644 --- a/src/lte/model/pf-ff-mac-scheduler.cc +++ b/src/lte/model/pf-ff-mac-scheduler.cc @@ -210,7 +210,8 @@ PfSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (const struct SchedUlCqiInf PfFfMacScheduler::PfFfMacScheduler () : m_cschedSapUser (0), m_schedSapUser (0), - m_timeWindow (0.5) + m_timeWindow (0.5), + m_schedTtiDelay (2) // WILD ACK: based on a m_macChTtiDelay = 1 { m_cschedSapProvider = new PfSchedulerMemberCschedSapProvider (this); m_schedSapProvider = new PfSchedulerMemberSchedSapProvider (this); @@ -679,7 +680,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::Sched int rbAllocated = 0; FfMacSchedSapUser::SchedUlConfigIndParameters ret; - + std::vector rbgAllocationMap; for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++) { if (rbAllocated + rbPerFlow > m_cschedCellConfig.m_ulBandwidth) @@ -687,6 +688,11 @@ PfFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::Sched // limit to physical resources last resource assignment rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated; } + // store info on allocation for managing ul-cqi interpretation + for (int i = 0; i < rbPerFlow; i++) + { + rbgAllocationMap.push_back ((*it).first); + } UlDciListElement_s uldci; uldci.m_rnti = (*it).first; uldci.m_rbStart = rbAllocated; @@ -708,6 +714,7 @@ PfFfMacScheduler::DoSchedUlTriggerReq (const struct FfMacSchedSapProvider::Sched uldci.m_pdcchPowerOffset = 0; // not used ret.m_dciList.push_back (uldci); } + m_allocationMaps.insert (std::pair > (params.m_sfnSf, rbgAllocationMap)); m_schedSapUser->SchedUlConfigInd (ret); return; } @@ -763,7 +770,57 @@ void PfFfMacScheduler::DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) { NS_LOG_FUNCTION (this); - // TODO: Implementation of the API + //NS_LOG_DEBUG (this << " RX UL CQI at " << params.m_sfnSf); + // correlate info on UL-CQIs with previous scheduling -> calculate m_sfnSf of transmission + uint32_t frameNo = (0xFF & params.m_sfnSf) >> 4; + uint32_t subframeNo = (0xF & params.m_sfnSf); + //NS_LOG_DEBUG (this << " sfn " << frameNo << " sbfn " << subframeNo); + if (subframeNo - m_schedTtiDelay < 0) + { + frameNo--; + } + subframeNo = (subframeNo - m_schedTtiDelay) % 10; + //NS_LOG_DEBUG (this << " Actual sfn " << frameNo << " sbfn " << subframeNo); + uint16_t sfnSf = ((0xFF & frameNo) << 4) | (0xF & subframeNo); + // retrieve the allocation for this subframe + std::map >::iterator itMap; + std::map >::iterator itCqi; + itMap = m_allocationMaps.find (sfnSf); + if (itMap == m_allocationMaps.end()) + { + NS_LOG_DEBUG (this << " Does not find info on allocation"); + return; + } + for (uint32_t i = 0; i < (*itMap).second.size (); i++) + { + //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINR " << params.m_ulCqi.m_sinr.at (i)); + // fixed point notation Sxxxxxxxxxxx.xxx + itCqi = m_ueCqi.find ((*itMap).second.at (i)); + if (itCqi == m_ueCqi.end ()) + { + // create a new entry + std::vector newCqi; + for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++) + { + if (i==j) + { + newCqi.push_back (params.m_ulCqi.m_sinr.at (i)); + } + else + { + newCqi.push_back (0); // TBD : put the lower possible value + } + + } + } + else + { + // update the value + (*itCqi).second.at (i) = params.m_ulCqi.m_sinr.at (i); + } + + } + return; } diff --git a/src/lte/model/pf-ff-mac-scheduler.h b/src/lte/model/pf-ff-mac-scheduler.h index f0cda833f..4bd021651 100644 --- a/src/lte/model/pf-ff-mac-scheduler.h +++ b/src/lte/model/pf-ff-mac-scheduler.h @@ -151,6 +151,16 @@ private: */ std::map m_a30CqiRxed; + /* + * Map of previous allocated UE per RBG + * (used to retrieve info from UL-CQI) + */ + std::map > m_allocationMaps; + + /* + * Map of UEs' UL-CQI per RBG + */ + std::map > m_ueCqi; /* * Map of UE's buffer status reports received @@ -169,6 +179,7 @@ private: double m_timeWindow; + uint8_t m_schedTtiDelay; // delay between scheduling and reception (based on m_macChTtiDelay) };