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>
32 #include <ns3/string.h>
144 : m_scheduler (scheduler)
219 : m_cschedSapUser (0),
224 m_amc = CreateObject <LteAmc> ();
254 .AddConstructor<PssFfMacScheduler> ()
255 .AddAttribute (
"CqiTimerThreshold",
256 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
259 MakeUintegerChecker<uint32_t> ())
260 .AddAttribute (
"PssFdSchedulerType",
261 "FD scheduler in PSS (default value is PFsch)",
264 MakeStringChecker ())
265 .AddAttribute (
"nMux",
266 "The number of UE selected by TD scheduler (default value is 0)",
269 MakeUintegerChecker<uint32_t> ())
270 .AddAttribute (
"HarqEnabled",
271 "Activate/Deactivate the HARQ [by default is active].",
274 MakeBooleanChecker ())
275 .AddAttribute (
"UlGrantMcs",
276 "The MCS of the UL grant, must be [0..15] (default 0)",
279 MakeUintegerChecker<uint8_t> ())
334 dlHarqPrcStatus.resize (8,0);
337 dlHarqProcessesTimer.resize (8,0);
340 dlHarqdci.resize (8);
343 dlHarqRlcPdu.resize (2);
344 dlHarqRlcPdu.at (0).resize (8);
345 dlHarqRlcPdu.at (1).resize (8);
349 ulHarqPrcStatus.resize (8,0);
352 ulHarqdci.resize (8);
367 std::map <uint16_t, pssFlowPerf_t>::iterator it;
415 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
416 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
451 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
452 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
455 if ((*it).first.m_rnti == params.
m_rnti)
481 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
489 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
493 (*it).second = params;
518 for (
int i = 0; i < 4; i++)
533 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
537 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
538 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
539 || ((*it).second.m_rlcStatusPduSize > 0) ))
543 if ((*it).first.m_rnti > rnti)
566 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
568 uint8_t i = (*it).second;
573 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
574 if ((*itStat).second.at (i) == 0)
605 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
607 uint8_t i = (*it).second;
612 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
613 if ((*itStat).second.at (i) == 0)
616 (*itStat).second.at (i) = 1;
620 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
623 return ((*it).second);
632 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
641 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
642 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
645 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
647 (*itStat).second.at (i) = 0;
648 (*itTimers).second.at (i) = 0;
652 (*itTimers).second.at (i)++;
675 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
676 std::vector <bool> rbgMap;
677 uint16_t rbgAllocatedNum = 0;
678 std::set <uint16_t> rntiAllocated;
684 uint16_t rbStart = 0;
685 std::vector <struct RachListElement_s>::iterator itRach;
690 newRar.
m_rnti = (*itRach).m_rnti;
694 newRar.m_grant.m_rnti = newRar.m_rnti;
697 uint16_t tbSizeBits = 0;
704 if (tbSizeBits < (*itRach).m_estimatedSize)
709 newRar.m_grant.m_rbStart = rbStart;
710 newRar.m_grant.m_rbLen = rbLen;
711 newRar.m_grant.m_tbSize = tbSizeBits / 8;
712 newRar.m_grant.m_hopping =
false;
713 newRar.m_grant.m_tpc = 0;
714 newRar.m_grant.m_cqiRequest =
false;
715 newRar.m_grant.m_ulDelay =
false;
716 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);
717 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
721 rbStart = rbStart + rbLen;
735 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
751 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
755 if (itRnti != rntiAllocated.end ())
761 std::vector <bool> retx;
762 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
766 retx.push_back (
false);
773 if (retx.at (0) || retx.at (1))
778 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
787 if (dci.
m_rv.size () == 1)
789 rv = dci.
m_rv.at (0);
793 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
799 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
805 (*it).second.at (harqId) = 0;
811 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
813 (*itRlcPdu).second.at (k).at (harqId).clear ();
819 std::vector <int> dciRbg;
822 for (
int j = 0; j < 32; j++)
826 dciRbg.push_back (j);
832 for (uint8_t j = 0; j < dciRbg.size (); j++)
834 if (rbgMap.at (dciRbg.at (j)) ==
true)
844 for (uint8_t j = 0; j < dciRbg.size (); j++)
846 rbgMap.at (dciRbg.at (j)) =
true;
847 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
851 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
857 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
858 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
859 std::vector <bool> rbgMapCopy = rbgMap;
860 while ((j < dciRbg.size ())&&(startRbg != rbgId))
862 if (rbgMapCopy.at (rbgId) ==
false)
864 rbgMapCopy.at (rbgId) =
true;
865 dciRbg.at (j) = rbgId;
870 if (j == dciRbg.size ())
873 uint32_t rbgMask = 0;
874 for (uint16_t k = 0; k < dciRbg.size (); k++)
876 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
881 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
886 dlInfoListUntxed.push_back (params.
m_dlInfoList.at (i));
887 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
895 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
897 for (uint8_t j = 0; j < nLayers; j++)
901 if (j >= dci.
m_ndi.size ())
904 dci.
m_ndi.push_back (0);
905 dci.
m_rv.push_back (0);
906 dci.
m_mcs.push_back (0);
908 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
912 dci.
m_ndi.at (j) = 0;
914 (*itHarq).second.at (harqId).m_rv.at (j)++;
915 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
921 dci.
m_ndi.at (j) = 0;
923 dci.
m_mcs.at (j) = 0;
925 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
928 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
930 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
931 for (uint8_t j = 0; j < nLayers; j++)
935 if (j < dci.
m_ndi.size ())
937 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
942 if (rlcPduListPerLc.size () > 0)
949 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
954 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
956 (*itHarqTimer).second.at (harqId) = 0;
958 rntiAllocated.insert (rnti);
975 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
985 std::map <uint16_t, pssFlowPerf_t>::iterator it;
986 std::map <uint16_t, pssFlowPerf_t> tdUeSet;
989 std::map <uint16_t, pssFlowPerf_t> ueSet;
994 ueSet.insert(std::pair <uint16_t, pssFlowPerf_t> ((*it).first, (*it).second));
998 if (ueSet.size() != 0)
1002 std::vector <std::pair<double, uint16_t> > ueSet1;
1003 std::vector <std::pair<double,uint16_t> > ueSet2;
1004 for (it = ueSet.begin (); it != ueSet.end (); it++)
1006 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1010 if (itRnti != rntiAllocated.end ())
1012 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1016 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1021 double metric = 0.0;
1022 if ((*it).second.lastAveragedThroughput < (*it).second.targetThroughput )
1025 metric = 1 / (*it).second.lastAveragedThroughput;
1026 ueSet1.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1031 std::map <uint16_t,uint8_t>::iterator itCqi;
1033 std::map <uint16_t,uint8_t>::iterator itTxMode;
1037 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1047 wbCqi = (*itCqi).second;
1055 double achievableRate = 0.0;
1056 for (uint8_t k = 0; k < nLayer; k++)
1063 metric = achievableRate / (*it).second.lastAveragedThroughput;
1067 ueSet2.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1072 if (ueSet1.size () != 0 || ueSet2.size () != 0)
1075 std::sort (ueSet1.rbegin (), ueSet1.rend ());
1076 std::sort (ueSet2.rbegin (), ueSet2.rend ());
1085 if (ueSet1.size() + ueSet2.size() <=2 )
1088 nMux = (int)((ueSet1.size() + ueSet2.size()) / 2) ;
1092 std::vector <std::pair<double, uint16_t> >::iterator itSet;
1093 for (itSet = ueSet1.begin (); itSet != ueSet1.end () && nMux != 0; itSet++)
1095 std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1097 tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1104 for (itSet = ueSet2.begin (); itSet != ueSet2.end () && nMux != 0; itSet++)
1106 std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1108 tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1121 std::map < uint16_t, uint8_t > sbCqiSum;
1122 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1125 for (
int i = 0; i < rbgNum; i++)
1127 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1129 std::map <uint16_t,uint8_t>::iterator itTxMode;
1133 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1136 std::vector <uint8_t> sbCqis;
1139 for (uint8_t k = 0; k < nLayer; k++)
1141 sbCqis.push_back (1);
1146 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1149 uint8_t cqi1 = sbCqis.at (0);
1151 if (sbCqis.size () > 1)
1153 cqi2 = sbCqis.at (1);
1157 if ((cqi1 > 0)||(cqi2 > 0))
1159 for (uint8_t k = 0; k < nLayer; k++)
1161 if (sbCqis.size () > k)
1163 sbCqi = sbCqis.at(k);
1175 sbCqiSum.insert (std::pair<uint16_t, uint8_t> ((*it).first, sum));
1178 for (
int i = 0; i < rbgNum; i++)
1180 if (rbgMap.at (i) ==
true)
1183 std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1184 double metricMax = 0.0;
1185 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1188 double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1192 std::map < uint16_t, uint8_t>::iterator itSbCqiSum;
1193 itSbCqiSum = sbCqiSum.find((*it).first);
1195 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1197 std::map <uint16_t,uint8_t>::iterator itTxMode;
1201 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1204 std::vector <uint8_t> sbCqis;
1207 for (uint8_t k = 0; k < nLayer; k++)
1209 sbCqis.push_back (1);
1214 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1217 uint8_t cqi1 = sbCqis.at( 0);
1219 if (sbCqis.size () > 1)
1221 cqi2 = sbCqis.at(1);
1225 double colMetric = 0.0;
1226 if ((cqi1 > 0)||(cqi2 > 0))
1228 for (uint8_t k = 0; k < nLayer; k++)
1230 if (sbCqis.size () > k)
1232 sbCqi = sbCqis.at(k);
1239 colMetric += (double)sbCqi / (
double)(*itSbCqiSum).second;
1243 double metric = 0.0;
1245 metric= weight * colMetric;
1249 if (metric > metricMax )
1263 allocationMap[(*itMax).first].push_back (i);
1264 rbgMap.at (i) =
true;
1274 for (
int i = 0; i < rbgNum; i++)
1276 if (rbgMap.at (i) ==
true)
1279 std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1280 double metricMax = 0.0;
1281 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1284 double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1288 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1290 std::map <uint16_t,uint8_t>::iterator itTxMode;
1294 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1297 std::vector <uint8_t> sbCqis;
1300 for (uint8_t k = 0; k < nLayer; k++)
1302 sbCqis.push_back (1);
1307 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1310 uint8_t cqi1 = sbCqis.at(0);
1312 if (sbCqis.size () > 1)
1314 cqi2 = sbCqis.at(1);
1317 double schMetric = 0.0;
1318 if ((cqi1 > 0)||(cqi2 > 0))
1320 double achievableRate = 0.0;
1321 for (uint8_t k = 0; k < nLayer; k++)
1324 if (sbCqis.size () > k)
1335 schMetric = achievableRate / (*it).second.secondLastAveragedThroughput;
1338 double metric = 0.0;
1339 metric= weight * schMetric;
1341 if (metric > metricMax )
1355 allocationMap[(*itMax).first].push_back (i);
1356 rbgMap.at (i) =
true;
1370 std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1373 (*itStats).second.lastTtiBytesTransmitted = 0;
1378 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1379 while (itMap != allocationMap.end ())
1383 newEl.
m_rnti = (*itMap).first;
1386 newDci.
m_rnti = (*itMap).first;
1391 uint16_t RgbPerRnti = (*itMap).second.size ();
1392 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1394 std::map <uint16_t,uint8_t>::iterator itTxMode;
1398 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1401 std::vector <uint8_t> worstCqi (2, 15);
1404 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1406 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1408 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)) );
1409 for (uint8_t j = 0; j < nLayer; j++)
1411 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1413 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1415 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1421 worstCqi.at (j) = 1;
1427 for (uint8_t j = 0; j < nLayer; j++)
1429 worstCqi.at (j) = 1;
1436 for (uint8_t j = 0; j < nLayer; j++)
1438 worstCqi.at (j) = 1;
1441 for (uint8_t j = 0; j < nLayer; j++)
1443 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1445 uint32_t bytesTxed = 0;
1446 for (uint8_t j = 0; j < nLayer; j++)
1452 bytesTxed += tbSize;
1457 uint32_t rbgMask = 0;
1458 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1460 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1461 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1466 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1469 if (((*itBufReq).first.m_rnti == (*itMap).first)
1470 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1471 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1472 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1474 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1475 for (uint8_t j = 0; j < nLayer; j++)
1481 newRlcPduLe.push_back (newRlcEl);
1489 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1491 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1496 if ((*itBufReq).first.m_rnti > (*itMap).first)
1501 for (uint8_t j = 0; j < nLayer; j++)
1503 newDci.
m_ndi.push_back (1);
1504 newDci.
m_rv.push_back (0);
1507 newEl.
m_dci = newDci;
1531 std::map <uint16_t, pssFlowPerf_t>::iterator it;
1535 (*it).second.lastTtiBytesTransmitted = bytesTxed;
1536 NS_LOG_INFO (
this <<
" UE total bytes txed " << (*it).second.lastTtiBytesTransmitted);
1554 std::map <uint16_t, pssFlowPerf_t>::iterator itUeScheduleted = tdUeSet.end();
1555 itUeScheduleted = tdUeSet.find((*itStats).first);
1556 if (itUeScheduleted != tdUeSet.end())
1558 (*itStats).second.secondLastAveragedThroughput = ((1.0 - (1 /
m_timeWindow)) * (*itStats).second.secondLastAveragedThroughput) + ((1 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1561 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTransmitted;
1563 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 /
m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1564 (*itStats).second.lastTtiBytesTransmitted = 0;
1589 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1594 std::map <uint16_t,uint8_t>::iterator it;
1595 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1600 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1607 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1609 std::map <uint16_t,uint32_t>::iterator itTimers;
1617 std::map <uint16_t,SbMeasResult_s>::iterator it;
1618 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1623 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1629 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1630 std::map <uint16_t,uint32_t>::iterator itTimers;
1648 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1662 double sinr = (*itCqi).second.at (i);
1669 double estimatedSinr = sinrSum / (double)sinrNum;
1671 (*itCqi).second.at (rb) = estimatedSinr;
1672 return (estimatedSinr);
1685 std::vector <bool> rbMap;
1686 uint16_t rbAllocatedNum = 0;
1687 std::set <uint16_t> rntiAllocated;
1688 std::vector <uint16_t> rbgAllocationMap;
1699 if (rbgAllocationMap.at (i) != 0)
1701 rbMap.at (i) =
true;
1711 std::map <uint16_t, uint8_t>::iterator itProcId;
1714 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
1717 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1726 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1729 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1733 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1740 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1742 if ((*itStat).second.at (harqId) >= 3)
1744 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1750 if (rbMap.at (j) ==
true)
1761 rbMap.at (j) =
true;
1762 rbgAllocationMap.at (j) = dci.
m_rnti;
1770 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1775 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1776 (*itStat).second.at (harqId) = 0;
1777 (*itHarq).second.at ((*itProcId).second) = dci;
1779 rntiAllocated.insert (dci.
m_rnti);
1788 std::map <uint16_t,uint32_t>::iterator it;
1793 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1795 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1818 int rbAllocated = 0;
1820 std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1842 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1843 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1867 uldci.
m_rnti = (*it).first;
1869 bool allocated =
false;
1870 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow);
1875 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1877 if (rbMap.at (j) ==
true)
1887 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1889 rbMap.at (j) =
true;
1891 rbgAllocationMap.at (j) = (*it).first;
1893 rbAllocated += rbPerFlow;
1924 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1934 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1941 double sinr = (*itCqi).second.at (i);
1946 if ((*itCqi).second.at (i) < minSinr)
1948 minSinr = (*itCqi).second.at (i);
1953 double s = log2 ( 1 + (
1954 pow (10, minSinr / 10 ) /
1955 ( (-log (5.0 * 0.00005 )) / 1.5) ));
1989 std::map <uint16_t, uint8_t>::iterator itProcId;
1995 harqId = (*itProcId).second;
2001 (*itDci).second.at (harqId) = uldci;
2004 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);
2046 std::map <uint16_t,uint32_t>::iterator it;
2048 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
2059 uint32_t buffer = 0;
2060 for (uint8_t lcg = 0; lcg < 4; ++lcg)
2062 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
2067 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
2072 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
2077 (*it).second = buffer;
2120 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2121 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2122 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2128 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2132 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
2136 std::vector <double> newCqi;
2141 newCqi.push_back (sinr);
2150 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2157 (*itCqi).second.at (i) = sinr;
2158 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2160 std::map <uint16_t, uint32_t>::iterator itTimers;
2181 rnti = vsp->GetRnti ();
2184 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2189 std::vector <double> newCqi;
2193 newCqi.push_back (sinr);
2194 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2197 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2207 (*itCqi).second.at (j) = sinr;
2208 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2211 std::map <uint16_t, uint32_t>::iterator itTimers;
2224 NS_FATAL_ERROR (
"PssFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2237 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2241 if ((*itP10).second == 0)
2244 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2246 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2248 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2260 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2264 if ((*itA30).second == 0)
2267 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2269 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2271 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2290 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2294 if ((*itUl).second == 0)
2297 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2298 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2299 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2300 (*itMap).second.clear ();
2302 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2319 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2324 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);
2327 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2329 (*it).second.m_rlcStatusPduSize = 0;
2331 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2333 (*it).second.m_rlcRetransmissionQueueSize = 0;
2335 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2338 if ((*it).second.m_rlcTransmissionQueueSize <= size)
2340 (*it).second.m_rlcTransmissionQueueSize = 0;
2345 (*it).second.m_rlcTransmissionQueueSize -= size;
2351 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2360 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2363 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2364 if ((*it).second >= size)
2366 (*it).second -= size;
2375 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2383 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);