23 #include <ns3/pointer.h>
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/tdmt-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
37 int TdMtType0AllocationRbg[4] = {
45 NS_OBJECT_ENSURE_REGISTERED (TdMtFfMacScheduler);
66 TdMtSchedulerMemberCschedSapProvider::TdMtSchedulerMemberCschedSapProvider ()
70 TdMtSchedulerMemberCschedSapProvider::TdMtSchedulerMemberCschedSapProvider (TdMtFfMacScheduler* scheduler) : m_scheduler (scheduler)
78 m_scheduler->DoCschedCellConfigReq (params);
82 TdMtSchedulerMemberCschedSapProvider::CschedUeConfigReq (
const struct CschedUeConfigReqParameters& params)
84 m_scheduler->DoCschedUeConfigReq (params);
89 TdMtSchedulerMemberCschedSapProvider::CschedLcConfigReq (
const struct CschedLcConfigReqParameters& params)
91 m_scheduler->DoCschedLcConfigReq (params);
95 TdMtSchedulerMemberCschedSapProvider::CschedLcReleaseReq (
const struct CschedLcReleaseReqParameters& params)
97 m_scheduler->DoCschedLcReleaseReq (params);
101 TdMtSchedulerMemberCschedSapProvider::CschedUeReleaseReq (
const struct CschedUeReleaseReqParameters& params)
103 m_scheduler->DoCschedUeReleaseReq (params);
135 TdMtSchedulerMemberSchedSapProvider::TdMtSchedulerMemberSchedSapProvider ()
140 TdMtSchedulerMemberSchedSapProvider::TdMtSchedulerMemberSchedSapProvider (TdMtFfMacScheduler* scheduler)
141 : m_scheduler (scheduler)
146 TdMtSchedulerMemberSchedSapProvider::SchedDlRlcBufferReq (
const struct SchedDlRlcBufferReqParameters& params)
148 m_scheduler->DoSchedDlRlcBufferReq (params);
152 TdMtSchedulerMemberSchedSapProvider::SchedDlPagingBufferReq (
const struct SchedDlPagingBufferReqParameters& params)
154 m_scheduler->DoSchedDlPagingBufferReq (params);
158 TdMtSchedulerMemberSchedSapProvider::SchedDlMacBufferReq (
const struct SchedDlMacBufferReqParameters& params)
160 m_scheduler->DoSchedDlMacBufferReq (params);
164 TdMtSchedulerMemberSchedSapProvider::SchedDlTriggerReq (
const struct SchedDlTriggerReqParameters& params)
166 m_scheduler->DoSchedDlTriggerReq (params);
170 TdMtSchedulerMemberSchedSapProvider::SchedDlRachInfoReq (
const struct SchedDlRachInfoReqParameters& params)
172 m_scheduler->DoSchedDlRachInfoReq (params);
176 TdMtSchedulerMemberSchedSapProvider::SchedDlCqiInfoReq (
const struct SchedDlCqiInfoReqParameters& params)
178 m_scheduler->DoSchedDlCqiInfoReq (params);
182 TdMtSchedulerMemberSchedSapProvider::SchedUlTriggerReq (
const struct SchedUlTriggerReqParameters& params)
184 m_scheduler->DoSchedUlTriggerReq (params);
188 TdMtSchedulerMemberSchedSapProvider::SchedUlNoiseInterferenceReq (
const struct SchedUlNoiseInterferenceReqParameters& params)
190 m_scheduler->DoSchedUlNoiseInterferenceReq (params);
194 TdMtSchedulerMemberSchedSapProvider::SchedUlSrInfoReq (
const struct SchedUlSrInfoReqParameters& params)
196 m_scheduler->DoSchedUlSrInfoReq (params);
200 TdMtSchedulerMemberSchedSapProvider::SchedUlMacCtrlInfoReq (
const struct SchedUlMacCtrlInfoReqParameters& params)
202 m_scheduler->DoSchedUlMacCtrlInfoReq (params);
206 TdMtSchedulerMemberSchedSapProvider::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 TdMtFfMacScheduler::GetTypeId (
void)
250 .AddConstructor<TdMtFfMacScheduler> ()
251 .AddAttribute (
"CqiTimerThreshold",
252 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
254 MakeUintegerAccessor (&TdMtFfMacScheduler::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 (&TdMtFfMacScheduler::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 TdMtFfMacScheduler::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 TdMtFfMacScheduler::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 TdMtFfMacScheduler::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 TdMtFfMacScheduler::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 TdMtFfMacScheduler::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 TdMtFfMacScheduler::DoSchedDlPagingBufferReq (
const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params)
471 TdMtFfMacScheduler::DoSchedDlMacBufferReq (
const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params)
479 TdMtFfMacScheduler::GetRbgSize (
int dlbandwidth)
481 for (
int i = 0; i < 4; i++)
483 if (dlbandwidth < TdMtType0AllocationRbg[i])
494 TdMtFfMacScheduler::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;
948 std::set <uint16_t>::iterator it;
949 std::set <uint16_t>::iterator itMax = m_flowStatsDl.end ();
950 double metricMax = 0.0;
951 for (it = m_flowStatsDl.begin (); it != m_flowStatsDl.end (); it++)
953 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it));
957 if (itRnti != rntiAllocated.end ())
959 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it));
963 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it));
969 std::map <uint16_t,uint8_t>::iterator itTxMode;
970 itTxMode = m_uesTxMode.find ((*it));
971 if (itTxMode == m_uesTxMode.end ())
975 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
976 std::map <uint16_t,uint8_t>::iterator itCqi = m_p10CqiRxed.find ((*it));
978 if (itCqi != m_p10CqiRxed.end ())
980 wbCqi = (*itCqi).second;
990 if (LcActivePerFlow (*it) > 0)
993 double achievableRate = 0.0;
994 for (uint8_t k = 0; k < nLayer; k++)
997 mcs = m_amc->GetMcsFromCqi (wbCqi);
998 achievableRate += ((m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001);
1000 NS_LOG_DEBUG (
this <<
" RNTI " << (*it) <<
" MCS " << (uint32_t)mcs <<
" achievableRate " << achievableRate );
1003 double metric = achievableRate;
1005 if (metric > metricMax)
1016 if (itMax == m_flowStatsDl.end ())
1024 std::vector <uint16_t> tempMap;
1025 for (
int i = 0; i < rbgNum; i++)
1027 NS_LOG_INFO (
this <<
" ALLOCATION for RBG " << i <<
" of " << rbgNum);
1028 NS_LOG_DEBUG (
this <<
" ALLOCATION for RBG " << i <<
" of " << rbgNum);
1029 if (rbgMap.at (i) ==
false)
1031 rbgMap.at (i) =
true;
1032 tempMap.push_back (i);
1037 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax), tempMap));
1042 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1043 while (itMap != allocationMap.end ())
1046 BuildDataListElement_s newEl;
1047 newEl.m_rnti = (*itMap).first;
1049 DlDciListElement_s newDci;
1050 newDci.m_rnti = (*itMap).first;
1053 uint16_t lcActives = LcActivePerFlow ((*itMap).first);
1054 NS_LOG_INFO (
this <<
"Allocate user " << newEl.m_rnti <<
" rbg " << lcActives);
1055 uint16_t RgbPerRnti = (*itMap).second.size ();
1056 std::map <uint16_t,uint8_t>::iterator itCqi;
1057 itCqi = m_p10CqiRxed.find ((*itMap).first);
1058 std::map <uint16_t,uint8_t>::iterator itTxMode;
1059 itTxMode = m_uesTxMode.find ((*itMap).first);
1060 if (itTxMode == m_uesTxMode.end ())
1062 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1064 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1065 for (uint8_t j = 0; j < nLayer; j++)
1067 if (itCqi == m_p10CqiRxed.end ())
1069 newDci.m_mcs.push_back (0);
1073 newDci.m_mcs.push_back ( m_amc->GetMcsFromCqi ((*itCqi).second) );
1076 int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1077 newDci.m_tbsSize.push_back (tbSize);
1080 newDci.m_resAlloc = 0;
1081 newDci.m_rbBitmap = 0;
1082 uint32_t rbgMask = 0;
1083 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1085 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1086 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1088 newDci.m_rbBitmap = rbgMask;
1091 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1092 for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
1094 if (((*itBufReq).first.m_rnti == (*itMap).first)
1095 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1096 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1097 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1099 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1100 for (uint8_t j = 0; j < nLayer; j++)
1102 RlcPduListElement_s newRlcEl;
1103 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1104 newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
1105 NS_LOG_INFO (
this <<
" LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity <<
" size " << newRlcEl.m_size <<
" layer " << (uint16_t)j);
1106 newRlcPduLe.push_back (newRlcEl);
1107 UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
1111 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find ((*itMap).first);
1112 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
1114 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1116 (*itRlcPdu).second.at (j).at (newDci.m_harqProcess).push_back (newRlcEl);
1119 newEl.m_rlcPduList.push_back (newRlcPduLe);
1121 if ((*itBufReq).first.m_rnti > (*itMap).first)
1126 for (uint8_t j = 0; j < nLayer; j++)
1128 newDci.m_ndi.push_back (1);
1129 newDci.m_rv.push_back (0);
1132 newEl.m_dci = newDci;
1137 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci = m_dlHarqProcessesDciBuffer.find (newEl.m_rnti);
1138 if (itDci == m_dlHarqProcessesDciBuffer.end ())
1140 NS_FATAL_ERROR (
"Unable to find RNTI entry in DCI HARQ buffer for RNTI " << newEl.m_rnti);
1142 (*itDci).second.at (newDci.m_harqProcess) = newDci;
1144 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (newEl.m_rnti);
1145 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
1147 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1149 (*itHarqTimer).second.at (newDci.m_harqProcess) = 0;
1154 ret.m_buildDataList.push_back (newEl);
1158 ret.m_nrOfPdcchOfdmSymbols = 1;
1160 m_schedSapUser->SchedDlConfigInd (ret);
1167 TdMtFfMacScheduler::DoSchedDlRachInfoReq (
const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params)
1171 m_rachList = params.m_rachList;
1177 TdMtFfMacScheduler::DoSchedDlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
1181 for (
unsigned int i = 0; i < params.m_cqiList.size (); i++)
1183 if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
1186 std::map <uint16_t,uint8_t>::iterator it;
1187 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1188 it = m_p10CqiRxed.find (rnti);
1189 if (it == m_p10CqiRxed.end ())
1192 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) );
1194 m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1199 (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
1201 std::map <uint16_t,uint32_t>::iterator itTimers;
1202 itTimers = m_p10CqiTimers.find (rnti);
1203 (*itTimers).second = m_cqiTimersThreshold;
1206 else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
1209 std::map <uint16_t,SbMeasResult_s>::iterator it;
1210 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1211 it = m_a30CqiRxed.find (rnti);
1212 if (it == m_a30CqiRxed.end ())
1215 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
1216 m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1221 (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
1222 std::map <uint16_t,uint32_t>::iterator itTimers;
1223 itTimers = m_a30CqiTimers.find (rnti);
1224 (*itTimers).second = m_cqiTimersThreshold;
1238 TdMtFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
1240 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
1241 if (itCqi == m_ueCqi.end ())
1252 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1254 double sinr = (*itCqi).second.at (i);
1255 if (sinr != NO_SINR)
1261 double estimatedSinr = sinrSum / (double)sinrNum;
1263 (*itCqi).second.at (rb) = estimatedSinr;
1264 return (estimatedSinr);
1269 TdMtFfMacScheduler::DoSchedUlTriggerReq (
const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
1271 NS_LOG_FUNCTION (
this <<
" UL - Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf) <<
" size " << params.m_ulInfoList.size ());
1273 RefreshUlCqiMaps ();
1276 FfMacSchedSapUser::SchedUlConfigIndParameters ret;
1277 std::vector <bool> rbMap;
1278 uint16_t rbAllocatedNum = 0;
1279 std::set <uint16_t> rntiAllocated;
1280 std::vector <uint16_t> rbgAllocationMap;
1282 rbgAllocationMap = m_rachAllocationMap;
1284 m_rachAllocationMap.clear ();
1285 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1287 rbMap.resize (m_cschedCellConfig.m_ulBandwidth,
false);
1289 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1291 if (rbgAllocationMap.at (i) != 0)
1293 rbMap.at (i) =
true;
1303 std::map <uint16_t, uint8_t>::iterator itProcId;
1304 for (itProcId = m_ulHarqCurrentProcessId.begin (); itProcId != m_ulHarqCurrentProcessId.end (); itProcId++)
1306 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
1309 for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
1311 if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
1314 uint16_t rnti = params.m_ulInfoList.at (i).m_rnti;
1315 itProcId = m_ulHarqCurrentProcessId.find (rnti);
1316 if (itProcId == m_ulHarqCurrentProcessId.end ())
1318 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1320 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1321 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.m_ulInfoList.size ());
1322 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
1323 if (itHarq == m_ulHarqProcessesDciBuffer.end ())
1325 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1328 UlDciListElement_s dci = (*itHarq).second.at (harqId);
1329 std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (rnti);
1330 if (itStat == m_ulHarqProcessesStatus.end ())
1332 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1334 if ((*itStat).second.at (harqId) >= 3)
1336 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1340 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1342 if (rbMap.at (j) ==
true)
1351 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1353 rbMap.at (j) =
true;
1354 rbgAllocationMap.at (j) = dci.m_rnti;
1358 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);
1362 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1367 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1368 (*itStat).second.at (harqId) = 0;
1369 (*itHarq).second.at ((*itProcId).second) = dci;
1370 ret.m_dciList.push_back (dci);
1371 rntiAllocated.insert (dci.m_rnti);
1375 NS_LOG_INFO (
this <<
" HARQ-ACK feedback from RNTI " << params.m_ulInfoList.at (i).m_rnti);
1380 std::map <uint16_t,uint32_t>::iterator it;
1383 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1385 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1387 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1395 if (ret.m_dciList.size () > 0)
1397 m_schedSapUser->SchedUlConfigInd (ret);
1405 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size ());
1410 int rbAllocated = 0;
1412 if (m_nextRntiUl != 0)
1414 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1416 if ((*it).first == m_nextRntiUl)
1421 if (it == m_ceBsrRxed.end ())
1428 it = m_ceBsrRxed.begin ();
1429 m_nextRntiUl = (*it).first;
1433 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1434 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1438 if (it == m_ceBsrRxed.end ())
1441 it = m_ceBsrRxed.begin ();
1445 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1448 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1457 UlDciListElement_s uldci;
1458 uldci.m_rnti = (*it).first;
1459 uldci.m_rbLen = rbPerFlow;
1460 bool allocated =
false;
1461 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow);
1462 while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0))
1466 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1468 if (rbMap.at (j) ==
true)
1476 uldci.m_rbStart = rbAllocated;
1478 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1480 rbMap.at (j) =
true;
1482 rbgAllocationMap.at (j) = (*it).first;
1484 rbAllocated += rbPerFlow;
1489 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1492 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1504 m_nextRntiUl = (*it).first;
1505 if (ret.m_dciList.size () > 0)
1507 m_schedSapUser->SchedUlConfigInd (ret);
1509 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1515 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
1517 if (itCqi == m_ueCqi.end ())
1525 double minSinr = (*itCqi).second.at (uldci.m_rbStart);
1526 if (minSinr == NO_SINR)
1528 minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
1530 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1532 double sinr = (*itCqi).second.at (i);
1533 if (sinr == NO_SINR)
1535 sinr = EstimateUlSinr ((*it).first, i);
1537 if ((*itCqi).second.at (i) < minSinr)
1539 minSinr = (*itCqi).second.at (i);
1544 double s = log2 ( 1 + (
1545 pow (10, minSinr / 10 ) /
1546 ( (-log (5.0 * 0.00005 )) / 1.5) ));
1547 cqi = m_amc->GetCqiFromSpectralEfficiency (s);
1551 if (it == m_ceBsrRxed.end ())
1554 it = m_ceBsrRxed.begin ();
1558 uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
1561 uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
1562 UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
1564 uldci.m_cceIndex = 0;
1565 uldci.m_aggrLevel = 1;
1566 uldci.m_ueTxAntennaSelection = 3;
1567 uldci.m_hopping =
false;
1570 uldci.m_cqiRequest =
false;
1571 uldci.m_ulIndex = 0;
1573 uldci.m_freqHopping = 0;
1574 uldci.m_pdcchPowerOffset = 0;
1575 ret.m_dciList.push_back (uldci);
1580 std::map <uint16_t, uint8_t>::iterator itProcId;
1581 itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
1582 if (itProcId == m_ulHarqCurrentProcessId.end ())
1584 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << uldci.m_rnti);
1586 harqId = (*itProcId).second;
1587 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
1588 if (itDci == m_ulHarqProcessesDciBuffer.end ())
1590 NS_FATAL_ERROR (
"Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
1592 (*itDci).second.at (harqId) = uldci;
1595 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);
1599 if (it == m_ceBsrRxed.end ())
1602 it = m_ceBsrRxed.begin ();
1604 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1607 m_nextRntiUl = (*it).first;
1611 while (((*it).first != m_nextRntiUl)&&(rbPerFlow!=0));
1614 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1615 m_schedSapUser->SchedUlConfigInd (ret);
1621 TdMtFfMacScheduler::DoSchedUlNoiseInterferenceReq (
const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params)
1628 TdMtFfMacScheduler::DoSchedUlSrInfoReq (
const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params)
1635 TdMtFfMacScheduler::DoSchedUlMacCtrlInfoReq (
const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
1639 std::map <uint16_t,uint32_t>::iterator it;
1641 for (
unsigned int i = 0; i < params.m_macCeList.size (); i++)
1643 if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
1652 uint32_t buffer = 0;
1653 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1655 uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1656 buffer += BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
1659 uint16_t rnti = params.m_macCeList.at (i).m_rnti;
1660 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1661 it = m_ceBsrRxed.find (rnti);
1662 if (it == m_ceBsrRxed.end ())
1665 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1670 (*it).second = buffer;
1679 TdMtFfMacScheduler::DoSchedUlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
1683 switch (m_ulCqiFilter)
1685 case FfMacScheduler::SRS_UL_CQI:
1688 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1694 case FfMacScheduler::PUSCH_UL_CQI:
1697 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1702 case FfMacScheduler::ALL_UL_CQI:
1709 switch (params.m_ulCqi.m_type)
1711 case UlCqi_s::PUSCH:
1713 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1714 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1715 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
1716 itMap = m_allocationMaps.find (params.m_sfnSf);
1717 if (itMap == m_allocationMaps.end ())
1721 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1724 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
1725 itCqi = m_ueCqi.find ((*itMap).second.at (i));
1726 if (itCqi == m_ueCqi.end ())
1729 std::vector <double> newCqi;
1730 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1734 newCqi.push_back (sinr);
1739 newCqi.push_back (NO_SINR);
1743 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
1745 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
1750 (*itCqi).second.at (i) = sinr;
1751 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
1753 std::map <uint16_t, uint32_t>::iterator itTimers;
1754 itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
1755 (*itTimers).second = m_cqiTimersThreshold;
1761 m_allocationMaps.erase (itMap);
1768 NS_ASSERT (params.m_vendorSpecificList.size () > 0);
1769 for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
1771 if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
1773 Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
1774 rnti = vsp->GetRnti ();
1777 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1778 itCqi = m_ueCqi.find (rnti);
1779 if (itCqi == m_ueCqi.end ())
1782 std::vector <double> newCqi;
1783 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1785 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1786 newCqi.push_back (sinr);
1787 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
1790 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
1792 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1797 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1799 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1800 (*itCqi).second.at (j) = sinr;
1801 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
1804 std::map <uint16_t, uint32_t>::iterator itTimers;
1805 itTimers = m_ueCqiTimers.find (rnti);
1806 (*itTimers).second = m_cqiTimersThreshold;
1813 case UlCqi_s::PUCCH_1:
1814 case UlCqi_s::PUCCH_2:
1815 case UlCqi_s::PRACH:
1817 NS_FATAL_ERROR (
"TdMtFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1827 TdMtFfMacScheduler::RefreshDlCqiMaps (
void)
1830 std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
1831 while (itP10 != m_p10CqiTimers.end ())
1833 NS_LOG_INFO (
this <<
" P10-CQI for user " << (*itP10).first <<
" is " << (uint32_t)(*itP10).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1834 if ((*itP10).second == 0)
1837 std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
1838 NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (),
" Does not find CQI report for user " << (*itP10).first);
1839 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
1840 m_p10CqiRxed.erase (itMap);
1841 std::map <uint16_t,uint32_t>::iterator temp = itP10;
1843 m_p10CqiTimers.erase (temp);
1853 std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
1854 while (itA30 != m_a30CqiTimers.end ())
1856 NS_LOG_INFO (
this <<
" A30-CQI for user " << (*itA30).first <<
" is " << (uint32_t)(*itA30).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1857 if ((*itA30).second == 0)
1860 std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
1861 NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (),
" Does not find CQI report for user " << (*itA30).first);
1862 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
1863 m_a30CqiRxed.erase (itMap);
1864 std::map <uint16_t,uint32_t>::iterator temp = itA30;
1866 m_a30CqiTimers.erase (temp);
1880 TdMtFfMacScheduler::RefreshUlCqiMaps (
void)
1883 std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
1884 while (itUl != m_ueCqiTimers.end ())
1886 NS_LOG_INFO (
this <<
" UL-CQI for user " << (*itUl).first <<
" is " << (uint32_t)(*itUl).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1887 if ((*itUl).second == 0)
1890 std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
1891 NS_ASSERT_MSG (itMap != m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
1892 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
1893 (*itMap).second.clear ();
1894 m_ueCqi.erase (itMap);
1895 std::map <uint16_t,uint32_t>::iterator temp = itUl;
1897 m_ueCqiTimers.erase (temp);
1910 TdMtFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
1912 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
1913 LteFlowId_t flow (rnti, lcid);
1914 it = m_rlcBufferReq.find (flow);
1915 if (it != m_rlcBufferReq.end ())
1917 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);
1920 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
1922 (*it).second.m_rlcStatusPduSize = 0;
1924 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
1926 (*it).second.m_rlcRetransmissionQueueSize = 0;
1928 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
1931 if ((*it).second.m_rlcTransmissionQueueSize <= size)
1933 (*it).second.m_rlcTransmissionQueueSize = 0;
1938 (*it).second.m_rlcTransmissionQueueSize -= size;
1944 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
1949 TdMtFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
1953 std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
1954 if (it != m_ceBsrRxed.end ())
1956 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
1957 if ((*it).second >= size)
1959 (*it).second -= size;
1968 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
1974 TdMtFfMacScheduler::TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode)
1976 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
1977 FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params;
1978 params.m_rnti = rnti;
1979 params.m_transmissionMode = txMode;
1980 m_cschedSapUser->CschedUeConfigUpdateInd (params);
#define NS_LOG_FUNCTION(parameters)
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual ~TdMtFfMacScheduler()
See section 4.3.10 buildRARListElement.
#define NS_FATAL_ERROR(msg)
fatal error handling
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
Hold an unsigned integer type.
#define NS_LOG_LOGIC(msg)
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
#define NS_ASSERT_MSG(condition, message)
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
#define NS_LOG_DEBUG(msg)
#define NS_LOG_ERROR(msg)
TdMtFfMacScheduler()
Constructor.
virtual void DoDispose(void)
Implements the SCHED SAP and CSCHED SAP for a Time Domain Maximize Throughput scheduler.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.