23 #include <ns3/pointer.h>
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/fdbet-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
37 int FdBetType0AllocationRbg[4] = {
45 NS_OBJECT_ENSURE_REGISTERED (FdBetFfMacScheduler);
66 FdBetSchedulerMemberCschedSapProvider::FdBetSchedulerMemberCschedSapProvider ()
70 FdBetSchedulerMemberCschedSapProvider::FdBetSchedulerMemberCschedSapProvider (FdBetFfMacScheduler* scheduler) : m_scheduler (scheduler)
78 m_scheduler->DoCschedCellConfigReq (params);
82 FdBetSchedulerMemberCschedSapProvider::CschedUeConfigReq (
const struct CschedUeConfigReqParameters& params)
84 m_scheduler->DoCschedUeConfigReq (params);
89 FdBetSchedulerMemberCschedSapProvider::CschedLcConfigReq (
const struct CschedLcConfigReqParameters& params)
91 m_scheduler->DoCschedLcConfigReq (params);
95 FdBetSchedulerMemberCschedSapProvider::CschedLcReleaseReq (
const struct CschedLcReleaseReqParameters& params)
97 m_scheduler->DoCschedLcReleaseReq (params);
101 FdBetSchedulerMemberCschedSapProvider::CschedUeReleaseReq (
const struct CschedUeReleaseReqParameters& params)
103 m_scheduler->DoCschedUeReleaseReq (params);
135 FdBetSchedulerMemberSchedSapProvider::FdBetSchedulerMemberSchedSapProvider ()
140 FdBetSchedulerMemberSchedSapProvider::FdBetSchedulerMemberSchedSapProvider (FdBetFfMacScheduler* scheduler)
141 : m_scheduler (scheduler)
146 FdBetSchedulerMemberSchedSapProvider::SchedDlRlcBufferReq (
const struct SchedDlRlcBufferReqParameters& params)
148 m_scheduler->DoSchedDlRlcBufferReq (params);
152 FdBetSchedulerMemberSchedSapProvider::SchedDlPagingBufferReq (
const struct SchedDlPagingBufferReqParameters& params)
154 m_scheduler->DoSchedDlPagingBufferReq (params);
158 FdBetSchedulerMemberSchedSapProvider::SchedDlMacBufferReq (
const struct SchedDlMacBufferReqParameters& params)
160 m_scheduler->DoSchedDlMacBufferReq (params);
164 FdBetSchedulerMemberSchedSapProvider::SchedDlTriggerReq (
const struct SchedDlTriggerReqParameters& params)
166 m_scheduler->DoSchedDlTriggerReq (params);
170 FdBetSchedulerMemberSchedSapProvider::SchedDlRachInfoReq (
const struct SchedDlRachInfoReqParameters& params)
172 m_scheduler->DoSchedDlRachInfoReq (params);
176 FdBetSchedulerMemberSchedSapProvider::SchedDlCqiInfoReq (
const struct SchedDlCqiInfoReqParameters& params)
178 m_scheduler->DoSchedDlCqiInfoReq (params);
182 FdBetSchedulerMemberSchedSapProvider::SchedUlTriggerReq (
const struct SchedUlTriggerReqParameters& params)
184 m_scheduler->DoSchedUlTriggerReq (params);
188 FdBetSchedulerMemberSchedSapProvider::SchedUlNoiseInterferenceReq (
const struct SchedUlNoiseInterferenceReqParameters& params)
190 m_scheduler->DoSchedUlNoiseInterferenceReq (params);
194 FdBetSchedulerMemberSchedSapProvider::SchedUlSrInfoReq (
const struct SchedUlSrInfoReqParameters& params)
196 m_scheduler->DoSchedUlSrInfoReq (params);
200 FdBetSchedulerMemberSchedSapProvider::SchedUlMacCtrlInfoReq (
const struct SchedUlMacCtrlInfoReqParameters& params)
202 m_scheduler->DoSchedUlMacCtrlInfoReq (params);
206 FdBetSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (
const struct SchedUlCqiInfoReqParameters& params)
208 m_scheduler->DoSchedUlCqiInfoReq (params);
216 : m_cschedSapUser (0),
221 m_amc = CreateObject <LteAmc> ();
235 m_dlHarqProcessesDciBuffer.clear ();
236 m_dlHarqProcessesTimer.clear ();
237 m_dlHarqProcessesRlcPduListBuffer.clear ();
238 m_dlInfoListBuffered.clear ();
239 m_ulHarqCurrentProcessId.clear ();
240 m_ulHarqProcessesStatus.clear ();
241 m_ulHarqProcessesDciBuffer.clear ();
242 delete m_cschedSapProvider;
243 delete m_schedSapProvider;
247 FdBetFfMacScheduler::GetTypeId (
void)
251 .AddConstructor<FdBetFfMacScheduler> ()
252 .AddAttribute (
"CqiTimerThreshold",
253 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
255 MakeUintegerAccessor (&FdBetFfMacScheduler::m_cqiTimersThreshold),
256 MakeUintegerChecker<uint32_t> ())
257 .AddAttribute (
"HarqEnabled",
258 "Activate/Deactivate the HARQ [by default is active].",
261 MakeBooleanChecker ())
262 .AddAttribute (
"UlGrantMcs",
263 "The MCS of the UL grant, must be [0..15] (default 0)",
265 MakeUintegerAccessor (&FdBetFfMacScheduler::m_ulGrantMcs),
266 MakeUintegerChecker<uint8_t> ())
288 return m_cschedSapProvider;
294 return m_schedSapProvider;
302 m_cschedCellConfig = params;
303 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
305 cnf.m_result = SUCCESS;
306 m_cschedSapUser->CschedUeConfigCnf (cnf);
311 FdBetFfMacScheduler::DoCschedUeConfigReq (
const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params)
313 NS_LOG_FUNCTION (
this <<
" RNTI " << params.m_rnti <<
" txMode " << (uint16_t)params.m_transmissionMode);
314 std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
315 if (it == m_uesTxMode.end ())
317 m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
319 m_dlHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
320 DlHarqProcessesStatus_t dlHarqPrcStatus;
321 dlHarqPrcStatus.resize (8,0);
322 m_dlHarqProcessesStatus.insert (std::pair <uint16_t, DlHarqProcessesStatus_t> (params.m_rnti, dlHarqPrcStatus));
323 DlHarqProcessesTimer_t dlHarqProcessesTimer;
324 dlHarqProcessesTimer.resize (8,0);
325 m_dlHarqProcessesTimer.insert (std::pair <uint16_t, DlHarqProcessesTimer_t> (params.m_rnti, dlHarqProcessesTimer));
326 DlHarqProcessesDciBuffer_t dlHarqdci;
327 dlHarqdci.resize (8);
328 m_dlHarqProcessesDciBuffer.insert (std::pair <uint16_t, DlHarqProcessesDciBuffer_t> (params.m_rnti, dlHarqdci));
329 DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
330 dlHarqRlcPdu.resize (2);
331 dlHarqRlcPdu.at (0).resize (8);
332 dlHarqRlcPdu.at (1).resize (8);
333 m_dlHarqProcessesRlcPduListBuffer.insert (std::pair <uint16_t, DlHarqRlcPduListBuffer_t> (params.m_rnti, dlHarqRlcPdu));
334 m_ulHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
335 UlHarqProcessesStatus_t ulHarqPrcStatus;
336 ulHarqPrcStatus.resize (8,0);
337 m_ulHarqProcessesStatus.insert (std::pair <uint16_t, UlHarqProcessesStatus_t> (params.m_rnti, ulHarqPrcStatus));
338 UlHarqProcessesDciBuffer_t ulHarqdci;
339 ulHarqdci.resize (8);
340 m_ulHarqProcessesDciBuffer.insert (std::pair <uint16_t, UlHarqProcessesDciBuffer_t> (params.m_rnti, ulHarqdci));
344 (*it).second = params.m_transmissionMode;
350 FdBetFfMacScheduler::DoCschedLcConfigReq (
const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params)
354 std::map <uint16_t, fdbetsFlowPerf_t>::iterator it;
355 for (uint16_t i = 0; i < params.m_logicalChannelConfigList.size (); i++)
357 it = m_flowStatsDl.find (params.m_rnti);
359 if (it == m_flowStatsDl.end ())
361 fdbetsFlowPerf_t flowStatsDl;
363 flowStatsDl.totalBytesTransmitted = 0;
364 flowStatsDl.lastTtiBytesTrasmitted = 0;
365 flowStatsDl.lastAveragedThroughput = 1;
366 m_flowStatsDl.insert (std::pair<uint16_t, fdbetsFlowPerf_t> (params.m_rnti, flowStatsDl));
367 fdbetsFlowPerf_t flowStatsUl;
369 flowStatsUl.totalBytesTransmitted = 0;
370 flowStatsUl.lastTtiBytesTrasmitted = 0;
371 flowStatsUl.lastAveragedThroughput = 1;
372 m_flowStatsUl.insert (std::pair<uint16_t, fdbetsFlowPerf_t> (params.m_rnti, flowStatsUl));
384 FdBetFfMacScheduler::DoCschedLcReleaseReq (
const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params)
387 for (uint16_t i = 0; i < params.m_logicalChannelIdentity.size (); i++)
389 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
390 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
391 while (it!=m_rlcBufferReq.end ())
393 if (((*it).first.m_rnti == params.m_rnti) && ((*it).first.m_lcId == params.m_logicalChannelIdentity.at (i)))
397 m_rlcBufferReq.erase (temp);
409 FdBetFfMacScheduler::DoCschedUeReleaseReq (
const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params)
413 m_uesTxMode.erase (params.m_rnti);
414 m_dlHarqCurrentProcessId.erase (params.m_rnti);
415 m_dlHarqProcessesStatus.erase (params.m_rnti);
416 m_dlHarqProcessesTimer.erase (params.m_rnti);
417 m_dlHarqProcessesDciBuffer.erase (params.m_rnti);
418 m_dlHarqProcessesRlcPduListBuffer.erase (params.m_rnti);
419 m_ulHarqCurrentProcessId.erase (params.m_rnti);
420 m_ulHarqProcessesStatus.erase (params.m_rnti);
421 m_ulHarqProcessesDciBuffer.erase (params.m_rnti);
422 m_flowStatsDl.erase (params.m_rnti);
423 m_flowStatsUl.erase (params.m_rnti);
424 m_ceBsrRxed.erase (params.m_rnti);
425 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
426 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
427 while (it!=m_rlcBufferReq.end ())
429 if ((*it).first.m_rnti == params.m_rnti)
433 m_rlcBufferReq.erase (temp);
440 if (m_nextRntiUl == params.m_rnti)
450 FdBetFfMacScheduler::DoSchedDlRlcBufferReq (
const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params)
452 NS_LOG_FUNCTION (
this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
455 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
457 LteFlowId_t flow (params.m_rnti, params.m_logicalChannelIdentity);
459 it = m_rlcBufferReq.find (flow);
461 if (it == m_rlcBufferReq.end ())
463 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
467 (*it).second = params;
474 FdBetFfMacScheduler::DoSchedDlPagingBufferReq (
const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params)
482 FdBetFfMacScheduler::DoSchedDlMacBufferReq (
const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params)
490 FdBetFfMacScheduler::GetRbgSize (
int dlbandwidth)
492 for (
int i = 0; i < 4; i++)
494 if (dlbandwidth < FdBetType0AllocationRbg[i])
505 FdBetFfMacScheduler::LcActivePerFlow (uint16_t rnti)
507 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
509 for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
511 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
512 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
513 || ((*it).second.m_rlcStatusPduSize > 0) ))
517 if ((*it).first.m_rnti > rnti)
532 std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
533 if (it == m_dlHarqCurrentProcessId.end ())
537 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
538 if (itStat == m_dlHarqProcessesStatus.end ())
540 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
542 uint8_t i = (*it).second;
545 i = (i + 1) % HARQ_PROC_NUM;
547 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
548 if ((*itStat).second.at (i) == 0)
571 std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
572 if (it == m_dlHarqCurrentProcessId.end ())
576 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
577 if (itStat == m_dlHarqProcessesStatus.end ())
579 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
581 uint8_t i = (*it).second;
584 i = (i + 1) % HARQ_PROC_NUM;
586 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
587 if ((*itStat).second.at (i) == 0)
590 (*itStat).second.at (i) = 1;
594 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
597 return ((*it).second);
606 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
607 for (itTimers = m_dlHarqProcessesTimer.begin (); itTimers != m_dlHarqProcessesTimer.end (); itTimers ++)
609 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
611 if ((*itTimers).second.at (i) == HARQ_DL_TIMEOUT)
615 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
616 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find ((*itTimers).first);
617 if (itStat == m_dlHarqProcessesStatus.end ())
619 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
621 (*itStat).second.at (i) = 0;
622 (*itTimers).second.at (i) = 0;
626 (*itTimers).second.at (i)++;
637 NS_LOG_FUNCTION (
this <<
" Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
647 int rbgSize = GetRbgSize (m_cschedCellConfig.m_dlBandwidth);
648 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
649 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
650 std::vector <bool> rbgMap;
651 uint16_t rbgAllocatedNum = 0;
652 std::set <uint16_t> rntiAllocated;
653 rbgMap.resize (m_cschedCellConfig.m_dlBandwidth / rbgSize,
false);
657 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
658 uint16_t rbStart = 0;
659 std::vector <struct RachListElement_s>::iterator itRach;
660 for (itRach = m_rachList.begin (); itRach != m_rachList.end (); itRach++)
662 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");
664 newRar.m_rnti = (*itRach).m_rnti;
668 newRar.m_grant.m_rnti = newRar.m_rnti;
669 newRar.m_grant.m_mcs = m_ulGrantMcs;
671 uint16_t tbSizeBits = 0;
673 while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < m_cschedCellConfig.m_ulBandwidth))
676 tbSizeBits = m_amc->GetTbSizeFromMcs (m_ulGrantMcs, rbLen);
678 if (tbSizeBits < (*itRach).m_estimatedSize)
683 newRar.m_grant.m_rbStart = rbStart;
684 newRar.m_grant.m_rbLen = rbLen;
685 newRar.m_grant.m_tbSize = tbSizeBits / 8;
686 newRar.m_grant.m_hopping =
false;
687 newRar.m_grant.m_tpc = 0;
688 newRar.m_grant.m_cqiRequest =
false;
689 newRar.m_grant.m_ulDelay =
false;
690 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);
691 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
693 m_rachAllocationMap.at (i) = (*itRach).m_rnti;
695 rbStart = rbStart + rbLen;
697 ret.m_buildRarList.push_back (newRar);
705 if (m_dlInfoListBuffered.size () > 0)
707 if (params.m_dlInfoList.size () > 0)
709 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
710 m_dlInfoListBuffered.insert (m_dlInfoListBuffered.end (), params.m_dlInfoList.begin (), params.m_dlInfoList.end ());
715 if (params.m_dlInfoList.size () > 0)
717 m_dlInfoListBuffered = params.m_dlInfoList;
723 m_dlInfoListBuffered.clear ();
725 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
726 for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
728 std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
729 if (itRnti != rntiAllocated.end ())
734 uint8_t nLayers = m_dlInfoListBuffered.at (i).m_harqStatus.size ();
735 std::vector <bool> retx;
736 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
739 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
740 retx.push_back (
false);
744 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
745 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (1) == DlInfoListElement_s::NACK);
747 if (retx.at (0) || retx.at (1))
750 uint16_t rnti = m_dlInfoListBuffered.at (i).m_rnti;
751 uint8_t harqId = m_dlInfoListBuffered.at (i).m_harqProcessId;
752 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
753 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq = m_dlHarqProcessesDciBuffer.find (rnti);
754 if (itHarq == m_dlHarqProcessesDciBuffer.end ())
759 DlDciListElement_s dci = (*itHarq).second.at (harqId);
761 if (dci.m_rv.size () == 1)
763 rv = dci.m_rv.at (0);
767 rv = (dci.m_rv.at (0) > dci.m_rv.at (1) ? dci.m_rv.at (0) : dci.m_rv.at (1));
773 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
774 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (rnti);
775 if (it == m_dlHarqProcessesStatus.end ())
777 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at (i).m_rnti);
779 (*it).second.at (harqId) = 0;
780 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
781 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
783 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
785 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
787 (*itRlcPdu).second.at (k).at (harqId).clear ();
793 std::vector <int> dciRbg;
795 NS_LOG_INFO (
"Original RBGs " << dci.m_rbBitmap <<
" rnti " << dci.m_rnti);
796 for (
int j = 0; j < 32; j++)
798 if (((dci.m_rbBitmap & mask) >> j) == 1)
800 dciRbg.push_back (j);
806 for (uint8_t j = 0; j < dciRbg.size (); j++)
808 if (rbgMap.at (dciRbg.at (j)) ==
true)
818 for (uint8_t j = 0; j < dciRbg.size (); j++)
820 rbgMap.at (dciRbg.at (j)) =
true;
821 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
825 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
831 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
832 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
833 std::vector <bool> rbgMapCopy = rbgMap;
834 while ((j < dciRbg.size ())&&(startRbg != rbgId))
836 if (rbgMapCopy.at (rbgId) ==
false)
838 rbgMapCopy.at (rbgId) =
true;
839 dciRbg.at (j) = rbgId;
844 if (j == dciRbg.size ())
847 uint32_t rbgMask = 0;
848 for (uint16_t k = 0; k < dciRbg.size (); k++)
850 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
853 dci.m_rbBitmap = rbgMask;
855 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
860 dlInfoListUntxed.push_back (params.m_dlInfoList.at (i));
861 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
865 BuildDataListElement_s newEl;
866 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
867 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
869 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
871 for (uint8_t j = 0; j < nLayers; j++)
875 if (j >= dci.m_ndi.size ())
878 dci.m_ndi.push_back (0);
879 dci.m_rv.push_back (0);
880 dci.m_mcs.push_back (0);
881 dci.m_tbsSize.push_back (0);
882 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
886 dci.m_ndi.at (j) = 0;
888 (*itHarq).second.at (harqId).m_rv.at (j)++;
889 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.m_rv.at (j));
895 dci.m_ndi.at (j) = 0;
897 dci.m_mcs.at (j) = 0;
898 dci.m_tbsSize.at (j) = 0;
899 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
902 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.m_harqProcess).size (); k++)
904 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
905 for (uint8_t j = 0; j < nLayers; j++)
909 if (j < dci.m_ndi.size ())
911 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.m_harqProcess).at (k));
916 if (rlcPduListPerLc.size () > 0)
918 newEl.m_rlcPduList.push_back (rlcPduListPerLc);
923 (*itHarq).second.at (harqId).m_rv = dci.m_rv;
925 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (rnti);
926 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
928 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
930 (*itHarqTimer).second.at (harqId) = 0;
931 ret.m_buildDataList.push_back (newEl);
932 rntiAllocated.insert (rnti);
937 NS_LOG_INFO (
this <<
" HARQ received ACK for UE " << m_dlInfoListBuffered.at (i).m_rnti);
938 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (m_dlInfoListBuffered.at (i).m_rnti);
939 if (it == m_dlHarqProcessesStatus.end ())
941 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at (i).m_rnti);
943 (*it).second.at (m_dlInfoListBuffered.at (i).m_harqProcessId) = 0;
944 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (m_dlInfoListBuffered.at (i).m_rnti);
945 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
947 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
949 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
951 (*itRlcPdu).second.at (k).at (m_dlInfoListBuffered.at (i).m_harqProcessId).clear ();
955 m_dlInfoListBuffered.clear ();
956 m_dlInfoListBuffered = dlInfoListUntxed;
958 std::map <uint16_t, fdbetsFlowPerf_t>::iterator itFlow;
959 std::map <uint16_t, double> estAveThr;
960 std::map <uint16_t, double>::iterator itMax = estAveThr.end ();
961 std::map <uint16_t, double>::iterator it;
962 std::map <uint16_t, int> rbgPerRntiLog;
963 double metricMax = 0.0;
964 for (itFlow = m_flowStatsDl.begin (); itFlow != m_flowStatsDl.end (); itFlow++)
966 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*itFlow).first);
970 if (itRnti != rntiAllocated.end ())
972 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*itFlow).first);
976 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*itFlow).first);
981 estAveThr.insert (std::pair <uint16_t, double> ((*itFlow).first, (*itFlow).second.lastAveragedThroughput));
984 if (estAveThr.size () != 0)
987 for (it = estAveThr.begin (); it != estAveThr.end (); it++)
989 double metric = 1 / (*it).second;
990 if (metric > metricMax)
995 rbgPerRntiLog.insert (std::pair<uint16_t, int> ((*it).first, 1));
1003 NS_LOG_INFO (
this <<
" ALLOCATION for RBG " << i <<
" of " << rbgNum);
1004 if (rbgMap.at (i) ==
false)
1007 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1008 std::vector <uint16_t> tempMap;
1009 itMap = allocationMap.find ((*itMax).first);
1010 if (itMap == allocationMap.end ())
1012 tempMap.push_back (i);
1013 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1017 (*itMap).second.push_back (i);
1021 std::map <uint16_t,uint8_t>::iterator itCqi;
1022 itCqi = m_p10CqiRxed.find ((*itMax).first);
1023 std::map <uint16_t,uint8_t>::iterator itTxMode;
1024 itTxMode = m_uesTxMode.find ((*itMax).first);
1025 if (itTxMode == m_uesTxMode.end ())
1027 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMax).first);
1029 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1030 std::vector <uint8_t> mcs;
1031 for (uint8_t j = 0; j < nLayer; j++)
1033 if (itCqi == m_p10CqiRxed.end ())
1039 mcs.push_back (m_amc->GetMcsFromCqi ((*itCqi).second));
1043 std::map <uint16_t,int>::iterator itRbgPerRntiLog;
1044 itRbgPerRntiLog = rbgPerRntiLog.find ((*itMax).first);
1045 std::map <uint16_t, fdbetsFlowPerf_t>::iterator itPastAveThr;
1046 itPastAveThr = m_flowStatsDl.find ((*itMax).first);
1047 uint32_t bytesTxed = 0;
1048 for (uint8_t j = 0; j < nLayer; j++)
1050 int tbSize = (m_amc->GetTbSizeFromMcs (mcs.at (0), (*itRbgPerRntiLog).second * rbgSize) / 8);
1051 bytesTxed += tbSize;
1053 double expectedAveThr = ((1.0 - (1.0 / m_timeWindow)) * (*itPastAveThr).second.lastAveragedThroughput) + ((1.0 / m_timeWindow) * (double)(bytesTxed / 0.001));
1055 int rbgPerRnti = (*itRbgPerRntiLog).second;
1057 rbgPerRntiLog[(*itMax).first] = rbgPerRnti;
1058 estAveThr[(*itMax).first] = expectedAveThr;
1062 for (it = estAveThr.begin (); it != estAveThr.end (); it++)
1064 double metric = 1 / (*it).second;
1065 if (metric > metricMax)
1072 rbgMap.at (i) =
true;
1079 while ( i < rbgNum );
1084 std::map <uint16_t, fdbetsFlowPerf_t>::iterator itStats;
1085 for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
1087 (*itStats).second.lastTtiBytesTrasmitted = 0;
1092 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1093 while (itMap != allocationMap.end ())
1096 BuildDataListElement_s newEl;
1097 newEl.m_rnti = (*itMap).first;
1099 DlDciListElement_s newDci;
1100 newDci.m_rnti = (*itMap).first;
1103 uint16_t lcActives = LcActivePerFlow ((*itMap).first);
1104 NS_LOG_INFO (
this <<
"Allocate user " << newEl.m_rnti <<
" rbg " << lcActives);
1105 uint16_t RgbPerRnti = (*itMap).second.size ();
1106 std::map <uint16_t,uint8_t>::iterator itCqi;
1107 itCqi = m_p10CqiRxed.find ((*itMap).first);
1108 std::map <uint16_t,uint8_t>::iterator itTxMode;
1109 itTxMode = m_uesTxMode.find ((*itMap).first);
1110 if (itTxMode == m_uesTxMode.end ())
1112 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1114 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1116 uint32_t bytesTxed = 0;
1117 for (uint8_t j = 0; j < nLayer; j++)
1119 if (itCqi == m_p10CqiRxed.end ())
1121 newDci.m_mcs.push_back (0);
1125 newDci.m_mcs.push_back ( m_amc->GetMcsFromCqi ((*itCqi).second) );
1128 int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1129 newDci.m_tbsSize.push_back (tbSize);
1130 bytesTxed += tbSize;
1133 newDci.m_resAlloc = 0;
1134 newDci.m_rbBitmap = 0;
1135 uint32_t rbgMask = 0;
1136 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1138 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1139 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1141 newDci.m_rbBitmap = rbgMask;
1144 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1145 for (itBufReq = m_rlcBufferReq.begin (); itBufReq != m_rlcBufferReq.end (); itBufReq++)
1147 if (((*itBufReq).first.m_rnti == (*itMap).first)
1148 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1149 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1150 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1152 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1153 for (uint8_t j = 0; j < nLayer; j++)
1155 RlcPduListElement_s newRlcEl;
1156 newRlcEl.m_logicalChannelIdentity = (*itBufReq).first.m_lcId;
1157 newRlcEl.m_size = newDci.m_tbsSize.at (j) / lcActives;
1158 NS_LOG_INFO (
this <<
" LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity <<
" size " << newRlcEl.m_size <<
" layer " << (uint16_t)j);
1159 newRlcPduLe.push_back (newRlcEl);
1160 UpdateDlRlcBufferInfo (newDci.m_rnti, newRlcEl.m_logicalChannelIdentity, newRlcEl.m_size);
1164 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find ((*itMap).first);
1165 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
1167 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1169 (*itRlcPdu).second.at (j).at (newDci.m_harqProcess).push_back (newRlcEl);
1172 newEl.m_rlcPduList.push_back (newRlcPduLe);
1174 if ((*itBufReq).first.m_rnti > (*itMap).first)
1179 for (uint8_t j = 0; j < nLayer; j++)
1181 newDci.m_ndi.push_back (1);
1182 newDci.m_rv.push_back (0);
1185 newEl.m_dci = newDci;
1190 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci = m_dlHarqProcessesDciBuffer.find (newEl.m_rnti);
1191 if (itDci == m_dlHarqProcessesDciBuffer.end ())
1193 NS_FATAL_ERROR (
"Unable to find RNTI entry in DCI HARQ buffer for RNTI " << newEl.m_rnti);
1195 (*itDci).second.at (newDci.m_harqProcess) = newDci;
1197 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (newEl.m_rnti);
1198 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
1200 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1202 (*itHarqTimer).second.at (newDci.m_harqProcess) = 0;
1207 ret.m_buildDataList.push_back (newEl);
1209 std::map <uint16_t, fdbetsFlowPerf_t>::iterator it;
1210 it = m_flowStatsDl.find ((*itMap).first);
1211 if (it != m_flowStatsDl.end ())
1213 (*it).second.lastTtiBytesTrasmitted = bytesTxed;
1214 NS_LOG_INFO (
this <<
" UE total bytes txed " << (*it).second.lastTtiBytesTrasmitted);
1225 ret.m_nrOfPdcchOfdmSymbols = 1;
1230 for (itStats = m_flowStatsDl.begin (); itStats != m_flowStatsDl.end (); itStats++)
1232 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted;
1234 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 / m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 / m_timeWindow) * (double)((*itStats).second.lastTtiBytesTrasmitted / 0.001));
1235 NS_LOG_INFO (
this <<
" UE total bytes " << (*itStats).second.totalBytesTransmitted);
1236 NS_LOG_INFO (
this <<
" UE average throughput " << (*itStats).second.lastAveragedThroughput);
1237 (*itStats).second.lastTtiBytesTrasmitted = 0;
1240 m_schedSapUser->SchedDlConfigInd (ret);
1247 FdBetFfMacScheduler::DoSchedDlRachInfoReq (
const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params)
1251 m_rachList = params.m_rachList;
1257 FdBetFfMacScheduler::DoSchedDlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
1261 for (
unsigned int i = 0; i < params.m_cqiList.size (); i++)
1263 if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
1266 std::map <uint16_t,uint8_t>::iterator it;
1267 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1268 it = m_p10CqiRxed.find (rnti);
1269 if (it == m_p10CqiRxed.end ())
1272 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) );
1274 m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1279 (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
1281 std::map <uint16_t,uint32_t>::iterator itTimers;
1282 itTimers = m_p10CqiTimers.find (rnti);
1283 (*itTimers).second = m_cqiTimersThreshold;
1286 else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
1289 std::map <uint16_t,SbMeasResult_s>::iterator it;
1290 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1291 it = m_a30CqiRxed.find (rnti);
1292 if (it == m_a30CqiRxed.end ())
1295 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.m_cqiList.at (i).m_sbMeasResult) );
1296 m_a30CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1301 (*it).second = params.m_cqiList.at (i).m_sbMeasResult;
1302 std::map <uint16_t,uint32_t>::iterator itTimers;
1303 itTimers = m_a30CqiTimers.find (rnti);
1304 (*itTimers).second = m_cqiTimersThreshold;
1318 FdBetFfMacScheduler::EstimateUlSinr (uint16_t rnti, uint16_t rb)
1320 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find (rnti);
1321 if (itCqi == m_ueCqi.end ())
1332 for (uint32_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1334 double sinr = (*itCqi).second.at (i);
1335 if (sinr != NO_SINR)
1341 double estimatedSinr = sinrSum / (double)sinrNum;
1343 (*itCqi).second.at (rb) = estimatedSinr;
1344 return (estimatedSinr);
1349 FdBetFfMacScheduler::DoSchedUlTriggerReq (
const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
1351 NS_LOG_FUNCTION (
this <<
" UL - Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf) <<
" size " << params.m_ulInfoList.size ());
1353 RefreshUlCqiMaps ();
1356 FfMacSchedSapUser::SchedUlConfigIndParameters ret;
1357 std::vector <bool> rbMap;
1358 uint16_t rbAllocatedNum = 0;
1359 std::set <uint16_t> rntiAllocated;
1360 std::vector <uint16_t> rbgAllocationMap;
1362 rbgAllocationMap = m_rachAllocationMap;
1364 m_rachAllocationMap.clear ();
1365 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1367 rbMap.resize (m_cschedCellConfig.m_ulBandwidth,
false);
1369 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1371 if (rbgAllocationMap.at (i) != 0)
1373 rbMap.at (i) =
true;
1383 std::map <uint16_t, uint8_t>::iterator itProcId;
1384 for (itProcId = m_ulHarqCurrentProcessId.begin (); itProcId != m_ulHarqCurrentProcessId.end (); itProcId++)
1386 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
1389 for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
1391 if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
1394 uint16_t rnti = params.m_ulInfoList.at (i).m_rnti;
1395 itProcId = m_ulHarqCurrentProcessId.find (rnti);
1396 if (itProcId == m_ulHarqCurrentProcessId.end ())
1398 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1400 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1401 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.m_ulInfoList.size ());
1402 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
1403 if (itHarq == m_ulHarqProcessesDciBuffer.end ())
1405 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1408 UlDciListElement_s dci = (*itHarq).second.at (harqId);
1409 std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (rnti);
1410 if (itStat == m_ulHarqProcessesStatus.end ())
1412 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1414 if ((*itStat).second.at (harqId) >= 3)
1416 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1420 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1422 if (rbMap.at (j) ==
true)
1431 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1433 rbMap.at (j) =
true;
1434 rbgAllocationMap.at (j) = dci.m_rnti;
1438 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);
1442 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1447 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1448 (*itStat).second.at (harqId) = 0;
1449 (*itHarq).second.at ((*itProcId).second) = dci;
1450 ret.m_dciList.push_back (dci);
1451 rntiAllocated.insert (dci.m_rnti);
1455 NS_LOG_INFO (
this <<
" HARQ-ACK feedback from RNTI " << params.m_ulInfoList.at (i).m_rnti);
1460 std::map <uint16_t,uint32_t>::iterator it;
1463 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1465 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1467 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1475 if (ret.m_dciList.size () > 0)
1477 m_schedSapUser->SchedUlConfigInd (ret);
1485 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size ());
1490 int rbAllocated = 0;
1492 std::map <uint16_t, fdbetsFlowPerf_t>::iterator itStats;
1493 if (m_nextRntiUl != 0)
1495 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1497 if ((*it).first == m_nextRntiUl)
1502 if (it == m_ceBsrRxed.end ())
1509 it = m_ceBsrRxed.begin ();
1510 m_nextRntiUl = (*it).first;
1514 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1515 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1519 if (it == m_ceBsrRxed.end ())
1522 it = m_ceBsrRxed.begin ();
1526 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1529 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1538 UlDciListElement_s uldci;
1539 uldci.m_rnti = (*it).first;
1540 uldci.m_rbLen = rbPerFlow;
1541 bool allocated =
false;
1542 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow);
1543 while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0))
1547 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1549 if (rbMap.at (j) ==
true)
1557 uldci.m_rbStart = rbAllocated;
1559 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1561 rbMap.at (j) =
true;
1563 rbgAllocationMap.at (j) = (*it).first;
1565 rbAllocated += rbPerFlow;
1570 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1573 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1585 m_nextRntiUl = (*it).first;
1586 if (ret.m_dciList.size () > 0)
1588 m_schedSapUser->SchedUlConfigInd (ret);
1590 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1596 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
1598 if (itCqi == m_ueCqi.end ())
1606 double minSinr = (*itCqi).second.at (uldci.m_rbStart);
1607 if (minSinr == NO_SINR)
1609 minSinr = EstimateUlSinr ((*it).first, uldci.m_rbStart);
1611 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1613 double sinr = (*itCqi).second.at (i);
1614 if (sinr == NO_SINR)
1616 sinr = EstimateUlSinr ((*it).first, i);
1618 if ((*itCqi).second.at (i) < minSinr)
1620 minSinr = (*itCqi).second.at (i);
1625 double s = log2 ( 1 + (
1626 pow (10, minSinr / 10 ) /
1627 ( (-log (5.0 * 0.00005 )) / 1.5) ));
1628 cqi = m_amc->GetCqiFromSpectralEfficiency (s);
1632 if (it == m_ceBsrRxed.end ())
1635 it = m_ceBsrRxed.begin ();
1639 uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
1642 uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
1643 UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
1645 uldci.m_cceIndex = 0;
1646 uldci.m_aggrLevel = 1;
1647 uldci.m_ueTxAntennaSelection = 3;
1648 uldci.m_hopping =
false;
1651 uldci.m_cqiRequest =
false;
1652 uldci.m_ulIndex = 0;
1654 uldci.m_freqHopping = 0;
1655 uldci.m_pdcchPowerOffset = 0;
1656 ret.m_dciList.push_back (uldci);
1661 std::map <uint16_t, uint8_t>::iterator itProcId;
1662 itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
1663 if (itProcId == m_ulHarqCurrentProcessId.end ())
1665 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << uldci.m_rnti);
1667 harqId = (*itProcId).second;
1668 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
1669 if (itDci == m_ulHarqProcessesDciBuffer.end ())
1671 NS_FATAL_ERROR (
"Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
1673 (*itDci).second.at (harqId) = uldci;
1676 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);
1679 itStats = m_flowStatsUl.find ((*it).first);
1680 if (itStats != m_flowStatsUl.end ())
1682 (*itStats).second.lastTtiBytesTrasmitted = uldci.m_tbSize;
1686 NS_LOG_DEBUG (
this <<
" No Stats for this allocated UE");
1691 if (it == m_ceBsrRxed.end ())
1694 it = m_ceBsrRxed.begin ();
1696 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1699 m_nextRntiUl = (*it).first;
1703 while (((*it).first != m_nextRntiUl)&&(rbPerFlow!=0));
1708 for (itStats = m_flowStatsUl.begin (); itStats != m_flowStatsUl.end (); itStats++)
1710 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted;
1712 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 / m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 / m_timeWindow) * (double)((*itStats).second.lastTtiBytesTrasmitted / 0.001));
1713 NS_LOG_INFO (
this <<
" UE total bytes " << (*itStats).second.totalBytesTransmitted);
1714 NS_LOG_INFO (
this <<
" UE average throughput " << (*itStats).second.lastAveragedThroughput);
1715 (*itStats).second.lastTtiBytesTrasmitted = 0;
1717 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1718 m_schedSapUser->SchedUlConfigInd (ret);
1724 FdBetFfMacScheduler::DoSchedUlNoiseInterferenceReq (
const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params)
1731 FdBetFfMacScheduler::DoSchedUlSrInfoReq (
const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params)
1738 FdBetFfMacScheduler::DoSchedUlMacCtrlInfoReq (
const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
1742 std::map <uint16_t,uint32_t>::iterator it;
1744 for (
unsigned int i = 0; i < params.m_macCeList.size (); i++)
1746 if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
1755 uint32_t buffer = 0;
1756 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1758 uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1759 buffer += BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
1762 uint16_t rnti = params.m_macCeList.at (i).m_rnti;
1763 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1764 it = m_ceBsrRxed.find (rnti);
1765 if (it == m_ceBsrRxed.end ())
1768 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1773 (*it).second = buffer;
1782 FdBetFfMacScheduler::DoSchedUlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
1786 switch (m_ulCqiFilter)
1788 case FfMacScheduler::SRS_UL_CQI:
1791 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1797 case FfMacScheduler::PUSCH_UL_CQI:
1800 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1805 case FfMacScheduler::ALL_UL_CQI:
1812 switch (params.m_ulCqi.m_type)
1814 case UlCqi_s::PUSCH:
1816 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1817 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1818 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
1819 itMap = m_allocationMaps.find (params.m_sfnSf);
1820 if (itMap == m_allocationMaps.end ())
1824 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1827 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
1828 itCqi = m_ueCqi.find ((*itMap).second.at (i));
1829 if (itCqi == m_ueCqi.end ())
1832 std::vector <double> newCqi;
1833 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1837 newCqi.push_back (sinr);
1842 newCqi.push_back (NO_SINR);
1846 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
1848 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
1853 (*itCqi).second.at (i) = sinr;
1854 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
1856 std::map <uint16_t, uint32_t>::iterator itTimers;
1857 itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
1858 (*itTimers).second = m_cqiTimersThreshold;
1864 m_allocationMaps.erase (itMap);
1871 NS_ASSERT (params.m_vendorSpecificList.size () > 0);
1872 for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
1874 if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
1876 Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
1877 rnti = vsp->GetRnti ();
1880 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1881 itCqi = m_ueCqi.find (rnti);
1882 if (itCqi == m_ueCqi.end ())
1885 std::vector <double> newCqi;
1886 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1888 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1889 newCqi.push_back (sinr);
1890 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
1893 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
1895 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1900 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1902 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1903 (*itCqi).second.at (j) = sinr;
1904 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
1907 std::map <uint16_t, uint32_t>::iterator itTimers;
1908 itTimers = m_ueCqiTimers.find (rnti);
1909 (*itTimers).second = m_cqiTimersThreshold;
1916 case UlCqi_s::PUCCH_1:
1917 case UlCqi_s::PUCCH_2:
1918 case UlCqi_s::PRACH:
1920 NS_FATAL_ERROR (
"FdBetFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1930 FdBetFfMacScheduler::RefreshDlCqiMaps (
void)
1933 std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
1934 while (itP10 != m_p10CqiTimers.end ())
1936 NS_LOG_INFO (
this <<
" P10-CQI for user " << (*itP10).first <<
" is " << (uint32_t)(*itP10).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1937 if ((*itP10).second == 0)
1940 std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
1941 NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (),
" Does not find CQI report for user " << (*itP10).first);
1942 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
1943 m_p10CqiRxed.erase (itMap);
1944 std::map <uint16_t,uint32_t>::iterator temp = itP10;
1946 m_p10CqiTimers.erase (temp);
1956 std::map <uint16_t,uint32_t>::iterator itA30 = m_a30CqiTimers.begin ();
1957 while (itA30 != m_a30CqiTimers.end ())
1959 NS_LOG_INFO (
this <<
" A30-CQI for user " << (*itA30).first <<
" is " << (uint32_t)(*itA30).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1960 if ((*itA30).second == 0)
1963 std::map <uint16_t,SbMeasResult_s>::iterator itMap = m_a30CqiRxed.find ((*itA30).first);
1964 NS_ASSERT_MSG (itMap != m_a30CqiRxed.end (),
" Does not find CQI report for user " << (*itA30).first);
1965 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
1966 m_a30CqiRxed.erase (itMap);
1967 std::map <uint16_t,uint32_t>::iterator temp = itA30;
1969 m_a30CqiTimers.erase (temp);
1983 FdBetFfMacScheduler::RefreshUlCqiMaps (
void)
1986 std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
1987 while (itUl != m_ueCqiTimers.end ())
1989 NS_LOG_INFO (
this <<
" UL-CQI for user " << (*itUl).first <<
" is " << (uint32_t)(*itUl).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1990 if ((*itUl).second == 0)
1993 std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
1994 NS_ASSERT_MSG (itMap != m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
1995 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
1996 (*itMap).second.clear ();
1997 m_ueCqi.erase (itMap);
1998 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2000 m_ueCqiTimers.erase (temp);
2013 FdBetFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
2015 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2016 LteFlowId_t flow (rnti, lcid);
2017 it = m_rlcBufferReq.find (flow);
2018 if (it != m_rlcBufferReq.end ())
2020 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);
2023 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2025 (*it).second.m_rlcStatusPduSize = 0;
2027 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2029 (*it).second.m_rlcRetransmissionQueueSize = 0;
2031 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2034 if ((*it).second.m_rlcTransmissionQueueSize <= size)
2036 (*it).second.m_rlcTransmissionQueueSize = 0;
2041 (*it).second.m_rlcTransmissionQueueSize -= size;
2047 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2052 FdBetFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
2056 std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
2057 if (it != m_ceBsrRxed.end ())
2059 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2060 if ((*it).second >= size)
2062 (*it).second -= size;
2071 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2077 FdBetFfMacScheduler::TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode)
2079 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
2080 FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params;
2081 params.m_rnti = rnti;
2082 params.m_transmissionMode = txMode;
2083 m_cschedSapUser->CschedUeConfigUpdateInd (params);
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
#define NS_LOG_FUNCTION(parameters)
virtual ~FdBetFfMacScheduler()
virtual void DoDispose(void)
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
See section 4.3.10 buildRARListElement.
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
#define NS_FATAL_ERROR(msg)
fatal error handling
Implements the SCHED SAP and CSCHED SAP for a Frequency Domain Blind Equal Throughput scheduler...
Hold an unsigned integer type.
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
#define NS_LOG_LOGIC(msg)
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.
#define NS_ASSERT_MSG(condition, message)
#define NS_LOG_DEBUG(msg)
#define NS_LOG_ERROR(msg)
FdBetFfMacScheduler()
Constructor.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)