23 #include <ns3/pointer.h>
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/pss-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
33 #include <ns3/string.h>
145 : m_scheduler (scheduler)
220 : m_cschedSapUser (0),
225 m_amc = CreateObject <LteAmc> ();
255 .AddConstructor<PssFfMacScheduler> ()
256 .AddAttribute (
"CqiTimerThreshold",
257 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
260 MakeUintegerChecker<uint32_t> ())
261 .AddAttribute (
"PssFdSchedulerType",
262 "FD scheduler in PSS (default value is PFsch)",
265 MakeStringChecker ())
266 .AddAttribute (
"nMux",
267 "The number of UE selected by TD scheduler (default value is 0)",
270 MakeUintegerChecker<uint32_t> ())
271 .AddAttribute (
"HarqEnabled",
272 "Activate/Deactivate the HARQ [by default is active].",
275 MakeBooleanChecker ())
276 .AddAttribute (
"UlGrantMcs",
277 "The MCS of the UL grant, must be [0..15] (default 0)",
280 MakeUintegerChecker<uint8_t> ())
335 dlHarqPrcStatus.resize (8,0);
338 dlHarqProcessesTimer.resize (8,0);
341 dlHarqdci.resize (8);
344 dlHarqRlcPdu.resize (2);
345 dlHarqRlcPdu.at (0).resize (8);
346 dlHarqRlcPdu.at (1).resize (8);
350 ulHarqPrcStatus.resize (8,0);
353 ulHarqdci.resize (8);
368 std::map <uint16_t, pssFlowPerf_t>::iterator it;
414 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
415 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
450 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
451 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
454 if ((*it).first.m_rnti == params.
m_rnti)
480 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
488 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
492 (*it).second = params;
517 for (
int i = 0; i < 4; i++)
532 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
536 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
537 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
538 || ((*it).second.m_rlcStatusPduSize > 0) ))
542 if ((*it).first.m_rnti > rnti)
565 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
567 uint8_t i = (*it).second;
572 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
573 if ((*itStat).second.at (i) == 0)
604 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
606 uint8_t i = (*it).second;
611 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
612 if ((*itStat).second.at (i) == 0)
615 (*itStat).second.at (i) = 1;
619 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
622 return ((*it).second);
631 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
640 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
641 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
644 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
646 (*itStat).second.at (i) = 0;
647 (*itTimers).second.at (i) = 0;
651 (*itTimers).second.at (i)++;
674 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
675 std::vector <bool> rbgMap;
676 uint16_t rbgAllocatedNum = 0;
677 std::set <uint16_t> rntiAllocated;
683 uint16_t rbStart = 0;
684 std::vector <struct RachListElement_s>::iterator itRach;
689 newRar.
m_rnti = (*itRach).m_rnti;
693 newRar.m_grant.m_rnti = newRar.m_rnti;
696 uint16_t tbSizeBits = 0;
703 if (tbSizeBits < (*itRach).m_estimatedSize)
708 newRar.m_grant.m_rbStart = rbStart;
709 newRar.m_grant.m_rbLen = rbLen;
710 newRar.m_grant.m_tbSize = tbSizeBits / 8;
711 newRar.m_grant.m_hopping =
false;
712 newRar.m_grant.m_tpc = 0;
713 newRar.m_grant.m_cqiRequest =
false;
714 newRar.m_grant.m_ulDelay =
false;
715 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);
716 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
720 rbStart = rbStart + rbLen;
734 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
750 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
754 if (itRnti != rntiAllocated.end ())
760 std::vector <bool> retx;
761 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
765 retx.push_back (
false);
772 if (retx.at (0) || retx.at (1))
777 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
786 if (dci.
m_rv.size () == 1)
788 rv = dci.
m_rv.at (0);
792 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
798 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
804 (*it).second.at (harqId) = 0;
810 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
812 (*itRlcPdu).second.at (k).at (harqId).clear ();
818 std::vector <int> dciRbg;
821 for (
int j = 0; j < 32; j++)
825 dciRbg.push_back (j);
831 for (uint8_t j = 0; j < dciRbg.size (); j++)
833 if (rbgMap.at (dciRbg.at (j)) ==
true)
843 for (uint8_t j = 0; j < dciRbg.size (); j++)
845 rbgMap.at (dciRbg.at (j)) =
true;
846 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
850 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
856 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
857 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
858 std::vector <bool> rbgMapCopy = rbgMap;
859 while ((j < dciRbg.size ())&&(startRbg != rbgId))
861 if (rbgMapCopy.at (rbgId) ==
false)
863 rbgMapCopy.at (rbgId) =
true;
864 dciRbg.at (j) = rbgId;
869 if (j == dciRbg.size ())
872 uint32_t rbgMask = 0;
873 for (uint16_t k = 0; k < dciRbg.size (); k++)
875 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
880 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
885 dlInfoListUntxed.push_back (params.
m_dlInfoList.at (i));
886 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
894 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
896 for (uint8_t j = 0; j < nLayers; j++)
900 if (j >= dci.
m_ndi.size ())
903 dci.
m_ndi.push_back (0);
904 dci.
m_rv.push_back (0);
905 dci.
m_mcs.push_back (0);
907 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
911 dci.
m_ndi.at (j) = 0;
913 (*itHarq).second.at (harqId).m_rv.at (j)++;
914 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
920 dci.
m_ndi.at (j) = 0;
922 dci.
m_mcs.at (j) = 0;
924 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
927 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
929 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
930 for (uint8_t j = 0; j < nLayers; j++)
934 if (j < dci.
m_ndi.size ())
936 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
941 if (rlcPduListPerLc.size () > 0)
948 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
953 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
955 (*itHarqTimer).second.at (harqId) = 0;
957 rntiAllocated.insert (rnti);
974 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
984 std::map <uint16_t, pssFlowPerf_t>::iterator it;
985 std::map <uint16_t, pssFlowPerf_t> tdUeSet;
988 std::map <uint16_t, pssFlowPerf_t> ueSet;
993 ueSet.insert(std::pair <uint16_t, pssFlowPerf_t> ((*it).first, (*it).second));
997 if (ueSet.size() != 0)
1001 std::vector <std::pair<double, uint16_t> > ueSet1;
1002 std::vector <std::pair<double,uint16_t> > ueSet2;
1003 for (it = ueSet.begin (); it != ueSet.end (); it++)
1005 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1009 if (itRnti != rntiAllocated.end ())
1011 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1015 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1020 double metric = 0.0;
1021 if ((*it).second.lastAveragedThroughput < (*it).second.targetThroughput )
1024 metric = 1 / (*it).second.lastAveragedThroughput;
1025 ueSet1.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1030 std::map <uint16_t,uint8_t>::iterator itCqi;
1032 std::map <uint16_t,uint8_t>::iterator itTxMode;
1036 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1046 wbCqi = (*itCqi).second;
1054 double achievableRate = 0.0;
1055 for (uint8_t k = 0; k < nLayer; k++)
1062 metric = achievableRate / (*it).second.lastAveragedThroughput;
1066 ueSet2.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1071 if (ueSet1.size () != 0 || ueSet2.size () != 0)
1074 std::sort (ueSet1.rbegin (), ueSet1.rend ());
1075 std::sort (ueSet2.rbegin (), ueSet2.rend ());
1084 if (ueSet1.size() + ueSet2.size() <=2 )
1087 nMux = (int)((ueSet1.size() + ueSet2.size()) / 2) ;
1091 std::vector <std::pair<double, uint16_t> >::iterator itSet;
1092 for (itSet = ueSet1.begin (); itSet != ueSet1.end () && nMux != 0; itSet++)
1094 std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1096 tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1103 for (itSet = ueSet2.begin (); itSet != ueSet2.end () && nMux != 0; itSet++)
1105 std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1107 tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1120 std::map < uint16_t, uint8_t > sbCqiSum;
1121 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1124 for (
int i = 0; i < rbgNum; i++)
1126 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1128 std::map <uint16_t,uint8_t>::iterator itTxMode;
1132 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1135 std::vector <uint8_t> sbCqis;
1138 for (uint8_t k = 0; k < nLayer; k++)
1140 sbCqis.push_back (1);
1145 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1148 uint8_t cqi1 = sbCqis.at (0);
1150 if (sbCqis.size () > 1)
1152 cqi2 = sbCqis.at (1);
1156 if ((cqi1 > 0)||(cqi2 > 0))
1158 for (uint8_t k = 0; k < nLayer; k++)
1160 if (sbCqis.size () > k)
1162 sbCqi = sbCqis.at(k);
1174 sbCqiSum.insert (std::pair<uint16_t, uint8_t> ((*it).first, sum));
1177 for (
int i = 0; i < rbgNum; i++)
1179 if (rbgMap.at (i) ==
true)
1182 std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1183 double metricMax = 0.0;
1184 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1187 double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1191 std::map < uint16_t, uint8_t>::iterator itSbCqiSum;
1192 itSbCqiSum = sbCqiSum.find((*it).first);
1194 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1196 std::map <uint16_t,uint8_t>::iterator itTxMode;
1200 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1203 std::vector <uint8_t> sbCqis;
1206 for (uint8_t k = 0; k < nLayer; k++)
1208 sbCqis.push_back (1);
1213 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1216 uint8_t cqi1 = sbCqis.at( 0);
1218 if (sbCqis.size () > 1)
1220 cqi2 = sbCqis.at(1);
1224 double colMetric = 0.0;
1225 if ((cqi1 > 0)||(cqi2 > 0))
1227 for (uint8_t k = 0; k < nLayer; k++)
1229 if (sbCqis.size () > k)
1231 sbCqi = sbCqis.at(k);
1238 colMetric += (double)sbCqi / (
double)(*itSbCqiSum).second;
1242 double metric = 0.0;
1244 metric= weight * colMetric;
1248 if (metric > metricMax )
1262 allocationMap[(*itMax).first].push_back (i);
1263 rbgMap.at (i) =
true;
1273 for (
int i = 0; i < rbgNum; i++)
1275 if (rbgMap.at (i) ==
true)
1278 std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1279 double metricMax = 0.0;
1280 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1283 double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1287 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1289 std::map <uint16_t,uint8_t>::iterator itTxMode;
1293 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1296 std::vector <uint8_t> sbCqis;
1299 for (uint8_t k = 0; k < nLayer; k++)
1301 sbCqis.push_back (1);
1306 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1309 uint8_t cqi1 = sbCqis.at(0);
1311 if (sbCqis.size () > 1)
1313 cqi2 = sbCqis.at(1);
1316 double schMetric = 0.0;
1317 if ((cqi1 > 0)||(cqi2 > 0))
1319 double achievableRate = 0.0;
1320 for (uint8_t k = 0; k < nLayer; k++)
1323 if (sbCqis.size () > k)
1334 schMetric = achievableRate / (*it).second.secondLastAveragedThroughput;
1337 double metric = 0.0;
1338 metric= weight * schMetric;
1340 if (metric > metricMax )
1354 allocationMap[(*itMax).first].push_back (i);
1355 rbgMap.at (i) =
true;
1369 std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1372 (*itStats).second.lastTtiBytesTransmitted = 0;
1377 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1378 while (itMap != allocationMap.end ())
1382 newEl.
m_rnti = (*itMap).first;
1385 newDci.
m_rnti = (*itMap).first;
1393 lcActives = (uint16_t)65535;
1395 uint16_t RgbPerRnti = (*itMap).second.size ();
1396 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1398 std::map <uint16_t,uint8_t>::iterator itTxMode;
1402 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1405 std::vector <uint8_t> worstCqi (2, 15);
1408 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1410 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1412 NS_LOG_INFO (
this <<
" RBG " << (*itMap).second.at (k) <<
" CQI " << (uint16_t)((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (0)) );
1413 for (uint8_t j = 0; j < nLayer; j++)
1415 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1417 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1419 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1425 worstCqi.at (j) = 1;
1431 for (uint8_t j = 0; j < nLayer; j++)
1433 worstCqi.at (j) = 1;
1440 for (uint8_t j = 0; j < nLayer; j++)
1442 worstCqi.at (j) = 1;
1445 for (uint8_t j = 0; j < nLayer; j++)
1447 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1449 uint32_t bytesTxed = 0;
1450 for (uint8_t j = 0; j < nLayer; j++)
1456 bytesTxed += tbSize;
1461 uint32_t rbgMask = 0;
1462 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1464 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1465 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1470 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1473 if (((*itBufReq).first.m_rnti == (*itMap).first)
1474 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1475 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1476 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1478 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1479 for (uint8_t j = 0; j < nLayer; j++)
1485 newRlcPduLe.push_back (newRlcEl);
1493 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1495 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1500 if ((*itBufReq).first.m_rnti > (*itMap).first)
1505 for (uint8_t j = 0; j < nLayer; j++)
1507 newDci.
m_ndi.push_back (1);
1508 newDci.
m_rv.push_back (0);
1511 newEl.
m_dci = newDci;
1535 std::map <uint16_t, pssFlowPerf_t>::iterator it;
1539 (*it).second.lastTtiBytesTransmitted = bytesTxed;
1540 NS_LOG_INFO (
this <<
" UE total bytes txed " << (*it).second.lastTtiBytesTransmitted);
1558 std::map <uint16_t, pssFlowPerf_t>::iterator itUeScheduleted = tdUeSet.end();
1559 itUeScheduleted = tdUeSet.find((*itStats).first);
1560 if (itUeScheduleted != tdUeSet.end())
1562 (*itStats).second.secondLastAveragedThroughput = ((1.0 - (1 /
m_timeWindow)) * (*itStats).second.secondLastAveragedThroughput) + ((1 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1565 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTransmitted;
1567 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 /
m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1568 (*itStats).second.lastTtiBytesTransmitted = 0;
1593 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1598 std::map <uint16_t,uint8_t>::iterator it;
1599 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1604 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1611 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1613 std::map <uint16_t,uint32_t>::iterator itTimers;
1621 std::map <uint16_t,SbMeasResult_s>::iterator it;
1622 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1627 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1633 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1634 std::map <uint16_t,uint32_t>::iterator itTimers;
1652 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1666 double sinr = (*itCqi).second.at (i);
1673 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1675 (*itCqi).second.at (rb) = estimatedSinr;
1676 return (estimatedSinr);
1689 std::vector <bool> rbMap;
1690 uint16_t rbAllocatedNum = 0;
1691 std::set <uint16_t> rntiAllocated;
1692 std::vector <uint16_t> rbgAllocationMap;
1703 if (rbgAllocationMap.at (i) != 0)
1705 rbMap.at (i) =
true;
1715 std::map <uint16_t, uint8_t>::iterator itProcId;
1718 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
1721 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1730 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1733 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1737 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1744 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1746 if ((*itStat).second.at (harqId) >= 3)
1748 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1754 if (rbMap.at (j) ==
true)
1765 rbMap.at (j) =
true;
1766 rbgAllocationMap.at (j) = dci.
m_rnti;
1774 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1779 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1780 (*itStat).second.at (harqId) = 0;
1781 (*itHarq).second.at ((*itProcId).second) = dci;
1783 rntiAllocated.insert (dci.
m_rnti);
1792 std::map <uint16_t,uint32_t>::iterator it;
1797 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1799 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1822 int rbAllocated = 0;
1824 std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1846 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1847 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1850 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1872 uldci.
m_rnti = (*it).first;
1874 bool allocated =
false;
1875 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1880 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1882 if (rbMap.at (j) ==
true)
1892 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1894 rbMap.at (j) =
true;
1896 rbgAllocationMap.at (j) = (*it).first;
1898 rbAllocated += rbPerFlow;
1929 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1939 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1946 double sinr = (*itCqi).second.at (i);
1951 if ((*itCqi).second.at (i) < minSinr)
1953 minSinr = (*itCqi).second.at (i);
1958 double s = log2 ( 1 + (
1959 std::pow (10, minSinr / 10 ) /
1960 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1974 rbgAllocationMap.at (i) = 0;
2000 std::map <uint16_t, uint8_t>::iterator itProcId;
2006 harqId = (*itProcId).second;
2012 (*itDci).second.at (harqId) = uldci;
2015 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);
2057 std::map <uint16_t,uint32_t>::iterator it;
2059 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
2070 uint32_t buffer = 0;
2071 for (uint8_t lcg = 0; lcg < 4; ++lcg)
2073 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
2078 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
2083 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
2088 (*it).second = buffer;
2131 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2132 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2133 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2139 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2143 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
2147 std::vector <double> newCqi;
2152 newCqi.push_back (sinr);
2161 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2168 (*itCqi).second.at (i) = sinr;
2169 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2171 std::map <uint16_t, uint32_t>::iterator itTimers;
2192 rnti = vsp->GetRnti ();
2195 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2200 std::vector <double> newCqi;
2204 newCqi.push_back (sinr);
2205 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2208 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2218 (*itCqi).second.at (j) = sinr;
2219 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2222 std::map <uint16_t, uint32_t>::iterator itTimers;
2235 NS_FATAL_ERROR (
"PssFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2248 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2252 if ((*itP10).second == 0)
2255 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2257 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2259 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2271 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2275 if ((*itA30).second == 0)
2278 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2280 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2282 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2301 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2305 if ((*itUl).second == 0)
2308 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2309 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2310 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2311 (*itMap).second.clear ();
2313 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2330 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2335 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);
2338 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2340 (*it).second.m_rlcStatusPduSize = 0;
2342 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2344 (*it).second.m_rlcRetransmissionQueueSize = 0;
2346 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2348 uint32_t rlcOverhead;
2363 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2365 (*it).second.m_rlcTransmissionQueueSize = 0;
2369 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2375 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2384 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2387 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2388 if ((*it).second >= size)
2390 (*it).second -= size;
2399 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2407 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);