23 #include <ns3/pointer.h>
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/fdmt-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
37 int FdMtType0AllocationRbg[4] = {
45 NS_OBJECT_ENSURE_REGISTERED (FdMtFfMacScheduler);
66 FdMtSchedulerMemberCschedSapProvider::FdMtSchedulerMemberCschedSapProvider ()
70 FdMtSchedulerMemberCschedSapProvider::FdMtSchedulerMemberCschedSapProvider (FdMtFfMacScheduler* scheduler) : m_scheduler (scheduler)
78 m_scheduler->DoCschedCellConfigReq (params);
82 FdMtSchedulerMemberCschedSapProvider::CschedUeConfigReq (
const struct CschedUeConfigReqParameters& params)
84 m_scheduler->DoCschedUeConfigReq (params);
89 FdMtSchedulerMemberCschedSapProvider::CschedLcConfigReq (
const struct CschedLcConfigReqParameters& params)
91 m_scheduler->DoCschedLcConfigReq (params);
95 FdMtSchedulerMemberCschedSapProvider::CschedLcReleaseReq (
const struct CschedLcReleaseReqParameters& params)
97 m_scheduler->DoCschedLcReleaseReq (params);
101 FdMtSchedulerMemberCschedSapProvider::CschedUeReleaseReq (
const struct CschedUeReleaseReqParameters& params)
103 m_scheduler->DoCschedUeReleaseReq (params);
135 FdMtSchedulerMemberSchedSapProvider::FdMtSchedulerMemberSchedSapProvider ()
140 FdMtSchedulerMemberSchedSapProvider::FdMtSchedulerMemberSchedSapProvider (FdMtFfMacScheduler* scheduler)
141 : m_scheduler (scheduler)
146 FdMtSchedulerMemberSchedSapProvider::SchedDlRlcBufferReq (
const struct SchedDlRlcBufferReqParameters& params)
148 m_scheduler->DoSchedDlRlcBufferReq (params);
152 FdMtSchedulerMemberSchedSapProvider::SchedDlPagingBufferReq (
const struct SchedDlPagingBufferReqParameters& params)
154 m_scheduler->DoSchedDlPagingBufferReq (params);
158 FdMtSchedulerMemberSchedSapProvider::SchedDlMacBufferReq (
const struct SchedDlMacBufferReqParameters& params)
160 m_scheduler->DoSchedDlMacBufferReq (params);
164 FdMtSchedulerMemberSchedSapProvider::SchedDlTriggerReq (
const struct SchedDlTriggerReqParameters& params)
166 m_scheduler->DoSchedDlTriggerReq (params);
170 FdMtSchedulerMemberSchedSapProvider::SchedDlRachInfoReq (
const struct SchedDlRachInfoReqParameters& params)
172 m_scheduler->DoSchedDlRachInfoReq (params);
176 FdMtSchedulerMemberSchedSapProvider::SchedDlCqiInfoReq (
const struct SchedDlCqiInfoReqParameters& params)
178 m_scheduler->DoSchedDlCqiInfoReq (params);
182 FdMtSchedulerMemberSchedSapProvider::SchedUlTriggerReq (
const struct SchedUlTriggerReqParameters& params)
184 m_scheduler->DoSchedUlTriggerReq (params);
188 FdMtSchedulerMemberSchedSapProvider::SchedUlNoiseInterferenceReq (
const struct SchedUlNoiseInterferenceReqParameters& params)
190 m_scheduler->DoSchedUlNoiseInterferenceReq (params);
194 FdMtSchedulerMemberSchedSapProvider::SchedUlSrInfoReq (
const struct SchedUlSrInfoReqParameters& params)
196 m_scheduler->DoSchedUlSrInfoReq (params);
200 FdMtSchedulerMemberSchedSapProvider::SchedUlMacCtrlInfoReq (
const struct SchedUlMacCtrlInfoReqParameters& params)
202 m_scheduler->DoSchedUlMacCtrlInfoReq (params);
206 FdMtSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (
const struct SchedUlCqiInfoReqParameters& params)
208 m_scheduler->DoSchedUlCqiInfoReq (params);
216 : m_cschedSapUser (0),
220 m_amc = CreateObject <LteAmc> ();
234 m_dlHarqProcessesDciBuffer.clear ();
235 m_dlHarqProcessesTimer.clear ();
236 m_dlHarqProcessesRlcPduListBuffer.clear ();
237 m_dlInfoListBuffered.clear ();
238 m_ulHarqCurrentProcessId.clear ();
239 m_ulHarqProcessesStatus.clear ();
240 m_ulHarqProcessesDciBuffer.clear ();
241 delete m_cschedSapProvider;
242 delete m_schedSapProvider;
246 FdMtFfMacScheduler::GetTypeId (
void)
250 .AddConstructor<FdMtFfMacScheduler> ()
251 .AddAttribute (
"CqiTimerThreshold",
252 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
254 MakeUintegerAccessor (&FdMtFfMacScheduler::m_cqiTimersThreshold),
255 MakeUintegerChecker<uint32_t> ())
256 .AddAttribute (
"HarqEnabled",
257 "Activate/Deactivate the HARQ [by default is active].",
260 MakeBooleanChecker ())
261 .AddAttribute (
"UlGrantMcs",
262 "The MCS of the UL grant, must be [0..15] (default 0)",
264 MakeUintegerAccessor (&FdMtFfMacScheduler::m_ulGrantMcs),
265 MakeUintegerChecker<uint8_t> ())
287 return m_cschedSapProvider;
293 return m_schedSapProvider;
301 m_cschedCellConfig = params;
302 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
304 cnf.m_result = SUCCESS;
305 m_cschedSapUser->CschedUeConfigCnf (cnf);
310 FdMtFfMacScheduler::DoCschedUeConfigReq (
const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params)
312 NS_LOG_FUNCTION (
this <<
" RNTI " << params.m_rnti <<
" txMode " << (uint16_t)params.m_transmissionMode);
313 std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
314 if (it == m_uesTxMode.end ())
316 m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
318 m_dlHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
319 DlHarqProcessesStatus_t dlHarqPrcStatus;
320 dlHarqPrcStatus.resize (8,0);
321 m_dlHarqProcessesStatus.insert (std::pair <uint16_t, DlHarqProcessesStatus_t> (params.m_rnti, dlHarqPrcStatus));
322 DlHarqProcessesTimer_t dlHarqProcessesTimer;
323 dlHarqProcessesTimer.resize (8,0);
324 m_dlHarqProcessesTimer.insert (std::pair <uint16_t, DlHarqProcessesTimer_t> (params.m_rnti, dlHarqProcessesTimer));
325 DlHarqProcessesDciBuffer_t dlHarqdci;
326 dlHarqdci.resize (8);
327 m_dlHarqProcessesDciBuffer.insert (std::pair <uint16_t, DlHarqProcessesDciBuffer_t> (params.m_rnti, dlHarqdci));
328 DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
329 dlHarqRlcPdu.resize (2);
330 dlHarqRlcPdu.at (0).resize (8);
331 dlHarqRlcPdu.at (1).resize (8);
332 m_dlHarqProcessesRlcPduListBuffer.insert (std::pair <uint16_t, DlHarqRlcPduListBuffer_t> (params.m_rnti, dlHarqRlcPdu));
333 m_ulHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
334 UlHarqProcessesStatus_t ulHarqPrcStatus;
335 ulHarqPrcStatus.resize (8,0);
336 m_ulHarqProcessesStatus.insert (std::pair <uint16_t, UlHarqProcessesStatus_t> (params.m_rnti, ulHarqPrcStatus));
337 UlHarqProcessesDciBuffer_t ulHarqdci;
338 ulHarqdci.resize (8);
339 m_ulHarqProcessesDciBuffer.insert (std::pair <uint16_t, UlHarqProcessesDciBuffer_t> (params.m_rnti, ulHarqdci));
343 (*it).second = params.m_transmissionMode;
349 FdMtFfMacScheduler::DoCschedLcConfigReq (
const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params)
353 std::set <uint16_t>::iterator it;
354 for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++)
356 it = m_flowStatsDl.find (params.m_rnti);
358 if (it == m_flowStatsDl.end ())
360 m_flowStatsDl.insert (params.m_rnti);
361 m_flowStatsUl.insert (params.m_rnti);
373 FdMtFfMacScheduler::DoCschedLcReleaseReq (
const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params)
376 for (uint16_t i = 0; i < params.m_logicalChannelIdentity.size (); i++)
378 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
379 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
380 while (it!=m_rlcBufferReq.end ())
382 if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at (i)))
386 m_rlcBufferReq.erase (temp);
398 FdMtFfMacScheduler::DoCschedUeReleaseReq (
const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params)
402 m_uesTxMode.erase (params.m_rnti);
403 m_dlHarqCurrentProcessId.erase (params.m_rnti);
404 m_dlHarqProcessesStatus.erase (params.m_rnti);
405 m_dlHarqProcessesTimer.erase (params.m_rnti);
406 m_dlHarqProcessesDciBuffer.erase (params.m_rnti);
407 m_dlHarqProcessesRlcPduListBuffer.erase (params.m_rnti);
408 m_ulHarqCurrentProcessId.erase (params.m_rnti);
409 m_ulHarqProcessesStatus.erase (params.m_rnti);
410 m_ulHarqProcessesDciBuffer.erase (params.m_rnti);
411 m_flowStatsDl.erase (params.m_rnti);
412 m_flowStatsUl.erase (params.m_rnti);
413 m_ceBsrRxed.erase (params.m_rnti);
414 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
415 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
416 while (it!=m_rlcBufferReq.end ())
418 if ((*it).first.m_rnti == params.m_rnti)
422 m_rlcBufferReq.erase (temp);
429 if (m_nextRntiUl == params.m_rnti)
439 FdMtFfMacScheduler::DoSchedDlRlcBufferReq (
const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params)
441 NS_LOG_FUNCTION (
this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
444 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
446 LteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity);
448 it = m_rlcBufferReq.find (flow);
450 if (it == m_rlcBufferReq.end ())
452 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
456 (*it).second = params;
463 FdMtFfMacScheduler::DoSchedDlPagingBufferReq (
const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params)
471 FdMtFfMacScheduler::DoSchedDlMacBufferReq (
const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params)
479 FdMtFfMacScheduler::GetRbgSize (
int dlbandwidth)
481 for (
int i = 0; i < 4; i++)
483 if (dlbandwidth < FdMtType0AllocationRbg[i])
494 FdMtFfMacScheduler::LcActivePerFlow (uint16_t rnti)
496 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
498 for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
500 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
501 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
502 || ((*it).second.m_rlcStatusPduSize > 0) ))
506 if ((*it).first.m_rnti > rnti)
521 std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
522 if (it == m_dlHarqCurrentProcessId.end ())
526 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
527 if (itStat == m_dlHarqProcessesStatus.end ())
529 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
531 uint8_t i = (*it).second;
534 i = (i + 1) % HARQ_PROC_NUM;
536 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
537 if ((*itStat).second.at (i) == 0)
560 std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
561 if (it == m_dlHarqCurrentProcessId.end ())
565 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
566 if (itStat == m_dlHarqProcessesStatus.end ())
568 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
570 uint8_t i = (*it).second;
573 i = (i + 1) % HARQ_PROC_NUM;
575 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
576 if ((*itStat).second.at (i) == 0)
579 (*itStat).second.at (i) = 1;
583 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
586 return ((*it).second);
595 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
596 for (itTimers = m_dlHarqProcessesTimer.begin (); itTimers != m_dlHarqProcessesTimer.end (); itTimers ++)
598 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
600 if ((*itTimers).second.at (i) == HARQ_DL_TIMEOUT)
604 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
605 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find ((*itTimers).first);
606 if (itStat == m_dlHarqProcessesStatus.end ())
608 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
610 (*itStat).second.at (i) = 0;
611 (*itTimers).second.at (i) = 0;
615 (*itTimers).second.at (i)++;
626 NS_LOG_FUNCTION (
this <<
" Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
636 int rbgSize = GetRbgSize (m_cschedCellConfig.m_dlBandwidth);
637 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
638 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
639 std::vector <bool> rbgMap;
640 uint16_t rbgAllocatedNum = 0;
641 std::set <uint16_t> rntiAllocated;
642 rbgMap.resize (m_cschedCellConfig.m_dlBandwidth / rbgSize,
false);
646 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
647 uint16_t rbStart = 0;
648 std::vector <struct RachListElement_s>::iterator itRach;
649 for (itRach = m_rachList.begin (); itRach != m_rachList.end (); itRach++)
651 NS_ASSERT_MSG (m_amc->GetTbSizeFromMcs (m_ulGrantMcs, m_cschedCellConfig.m_ulBandwidth) > (*itRach).m_estimatedSize,
" Default UL Grant MCS does not allow to send RACH messages");
653 newRar.m_rnti = (*itRach).m_rnti;
657 newRar.m_grant.m_rnti = newRar.m_rnti;
658 newRar.m_grant.m_mcs = m_ulGrantMcs;
660 uint16_t tbSizeBits = 0;
662 while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < m_cschedCellConfig.m_ulBandwidth))
665 tbSizeBits = m_amc->GetTbSizeFromMcs (m_ulGrantMcs, rbLen);
667 if (tbSizeBits < (*itRach).m_estimatedSize)
672 newRar.m_grant.m_rbStart = rbStart;
673 newRar.m_grant.m_rbLen = rbLen;
674 newRar.m_grant.m_tbSize = tbSizeBits / 8;
675 newRar.m_grant.m_hopping =
false;
676 newRar.m_grant.m_tpc = 0;
677 newRar.m_grant.m_cqiRequest =
false;
678 newRar.m_grant.m_ulDelay =
false;
679 NS_LOG_INFO (
this <<
" UL grant allocated to RNTI " << (*itRach).m_rnti <<
" rbStart " << rbStart <<
" rbLen " << rbLen <<
" MCS " << m_ulGrantMcs <<
" tbSize " << newRar.m_grant.m_tbSize);
680 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
682 m_rachAllocationMap.at (i) = (*itRach).m_rnti;
684 rbStart = rbStart + rbLen;
686 ret.m_buildRarList.push_back (newRar);
694 if (m_dlInfoListBuffered.size () > 0)
696 if (params.m_dlInfoList.size () > 0)
698 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
699 m_dlInfoListBuffered.insert (m_dlInfoListBuffered.end (), params.m_dlInfoList.begin (), params.m_dlInfoList.end ());
704 if (params.m_dlInfoList.size () > 0)
706 m_dlInfoListBuffered = params.m_dlInfoList;
712 m_dlInfoListBuffered.clear ();
714 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
715 for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
717 std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
718 if (itRnti != rntiAllocated.end ())
723 uint8_t nLayers = m_dlInfoListBuffered.at (i).m_harqStatus.size ();
724 std::vector <bool> retx;
725 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
728 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
729 retx.push_back (
false);
733 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
734 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (1) == DlInfoListElement_s::NACK);
736 if (retx.at (0) || retx.at (1))
739 uint16_t rnti = m_dlInfoListBuffered.at (i).m_rnti;
740 uint8_t harqId = m_dlInfoListBuffered.at (i).m_harqProcessId;
741 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
742 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq = m_dlHarqProcessesDciBuffer.find (rnti);
743 if (itHarq == m_dlHarqProcessesDciBuffer.end ())
748 DlDciListElement_s dci = (*itHarq).second.at (harqId);
750 if (dci.m_rv.size () == 1)
752 rv = dci.m_rv.at (0);
756 rv = (dci.m_rv.at (0) > dci.m_rv.at (1) ? dci.m_rv.at (0) : dci.m_rv.at (1));
762 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
763 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (rnti);
764 if (it == m_dlHarqProcessesStatus.end ())
766 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at (i).m_rnti);
768 (*it).second.at (harqId) = 0;
769 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
770 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
772 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
774 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
776 (*itRlcPdu).second.at (k).at (harqId).clear ();
782 std::vector <int> dciRbg;
784 NS_LOG_INFO (
"Original RBGs " << dci.m_rbBitmap <<
" rnti " << dci.m_rnti);
785 for (
int j = 0; j < 32; j++)
787 if (((dci.m_rbBitmap & mask) >> j) == 1)
789 dciRbg.push_back (j);
795 for (uint8_t j = 0; j < dciRbg.size (); j++)
797 if (rbgMap.at (dciRbg.at (j)) ==
true)
807 for (uint8_t j = 0; j < dciRbg.size (); j++)
809 rbgMap.at (dciRbg.at (j)) =
true;
810 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
814 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
820 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
821 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
822 std::vector <bool> rbgMapCopy = rbgMap;
823 while ((j < dciRbg.size ())&&(startRbg != rbgId))
825 if (rbgMapCopy.at (rbgId) ==
false)
827 rbgMapCopy.at (rbgId) =
true;
828 dciRbg.at (j) = rbgId;
833 if (j == dciRbg.size ())
836 uint32_t rbgMask = 0;
837 for (uint16_t k = 0; k < dciRbg.size (); k++)
839 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
842 dci.m_rbBitmap = rbgMask;
844 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
849 dlInfoListUntxed.push_back (params.m_dlInfoList.at (i));
850 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
854 BuildDataListElement_s newEl;
855 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
856 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
858 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
860 for (uint8_t j = 0; j < nLayers; j++)
864 if (j >= dci.m_ndi.size ())
867 dci.m_ndi.push_back (0);
868 dci.m_rv.push_back (0);
869 dci.m_mcs.push_back (0);
870 dci.m_tbsSize.push_back (0);
871 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
875 dci.m_ndi.at (j) = 0;
877 (*itHarq).second.at (harqId).m_rv.at (j)++;
878 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.m_rv.at (j));
884 dci.m_ndi.at (j) = 0;
886 dci.m_mcs.at (j) = 0;
887 dci.m_tbsSize.at (j) = 0;
888 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
891 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.m_harqProcess).size (); k++)
893 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
894 for (uint8_t j = 0; j < nLayers; j++)
898 if (j < dci.m_ndi.size ())
900 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.m_harqProcess).at (k));
905 if (rlcPduListPerLc.size () > 0)
907 newEl.m_rlcPduList.push_back (rlcPduListPerLc);
912 (*itHarq).second.at (harqId).m_rv = dci.m_rv;
914 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (rnti);
915 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
917 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
919 (*itHarqTimer).second.at (harqId) = 0;
920 ret.m_buildDataList.push_back (newEl);
921 rntiAllocated.insert (rnti);
926 NS_LOG_INFO (
this <<
" HARQ received ACK for UE " << m_dlInfoListBuffered.at (i).m_rnti);
927 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (m_dlInfoListBuffered.at (i).m_rnti);
928 if (it == m_dlHarqProcessesStatus.end ())
930 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at (i).m_rnti);
932 (*it).second.at (m_dlInfoListBuffered.at (i).m_harqProcessId) = 0;
933 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (m_dlInfoListBuffered.at (i).m_rnti);
934 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
936 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
938 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
940 (*itRlcPdu).second.at (k).at (m_dlInfoListBuffered.at (i).m_harqProcessId).clear ();
944 m_dlInfoListBuffered.clear ();
945 m_dlInfoListBuffered = dlInfoListUntxed;
949 for (
int i = 0; i < rbgNum; i++)
951 NS_LOG_INFO (
this <<
" ALLOCATION for RBG " << i <<
" of " << rbgNum);
952 if (rbgMap.at (i) ==
false)
954 std::set <uint16_t>::iterator it;
955 std::set <uint16_t>::iterator itMax = m_flowStatsDl.end ();
956 double rcqiMax = 0.0;
957 for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++)
959 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it));
963 if (itRnti != rntiAllocated.end ())
965 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it));
969 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it));
974 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
975 itCqi = m_a30CqiRxed.find ((*it));
976 std::map <uint16_t,uint8_t>::iterator itTxMode;
977 itTxMode = m_uesTxMode.find ((*it));
978 if (itTxMode == m_uesTxMode.end ())
982 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
983 std::vector <uint8_t> sbCqi;
984 if (itCqi == m_a30CqiRxed.end ())
986 for (uint8_t k = 0; k < nLayer; k++)
993 sbCqi = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
995 uint8_t cqi1 = sbCqi.at (0);
997 if (sbCqi.size () > 1)
1001 if ((cqi1 > 0)||(cqi2 > 0))
1003 if (LcActivePerFlow ((*it)) > 0)
1006 double achievableRate = 0.0;
1008 for (uint8_t k = 0; k < nLayer; k++)
1010 if (sbCqi.size () > k)
1012 mcs = m_amc->GetMcsFromCqi (sbCqi.at (k));
1019 achievableRate += ((m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001);
1022 double rcqi = achievableRate;
1023 NS_LOG_INFO (
this <<
" RNTI " << (*it) <<
" MCS " << (uint32_t)mcs <<
" achievableRate " << achievableRate <<
" RCQI " << rcqi);
1035 if (itMax == m_flowStatsDl.end ())
1042 rbgMap.at (i) =
true;
1043 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1044 itMap = allocationMap.find ((*itMax));
1045 if (itMap == allocationMap.end ())
1048 std::vector <uint16_t> tempMap;
1049 tempMap.push_back (i);
1050 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax), tempMap));
1054 (*itMap).second.push_back (i);
1056 NS_LOG_INFO (
this <<
" UE assigned " << (*itMax));
1063 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1064 while (itMap != allocationMap.end ())
1067 BuildDataListElement_s newEl;
1068 newEl.m_rnti = (*itMap).first;
1070 DlDciListElement_s newDci;
1071 newDci.m_rnti = (*itMap).first;
1074 uint16_t lcActives = LcActivePerFlow ((*itMap).first);
1075 NS_LOG_INFO (
this <<
"Allocate user " << newEl.m_rnti <<
" rbg " << lcActives);
1076 uint16_t RgbPerRnti = (*itMap).second.size ();
1077 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1078 itCqi = m_a30CqiRxed.find ((*itMap).first);
1079 std::map <uint16_t,uint8_t>::iterator itTxMode;
1080 itTxMode = m_uesTxMode.find ((*itMap).first);
1081 if (itTxMode == m_uesTxMode.end ())
1083 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1085 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1086 std::vector <uint8_t> worstCqi (2, 15);
1087 if (itCqi != m_a30CqiRxed.end ())
1089 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1091 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1093 NS_LOG_INFO (
this <<
" RBG " << (*itMap).second.at (k) <<
" CQI " << (uint16_t)((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (0)) );
1094 for (uint8_t j = 0; j < nLayer; j++)
1096 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1098 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1100 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1106 worstCqi.at (j) = 1;
1112 for (uint8_t j = 0; j < nLayer; j++)
1114 worstCqi.at (j) = 1;
1121 for (uint8_t j = 0; j < nLayer; j++)
1123 worstCqi.at (j) = 1;
1126 for (uint8_t j = 0; j < nLayer; j++)
1128 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1130 uint32_t bytesTxed = 0;
1131 for (uint8_t j = 0; j < nLayer; j++)
1133 newDci.m_mcs.push_back (m_amc->GetMcsFromCqi (worstCqi.at (j)));
1134 int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1135 newDci.m_tbsSize.push_back (tbSize);
1136 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" MCS selected" << m_amc->GetMcsFromCqi (worstCqi.at (j)));
1137 bytesTxed += tbSize;
1140 newDci.m_resAlloc = 0;
1141 newDci.m_rbBitmap = 0;
1142 uint32_t rbgMask = 0;
1143 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1145 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1146 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1148 newDci.m_rbBitmap = rbgMask;
1151 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1152 for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
1154 if (((*itBufReq).first.m_rnti == (*itMap).first)
1155 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1156 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1157 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1159 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1160 for (uint8_t j = 0; j < nLayer; j++)
1162 RlcPduListElement_s newRlcEl;
1163 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1164 newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
1165 NS_LOG_INFO (
this <<
" LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity <<
" size " << newRlcEl.m_size <<
" layer " << (uint16_t)j);
1166 newRlcPduLe.push_back (newRlcEl);
1167 UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
1171 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find ((*itMap).first);
1172 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
1174 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1176 (*itRlcPdu).second.at (j).at (newDci.m_harqProcess).push_back (newRlcEl);
1179 newEl.m_rlcPduList.push_back (newRlcPduLe);
1181 if ((*itBufReq).first.m_rnti > (*itMap).first)
1186 for (uint8_t j = 0; j < nLayer; j++)
1188 newDci.m_ndi.push_back (1);
1189 newDci.m_rv.push_back (0);
1192 newEl.m_dci = newDci;
1197 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci = m_dlHarqProcessesDciBuffer.find (newEl.m_rnti);
1198 if (itDci == m_dlHarqProcessesDciBuffer.end ())
1200 NS_FATAL_ERROR (
"Unable to find RNTI entry in DCI HARQ buffer for RNTI " << newEl.m_rnti);
1202 (*itDci).second.at (newDci.m_harqProcess) = newDci;
1204 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (newEl.m_rnti);
1205 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
1207 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1209 (*itHarqTimer).second.at (newDci.m_harqProcess) = 0;
1214 ret.m_buildDataList.push_back (newEl);
1218 ret.m_nrOfPdcchOfdmSymbols = 1;
1220 m_schedSapUser->SchedDlConfigInd (ret);
1227 FdMtFfMacScheduler::DoSchedDlRachInfoReq (
const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params)
1231 m_rachList = params.m_rachList;
1237 FdMtFfMacScheduler::DoSchedDlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
1241 for (
unsigned int i = 0; i < params.m_cqiList.size (); i++)
1243 if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
1246 std::map <uint16_t,uint8_t>::iterator it;
1247 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1248 it = m_p10CqiRxed.find (rnti);
1249 if (it == m_p10CqiRxed.end ())
1252 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) );
1254 m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1259 (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
1261 std::map <uint16_t,uint32_t>::iterator itTimers;
1262 itTimers = m_p10CqiTimers.find (rnti);
1263 (*itTimers).second = m_cqiTimersThreshold;
1266 else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
1269 std::map <uint16_t,SbMeasResult_s>::iterator it;
1270 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1271 it = m_a30CqiRxed.find (rnti);
1272 if (it == m_a30CqiRxed.end ())
1275 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
1276 m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1281 (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
1282 std::map <uint16_t,uint32_t>::iterator itTimers;
1283 itTimers = m_a30CqiTimers.find (rnti);
1284 (*itTimers).second = m_cqiTimersThreshold;
1298 FdMtFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
1300 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
1301 if (itCqi == m_ueCqi.end ())
1312 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1314 double sinr = (*itCqi).second.at (i);
1315 if (sinr != NO_SINR)
1321 double estimatedSinr = sinrSum / (double)sinrNum;
1323 (*itCqi).second.at (rb) = estimatedSinr;
1324 return (estimatedSinr);
1329 FdMtFfMacScheduler::DoSchedUlTriggerReq (
const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
1331 NS_LOG_FUNCTION (
this <<
" UL - Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf) <<
" size " << params.m_ulInfoList.size ());
1333 RefreshUlCqiMaps ();
1336 FfMacSchedSapUser::SchedUlConfigIndParameters ret;
1337 std::vector <bool> rbMap;
1338 uint16_t rbAllocatedNum = 0;
1339 std::set <uint16_t> rntiAllocated;
1340 std::vector <uint16_t> rbgAllocationMap;
1342 rbgAllocationMap = m_rachAllocationMap;
1344 m_rachAllocationMap.clear ();
1345 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1347 rbMap.resize (m_cschedCellConfig.m_ulBandwidth,
false);
1349 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1351 if (rbgAllocationMap.at (i) != 0)
1353 rbMap.at (i) =
true;
1363 std::map <uint16_t, uint8_t>::iterator itProcId;
1364 for (itProcId = m_ulHarqCurrentProcessId.begin (); itProcId != m_ulHarqCurrentProcessId.end (); itProcId++)
1366 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
1369 for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
1371 if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
1374 uint16_t rnti = params.m_ulInfoList.at (i).m_rnti;
1375 itProcId = m_ulHarqCurrentProcessId.find (rnti);
1376 if (itProcId == m_ulHarqCurrentProcessId.end ())
1378 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1380 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1381 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.m_ulInfoList.size ());
1382 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
1383 if (itHarq == m_ulHarqProcessesDciBuffer.end ())
1385 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1388 UlDciListElement_s dci = (*itHarq).second.at (harqId);
1389 std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (rnti);
1390 if (itStat == m_ulHarqProcessesStatus.end ())
1392 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1394 if ((*itStat).second.at (harqId) >= 3)
1396 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1400 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1402 if (rbMap.at (j) ==
true)
1411 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1413 rbMap.at (j) =
true;
1414 rbgAllocationMap.at (j) = dci.m_rnti;
1418 NS_LOG_INFO (
this <<
" Send retx in the same RBs " << (uint16_t)dci.m_rbStart <<
" to " << dci.m_rbStart + dci.m_rbLen <<
" RV " << (*itStat).second.at (harqId) + 1);
1422 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1427 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1428 (*itStat).second.at (harqId) = 0;
1429 (*itHarq).second.at ((*itProcId).second) = dci;
1430 ret.m_dciList.push_back (dci);
1431 rntiAllocated.insert (dci.m_rnti);
1435 NS_LOG_INFO (
this <<
" HARQ-ACK feedback from RNTI " << params.m_ulInfoList.at (i).m_rnti);
1440 std::map <uint16_t,uint32_t>::iterator it;
1443 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1445 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1447 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1455 if (ret.m_dciList.size () > 0)
1457 m_schedSapUser->SchedUlConfigInd (ret);
1465 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size ());
1470 int rbAllocated = 0;
1472 if (m_nextRntiUl != 0)
1474 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1476 if ((*it).first == m_nextRntiUl)
1481 if (it == m_ceBsrRxed.end ())
1488 it = m_ceBsrRxed.begin ();
1489 m_nextRntiUl = (*it).first;
1493 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1494 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1498 if (it == m_ceBsrRxed.end ())
1501 it = m_ceBsrRxed.begin ();
1505 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1508 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1517 UlDciListElement_s uldci;
1518 uldci.m_rnti = (*it).first;
1519 uldci.m_rbLen = rbPerFlow;
1520 bool allocated =
false;
1521 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow);
1522 while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0))
1526 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1528 if (rbMap.at (j) ==
true)
1536 uldci.m_rbStart = rbAllocated;
1538 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1540 rbMap.at (j) =
true;
1542 rbgAllocationMap.at (j) = (*it).first;
1544 rbAllocated += rbPerFlow;
1549 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1552 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1564 m_nextRntiUl = (*it).first;
1565 if (ret.m_dciList.size () > 0)
1567 m_schedSapUser->SchedUlConfigInd (ret);
1569 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1575 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
1577 if (itCqi == m_ueCqi.end ())
1585 double minSinr = (*itCqi).second.at (uldci.m_rbStart);
1586 if (minSinr == NO_SINR)
1588 minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
1590 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1592 double sinr = (*itCqi).second.at (i);
1593 if (sinr == NO_SINR)
1595 sinr = EstimateUlSinr ((*it).first, i);
1597 if ((*itCqi).second.at (i) < minSinr)
1599 minSinr = (*itCqi).second.at (i);
1604 double s = log2 ( 1 + (
1605 pow (10, minSinr / 10 ) /
1606 ( (-log (5.0 * 0.00005 )) / 1.5) ));
1607 cqi = m_amc->GetCqiFromSpectralEfficiency (s);
1611 if (it == m_ceBsrRxed.end ())
1614 it = m_ceBsrRxed.begin ();
1618 uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
1621 uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
1622 UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
1624 uldci.m_cceIndex = 0;
1625 uldci.m_aggrLevel = 1;
1626 uldci.m_ueTxAntennaSelection = 3;
1627 uldci.m_hopping =
false;
1630 uldci.m_cqiRequest =
false;
1631 uldci.m_ulIndex = 0;
1633 uldci.m_freqHopping = 0;
1634 uldci.m_pdcchPowerOffset = 0;
1635 ret.m_dciList.push_back (uldci);
1640 std::map <uint16_t, uint8_t>::iterator itProcId;
1641 itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
1642 if (itProcId == m_ulHarqCurrentProcessId.end ())
1644 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << uldci.m_rnti);
1646 harqId = (*itProcId).second;
1647 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
1648 if (itDci == m_ulHarqProcessesDciBuffer.end ())
1650 NS_FATAL_ERROR (
"Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
1652 (*itDci).second.at (harqId) = uldci;
1655 NS_LOG_INFO (
this <<
" UE Allocation RNTI " << (*it).first <<
" startPRB " << (uint32_t)uldci.m_rbStart <<
" nPRB " << (uint32_t)uldci.m_rbLen <<
" CQI " << cqi <<
" MCS " << (uint32_t)uldci.m_mcs <<
" TBsize " << uldci.m_tbSize <<
" RbAlloc " << rbAllocated <<
" harqId " << (uint16_t)harqId);
1659 if (it == m_ceBsrRxed.end ())
1662 it = m_ceBsrRxed.begin ();
1664 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1667 m_nextRntiUl = (*it).first;
1671 while (((*it).first != m_nextRntiUl)&&(rbPerFlow!=0));
1674 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1675 m_schedSapUser->SchedUlConfigInd (ret);
1681 FdMtFfMacScheduler::DoSchedUlNoiseInterferenceReq (
const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params)
1688 FdMtFfMacScheduler::DoSchedUlSrInfoReq (
const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params)
1695 FdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq (
const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
1699 std::map <uint16_t,uint32_t>::iterator it;
1701 for (
unsigned int i = 0; i < params.m_macCeList.size (); i++)
1703 if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
1712 uint32_t buffer = 0;
1713 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1715 uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1716 buffer += BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
1719 uint16_t rnti = params.m_macCeList.at (i).m_rnti;
1720 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1721 it = m_ceBsrRxed.find (rnti);
1722 if (it == m_ceBsrRxed.end ())
1725 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1730 (*it).second = buffer;
1739 FdMtFfMacScheduler::DoSchedUlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
1743 switch (m_ulCqiFilter)
1745 case FfMacScheduler::SRS_UL_CQI:
1748 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1754 case FfMacScheduler::PUSCH_UL_CQI:
1757 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1762 case FfMacScheduler::ALL_UL_CQI:
1769 switch (params.m_ulCqi.m_type)
1771 case UlCqi_s::PUSCH:
1773 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1774 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1775 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
1776 itMap = m_allocationMaps.find (params.m_sfnSf);
1777 if (itMap == m_allocationMaps.end ())
1781 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1784 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
1785 itCqi = m_ueCqi.find ((*itMap).second.at (i));
1786 if (itCqi == m_ueCqi.end ())
1789 std::vector <double> newCqi;
1790 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1794 newCqi.push_back (sinr);
1799 newCqi.push_back (NO_SINR);
1803 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
1805 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
1810 (*itCqi).second.at (i) = sinr;
1811 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
1813 std::map <uint16_t, uint32_t>::iterator itTimers;
1814 itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
1815 (*itTimers).second = m_cqiTimersThreshold;
1821 m_allocationMaps.erase (itMap);
1828 NS_ASSERT (params.m_vendorSpecificList.size () > 0);
1829 for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
1831 if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
1833 Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
1834 rnti = vsp->GetRnti ();
1837 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1838 itCqi = m_ueCqi.find (rnti);
1839 if (itCqi == m_ueCqi.end ())
1842 std::vector <double> newCqi;
1843 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1845 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1846 newCqi.push_back (sinr);
1847 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
1850 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
1852 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1857 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1859 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1860 (*itCqi).second.at (j) = sinr;
1861 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
1864 std::map <uint16_t, uint32_t>::iterator itTimers;
1865 itTimers = m_ueCqiTimers.find (rnti);
1866 (*itTimers).second = m_cqiTimersThreshold;
1873 case UlCqi_s::PUCCH_1:
1874 case UlCqi_s::PUCCH_2:
1875 case UlCqi_s::PRACH:
1877 NS_FATAL_ERROR (
"FdMtFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1887 FdMtFfMacScheduler::RefreshDlCqiMaps (
void)
1890 std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
1891 while (itP10 != m_p10CqiTimers.end ())
1893 NS_LOG_INFO (
this <<
" P10-CQI for user " << (*itP10).first <<
" is " << (uint32_t)(*itP10).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1894 if ((*itP10).second == 0)
1897 std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
1898 NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (),
" Does not find CQI report for user " << (*itP10).first);
1899 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
1900 m_p10CqiRxed.erase (itMap);
1901 std::map <uint16_t,uint32_t>::iterator temp = itP10;
1903 m_p10CqiTimers.erase (temp);
1913 std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
1914 while (itA30 != m_a30CqiTimers.end ())
1916 NS_LOG_INFO (
this <<
" A30-CQI for user " << (*itA30).first <<
" is " << (uint32_t)(*itA30).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1917 if ((*itA30).second == 0)
1920 std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
1921 NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (),
" Does not find CQI report for user " << (*itA30).first);
1922 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
1923 m_a30CqiRxed.erase (itMap);
1924 std::map <uint16_t,uint32_t>::iterator temp = itA30;
1926 m_a30CqiTimers.erase (temp);
1940 FdMtFfMacScheduler::RefreshUlCqiMaps (
void)
1943 std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
1944 while (itUl != m_ueCqiTimers.end ())
1946 NS_LOG_INFO (
this <<
" UL-CQI for user " << (*itUl).first <<
" is " << (uint32_t)(*itUl).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1947 if ((*itUl).second == 0)
1950 std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
1951 NS_ASSERT_MSG (itMap != m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
1952 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
1953 (*itMap).second.clear ();
1954 m_ueCqi.erase (itMap);
1955 std::map <uint16_t,uint32_t>::iterator temp = itUl;
1957 m_ueCqiTimers.erase (temp);
1970 FdMtFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
1972 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
1973 LteFlowId_t flow (rnti, lcid);
1974 it = m_rlcBufferReq.find (flow);
1975 if (it != m_rlcBufferReq.end ())
1977 NS_LOG_INFO (
this <<
" UE " << rnti <<
" LC " << (uint16_t)lcid <<
" txqueue " << (*it).second.m_rlcTransmissionQueueSize <<
" retxqueue " << (*it).second.m_rlcRetransmissionQueueSize <<
" status " << (*it).second.m_rlcStatusPduSize <<
" decrease " << size);
1980 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
1982 (*it).second.m_rlcStatusPduSize = 0;
1984 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
1986 (*it).second.m_rlcRetransmissionQueueSize = 0;
1988 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
1991 if ((*it).second.m_rlcTransmissionQueueSize <= size)
1993 (*it).second.m_rlcTransmissionQueueSize = 0;
1998 (*it).second.m_rlcTransmissionQueueSize -= size;
2004 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2009 FdMtFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
2013 std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
2014 if (it != m_ceBsrRxed.end ())
2016 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2017 if ((*it).second >= size)
2019 (*it).second -= size;
2028 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2034 FdMtFfMacScheduler::TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode)
2036 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
2037 FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params;
2038 params.m_rnti = rnti;
2039 params.m_transmissionMode = txMode;
2040 m_cschedSapUser->CschedUeConfigUpdateInd (params);
#define NS_LOG_FUNCTION(parameters)
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
See section 4.3.10 buildRARListElement.
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
Implements the SCHED SAP and CSCHED SAP for a Frequency Domain Maximize Throughput scheduler...
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.
#define NS_FATAL_ERROR(msg)
fatal error handling
virtual void DoDispose(void)
Hold an unsigned integer type.
#define NS_LOG_LOGIC(msg)
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
virtual ~FdMtFfMacScheduler()
#define NS_ASSERT_MSG(condition, message)
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
FdMtFfMacScheduler()
Constructor.
#define NS_LOG_DEBUG(msg)
#define NS_LOG_ERROR(msg)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)