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>
146 : m_scheduler (scheduler)
221 : m_cschedSapUser (0),
226 m_amc = CreateObject <LteAmc> ();
256 .AddConstructor<PssFfMacScheduler> ()
257 .AddAttribute (
"CqiTimerThreshold",
258 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
261 MakeUintegerChecker<uint32_t> ())
262 .AddAttribute (
"PssFdSchedulerType",
263 "FD scheduler in PSS (default value is PFsch)",
266 MakeStringChecker ())
267 .AddAttribute (
"nMux",
268 "The number of UE selected by TD scheduler (default value is 0)",
271 MakeUintegerChecker<uint32_t> ())
272 .AddAttribute (
"HarqEnabled",
273 "Activate/Deactivate the HARQ [by default is active].",
276 MakeBooleanChecker ())
277 .AddAttribute (
"UlGrantMcs",
278 "The MCS of the UL grant, must be [0..15] (default 0)",
281 MakeUintegerChecker<uint8_t> ())
336 dlHarqPrcStatus.resize (8,0);
339 dlHarqProcessesTimer.resize (8,0);
342 dlHarqdci.resize (8);
345 dlHarqRlcPdu.resize (2);
346 dlHarqRlcPdu.at (0).resize (8);
347 dlHarqRlcPdu.at (1).resize (8);
351 ulHarqPrcStatus.resize (8,0);
354 ulHarqdci.resize (8);
369 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;
683 std::map <uint16_t, uint8_t>::iterator itProcId;
686 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
691 uint16_t rbStart = 0;
692 std::vector <struct RachListElement_s>::iterator itRach;
697 newRar.
m_rnti = (*itRach).m_rnti;
701 newRar.m_grant.m_rnti = newRar.m_rnti;
704 uint16_t tbSizeBits = 0;
711 if (tbSizeBits < (*itRach).m_estimatedSize)
716 newRar.m_grant.m_rbStart = rbStart;
717 newRar.m_grant.m_rbLen = rbLen;
718 newRar.m_grant.m_tbSize = tbSizeBits / 8;
719 newRar.m_grant.m_hopping =
false;
720 newRar.m_grant.m_tpc = 0;
721 newRar.m_grant.m_cqiRequest =
false;
722 newRar.m_grant.m_ulDelay =
false;
723 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);
724 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
728 rbStart = rbStart + rbLen;
734 uldci.
m_rnti = newRar.m_rnti;
753 std::map <uint16_t, uint8_t>::iterator itProcId;
759 harqId = (*itProcId).second;
765 (*itDci).second.at (harqId) = uldci;
780 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
796 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
800 if (itRnti != rntiAllocated.end ())
806 std::vector <bool> retx;
807 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
811 retx.push_back (
false);
818 if (retx.at (0) || retx.at (1))
823 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
832 if (dci.
m_rv.size () == 1)
834 rv = dci.
m_rv.at (0);
838 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
844 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
850 (*it).second.at (harqId) = 0;
856 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
858 (*itRlcPdu).second.at (k).at (harqId).clear ();
864 std::vector <int> dciRbg;
867 for (
int j = 0; j < 32; j++)
871 dciRbg.push_back (j);
877 for (uint8_t j = 0; j < dciRbg.size (); j++)
879 if (rbgMap.at (dciRbg.at (j)) ==
true)
889 for (uint8_t j = 0; j < dciRbg.size (); j++)
891 rbgMap.at (dciRbg.at (j)) =
true;
892 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
896 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
902 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
903 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
904 std::vector <bool> rbgMapCopy = rbgMap;
905 while ((j < dciRbg.size ())&&(startRbg != rbgId))
907 if (rbgMapCopy.at (rbgId) ==
false)
909 rbgMapCopy.at (rbgId) =
true;
910 dciRbg.at (j) = rbgId;
915 if (j == dciRbg.size ())
918 uint32_t rbgMask = 0;
919 for (uint16_t k = 0; k < dciRbg.size (); k++)
921 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
926 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
931 dlInfoListUntxed.push_back (params.
m_dlInfoList.at (i));
932 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
940 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
942 for (uint8_t j = 0; j < nLayers; j++)
946 if (j >= dci.
m_ndi.size ())
949 dci.
m_ndi.push_back (0);
950 dci.
m_rv.push_back (0);
951 dci.
m_mcs.push_back (0);
953 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
957 dci.
m_ndi.at (j) = 0;
959 (*itHarq).second.at (harqId).m_rv.at (j)++;
960 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
966 dci.
m_ndi.at (j) = 0;
968 dci.
m_mcs.at (j) = 0;
970 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
973 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
975 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
976 for (uint8_t j = 0; j < nLayers; j++)
980 if (j < dci.
m_ndi.size ())
982 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
987 if (rlcPduListPerLc.size () > 0)
994 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
999 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
1001 (*itHarqTimer).second.at (harqId) = 0;
1003 rntiAllocated.insert (rnti);
1020 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1029 if (rbgAllocatedNum == rbgNum)
1040 std::map <uint16_t, pssFlowPerf_t>::iterator it;
1041 std::map <uint16_t, pssFlowPerf_t> tdUeSet;
1044 std::map <uint16_t, pssFlowPerf_t> ueSet;
1049 ueSet.insert(std::pair <uint16_t, pssFlowPerf_t> ((*it).first, (*it).second));
1053 if (ueSet.size() != 0)
1057 std::vector <std::pair<double, uint16_t> > ueSet1;
1058 std::vector <std::pair<double,uint16_t> > ueSet2;
1059 for (it = ueSet.begin (); it != ueSet.end (); it++)
1061 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1065 if (itRnti != rntiAllocated.end ())
1067 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1071 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1076 double metric = 0.0;
1077 if ((*it).second.lastAveragedThroughput < (*it).second.targetThroughput )
1080 metric = 1 / (*it).second.lastAveragedThroughput;
1081 ueSet1.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1086 std::map <uint16_t,uint8_t>::iterator itCqi;
1088 std::map <uint16_t,uint8_t>::iterator itTxMode;
1092 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1102 wbCqi = (*itCqi).second;
1110 double achievableRate = 0.0;
1111 for (uint8_t k = 0; k < nLayer; k++)
1114 mcs =
m_amc->GetMcsFromCqi (wbCqi);
1115 achievableRate += ((
m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001);
1118 metric = achievableRate / (*it).second.lastAveragedThroughput;
1122 ueSet2.push_back(std::pair<double, uint16_t> (metric, (*it).first));
1127 if (ueSet1.size () != 0 || ueSet2.size () != 0)
1130 std::sort (ueSet1.rbegin (), ueSet1.rend ());
1131 std::sort (ueSet2.rbegin (), ueSet2.rend ());
1140 if (ueSet1.size() + ueSet2.size() <=2 )
1143 nMux = (int)((ueSet1.size() + ueSet2.size()) / 2) ;
1147 std::vector <std::pair<double, uint16_t> >::iterator itSet;
1148 for (itSet = ueSet1.begin (); itSet != ueSet1.end () && nMux != 0; itSet++)
1150 std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1152 tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1159 for (itSet = ueSet2.begin (); itSet != ueSet2.end () && nMux != 0; itSet++)
1161 std::map <uint16_t, pssFlowPerf_t>::iterator itUe;
1163 tdUeSet.insert(std::pair<uint16_t, pssFlowPerf_t> ( (*itUe).first, (*itUe).second ) );
1176 std::map < uint16_t, uint8_t > sbCqiSum;
1177 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1180 for (
int i = 0; i < rbgNum; i++)
1182 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1184 std::map <uint16_t,uint8_t>::iterator itTxMode;
1188 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1191 std::vector <uint8_t> sbCqis;
1194 for (uint8_t k = 0; k < nLayer; k++)
1196 sbCqis.push_back (1);
1201 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1204 uint8_t cqi1 = sbCqis.at (0);
1206 if (sbCqis.size () > 1)
1208 cqi2 = sbCqis.at (1);
1212 if ((cqi1 > 0)||(cqi2 > 0))
1214 for (uint8_t k = 0; k < nLayer; k++)
1216 if (sbCqis.size () > k)
1218 sbCqi = sbCqis.at(k);
1230 sbCqiSum.insert (std::pair<uint16_t, uint8_t> ((*it).first, sum));
1233 for (
int i = 0; i < rbgNum; i++)
1235 if (rbgMap.at (i) ==
true)
1238 std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1239 double metricMax = 0.0;
1240 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1243 double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1247 std::map < uint16_t, uint8_t>::iterator itSbCqiSum;
1248 itSbCqiSum = sbCqiSum.find((*it).first);
1250 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1252 std::map <uint16_t,uint8_t>::iterator itTxMode;
1256 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1259 std::vector <uint8_t> sbCqis;
1262 for (uint8_t k = 0; k < nLayer; k++)
1264 sbCqis.push_back (1);
1269 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1272 uint8_t cqi1 = sbCqis.at( 0);
1274 if (sbCqis.size () > 1)
1276 cqi2 = sbCqis.at(1);
1280 double colMetric = 0.0;
1281 if ((cqi1 > 0)||(cqi2 > 0))
1283 for (uint8_t k = 0; k < nLayer; k++)
1285 if (sbCqis.size () > k)
1287 sbCqi = sbCqis.at(k);
1294 colMetric += (double)sbCqi / (
double)(*itSbCqiSum).second;
1298 double metric = 0.0;
1300 metric= weight * colMetric;
1304 if (metric > metricMax )
1318 allocationMap[(*itMax).first].push_back (i);
1319 rbgMap.at (i) =
true;
1329 for (
int i = 0; i < rbgNum; i++)
1331 if (rbgMap.at (i) ==
true)
1334 std::map <uint16_t, pssFlowPerf_t>::iterator itMax = tdUeSet.end ();
1335 double metricMax = 0.0;
1336 for (it = tdUeSet.begin (); it != tdUeSet.end (); it++)
1339 double weight = (*it).second.targetThroughput / (*it).second.lastAveragedThroughput;
1343 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1345 std::map <uint16_t,uint8_t>::iterator itTxMode;
1349 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1352 std::vector <uint8_t> sbCqis;
1355 for (uint8_t k = 0; k < nLayer; k++)
1357 sbCqis.push_back (1);
1362 sbCqis = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1365 uint8_t cqi1 = sbCqis.at(0);
1367 if (sbCqis.size () > 1)
1369 cqi2 = sbCqis.at(1);
1372 double schMetric = 0.0;
1373 if ((cqi1 > 0)||(cqi2 > 0))
1375 double achievableRate = 0.0;
1376 for (uint8_t k = 0; k < nLayer; k++)
1379 if (sbCqis.size () > k)
1381 mcs =
m_amc->GetMcsFromCqi (sbCqis.at (k));
1388 achievableRate += ((
m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001);
1390 schMetric = achievableRate / (*it).second.secondLastAveragedThroughput;
1393 double metric = 0.0;
1394 metric= weight * schMetric;
1396 if (metric > metricMax )
1410 allocationMap[(*itMax).first].push_back (i);
1411 rbgMap.at (i) =
true;
1425 std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1428 (*itStats).second.lastTtiBytesTransmitted = 0;
1433 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1434 while (itMap != allocationMap.end ())
1438 newEl.
m_rnti = (*itMap).first;
1441 newDci.
m_rnti = (*itMap).first;
1449 lcActives = (uint16_t)65535;
1451 uint16_t RgbPerRnti = (*itMap).second.size ();
1452 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1454 std::map <uint16_t,uint8_t>::iterator itTxMode;
1458 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1461 std::vector <uint8_t> worstCqi (2, 15);
1464 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1466 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1468 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)) );
1469 for (uint8_t j = 0; j < nLayer; j++)
1471 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1473 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1475 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1481 worstCqi.at (j) = 1;
1487 for (uint8_t j = 0; j < nLayer; j++)
1489 worstCqi.at (j) = 1;
1496 for (uint8_t j = 0; j < nLayer; j++)
1498 worstCqi.at (j) = 1;
1501 for (uint8_t j = 0; j < nLayer; j++)
1503 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1505 uint32_t bytesTxed = 0;
1506 for (uint8_t j = 0; j < nLayer; j++)
1508 newDci.
m_mcs.push_back (
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1509 int tbSize = (
m_amc->GetTbSizeFromMcs (newDci.
m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1511 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" MCS selected" <<
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1512 bytesTxed += tbSize;
1517 uint32_t rbgMask = 0;
1518 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1520 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1521 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1526 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1529 if (((*itBufReq).first.m_rnti == (*itMap).first)
1530 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1531 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1532 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1534 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1535 for (uint8_t j = 0; j < nLayer; j++)
1541 newRlcPduLe.push_back (newRlcEl);
1549 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1551 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1556 if ((*itBufReq).first.m_rnti > (*itMap).first)
1561 for (uint8_t j = 0; j < nLayer; j++)
1563 newDci.
m_ndi.push_back (1);
1564 newDci.
m_rv.push_back (0);
1567 newEl.
m_dci = newDci;
1591 std::map <uint16_t, pssFlowPerf_t>::iterator it;
1595 (*it).second.lastTtiBytesTransmitted = bytesTxed;
1596 NS_LOG_INFO (
this <<
" UE total bytes txed " << (*it).second.lastTtiBytesTransmitted);
1614 std::map <uint16_t, pssFlowPerf_t>::iterator itUeScheduleted = tdUeSet.end();
1615 itUeScheduleted = tdUeSet.find((*itStats).first);
1616 if (itUeScheduleted != tdUeSet.end())
1618 (*itStats).second.secondLastAveragedThroughput = ((1.0 - (1 /
m_timeWindow)) * (*itStats).second.secondLastAveragedThroughput) + ((1 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1621 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTransmitted;
1623 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 /
m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTransmitted / 0.001));
1624 (*itStats).second.lastTtiBytesTransmitted = 0;
1649 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1654 std::map <uint16_t,uint8_t>::iterator it;
1655 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1660 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1667 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1669 std::map <uint16_t,uint32_t>::iterator itTimers;
1677 std::map <uint16_t,SbMeasResult_s>::iterator it;
1678 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1683 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1689 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1690 std::map <uint16_t,uint32_t>::iterator itTimers;
1708 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1722 double sinr = (*itCqi).second.at (i);
1729 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1731 (*itCqi).second.at (rb) = estimatedSinr;
1732 return (estimatedSinr);
1745 std::vector <bool> rbMap;
1746 uint16_t rbAllocatedNum = 0;
1747 std::set <uint16_t> rntiAllocated;
1748 std::vector <uint16_t> rbgAllocationMap;
1759 if (rbgAllocationMap.at (i) != 0)
1761 rbMap.at (i) =
true;
1770 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1779 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1782 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1786 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1793 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1795 if ((*itStat).second.at (harqId) >= 3)
1797 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1803 if (rbMap.at (j) ==
true)
1814 rbMap.at (j) =
true;
1815 rbgAllocationMap.at (j) = dci.
m_rnti;
1823 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1828 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1829 (*itStat).second.at (harqId) = 0;
1830 (*itHarq).second.at ((*itProcId).second) = dci;
1832 rntiAllocated.insert (dci.
m_rnti);
1841 std::map <uint16_t,uint32_t>::iterator it;
1846 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1848 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1871 int rbAllocated = 0;
1873 std::map <uint16_t, pssFlowPerf_t>::iterator itStats;
1895 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1896 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1899 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1921 uldci.
m_rnti = (*it).first;
1923 bool allocated =
false;
1924 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1929 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1931 if (rbMap.at (j) ==
true)
1941 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1943 rbMap.at (j) =
true;
1945 rbgAllocationMap.at (j) = (*it).first;
1947 rbAllocated += rbPerFlow;
1978 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1988 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1995 double sinr = (*itCqi).second.at (i);
2000 if ((*itCqi).second.at (i) < minSinr)
2002 minSinr = (*itCqi).second.at (i);
2007 double s = log2 ( 1 + (
2008 std::pow (10, minSinr / 10 ) /
2009 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
2010 cqi =
m_amc->GetCqiFromSpectralEfficiency (s);
2023 rbgAllocationMap.at (i) = 0;
2049 std::map <uint16_t, uint8_t>::iterator itProcId;
2055 harqId = (*itProcId).second;
2061 (*itDci).second.at (harqId) = uldci;
2064 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);
2106 std::map <uint16_t,uint32_t>::iterator it;
2108 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
2119 uint32_t buffer = 0;
2120 for (uint8_t lcg = 0; lcg < 4; ++lcg)
2122 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
2127 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
2132 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
2137 (*it).second = buffer;
2180 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2181 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2182 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2188 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2192 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
2196 std::vector <double> newCqi;
2201 newCqi.push_back (sinr);
2210 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2217 (*itCqi).second.at (i) = sinr;
2218 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2220 std::map <uint16_t, uint32_t>::iterator itTimers;
2241 rnti = vsp->GetRnti ();
2244 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2249 std::vector <double> newCqi;
2253 newCqi.push_back (sinr);
2254 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2257 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2267 (*itCqi).second.at (j) = sinr;
2268 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2271 std::map <uint16_t, uint32_t>::iterator itTimers;
2284 NS_FATAL_ERROR (
"PssFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2297 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2301 if ((*itP10).second == 0)
2304 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2306 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2308 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2320 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2324 if ((*itA30).second == 0)
2327 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2329 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2331 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2350 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2354 if ((*itUl).second == 0)
2357 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2358 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2359 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2360 (*itMap).second.clear ();
2362 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2379 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2384 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);
2387 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2389 (*it).second.m_rlcStatusPduSize = 0;
2391 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2393 (*it).second.m_rlcRetransmissionQueueSize = 0;
2395 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2397 uint32_t rlcOverhead;
2412 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2414 (*it).second.m_rlcTransmissionQueueSize = 0;
2418 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2424 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2433 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2436 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2437 if ((*it).second >= size)
2439 (*it).second -= size;
2448 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2456 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
virtual void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters ¶ms)
std::vector< struct UlInfoListElement_s > m_ulInfoList
See section 4.3.1 dlDciListElement.
std::map< uint16_t, uint32_t > m_p10CqiTimers
PssSchedulerMemberCschedSapProvider()
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
void DoCschedLcConfigReq(const struct FfMacCschedSapProvider::CschedLcConfigReqParameters ¶ms)
std::map< uint16_t, uint8_t > m_uesTxMode
void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters ¶ms)
Parameters of the CSCHED_UE_CONFIG_CNF primitive.
hold variables of type string
int LcActivePerFlow(uint16_t rnti)
Parameters of the CSCHED_UE_RELEASE_REQ primitive.
void DoCschedLcReleaseReq(const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters ¶ms)
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
std::map< uint16_t, uint8_t > m_p10CqiRxed
enum ns3::UlCqi_s::Type_e m_type
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
std::vector< UlDciListElement_s > UlHarqProcessesDciBuffer_t
std::vector< struct LogicalChannelConfigListElement_s > m_logicalChannelConfigList
std::vector< uint16_t > m_sinr
std::map< uint16_t, pssFlowPerf_t > m_flowStatsUl
std::vector< uint8_t > DlHarqProcessesTimer_t
#define NS_ASSERT(condition)
virtual void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters ¶ms)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
std::vector< uint8_t > m_mcs
See section 4.3.2 ulDciListElement.
int PssType0AllocationRbg[4]
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
virtual void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters ¶ms)
std::vector< struct UlDciListElement_s > m_dciList
See section 4.3.10 buildRARListElement.
virtual void CschedUeConfigReq(const struct CschedUeConfigReqParameters ¶ms)
Parameters of the CSCHED_UE_CONFIG_UPDATE_IND primitive.
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
PssFfMacScheduler * m_scheduler
Parameters of the CSCHED_LC_RELEASE_REQ primitive.
std::vector< std::vector< struct RlcPduListElement_s > > m_rlcPduList
uint8_t m_transmissionMode
Parameters of the SCHED_DL_TRIGGER_REQ primitive.
uint8_t m_logicalChannelIdentity
static TypeId GetTypeId(void)
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
#define NS_FATAL_ERROR(msg)
fatal error handling
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
void RefreshUlCqiMaps(void)
std::string m_fdSchedulerType
FfMacCschedSapUser * m_cschedSapUser
void DoSchedUlMacCtrlInfoReq(const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters ¶ms)
void DoSchedDlTriggerReq(const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters ¶ms)
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
int GetRbgSize(int dlbandwidth)
Parameters of the SCHED_DL_MAC_BUFFER_REQ primitive.
Parameters of the SCHED_DL_PAGING_BUFFER_REQ primitive.
virtual void CschedUeConfigUpdateInd(const struct CschedUeConfigUpdateIndParameters ¶ms)=0
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
uint32_t m_cqiTimersThreshold
void DoSchedDlCqiInfoReq(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters ¶ms)
double secondLastAveragedThroughput
Past average throughput.
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
Parameters of the SCHED_UL_TRIGGER_REQ primitive.
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
Hold an unsigned integer type.
static uint8_t TxMode2LayerNum(uint8_t txMode)
bool m_harqOn
m_harqOn when false inhibit te HARQ mechanisms (by default active)
std::vector< uint8_t > m_ndi
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
void DoSchedDlRlcBufferReq(const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters ¶ms)
virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters ¶ms)
virtual void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters ¶ms)=0
unsigned int lastTtiBytesTransmitted
Total bytes send by eNb for this UE.
std::vector< uint8_t > m_logicalChannelIdentity
#define NS_LOG_LOGIC(msg)
Parameters of the SCHED_UL_NOISE_INTERFERENCE_REQ primitive.
friend class PssSchedulerMemberSchedSapProvider
uint8_t m_logicalChannelIdentity
std::vector< struct CqiListElement_s > m_cqiList
std::vector< struct DlInfoListElement_s > m_dlInfoList
virtual void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters ¶ms)
void DoCschedUeConfigReq(const struct FfMacCschedSapProvider::CschedUeConfigReqParameters ¶ms)
PssFfMacScheduler()
Constructor.
double lastAveragedThroughput
Total bytes send by eNB in last tti for this UE.
void RefreshDlCqiMaps(void)
virtual void SchedDlConfigInd(const struct SchedDlConfigIndParameters ¶ms)=0
virtual void CschedLcConfigReq(const struct CschedLcConfigReqParameters ¶ms)
Parameters of the API primitives.
int8_t m_pdcchPowerOffset
std::vector< uint16_t > m_tbsSize
See section 4.3.9 rlcPDU_ListElement.
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
void DoSchedUlNoiseInterferenceReq(const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters ¶ms)
void DoSchedDlPagingBufferReq(const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters ¶ms)
unsigned long totalBytesTransmitted
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
Parameters of the CSCHED_LC_CONFIG_REQ primitive.
PssFfMacScheduler * m_scheduler
std::vector< uint8_t > m_rv
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
set the user part of the FfMacSchedSap that this Scheduler will interact with.
std::map< uint16_t, pssFlowPerf_t > m_flowStatsDl
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
virtual void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters ¶ms)
virtual void SchedUlConfigInd(const struct SchedUlConfigIndParameters ¶ms)=0
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
static Time Now(void)
Return the "current simulation time".
NS_LOG_COMPONENT_DEFINE("PssFfMacScheduler")
UlCqiFilter_t m_ulCqiFilter
void DoSchedUlTriggerReq(const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters ¶ms)
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
PssSchedulerMemberSchedSapProvider()
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
This abstract base class identifies the interface by means of which the helper object can plug on the...
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
#define NS_ASSERT_MSG(condition, message)
uint8_t m_nrOfPdcchOfdmSymbols
std::vector< struct RachListElement_s > m_rachList
void DoSchedDlMacBufferReq(const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters ¶ms)
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
std::vector< struct MacCeListElement_s > m_macCeList
Parameters of the API primitives.
std::vector< struct RachListElement_s > m_rachList
void DoCschedCellConfigReq(const struct FfMacCschedSapProvider::CschedCellConfigReqParameters ¶ms)
static double fpS11dot3toDouble(uint16_t val)
virtual ~PssFfMacScheduler()
Destructor.
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
void DoSchedUlCqiInfoReq(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms)
std::map< uint16_t, uint32_t > m_ceBsrRxed
std::vector< uint8_t > UlHarqProcessesStatus_t
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
std::vector< uint8_t > DlHarqProcessesStatus_t
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters ¶ms)
void DoSchedDlRachInfoReq(const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters ¶ms)
static uint32_t BsrId2BufferSize(uint8_t val)
uint8_t m_transmissionMode
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
Parameters of the API primitives.
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
set the user part of the FfMacCschedSap that this Scheduler will interact with.
Parameters of the SCHED_UL_MAC_CTRL_INFO_REQ primitive.
#define NS_LOG_DEBUG(msg)
virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters ¶ms)
std::vector< uint16_t > m_rachAllocationMap
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
virtual void SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters ¶ms)
FfMacCschedSapProvider * m_cschedSapProvider
std::map< uint16_t, uint32_t > m_a30CqiTimers
Parameters of the SCHED_UL_SR_INFO_REQ primitive.
virtual void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters ¶ms)
virtual void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters ¶ms)
std::map< uint16_t, std::vector< double > > m_ueCqi
std::map< uint16_t, uint32_t > m_ueCqiTimers
#define NS_LOG_ERROR(msg)
Parameters of the SCHED_DL_RACH_INFO_REQ primitive.
Parameters of the SCHED_UL_CONFIG_IND primitive.
Parameters of the CSCHED_UE_CONFIG_REQ primitive.
void DoCschedUeReleaseReq(const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters ¶ms)
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
struct DlDciListElement_s m_dci
std::vector< struct BuildRarListElement_s > m_buildRarList
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
FfMacSchedSapUser * m_schedSapUser
a unique identifier for an interface.
FfMacSchedSapProvider * m_schedSapProvider
virtual void SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters ¶ms)
TypeId SetParent(TypeId tid)
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.
std::vector< struct BuildDataListElement_s > m_buildDataList
virtual void SchedUlNoiseInterferenceReq(const struct SchedUlNoiseInterferenceReqParameters ¶ms)
uint8_t m_ueTxAntennaSelection
friend class PssSchedulerMemberCschedSapProvider
See section 4.3.8 builDataListElement.
Implements the SCHED SAP and CSCHED SAP for a Priority Set scheduler.