22 #include <ns3/pointer.h>
26 #include <ns3/lte-amc.h>
27 #include <ns3/rr-ff-mac-scheduler.h>
28 #include <ns3/simulator.h>
29 #include <ns3/lte-common.h>
30 #include <ns3/lte-vendor-specific-parameters.h>
31 #include <ns3/boolean.h>
37 int Type0AllocationRbg[4] = {
47 NS_OBJECT_ENSURE_REGISTERED (RrFfMacScheduler);
67 RrSchedulerMemberCschedSapProvider::RrSchedulerMemberCschedSapProvider ()
71 RrSchedulerMemberCschedSapProvider::RrSchedulerMemberCschedSapProvider (RrFfMacScheduler* scheduler) : m_scheduler (scheduler)
79 m_scheduler->DoCschedCellConfigReq (params);
83 RrSchedulerMemberCschedSapProvider::CschedUeConfigReq (
const struct CschedUeConfigReqParameters& params)
85 m_scheduler->DoCschedUeConfigReq (params);
90 RrSchedulerMemberCschedSapProvider::CschedLcConfigReq (
const struct CschedLcConfigReqParameters& params)
92 m_scheduler->DoCschedLcConfigReq (params);
96 RrSchedulerMemberCschedSapProvider::CschedLcReleaseReq (
const struct CschedLcReleaseReqParameters& params)
98 m_scheduler->DoCschedLcReleaseReq (params);
102 RrSchedulerMemberCschedSapProvider::CschedUeReleaseReq (
const struct CschedUeReleaseReqParameters& params)
104 m_scheduler->DoCschedUeReleaseReq (params);
136 RrSchedulerMemberSchedSapProvider::RrSchedulerMemberSchedSapProvider ()
141 RrSchedulerMemberSchedSapProvider::RrSchedulerMemberSchedSapProvider (RrFfMacScheduler* scheduler)
142 : m_scheduler (scheduler)
147 RrSchedulerMemberSchedSapProvider::SchedDlRlcBufferReq (
const struct SchedDlRlcBufferReqParameters& params)
149 m_scheduler->DoSchedDlRlcBufferReq (params);
153 RrSchedulerMemberSchedSapProvider::SchedDlPagingBufferReq (
const struct SchedDlPagingBufferReqParameters& params)
155 m_scheduler->DoSchedDlPagingBufferReq (params);
159 RrSchedulerMemberSchedSapProvider::SchedDlMacBufferReq (
const struct SchedDlMacBufferReqParameters& params)
161 m_scheduler->DoSchedDlMacBufferReq (params);
165 RrSchedulerMemberSchedSapProvider::SchedDlTriggerReq (
const struct SchedDlTriggerReqParameters& params)
167 m_scheduler->DoSchedDlTriggerReq (params);
171 RrSchedulerMemberSchedSapProvider::SchedDlRachInfoReq (
const struct SchedDlRachInfoReqParameters& params)
173 m_scheduler->DoSchedDlRachInfoReq (params);
177 RrSchedulerMemberSchedSapProvider::SchedDlCqiInfoReq (
const struct SchedDlCqiInfoReqParameters& params)
179 m_scheduler->DoSchedDlCqiInfoReq (params);
183 RrSchedulerMemberSchedSapProvider::SchedUlTriggerReq (
const struct SchedUlTriggerReqParameters& params)
185 m_scheduler->DoSchedUlTriggerReq (params);
189 RrSchedulerMemberSchedSapProvider::SchedUlNoiseInterferenceReq (
const struct SchedUlNoiseInterferenceReqParameters& params)
191 m_scheduler->DoSchedUlNoiseInterferenceReq (params);
195 RrSchedulerMemberSchedSapProvider::SchedUlSrInfoReq (
const struct SchedUlSrInfoReqParameters& params)
197 m_scheduler->DoSchedUlSrInfoReq (params);
201 RrSchedulerMemberSchedSapProvider::SchedUlMacCtrlInfoReq (
const struct SchedUlMacCtrlInfoReqParameters& params)
203 m_scheduler->DoSchedUlMacCtrlInfoReq (params);
207 RrSchedulerMemberSchedSapProvider::SchedUlCqiInfoReq (
const struct SchedUlCqiInfoReqParameters& params)
209 m_scheduler->DoSchedUlCqiInfoReq (params);
217 : m_cschedSapUser (0),
222 m_amc = CreateObject <LteAmc> ();
236 m_dlHarqProcessesDciBuffer.clear ();
237 m_dlHarqProcessesTimer.clear ();
238 m_dlHarqProcessesRlcPduListBuffer.clear ();
239 m_dlInfoListBuffered.clear ();
240 m_ulHarqCurrentProcessId.clear ();
241 m_ulHarqProcessesStatus.clear ();
242 m_ulHarqProcessesDciBuffer.clear ();
243 delete m_cschedSapProvider;
244 delete m_schedSapProvider;
248 RrFfMacScheduler::GetTypeId (
void)
252 .AddConstructor<RrFfMacScheduler> ()
253 .AddAttribute (
"CqiTimerThreshold",
254 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
256 MakeUintegerAccessor (&RrFfMacScheduler::m_cqiTimersThreshold),
257 MakeUintegerChecker<uint32_t> ())
258 .AddAttribute (
"HarqEnabled",
259 "Activate/Deactivate the HARQ [by default is active].",
262 MakeBooleanChecker ())
263 .AddAttribute (
"UlGrantMcs",
264 "The MCS of the UL grant, must be [0..15] (default 0)",
266 MakeUintegerAccessor (&RrFfMacScheduler::m_ulGrantMcs),
267 MakeUintegerChecker<uint8_t> ())
289 return m_cschedSapProvider;
295 return m_schedSapProvider;
303 m_cschedCellConfig = params;
304 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
306 cnf.m_result = SUCCESS;
307 m_cschedSapUser->CschedUeConfigCnf (cnf);
312 RrFfMacScheduler::DoCschedUeConfigReq (
const struct FfMacCschedSapProvider::CschedUeConfigReqParameters& params)
314 NS_LOG_FUNCTION (
this <<
" RNTI " << params.m_rnti <<
" txMode " << (uint16_t)params.m_transmissionMode);
315 std::map <uint16_t,uint8_t>::iterator it = m_uesTxMode.find (params.m_rnti);
316 if (it == m_uesTxMode.end ())
318 m_uesTxMode.insert (std::pair <uint16_t, double> (params.m_rnti, params.m_transmissionMode));
320 m_dlHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
321 DlHarqProcessesStatus_t dlHarqPrcStatus;
322 dlHarqPrcStatus.resize (8,0);
323 m_dlHarqProcessesStatus.insert (std::pair <uint16_t, DlHarqProcessesStatus_t> (params.m_rnti, dlHarqPrcStatus));
324 DlHarqProcessesTimer_t dlHarqProcessesTimer;
325 dlHarqProcessesTimer.resize (8,0);
326 m_dlHarqProcessesTimer.insert (std::pair <uint16_t, DlHarqProcessesTimer_t> (params.m_rnti, dlHarqProcessesTimer));
327 DlHarqProcessesDciBuffer_t dlHarqdci;
328 dlHarqdci.resize (8);
329 m_dlHarqProcessesDciBuffer.insert (std::pair <uint16_t, DlHarqProcessesDciBuffer_t> (params.m_rnti, dlHarqdci));
330 DlHarqRlcPduListBuffer_t dlHarqRlcPdu;
331 dlHarqRlcPdu.resize (2);
332 dlHarqRlcPdu.at (0).resize (8);
333 dlHarqRlcPdu.at (1).resize (8);
334 m_dlHarqProcessesRlcPduListBuffer.insert (std::pair <uint16_t, DlHarqRlcPduListBuffer_t> (params.m_rnti, dlHarqRlcPdu));
335 m_ulHarqCurrentProcessId.insert (std::pair <uint16_t,uint8_t > (params.m_rnti, 0));
336 UlHarqProcessesStatus_t ulHarqPrcStatus;
337 ulHarqPrcStatus.resize (8,0);
338 m_ulHarqProcessesStatus.insert (std::pair <uint16_t, UlHarqProcessesStatus_t> (params.m_rnti, ulHarqPrcStatus));
339 UlHarqProcessesDciBuffer_t ulHarqdci;
340 ulHarqdci.resize (8);
341 m_ulHarqProcessesDciBuffer.insert (std::pair <uint16_t, UlHarqProcessesDciBuffer_t> (params.m_rnti, ulHarqdci));
345 (*it).second = params.m_transmissionMode;
351 RrFfMacScheduler::DoCschedLcConfigReq (
const struct FfMacCschedSapProvider::CschedLcConfigReqParameters& params)
359 RrFfMacScheduler::DoCschedLcReleaseReq (
const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters& params)
362 for (uint16_t i = 0; i < params.m_logicalChannelIdentity.size (); i++)
364 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
365 while (it!=m_rlcBufferReq.end ())
367 if (((*it).m_rnti == params.m_rnti)&&((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity.at (i)))
369 it = m_rlcBufferReq.erase (it);
381 RrFfMacScheduler::DoCschedUeReleaseReq (
const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters& params)
385 m_uesTxMode.erase (params.m_rnti);
386 m_dlHarqCurrentProcessId.erase (params.m_rnti);
387 m_dlHarqProcessesStatus.erase (params.m_rnti);
388 m_dlHarqProcessesTimer.erase (params.m_rnti);
389 m_dlHarqProcessesDciBuffer.erase (params.m_rnti);
390 m_dlHarqProcessesRlcPduListBuffer.erase (params.m_rnti);
391 m_ulHarqCurrentProcessId.erase (params.m_rnti);
392 m_ulHarqProcessesStatus.erase (params.m_rnti);
393 m_ulHarqProcessesDciBuffer.erase (params.m_rnti);
394 m_ceBsrRxed.erase (params.m_rnti);
395 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
396 while (it != m_rlcBufferReq.end ())
398 if ((*it).m_rnti == params.m_rnti)
400 NS_LOG_INFO (
this <<
" Erase RNTI " << (*it).m_rnti <<
" LC " << (uint16_t)(*it).m_logicalChannelIdentity);
401 it = m_rlcBufferReq.erase (it);
408 if (m_nextRntiUl == params.m_rnti)
413 if (m_nextRntiDl == params.m_rnti)
423 RrFfMacScheduler::DoSchedDlRlcBufferReq (
const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters& params)
425 NS_LOG_FUNCTION (
this << params.m_rnti << (uint32_t) params.m_logicalChannelIdentity);
427 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it = m_rlcBufferReq.begin ();
429 while (it != m_rlcBufferReq.end ())
432 if (((*it).m_rnti == params.m_rnti)&&((*it).m_logicalChannelIdentity == params.m_logicalChannelIdentity))
434 it = m_rlcBufferReq.erase (it);
443 m_rlcBufferReq.insert (it, params);
444 NS_LOG_INFO (
this <<
" RNTI " << params.m_rnti <<
" LC " << (uint16_t)params.m_logicalChannelIdentity <<
" RLC tx size " << params.m_rlcTransmissionQueueHolDelay <<
" RLC retx size " << params.m_rlcRetransmissionQueueSize <<
" RLC stat size " << params.m_rlcStatusPduSize);
448 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (params.m_rnti, 1));
450 m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (params.m_rnti, m_cqiTimersThreshold));
457 RrFfMacScheduler::DoSchedDlPagingBufferReq (
const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters& params)
465 RrFfMacScheduler::DoSchedDlMacBufferReq (
const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters& params)
473 RrFfMacScheduler::GetRbgSize (
int dlbandwidth)
475 for (
int i = 0; i < 4; i++)
477 if (dlbandwidth < Type0AllocationRbg[i])
487 RrFfMacScheduler::SortRlcBufferReq (FfMacSchedSapProvider::SchedDlRlcBufferReqParameters i,FfMacSchedSapProvider::SchedDlRlcBufferReqParameters j)
489 return (i.m_rnti < j.m_rnti);
498 std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
499 if (it == m_dlHarqCurrentProcessId.end ())
503 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
504 if (itStat == m_dlHarqProcessesStatus.end ())
506 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
508 uint8_t i = (*it).second;
511 i = (i + 1) % HARQ_PROC_NUM;
513 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
514 if ((*itStat).second.at (i) == 0)
537 std::map <uint16_t, uint8_t>::iterator it = m_dlHarqCurrentProcessId.find (rnti);
538 if (it == m_dlHarqCurrentProcessId.end ())
542 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find (rnti);
543 if (itStat == m_dlHarqProcessesStatus.end ())
545 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
547 uint8_t i = (*it).second;
550 i = (i + 1) % HARQ_PROC_NUM;
552 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
553 if ((*itStat).second.at (i) == 0)
556 (*itStat).second.at (i) = 1;
563 return ((*it).second);
572 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
573 for (itTimers = m_dlHarqProcessesTimer.begin (); itTimers != m_dlHarqProcessesTimer.end (); itTimers ++)
575 for (uint16_t i = 0; i < HARQ_PROC_NUM; i++)
577 if ((*itTimers).second.at (i) == HARQ_DL_TIMEOUT)
581 NS_LOG_INFO (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
582 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat = m_dlHarqProcessesStatus.find ((*itTimers).first);
583 if (itStat == m_dlHarqProcessesStatus.end ())
585 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
587 (*itStat).second.at (i) = 0;
588 (*itTimers).second.at (i) = 0;
592 (*itTimers).second.at (i)++;
604 NS_LOG_FUNCTION (
this <<
" DL Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
608 int rbgSize = GetRbgSize (m_cschedCellConfig.m_dlBandwidth);
609 int rbgNum = m_cschedCellConfig.m_dlBandwidth / rbgSize;
613 std::vector <bool> rbgMap;
614 uint16_t rbgAllocatedNum = 0;
615 std::set <uint16_t> rntiAllocated;
616 rbgMap.resize (m_cschedCellConfig.m_dlBandwidth / rbgSize,
false);
619 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
620 uint16_t rbStart = 0;
621 std::vector <struct RachListElement_s>::iterator itRach;
622 for (itRach = m_rachList.begin (); itRach != m_rachList.end (); itRach++)
624 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");
626 newRar.m_rnti = (*itRach).m_rnti;
630 newRar.m_grant.m_rnti = newRar.m_rnti;
631 newRar.m_grant.m_mcs = m_ulGrantMcs;
633 uint16_t tbSizeBits = 0;
635 while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < m_cschedCellConfig.m_ulBandwidth))
638 tbSizeBits = m_amc->GetTbSizeFromMcs (m_ulGrantMcs, rbLen);
640 if (tbSizeBits < (*itRach).m_estimatedSize)
645 newRar.m_grant.m_rbStart = rbStart;
646 newRar.m_grant.m_rbLen = rbLen;
647 newRar.m_grant.m_tbSize = tbSizeBits / 8;
648 newRar.m_grant.m_hopping =
false;
649 newRar.m_grant.m_tpc = 0;
650 newRar.m_grant.m_cqiRequest =
false;
651 newRar.m_grant.m_ulDelay =
false;
652 NS_LOG_INFO (
this <<
" UL grant allocated to RNTI " << (*itRach).m_rnti <<
" rbStart " << rbStart <<
" rbLen " << rbLen <<
" MCS " << (uint16_t) m_ulGrantMcs <<
" tbSize " << newRar.m_grant.m_tbSize);
653 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
655 m_rachAllocationMap.at (i) = (*itRach).m_rnti;
657 rbStart = rbStart + rbLen;
659 ret.m_buildRarList.push_back (newRar);
666 if (m_dlInfoListBuffered.size () > 0)
668 if (params.m_dlInfoList.size () > 0)
670 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
671 m_dlInfoListBuffered.insert (m_dlInfoListBuffered.end (), params.m_dlInfoList.begin (), params.m_dlInfoList.end ());
676 if (params.m_dlInfoList.size () > 0)
678 m_dlInfoListBuffered = params.m_dlInfoList;
684 m_dlInfoListBuffered.clear ();
686 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
687 for (uint16_t i = 0; i < m_dlInfoListBuffered.size (); i++)
689 std::set <uint16_t>::iterator itRnti = rntiAllocated.find (m_dlInfoListBuffered.at (i).m_rnti);
690 if (itRnti != rntiAllocated.end ())
695 uint8_t nLayers = m_dlInfoListBuffered.at (i).m_harqStatus.size ();
696 std::vector <bool> retx;
697 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
700 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
701 retx.push_back (
false);
705 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (0) == DlInfoListElement_s::NACK);
706 retx.push_back (m_dlInfoListBuffered.at (i).m_harqStatus.at (1) == DlInfoListElement_s::NACK);
708 if (retx.at (0) || retx.at (1))
711 uint16_t rnti = m_dlInfoListBuffered.at (i).m_rnti;
712 uint8_t harqId = m_dlInfoListBuffered.at (i).m_harqProcessId;
713 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
714 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itHarq = m_dlHarqProcessesDciBuffer.find (rnti);
715 if (itHarq == m_dlHarqProcessesDciBuffer.end ())
720 DlDciListElement_s dci = (*itHarq).second.at (harqId);
722 if (dci.m_rv.size () == 1)
724 rv = dci.m_rv.at (0);
728 rv = (dci.m_rv.at (0) > dci.m_rv.at (1) ? dci.m_rv.at (0) : dci.m_rv.at (1));
734 NS_LOG_INFO (
"Max number of retransmissions reached -> drop process");
735 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (rnti);
736 if (it == m_dlHarqProcessesStatus.end ())
738 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << m_dlInfoListBuffered.at (i).m_rnti);
740 (*it).second.at (harqId) = 0;
741 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
742 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
744 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
746 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
748 (*itRlcPdu).second.at (k).at (harqId).clear ();
754 std::vector <int> dciRbg;
756 NS_LOG_INFO (
"Original RBGs " << dci.m_rbBitmap <<
" rnti " << dci.m_rnti);
757 for (
int j = 0; j < 32; j++)
759 if (((dci.m_rbBitmap & mask) >> j) == 1)
761 dciRbg.push_back (j);
767 for (uint8_t j = 0; j < dciRbg.size (); j++)
769 if (rbgMap.at (dciRbg.at (j)) ==
true)
779 for (uint8_t j = 0; j < dciRbg.size (); j++)
781 rbgMap.at (dciRbg.at (j)) =
true;
782 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
786 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
792 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
793 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
794 std::vector <bool> rbgMapCopy = rbgMap;
795 while ((j < dciRbg.size ())&&(startRbg != rbgId))
797 if (rbgMapCopy.at (rbgId) ==
false)
799 rbgMapCopy.at (rbgId) =
true;
800 dciRbg.at (j) = rbgId;
805 if (j == dciRbg.size ())
808 uint32_t rbgMask = 0;
809 for (uint16_t k = 0; k < dciRbg.size (); k++)
811 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
812 NS_LOG_INFO (
this <<
" New allocated RBG " << dciRbg.at (k));
815 dci.m_rbBitmap = rbgMask;
821 dlInfoListUntxed.push_back (params.m_dlInfoList.at (i));
822 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
826 BuildDataListElement_s newEl;
827 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (rnti);
828 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
830 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
832 for (uint8_t j = 0; j < nLayers; j++)
836 if (j >= dci.m_ndi.size ())
839 dci.m_ndi.push_back (0);
840 dci.m_rv.push_back (0);
841 dci.m_mcs.push_back (0);
842 dci.m_tbsSize.push_back (0);
843 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
848 dci.m_ndi.at (j) = 0;
850 (*itHarq).second.at (harqId).m_rv.at (j)++;
851 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.m_rv.at (j));
857 dci.m_ndi.at (j) = 0;
859 dci.m_mcs.at (j) = 0;
860 dci.m_tbsSize.at (j) = 0;
861 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
865 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.m_harqProcess).size (); k++)
867 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
868 for (uint8_t j = 0; j < nLayers; j++)
872 if (j < dci.m_ndi.size ())
874 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.m_harqProcess).at (k));
879 if (rlcPduListPerLc.size () > 0)
881 newEl.m_rlcPduList.push_back (rlcPduListPerLc);
886 (*itHarq).second.at (harqId).m_rv = dci.m_rv;
888 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (rnti);
889 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
891 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
893 (*itHarqTimer).second.at (harqId) = 0;
894 ret.m_buildDataList.push_back (newEl);
895 rntiAllocated.insert (rnti);
900 NS_LOG_INFO (
this <<
" HARQ ACK UE " << m_dlInfoListBuffered.at (i).m_rnti);
901 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator it = m_dlHarqProcessesStatus.find (m_dlInfoListBuffered.at (i).m_rnti);
902 if (it == m_dlHarqProcessesStatus.end ())
904 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << m_dlInfoListBuffered.at (i).m_rnti);
906 (*it).second.at (m_dlInfoListBuffered.at (i).m_harqProcessId) = 0;
907 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find (m_dlInfoListBuffered.at (i).m_rnti);
908 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
910 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << m_dlInfoListBuffered.at (i).m_rnti);
912 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
914 (*itRlcPdu).second.at (k).at (m_dlInfoListBuffered.at (i).m_harqProcessId).clear ();
918 m_dlInfoListBuffered.clear ();
919 m_dlInfoListBuffered = dlInfoListUntxed;
922 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
923 m_rlcBufferReq.sort (SortRlcBufferReq);
926 std::map <uint16_t,uint8_t> lcActivesPerRnti;
927 std::map <uint16_t,uint8_t>::iterator itLcRnti;
928 for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
931 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).m_rnti);
932 if ( (((*it).m_rlcTransmissionQueueSize > 0)
933 || ((*it).m_rlcRetransmissionQueueSize > 0)
934 || ((*it).m_rlcStatusPduSize > 0))
935 && (itRnti == rntiAllocated.end ())
939 NS_LOG_LOGIC (
this <<
" User " << (*it).m_rnti <<
" LC " << (uint16_t)(*it).m_logicalChannelIdentity <<
" is active, status " << (*it).m_rlcStatusPduSize <<
" retx " << (*it).m_rlcRetransmissionQueueSize <<
" tx " << (*it).m_rlcTransmissionQueueSize);
940 std::map <uint16_t,uint8_t>::iterator itCqi = m_p10CqiRxed.find ((*it).m_rnti);
942 if (itCqi != m_p10CqiRxed.end ())
944 cqi = (*itCqi).second;
954 itLcRnti = lcActivesPerRnti.find ((*it).m_rnti);
955 if (itLcRnti != lcActivesPerRnti.end ())
957 (*itLcRnti).second++;
961 lcActivesPerRnti.insert (std::pair<uint16_t, uint8_t > ((*it).m_rnti, 1));
971 if ((ret.m_buildDataList.size () > 0) || (ret.m_buildRarList.size () > 0))
973 m_schedSapUser->SchedDlConfigInd (ret);
980 int rbgPerTb = (rbgNum - rbgAllocatedNum) / nTbs;
981 NS_LOG_INFO (
this <<
" Flows to be transmitted " << nflows <<
" rbgPerTb " << rbgPerTb);
986 int rbgAllocated = 0;
990 if (m_nextRntiDl != 0)
992 for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
994 if ((*it).m_rnti == m_nextRntiDl)
1000 if (it == m_rlcBufferReq.end ())
1007 it = m_rlcBufferReq.begin ();
1008 m_nextRntiDl = (*it).m_rnti;
1010 std::map <uint16_t,uint8_t>::iterator itTxMode;
1013 itLcRnti = lcActivesPerRnti.find ((*it).m_rnti);
1014 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).m_rnti);
1015 if ((itLcRnti == lcActivesPerRnti.end ())||(itRnti != rntiAllocated.end ()))
1018 uint16_t rntiDiscared = (*it).m_rnti;
1019 while (it != m_rlcBufferReq.end ())
1021 if ((*it).m_rnti != rntiDiscared)
1027 if (it == m_rlcBufferReq.end ())
1030 it = m_rlcBufferReq.begin ();
1034 itTxMode = m_uesTxMode.find ((*it).m_rnti);
1035 if (itTxMode == m_uesTxMode.end ())
1037 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).m_rnti);
1039 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second);
1040 int lcNum = (*itLcRnti).second;
1042 BuildDataListElement_s newEl;
1043 newEl.m_rnti = (*it).m_rnti;
1045 DlDciListElement_s newDci;
1046 newDci.m_rnti = (*it).m_rnti;
1048 newDci.m_resAlloc = 0;
1049 newDci.m_rbBitmap = 0;
1050 std::map <uint16_t,uint8_t>::iterator itCqi = m_p10CqiRxed.find (newEl.m_rnti);
1051 for (uint8_t i = 0; i < nLayer; i++)
1053 if (itCqi == m_p10CqiRxed.end ())
1055 newDci.m_mcs.push_back (0);
1059 newDci.m_mcs.push_back ( m_amc->GetMcsFromCqi ((*itCqi).second) );
1062 int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (0), rbgPerTb * rbgSize) / 8);
1063 uint16_t rlcPduSize = tbSize / lcNum;
1066 if ( ((*it).m_rlcTransmissionQueueSize > 0)
1067 || ((*it).m_rlcRetransmissionQueueSize > 0)
1068 || ((*it).m_rlcStatusPduSize > 0) )
1070 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1071 for (uint8_t j = 0; j < nLayer; j++)
1073 RlcPduListElement_s newRlcEl;
1074 newRlcEl.m_logicalChannelIdentity = (*it).m_logicalChannelIdentity;
1075 NS_LOG_INFO (
this <<
"LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity <<
" size " << rlcPduSize <<
" ID " << (*it).m_rnti <<
" layer " << (uint16_t)j);
1076 newRlcEl.m_size = rlcPduSize;
1077 UpdateDlRlcBufferInfo ((*it).m_rnti, newRlcEl.m_logicalChannelIdentity, rlcPduSize);
1078 newRlcPduLe.push_back (newRlcEl);
1083 std::map <uint16_t, DlHarqRlcPduListBuffer_t>::iterator itRlcPdu = m_dlHarqProcessesRlcPduListBuffer.find ((*it).m_rnti);
1084 if (itRlcPdu == m_dlHarqProcessesRlcPduListBuffer.end ())
1086 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*it).m_rnti);
1088 (*itRlcPdu).second.at (j).at (newDci.m_harqProcess).push_back (newRlcEl);
1092 newEl.m_rlcPduList.push_back (newRlcPduLe);
1096 if (it == m_rlcBufferReq.end ())
1099 it = m_rlcBufferReq.begin ();
1102 uint32_t rbgMask = 0;
1104 NS_LOG_INFO (
this <<
" DL - Allocate user " << newEl.m_rnti <<
" LCs " << (uint16_t)(*itLcRnti).second <<
" bytes " << tbSize <<
" mcs " << (uint16_t) newDci.m_mcs.at (0) <<
" harqId " << (uint16_t)newDci.m_harqProcess <<
" layers " << nLayer);
1106 while (i < rbgPerTb)
1108 if (rbgMap.at (rbgAllocated) ==
false)
1110 rbgMask = rbgMask + (0x1 << rbgAllocated);
1113 rbgMap.at (rbgAllocated) =
true;
1117 newDci.m_rbBitmap = rbgMask;
1119 for (
int i = 0; i < nLayer; i++)
1121 newDci.m_tbsSize.push_back (tbSize);
1122 newDci.m_ndi.push_back (1);
1123 newDci.m_rv.push_back (0);
1125 newEl.m_dci = newDci;
1129 std::map <uint16_t, DlHarqProcessesDciBuffer_t>::iterator itDci = m_dlHarqProcessesDciBuffer.find (newEl.m_rnti);
1130 if (itDci == m_dlHarqProcessesDciBuffer.end ())
1132 NS_FATAL_ERROR (
"Unable to find RNTI entry in DCI HARQ buffer for RNTI " << (*it).m_rnti);
1134 (*itDci).second.at (newDci.m_harqProcess) = newDci;
1136 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itHarqTimer = m_dlHarqProcessesTimer.find (newEl.m_rnti);
1137 if (itHarqTimer== m_dlHarqProcessesTimer.end ())
1139 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)newEl.m_rnti);
1141 (*itHarqTimer).second.at (newDci.m_harqProcess) = 0;
1145 ret.m_buildDataList.push_back (newEl);
1146 if (rbgAllocated == rbgNum)
1148 m_nextRntiDl = (*it).m_rnti;
1152 while ((*it).m_rnti != m_nextRntiDl);
1154 ret.m_nrOfPdcchOfdmSymbols = 1;
1156 m_schedSapUser->SchedDlConfigInd (ret);
1161 RrFfMacScheduler::DoSchedDlRachInfoReq (
const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters& params)
1165 m_rachList = params.m_rachList;
1171 RrFfMacScheduler::DoSchedDlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters& params)
1175 std::map <uint16_t,uint8_t>::iterator it;
1176 for (
unsigned int i = 0; i < params.m_cqiList.size (); i++)
1178 if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::P10 )
1181 std::map <uint16_t,uint8_t>::iterator it;
1182 uint16_t rnti = params.m_cqiList.at (i).m_rnti;
1183 it = m_p10CqiRxed.find (rnti);
1184 if (it == m_p10CqiRxed.end ())
1187 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.m_cqiList.at (i).m_wbCqi.at (0)) );
1189 m_p10CqiTimers.insert ( std::pair<uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1194 (*it).second = params.m_cqiList.at (i).m_wbCqi.at (0);
1196 std::map <uint16_t,uint32_t>::iterator itTimers;
1197 itTimers = m_p10CqiTimers.find (rnti);
1198 (*itTimers).second = m_cqiTimersThreshold;
1201 else if ( params.m_cqiList.at (i).m_cqiType == CqiListElement_s::A30 )
1216 RrFfMacScheduler::DoSchedUlTriggerReq (
const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters& params)
1218 NS_LOG_FUNCTION (
this <<
" Ul - Frame no. " << (params.m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.m_sfnSf));
1221 RefreshUlCqiMaps ();
1224 FfMacSchedSapUser::SchedUlConfigIndParameters ret;
1225 std::vector <bool> rbMap;
1226 uint16_t rbAllocatedNum = 0;
1227 std::set <uint16_t> rntiAllocated;
1228 std::vector <uint16_t> rbgAllocationMap;
1230 rbgAllocationMap = m_rachAllocationMap;
1232 m_rachAllocationMap.clear ();
1233 m_rachAllocationMap.resize (m_cschedCellConfig.m_ulBandwidth, 0);
1235 rbMap.resize (m_cschedCellConfig.m_ulBandwidth,
false);
1237 for (uint16_t i = 0; i < m_cschedCellConfig.m_ulBandwidth; i++)
1239 if (rbgAllocationMap.at (i) != 0)
1241 rbMap.at (i) =
true;
1249 std::map <uint16_t, uint8_t>::iterator itProcId;
1250 for (itProcId = m_ulHarqCurrentProcessId.begin (); itProcId != m_ulHarqCurrentProcessId.end (); itProcId++)
1252 (*itProcId).second = ((*itProcId).second + 1) % HARQ_PROC_NUM;
1254 for (uint16_t i = 0; i < params.m_ulInfoList.size (); i++)
1256 if (params.m_ulInfoList.at (i).m_receptionStatus == UlInfoListElement_s::NotOk)
1259 uint16_t rnti = params.m_ulInfoList.at (i).m_rnti;
1260 itProcId = m_ulHarqCurrentProcessId.find (rnti);
1261 if (itProcId == m_ulHarqCurrentProcessId.end ())
1263 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1265 uint8_t harqId = (uint8_t)((*itProcId).second - HARQ_PERIOD) % HARQ_PROC_NUM;
1266 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
1267 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itHarq = m_ulHarqProcessesDciBuffer.find (rnti);
1268 if (itHarq == m_ulHarqProcessesDciBuffer.end ())
1270 NS_LOG_ERROR (
"No info find in UL-HARQ buffer for UE (might change eNB) " << rnti);
1272 UlDciListElement_s dci = (*itHarq).second.at (harqId);
1273 std::map <uint16_t, UlHarqProcessesStatus_t>::iterator itStat = m_ulHarqProcessesStatus.find (rnti);
1274 if (itStat == m_ulHarqProcessesStatus.end ())
1276 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1278 if ((*itStat).second.at (harqId) > 3)
1280 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1284 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1286 if (rbMap.at (j) ==
true)
1295 for (
int j = dci.m_rbStart; j < dci.m_rbStart + dci.m_rbLen; j++)
1297 rbMap.at (j) =
true;
1298 rbgAllocationMap.at (j) = dci.m_rnti;
1302 NS_LOG_INFO (
this <<
" Send retx in the same RBGs " << (uint16_t)dci.m_rbStart <<
" to " << dci.m_rbStart + dci.m_rbLen <<
" RV " << (*itStat).second.at (harqId) + 1);
1306 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1311 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1312 (*itStat).second.at (harqId) = 0;
1313 (*itHarq).second.at ((*itProcId).second) = dci;
1314 ret.m_dciList.push_back (dci);
1315 rntiAllocated.insert (dci.m_rnti);
1320 std::map <uint16_t,uint32_t>::iterator it;
1323 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1325 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1327 NS_LOG_INFO (
this <<
" UE " << (*it).first <<
" queue " << (*it).second);
1328 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1336 if (ret.m_dciList.size () > 0)
1338 m_schedSapUser->SchedUlConfigInd (ret);
1345 uint16_t rbPerFlow = (m_cschedCellConfig.m_ulBandwidth) / (nflows + rntiAllocated.size ());
1350 uint16_t rbAllocated = 0;
1352 if (m_nextRntiUl != 0)
1354 for (it = m_ceBsrRxed.begin (); it != m_ceBsrRxed.end (); it++)
1356 if ((*it).first == m_nextRntiUl)
1361 if (it == m_ceBsrRxed.end ())
1368 it = m_ceBsrRxed.begin ();
1369 m_nextRntiUl = (*it).first;
1371 NS_LOG_INFO (
this <<
" NFlows " << nflows <<
" RB per Flow " << rbPerFlow);
1374 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1375 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1379 if (it == m_ceBsrRxed.end ())
1382 it = m_ceBsrRxed.begin ();
1386 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1389 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1397 NS_LOG_INFO (
this <<
" try to allocate " << (*it).first);
1398 UlDciListElement_s uldci;
1399 uldci.m_rnti = (*it).first;
1400 uldci.m_rbLen = rbPerFlow;
1401 bool allocated =
false;
1402 while ((!allocated)&&((rbAllocated + rbPerFlow - 1) < m_cschedCellConfig.m_ulBandwidth) && (rbPerFlow != 0))
1406 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1408 if (rbMap.at (j) ==
true)
1416 uldci.m_rbStart = rbAllocated;
1418 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1420 rbMap.at (j) =
true;
1422 rbgAllocationMap.at (j) = (*it).first;
1425 rbAllocated += rbPerFlow;
1430 if (rbAllocated + rbPerFlow - 1 > m_cschedCellConfig.m_ulBandwidth)
1433 rbPerFlow = m_cschedCellConfig.m_ulBandwidth - rbAllocated;
1445 m_nextRntiUl = (*it).first;
1446 if (ret.m_dciList.size () > 0)
1448 m_schedSapUser->SchedUlConfigInd (ret);
1450 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1453 std::map <uint16_t, std::vector <double> >::iterator itCqi = m_ueCqi.find ((*it).first);
1455 if (itCqi == m_ueCqi.end ())
1459 NS_LOG_INFO (
this <<
" UE does not have ULCQI " << (*it).first );
1464 double minSinr = (*itCqi).second.at (uldci.m_rbStart);
1465 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++)
1467 if ((*itCqi).second.at (i) < minSinr)
1469 minSinr = (*itCqi).second.at (i);
1473 double s = log2 ( 1 + (
1474 std::pow (10, minSinr / 10 ) /
1475 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1478 cqi = m_amc->GetCqiFromSpectralEfficiency (s);
1482 if (it == m_ceBsrRxed.end ())
1485 it = m_ceBsrRxed.begin ();
1487 NS_LOG_INFO (
this <<
" UE discarded for CQI = 0");
1490 uldci.m_mcs = m_amc->GetMcsFromCqi (cqi);
1492 uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8);
1494 UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize);
1496 uldci.m_cceIndex = 0;
1497 uldci.m_aggrLevel = 1;
1498 uldci.m_ueTxAntennaSelection = 3;
1499 uldci.m_hopping =
false;
1502 uldci.m_cqiRequest =
false;
1503 uldci.m_ulIndex = 0;
1505 uldci.m_freqHopping = 0;
1506 uldci.m_pdcchPowerOffset = 0;
1507 ret.m_dciList.push_back (uldci);
1512 std::map <uint16_t, uint8_t>::iterator itProcId;
1513 itProcId = m_ulHarqCurrentProcessId.find (uldci.m_rnti);
1514 if (itProcId == m_ulHarqCurrentProcessId.end ())
1516 NS_FATAL_ERROR (
"No info find in HARQ buffer for UE " << uldci.m_rnti);
1518 harqId = (*itProcId).second;
1519 std::map <uint16_t, UlHarqProcessesDciBuffer_t>::iterator itDci = m_ulHarqProcessesDciBuffer.find (uldci.m_rnti);
1520 if (itDci == m_ulHarqProcessesDciBuffer.end ())
1522 NS_FATAL_ERROR (
"Unable to find RNTI entry in UL DCI HARQ buffer for RNTI " << uldci.m_rnti);
1524 (*itDci).second.at (harqId) = uldci;
1526 NS_LOG_INFO (
this <<
" UL Allocation - UE " << (*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 <<
" harqId " << (uint16_t)harqId);
1529 if (it == m_ceBsrRxed.end ())
1532 it = m_ceBsrRxed.begin ();
1534 if ((rbAllocated == m_cschedCellConfig.m_ulBandwidth) || (rbPerFlow == 0))
1537 m_nextRntiUl = (*it).first;
1541 while (((*it).first != m_nextRntiUl)&&(rbPerFlow!=0));
1543 m_allocationMaps.insert (std::pair <uint16_t, std::vector <uint16_t> > (params.m_sfnSf, rbgAllocationMap));
1545 m_schedSapUser->SchedUlConfigInd (ret);
1550 RrFfMacScheduler::DoSchedUlNoiseInterferenceReq (
const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters& params)
1557 RrFfMacScheduler::DoSchedUlSrInfoReq (
const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters& params)
1564 RrFfMacScheduler::DoSchedUlMacCtrlInfoReq (
const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters& params)
1568 std::map <uint16_t,uint32_t>::iterator it;
1570 for (
unsigned int i = 0; i < params.m_macCeList.size (); i++)
1572 if ( params.m_macCeList.at (i).m_macCeType == MacCeListElement_s::BSR )
1581 uint32_t buffer = 0;
1582 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1584 uint8_t bsrId = params.m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1585 buffer += BufferSizeLevelBsr::BsrId2BufferSize (bsrId);
1588 uint16_t rnti = params.m_macCeList.at (i).m_rnti;
1589 it = m_ceBsrRxed.find (rnti);
1590 if (it == m_ceBsrRxed.end ())
1593 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1594 NS_LOG_INFO (
this <<
" Insert RNTI " << rnti <<
" queue " << buffer);
1599 (*it).second = buffer;
1600 NS_LOG_INFO (
this <<
" Update RNTI " << rnti <<
" queue " << buffer);
1609 RrFfMacScheduler::DoSchedUlCqiInfoReq (
const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params)
1613 switch (m_ulCqiFilter)
1615 case FfMacScheduler::SRS_UL_CQI:
1618 if (params.m_ulCqi.m_type != UlCqi_s::SRS)
1624 case FfMacScheduler::PUSCH_UL_CQI:
1627 if (params.m_ulCqi.m_type != UlCqi_s::PUSCH)
1632 case FfMacScheduler::ALL_UL_CQI:
1638 switch (params.m_ulCqi.m_type)
1640 case UlCqi_s::PUSCH:
1642 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1643 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1644 itMap = m_allocationMaps.find (params.m_sfnSf);
1645 if (itMap == m_allocationMaps.end ())
1647 NS_LOG_INFO (
this <<
" Does not find info on allocation, size : " << m_allocationMaps.size ());
1650 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1653 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i));
1654 itCqi = m_ueCqi.find ((*itMap).second.at (i));
1655 if (itCqi == m_ueCqi.end ())
1658 std::vector <double> newCqi;
1659 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1663 newCqi.push_back (sinr);
1668 newCqi.push_back (30.0);
1672 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
1674 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > ((*itMap).second.at (i), m_cqiTimersThreshold));
1679 (*itCqi).second.at (i) = sinr;
1681 std::map <uint16_t, uint32_t>::iterator itTimers;
1682 itTimers = m_ueCqiTimers.find ((*itMap).second.at (i));
1683 (*itTimers).second = m_cqiTimersThreshold;
1689 m_allocationMaps.erase (itMap);
1696 NS_ASSERT (params.m_vendorSpecificList.size () > 0);
1697 for (uint16_t i = 0; i < params.m_vendorSpecificList.size (); i++)
1699 if (params.m_vendorSpecificList.at (i).m_type == SRS_CQI_RNTI_VSP)
1701 Ptr<SrsCqiRntiVsp> vsp = DynamicCast<SrsCqiRntiVsp> (params.m_vendorSpecificList.at (i).m_value);
1702 rnti = vsp->GetRnti ();
1705 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1706 itCqi = m_ueCqi.find (rnti);
1707 if (itCqi == m_ueCqi.end ())
1710 std::vector <double> newCqi;
1711 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1713 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1714 newCqi.push_back (sinr);
1715 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
1718 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
1720 m_ueCqiTimers.insert (std::pair <uint16_t, uint32_t > (rnti, m_cqiTimersThreshold));
1725 for (uint32_t j = 0; j < m_cschedCellConfig.m_ulBandwidth; j++)
1727 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (j));
1728 (*itCqi).second.at (j) = sinr;
1729 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
1732 std::map <uint16_t, uint32_t>::iterator itTimers;
1733 itTimers = m_ueCqiTimers.find (rnti);
1734 (*itTimers).second = m_cqiTimersThreshold;
1741 case UlCqi_s::PUCCH_1:
1742 case UlCqi_s::PUCCH_2:
1743 case UlCqi_s::PRACH:
1745 NS_FATAL_ERROR (
"PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1756 RrFfMacScheduler::RefreshDlCqiMaps (
void)
1760 std::map <uint16_t,uint32_t>::iterator itP10 = m_p10CqiTimers.begin ();
1761 while (itP10 != m_p10CqiTimers.end ())
1763 NS_LOG_INFO (
this <<
" P10-CQI for user " << (*itP10).first <<
" is " << (uint32_t)(*itP10).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1764 if ((*itP10).second == 0)
1767 std::map <uint16_t,uint8_t>::iterator itMap = m_p10CqiRxed.find ((*itP10).first);
1768 NS_ASSERT_MSG (itMap != m_p10CqiRxed.end (),
" Does not find CQI report for user " << (*itP10).first);
1769 NS_LOG_INFO (
this <<
" P10-CQI exired for user " << (*itP10).first);
1770 m_p10CqiRxed.erase (itMap);
1771 std::map <uint16_t,uint32_t>::iterator temp = itP10;
1773 m_p10CqiTimers.erase (temp);
1787 RrFfMacScheduler::RefreshUlCqiMaps (
void)
1790 std::map <uint16_t,uint32_t>::iterator itUl = m_ueCqiTimers.begin ();
1791 while (itUl != m_ueCqiTimers.end ())
1793 NS_LOG_INFO (
this <<
" UL-CQI for user " << (*itUl).first <<
" is " << (uint32_t)(*itUl).second <<
" thr " << (uint32_t)m_cqiTimersThreshold);
1794 if ((*itUl).second == 0)
1797 std::map <uint16_t, std::vector <double> >::iterator itMap = m_ueCqi.find ((*itUl).first);
1798 NS_ASSERT_MSG (itMap != m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
1799 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
1800 (*itMap).second.clear ();
1801 m_ueCqi.erase (itMap);
1802 std::map <uint16_t,uint32_t>::iterator temp = itUl;
1804 m_ueCqiTimers.erase (temp);
1817 RrFfMacScheduler::UpdateDlRlcBufferInfo (uint16_t rnti, uint8_t lcid, uint16_t size)
1820 std::list<FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
1821 for (it = m_rlcBufferReq.begin (); it != m_rlcBufferReq.end (); it++)
1823 if (((*it).m_rnti == rnti) && ((*it).m_logicalChannelIdentity == lcid))
1825 NS_LOG_INFO (
this <<
" UE " << rnti <<
" LC " << (uint16_t)lcid <<
" txqueue " << (*it).m_rlcTransmissionQueueSize <<
" retxqueue " << (*it).m_rlcRetransmissionQueueSize <<
" status " << (*it).m_rlcStatusPduSize <<
" decrease " << size);
1828 if (((*it).m_rlcStatusPduSize > 0) && (size >= (*it).m_rlcStatusPduSize))
1830 (*it).m_rlcStatusPduSize = 0;
1832 else if (((*it).m_rlcRetransmissionQueueSize > 0) && (size >= (*it).m_rlcRetransmissionQueueSize))
1834 (*it).m_rlcRetransmissionQueueSize = 0;
1836 else if ((*it).m_rlcTransmissionQueueSize > 0)
1839 if ((*it).m_rlcTransmissionQueueSize <= size)
1841 (*it).m_rlcTransmissionQueueSize = 0;
1846 (*it).m_rlcTransmissionQueueSize -= size;
1855 RrFfMacScheduler::UpdateUlRlcBufferInfo (uint16_t rnti, uint16_t size)
1859 std::map <uint16_t,uint32_t>::iterator it = m_ceBsrRxed.find (rnti);
1860 if (it != m_ceBsrRxed.end ())
1862 NS_LOG_INFO (
this <<
" Update RLC BSR UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
1863 if ((*it).second >= size)
1865 (*it).second -= size;
1874 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
1881 RrFfMacScheduler::TransmissionModeConfigurationUpdate (uint16_t rnti, uint8_t txMode)
1883 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
1884 FfMacCschedSapUser::CschedUeConfigUpdateIndParameters params;
1885 params.m_rnti = rnti;
1886 params.m_transmissionMode = txMode;
1887 m_cschedSapUser->CschedUeConfigUpdateInd (params);
#define NS_LOG_FUNCTION(parameters)
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
See section 4.3.10 buildRARListElement.
virtual ~RrFfMacScheduler()
#define NS_FATAL_ERROR(msg)
fatal error handling
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
Hold an unsigned integer type.
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
#define NS_LOG_LOGIC(msg)
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
#define NS_ASSERT_MSG(condition, message)
Implements the SCHED SAP and CSCHED SAP for a Round Robin scheduler.
RrFfMacScheduler()
Constructor.
#define NS_LOG_ERROR(msg)
virtual void DoDispose(void)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.