diff --git a/src/lte/model/rr-ff-mac-scheduler.cc b/src/lte/model/rr-ff-mac-scheduler.cc index 415b192d7..89b923037 100644 --- a/src/lte/model/rr-ff-mac-scheduler.cc +++ b/src/lte/model/rr-ff-mac-scheduler.cc @@ -208,7 +208,8 @@ RrSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (const struct SchedUlCqiInf RrFfMacScheduler::RrFfMacScheduler () : m_cschedSapUser (0), m_schedSapUser (0), - m_schedTtiDelay (2) // WILD ACK: based on a m_macChTtiDelay = 1 + m_schedTtiDelay (2), // WILD ACK: based on a m_macChTtiDelay = 1 + m_nextRnti (0) { m_cschedSapProvider = new RrSchedulerMemberCschedSapProvider (this); m_schedSapProvider = new RrSchedulerMemberSchedSapProvider (this); @@ -369,7 +370,7 @@ RrFfMacScheduler::GetRbgSize (int dlbandwidth) void RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters& params) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this << " Frame no. " << (params.m_sfnSf>>4) << " subframe no. " << (0xF & params.m_sfnSf)); // API generated by RLC for triggering the scheduling of a DL subframe // Get the actual active flows (queue!=0) @@ -404,7 +405,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched } } } - + if (nflows == 0) { return; @@ -421,16 +422,40 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched int rbgAllocated = 0; FfMacSchedSapUser::SchedDlConfigIndParameters ret; - // round robin assignment to all UE-LC registered - it = m_rlcBufferReq.begin (); - //for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++) - while (it != m_rlcBufferReq.end ()) + // round robin assignment to all UE-LC registered starting from the subsequent of the one + // served last scheduling trigger + NS_LOG_DEBUG (this << " next to be served " << m_nextRnti << " nflows " << nflows); + if (m_nextRnti!=0) + { + for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++) + { + if ((*it).m_rnti == m_nextRnti) + { + break; + } + } + + if (it == m_rlcBufferReq.end ()) + { + NS_LOG_ERROR (this << " no user found"); + } + } + else + { + it = m_rlcBufferReq.begin (); + } + do { itLcRnti = lcActivesPerRnti.find ((*it).m_rnti); if (itLcRnti==lcActivesPerRnti.end ()) { // skip this entry it++; + if (it==m_rlcBufferReq.end ()) + { + // restart from the first + it = m_rlcBufferReq.begin (); + } continue; } int lcNum = (*itLcRnti).second; @@ -445,7 +470,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched std::map ::iterator itCqi = m_p10CqiRxed.find (newEl.m_rnti); if (itCqi == m_p10CqiRxed.end ()) { - newDci.m_mcs.push_back (1); // no info on this user -> lowest MCS + newDci.m_mcs.push_back (0); // no info on this user -> lowest MCS } else { @@ -455,7 +480,7 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched std::vector newRlcPduLe; int totRbg = lcNum * rbgPerFlow; int tbSize = (LteAmc::GetTbSizeFromMcs (newDci.m_mcs.at (0), totRbg * rbgSize) / 8); - //NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " LCs " << (uint16_t)(*itLcRnti).second << " bytes " << tbSize); + NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " LCs " << (uint16_t)(*itLcRnti).second << " bytes " << tbSize << " PRBs " << totRbg * rbgSize << " mcs " << (uint16_t) newDci.m_mcs.at (0)); uint16_t rlcPduSize = tbSize / lcNum; for (int i = 0; i < lcNum ; i++) { @@ -465,12 +490,16 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched newRlcEl.m_size = rlcPduSize; newRlcPduLe.push_back (newRlcEl); it++; + if (it==m_rlcBufferReq.end ()) + { + // restart from the first + it = m_rlcBufferReq.begin (); + } } uint32_t rbgMask = 0; for (int i = 0; i < totRbg; i++) { rbgMask = rbgMask + (0x1 << rbgAllocated); - //NS_LOG_DEBUG (this << " Allocated RBG " << rbgAllocated); rbgAllocated++; } newDci.m_rbBitmap = rbgMask; // (32 bit bitmap see 7.1.6 of 36.213) @@ -492,9 +521,11 @@ RrFfMacScheduler::DoSchedDlTriggerReq (const struct FfMacSchedSapProvider::Sched ret.m_buildDataList.push_back (newEl); if (rbgAllocated == rbgNum) { + NS_LOG_DEBUG (this << " FULL " << (*it).m_rnti); + m_nextRnti = (*it).m_rnti; // store last RNTI served break; // no more RGB to be allocated } - } // end while + } while ((*it).m_rnti != m_nextRnti); ret.m_nrOfPdcchOfdmSymbols = 1; // TODO: check correct value according the DCIs txed diff --git a/src/lte/model/rr-ff-mac-scheduler.h b/src/lte/model/rr-ff-mac-scheduler.h index 855ea2bd4..399b2159b 100644 --- a/src/lte/model/rr-ff-mac-scheduler.h +++ b/src/lte/model/rr-ff-mac-scheduler.h @@ -159,6 +159,8 @@ private: FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig; uint8_t m_schedTtiDelay; // delay between scheduling and reception (based on m_macChTtiDelay) + + uint16_t m_nextRnti; // RNTI of the next user to be served next scheduling };