23 #include <ns3/pointer.h>
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/fdtbfq-ff-mac-scheduler.h>
29 #include <ns3/lte-vendor-specific-parameters.h>
30 #include <ns3/boolean.h>
31 #include <ns3/integer.h>
142 : m_scheduler (scheduler)
217 : m_cschedSapUser (0),
223 m_amc = CreateObject <LteAmc> ();
251 static TypeId tid =
TypeId (
"ns3::FdTbfqFfMacScheduler")
253 .AddConstructor<FdTbfqFfMacScheduler> ()
254 .AddAttribute (
"CqiTimerThreshold",
255 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
258 MakeUintegerChecker<uint32_t> ())
259 .AddAttribute (
"DebtLimit",
260 "Flow debt limit (default -625000 bytes)",
263 MakeIntegerChecker<int> ())
264 .AddAttribute (
"CreditLimit",
265 "Flow credit limit (default 625000 bytes)",
268 MakeUintegerChecker<uint32_t> ())
269 .AddAttribute (
"TokenPoolSize",
270 "The maximum value of flow token pool (default 1 bytes)",
273 MakeUintegerChecker<uint32_t> ())
274 .AddAttribute (
"CreditableThreshold",
275 "Threshold of flow credit (default 0 bytes)",
278 MakeUintegerChecker<uint32_t> ())
280 .AddAttribute (
"HarqEnabled",
281 "Activate/Deactivate the HARQ [by default is active].",
284 MakeBooleanChecker ())
285 .AddAttribute (
"UlGrantMcs",
286 "The MCS of the UL grant, must be [0..15] (default 0)",
289 MakeUintegerChecker<uint8_t> ())
344 dlHarqPrcStatus.resize (8,0);
347 dlHarqProcessesTimer.resize (8,0);
350 dlHarqdci.resize (8);
353 dlHarqRlcPdu.resize (2);
354 dlHarqRlcPdu.at (0).resize (8);
355 dlHarqRlcPdu.at (1).resize (8);
359 ulHarqPrcStatus.resize (8,0);
362 ulHarqdci.resize (8);
377 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator it;
397 m_flowStatsDl.insert (std::pair<uint16_t, fdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsDl));
408 m_flowStatsUl.insert (std::pair<uint16_t, fdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsUl));
417 m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
418 m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
432 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
433 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
468 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
469 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
472 if ((*it).first.m_rnti == params.
m_rnti)
498 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
506 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
510 (*it).second = params;
535 for (
int i = 0; i < 4; i++)
550 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
554 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
555 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
556 || ((*it).second.m_rlcStatusPduSize > 0) ))
560 if ((*it).first.m_rnti > rnti)
583 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
585 uint8_t i = (*it).second;
590 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
591 if ((*itStat).second.at (i) == 0)
622 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
624 uint8_t i = (*it).second;
629 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
630 if ((*itStat).second.at (i) == 0)
633 (*itStat).second.at (i) = 1;
637 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
640 return ((*it).second);
649 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
658 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
659 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
662 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
664 (*itStat).second.at (i) = 0;
665 (*itTimers).second.at (i) = 0;
669 (*itTimers).second.at (i)++;
692 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
693 std::vector <bool> rbgMap;
694 uint16_t rbgAllocatedNum = 0;
695 std::set <uint16_t> rntiAllocated;
701 uint16_t rbStart = 0;
702 std::vector <struct RachListElement_s>::iterator itRach;
707 newRar.
m_rnti = (*itRach).m_rnti;
711 newRar.m_grant.m_rnti = newRar.m_rnti;
714 uint16_t tbSizeBits = 0;
721 if (tbSizeBits < (*itRach).m_estimatedSize)
726 newRar.m_grant.m_rbStart = rbStart;
727 newRar.m_grant.m_rbLen = rbLen;
728 newRar.m_grant.m_tbSize = tbSizeBits / 8;
729 newRar.m_grant.m_hopping =
false;
730 newRar.m_grant.m_tpc = 0;
731 newRar.m_grant.m_cqiRequest =
false;
732 newRar.m_grant.m_ulDelay =
false;
733 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);
734 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
738 rbStart = rbStart + rbLen;
752 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
768 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
772 if (itRnti != rntiAllocated.end ())
778 std::vector <bool> retx;
779 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
783 retx.push_back (
false);
790 if (retx.at (0) || retx.at (1))
795 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
804 if (dci.
m_rv.size () == 1)
806 rv = dci.
m_rv.at (0);
810 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
816 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
822 (*it).second.at (harqId) = 0;
828 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
830 (*itRlcPdu).second.at (k).at (harqId).clear ();
836 std::vector <int> dciRbg;
839 for (
int j = 0; j < 32; j++)
843 dciRbg.push_back (j);
849 for (uint8_t j = 0; j < dciRbg.size (); j++)
851 if (rbgMap.at (dciRbg.at (j)) ==
true)
861 for (uint8_t j = 0; j < dciRbg.size (); j++)
863 rbgMap.at (dciRbg.at (j)) =
true;
864 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
868 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
874 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
875 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
876 std::vector <bool> rbgMapCopy = rbgMap;
877 while ((j < dciRbg.size ())&&(startRbg != rbgId))
879 if (rbgMapCopy.at (rbgId) ==
false)
881 rbgMapCopy.at (rbgId) =
true;
882 dciRbg.at (j) = rbgId;
887 if (j == dciRbg.size ())
890 uint32_t rbgMask = 0;
891 for (uint16_t k = 0; k < dciRbg.size (); k++)
893 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
898 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
903 dlInfoListUntxed.push_back (params.
m_dlInfoList.at (i));
904 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
912 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
914 for (uint8_t j = 0; j < nLayers; j++)
918 if (j >= dci.
m_ndi.size ())
921 dci.
m_ndi.push_back (0);
922 dci.
m_rv.push_back (0);
923 dci.
m_mcs.push_back (0);
925 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
929 dci.
m_ndi.at (j) = 0;
931 (*itHarq).second.at (harqId).m_rv.at (j)++;
932 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
938 dci.
m_ndi.at (j) = 0;
940 dci.
m_mcs.at (j) = 0;
942 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
945 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
947 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
948 for (uint8_t j = 0; j < nLayers; j++)
952 if (j < dci.
m_ndi.size ())
954 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
959 if (rlcPduListPerLc.size () > 0)
966 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
971 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
973 (*itHarqTimer).second.at (harqId) = 0;
975 rntiAllocated.insert (rnti);
992 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1003 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itStats;
1006 if ( (*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
1008 (*itStats).second.counter += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1009 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
1010 bankSize += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1014 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
1018 std::set <uint16_t> allocatedRnti;
1019 std::set <uint8_t> allocatedRbg;
1022 while (totalRbg < rbgNum)
1025 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator it;
1026 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itMax =
m_flowStatsDl.end ();
1027 double metricMax = 0.0;
1028 bool firstRnti =
true;
1031 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1035 if (itRnti != rntiAllocated.end ())
1037 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1041 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1051 std::set <uint16_t>::iterator rnti;
1052 rnti = allocatedRnti.find((*it).first);
1053 if (rnti != allocatedRnti.end ())
1058 double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
1060 if (firstRnti ==
true)
1067 if (metric > metricMax)
1081 allocatedRnti.insert((*itMax).first);
1084 uint32_t budget = 0;
1087 budget = (*itMax).second.counter - (*itMax).second.debtLimit;
1088 if ( budget > (*itMax).second.burstCredit )
1089 budget = (*itMax).second.burstCredit;
1093 budget = budget + (*itMax).second.tokenPoolSize;
1104 uint32_t rlcBufSize = 0;
1106 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itRlcBuf;
1109 if ( (*itRlcBuf).first.m_rnti == (*itMax).first )
1110 lcid = (*itRlcBuf).first.m_lcId;
1115 rlcBufSize = (*itRlcBuf).second.m_rlcTransmissionQueueSize + (*itRlcBuf).second.m_rlcRetransmissionQueueSize + (*itRlcBuf).second.m_rlcStatusPduSize;
1116 if ( budget > rlcBufSize )
1117 budget = rlcBufSize;
1121 uint32_t bytesTxed = 0;
1122 uint32_t bytesTxedTmp = 0;
1124 while ( bytesTxed <= budget )
1128 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1130 std::map <uint16_t,uint8_t>::iterator itTxMode;
1134 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1139 double achievableRateMax = 0.0;
1141 for (
int k = 0; k < rbgNum; k++)
1143 std::set <uint8_t>::iterator rbg;
1144 rbg = allocatedRbg.find (k);
1145 if (rbg != allocatedRbg.end ())
1148 if ( rbgMap.at (k) ==
true)
1151 std::vector <uint8_t> sbCqi;
1154 for (uint8_t k = 0; k < nLayer; k++)
1156 sbCqi.push_back (1);
1161 sbCqi = (*itCqi).second.m_higherLayerSelected.at (k).m_sbCqi;
1163 uint8_t cqi1 = sbCqi.at (0);
1165 if (sbCqi.size () > 1)
1167 cqi2 = sbCqi.at (1);
1170 if ((cqi1 > 0)||(cqi2 > 0))
1175 double achievableRate = 0.0;
1176 for (uint8_t j = 0; j < nLayer; j++)
1179 if (sbCqi.size () > j)
1191 if ( achievableRate > achievableRateMax )
1193 achievableRateMax = achievableRate;
1200 if ( rbgIndex == rbgNum)
1209 allocatedRbg.insert (rbgIndex);
1213 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1214 itMap = allocationMap.find ((*itMax).first);
1215 uint16_t RbgPerRnti;
1216 if (itMap == allocationMap.end ())
1219 std::vector <uint16_t> tempMap;
1220 tempMap.push_back (rbgIndex);
1221 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1222 itMap = allocationMap.find ((*itMax).first);
1226 (*itMap).second.push_back (rbgIndex);
1228 rbgMap.at (rbgIndex) =
true;
1230 RbgPerRnti = (*itMap).second.size();
1233 std::vector <uint8_t> worstCqi (2, 15);
1236 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1238 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1240 for (uint8_t j = 0; j < nLayer; j++)
1242 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1244 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1246 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1252 worstCqi.at (j) = 1;
1258 for (uint8_t j = 0; j < nLayer; j++)
1260 worstCqi.at (j) = 1;
1267 for (uint8_t j = 0; j < nLayer; j++)
1269 worstCqi.at (j) = 1;
1273 bytesTxedTmp = bytesTxed;
1275 for (uint8_t j = 0; j < nLayer; j++)
1278 bytesTxed += tbSize;
1284 if ( bytesTxed > budget )
1286 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1287 itMap = allocationMap.find ((*itMax).first);
1288 (*itMap).second.pop_back ();
1289 allocatedRbg.erase (rbgIndex);
1290 bytesTxed = bytesTxedTmp;
1292 rbgMap.at (rbgIndex) =
false;
1296 if ( bytesTxed <= (*itMax).second.tokenPoolSize )
1298 (*itMax).second.tokenPoolSize -= bytesTxed;
1302 (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
1303 (*itMax).second.tokenPoolSize = 0;
1304 if (
bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
1313 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1314 while (itMap != allocationMap.end ())
1318 newEl.
m_rnti = (*itMap).first;
1321 newDci.
m_rnti = (*itMap).first;
1326 uint16_t RgbPerRnti = (*itMap).second.size ();
1327 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1329 std::map <uint16_t,uint8_t>::iterator itTxMode;
1333 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1336 std::vector <uint8_t> worstCqi (2, 15);
1339 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1341 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1343 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)) );
1344 for (uint8_t j = 0; j < nLayer; j++)
1346 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1348 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1350 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1356 worstCqi.at (j) = 1;
1362 for (uint8_t j = 0; j < nLayer; j++)
1364 worstCqi.at (j) = 1;
1371 for (uint8_t j = 0; j < nLayer; j++)
1373 worstCqi.at (j) = 1;
1376 for (uint8_t j = 0; j < nLayer; j++)
1378 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1380 uint32_t bytesTxed = 0;
1381 for (uint8_t j = 0; j < nLayer; j++)
1387 bytesTxed += tbSize;
1392 uint32_t rbgMask = 0;
1393 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1395 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1396 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1401 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1404 if (((*itBufReq).first.m_rnti == (*itMap).first)
1405 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1406 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1407 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1409 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1410 for (uint8_t j = 0; j < nLayer; j++)
1416 newRlcPduLe.push_back (newRlcEl);
1424 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1426 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1431 if ((*itBufReq).first.m_rnti > (*itMap).first)
1436 for (uint8_t j = 0; j < nLayer; j++)
1438 newDci.
m_ndi.push_back (1);
1439 newDci.
m_rv.push_back (0);
1442 newEl.
m_dci = newDci;
1491 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1496 std::map <uint16_t,uint8_t>::iterator it;
1497 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1502 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1509 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1511 std::map <uint16_t,uint32_t>::iterator itTimers;
1519 std::map <uint16_t,SbMeasResult_s>::iterator it;
1520 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1525 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1531 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1532 std::map <uint16_t,uint32_t>::iterator itTimers;
1550 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1564 double sinr = (*itCqi).second.at (i);
1571 double estimatedSinr = sinrSum / (double)sinrNum;
1573 (*itCqi).second.at (rb) = estimatedSinr;
1574 return (estimatedSinr);
1587 std::vector <bool> rbMap;
1588 uint16_t rbAllocatedNum = 0;
1589 std::set <uint16_t> rntiAllocated;
1590 std::vector <uint16_t> rbgAllocationMap;
1601 if (rbgAllocationMap.at (i) != 0)
1603 rbMap.at (i) =
true;
1613 std::map <uint16_t, uint8_t>::iterator itProcId;
1616 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
1619 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1628 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1631 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1635 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1642 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1644 if ((*itStat).second.at (harqId) >= 3)
1646 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1652 if (rbMap.at (j) ==
true)
1663 rbMap.at (j) =
true;
1664 rbgAllocationMap.at (j) = dci.
m_rnti;
1672 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1677 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1678 (*itStat).second.at (harqId) = 0;
1679 (*itHarq).second.at ((*itProcId).second) = dci;
1681 rntiAllocated.insert (dci.
m_rnti);
1690 std::map <uint16_t,uint32_t>::iterator it;
1695 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1697 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1720 int rbAllocated = 0;
1722 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itStats;
1744 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1745 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1769 uldci.
m_rnti = (*it).first;
1771 bool allocated =
false;
1772 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow);
1777 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1779 if (rbMap.at (j) ==
true)
1789 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1791 rbMap.at (j) =
true;
1793 rbgAllocationMap.at (j) = (*it).first;
1795 rbAllocated += rbPerFlow;
1826 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1836 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1843 double sinr = (*itCqi).second.at (i);
1848 if ((*itCqi).second.at (i) < minSinr)
1850 minSinr = (*itCqi).second.at (i);
1855 double s = log2 ( 1 + (
1856 pow (10, minSinr / 10 ) /
1857 ( (-log (5.0 * 0.00005 )) / 1.5) ));
1891 std::map <uint16_t, uint8_t>::iterator itProcId;
1897 harqId = (*itProcId).second;
1903 (*itDci).second.at (harqId) = uldci;
1906 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);
1949 std::map <uint16_t,uint32_t>::iterator it;
1951 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
1962 uint32_t buffer = 0;
1963 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1965 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1970 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1975 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1980 (*it).second = buffer;
2023 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2024 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2025 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2031 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2035 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
2039 std::vector <double> newCqi;
2044 newCqi.push_back (sinr);
2053 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2060 (*itCqi).second.at (i) = sinr;
2061 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2063 std::map <uint16_t, uint32_t>::iterator itTimers;
2084 rnti = vsp->GetRnti ();
2087 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2092 std::vector <double> newCqi;
2096 newCqi.push_back (sinr);
2097 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2100 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2110 (*itCqi).second.at (j) = sinr;
2111 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2114 std::map <uint16_t, uint32_t>::iterator itTimers;
2127 NS_FATAL_ERROR (
"FdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2140 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2144 if ((*itP10).second == 0)
2147 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2149 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2151 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2163 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2167 if ((*itA30).second == 0)
2170 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2172 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2174 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2193 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2197 if ((*itUl).second == 0)
2200 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2201 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2202 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2203 (*itMap).second.clear ();
2205 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2222 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2227 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);
2230 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2232 (*it).second.m_rlcStatusPduSize = 0;
2234 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2236 (*it).second.m_rlcRetransmissionQueueSize = 0;
2238 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2241 if ((*it).second.m_rlcTransmissionQueueSize <= size)
2243 (*it).second.m_rlcTransmissionQueueSize = 0;
2248 (*it).second.m_rlcTransmissionQueueSize -= size;
2254 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2263 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2266 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2267 if ((*it).second >= size)
2269 (*it).second -= size;
2278 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2286 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);