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>
143 : m_scheduler (scheduler)
218 : m_cschedSapUser (0),
224 m_amc = CreateObject <LteAmc> ();
252 static TypeId tid =
TypeId (
"ns3::FdTbfqFfMacScheduler")
254 .AddConstructor<FdTbfqFfMacScheduler> ()
255 .AddAttribute (
"CqiTimerThreshold",
256 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
259 MakeUintegerChecker<uint32_t> ())
260 .AddAttribute (
"DebtLimit",
261 "Flow debt limit (default -625000 bytes)",
264 MakeIntegerChecker<int> ())
265 .AddAttribute (
"CreditLimit",
266 "Flow credit limit (default 625000 bytes)",
269 MakeUintegerChecker<uint32_t> ())
270 .AddAttribute (
"TokenPoolSize",
271 "The maximum value of flow token pool (default 1 bytes)",
274 MakeUintegerChecker<uint32_t> ())
275 .AddAttribute (
"CreditableThreshold",
276 "Threshold of flow credit (default 0 bytes)",
279 MakeUintegerChecker<uint32_t> ())
281 .AddAttribute (
"HarqEnabled",
282 "Activate/Deactivate the HARQ [by default is active].",
285 MakeBooleanChecker ())
286 .AddAttribute (
"UlGrantMcs",
287 "The MCS of the UL grant, must be [0..15] (default 0)",
290 MakeUintegerChecker<uint8_t> ())
345 dlHarqPrcStatus.resize (8,0);
348 dlHarqProcessesTimer.resize (8,0);
351 dlHarqdci.resize (8);
354 dlHarqRlcPdu.resize (2);
355 dlHarqRlcPdu.at (0).resize (8);
356 dlHarqRlcPdu.at (1).resize (8);
360 ulHarqPrcStatus.resize (8,0);
363 ulHarqdci.resize (8);
378 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator it;
398 m_flowStatsDl.insert (std::pair<uint16_t, fdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsDl));
409 m_flowStatsUl.insert (std::pair<uint16_t, fdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsUl));
416 m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
417 m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
431 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
432 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
467 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
468 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
471 if ((*it).first.m_rnti == params.
m_rnti)
497 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
505 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
509 (*it).second = params;
534 for (
int i = 0; i < 4; i++)
549 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
553 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
554 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
555 || ((*it).second.m_rlcStatusPduSize > 0) ))
559 if ((*it).first.m_rnti > rnti)
582 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
584 uint8_t i = (*it).second;
589 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
590 if ((*itStat).second.at (i) == 0)
621 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
623 uint8_t i = (*it).second;
628 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
629 if ((*itStat).second.at (i) == 0)
632 (*itStat).second.at (i) = 1;
636 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
639 return ((*it).second);
648 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
657 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
658 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
661 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
663 (*itStat).second.at (i) = 0;
664 (*itTimers).second.at (i) = 0;
668 (*itTimers).second.at (i)++;
691 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
692 std::vector <bool> rbgMap;
693 uint16_t rbgAllocatedNum = 0;
694 std::set <uint16_t> rntiAllocated;
700 uint16_t rbStart = 0;
701 std::vector <struct RachListElement_s>::iterator itRach;
706 newRar.
m_rnti = (*itRach).m_rnti;
710 newRar.m_grant.m_rnti = newRar.m_rnti;
713 uint16_t tbSizeBits = 0;
720 if (tbSizeBits < (*itRach).m_estimatedSize)
725 newRar.m_grant.m_rbStart = rbStart;
726 newRar.m_grant.m_rbLen = rbLen;
727 newRar.m_grant.m_tbSize = tbSizeBits / 8;
728 newRar.m_grant.m_hopping =
false;
729 newRar.m_grant.m_tpc = 0;
730 newRar.m_grant.m_cqiRequest =
false;
731 newRar.m_grant.m_ulDelay =
false;
732 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);
733 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
737 rbStart = rbStart + rbLen;
751 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
767 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
771 if (itRnti != rntiAllocated.end ())
777 std::vector <bool> retx;
778 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
782 retx.push_back (
false);
789 if (retx.at (0) || retx.at (1))
794 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
803 if (dci.
m_rv.size () == 1)
805 rv = dci.
m_rv.at (0);
809 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
815 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
821 (*it).second.at (harqId) = 0;
827 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
829 (*itRlcPdu).second.at (k).at (harqId).clear ();
835 std::vector <int> dciRbg;
838 for (
int j = 0; j < 32; j++)
842 dciRbg.push_back (j);
848 for (uint8_t j = 0; j < dciRbg.size (); j++)
850 if (rbgMap.at (dciRbg.at (j)) ==
true)
860 for (uint8_t j = 0; j < dciRbg.size (); j++)
862 rbgMap.at (dciRbg.at (j)) =
true;
863 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
867 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
873 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
874 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
875 std::vector <bool> rbgMapCopy = rbgMap;
876 while ((j < dciRbg.size ())&&(startRbg != rbgId))
878 if (rbgMapCopy.at (rbgId) ==
false)
880 rbgMapCopy.at (rbgId) =
true;
881 dciRbg.at (j) = rbgId;
886 if (j == dciRbg.size ())
889 uint32_t rbgMask = 0;
890 for (uint16_t k = 0; k < dciRbg.size (); k++)
892 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
897 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
902 dlInfoListUntxed.push_back (params.
m_dlInfoList.at (i));
903 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
911 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
913 for (uint8_t j = 0; j < nLayers; j++)
917 if (j >= dci.
m_ndi.size ())
920 dci.
m_ndi.push_back (0);
921 dci.
m_rv.push_back (0);
922 dci.
m_mcs.push_back (0);
924 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
928 dci.
m_ndi.at (j) = 0;
930 (*itHarq).second.at (harqId).m_rv.at (j)++;
931 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
937 dci.
m_ndi.at (j) = 0;
939 dci.
m_mcs.at (j) = 0;
941 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
944 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
946 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
947 for (uint8_t j = 0; j < nLayers; j++)
951 if (j < dci.
m_ndi.size ())
953 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
958 if (rlcPduListPerLc.size () > 0)
965 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
970 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
972 (*itHarqTimer).second.at (harqId) = 0;
974 rntiAllocated.insert (rnti);
991 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1002 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itStats;
1005 if ( (*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
1007 (*itStats).second.counter += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1008 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
1009 bankSize += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1013 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
1017 std::set <uint16_t> allocatedRnti;
1018 std::set <uint8_t> allocatedRbg;
1021 while (totalRbg < rbgNum)
1024 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator it;
1025 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itMax =
m_flowStatsDl.end ();
1026 double metricMax = 0.0;
1027 bool firstRnti =
true;
1030 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1034 if (itRnti != rntiAllocated.end ())
1036 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1040 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1050 std::set <uint16_t>::iterator rnti;
1051 rnti = allocatedRnti.find((*it).first);
1052 if (rnti != allocatedRnti.end ())
1057 double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
1059 if (firstRnti ==
true)
1066 if (metric > metricMax)
1080 allocatedRnti.insert((*itMax).first);
1083 uint32_t budget = 0;
1086 budget = (*itMax).second.counter - (*itMax).second.debtLimit;
1087 if ( budget > (*itMax).second.burstCredit )
1088 budget = (*itMax).second.burstCredit;
1092 budget = budget + (*itMax).second.tokenPoolSize;
1103 uint32_t rlcBufSize = 0;
1105 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itRlcBuf;
1108 if ( (*itRlcBuf).first.m_rnti == (*itMax).first )
1109 lcid = (*itRlcBuf).first.m_lcId;
1114 rlcBufSize = (*itRlcBuf).second.m_rlcTransmissionQueueSize + (*itRlcBuf).second.m_rlcRetransmissionQueueSize + (*itRlcBuf).second.m_rlcStatusPduSize;
1115 if ( budget > rlcBufSize )
1116 budget = rlcBufSize;
1120 uint32_t bytesTxed = 0;
1121 uint32_t bytesTxedTmp = 0;
1123 while ( bytesTxed <= budget )
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);
1138 double achievableRateMax = 0.0;
1140 for (
int k = 0; k < rbgNum; k++)
1142 std::set <uint8_t>::iterator rbg;
1143 rbg = allocatedRbg.find (k);
1144 if (rbg != allocatedRbg.end ())
1147 if ( rbgMap.at (k) ==
true)
1150 std::vector <uint8_t> sbCqi;
1153 for (uint8_t k = 0; k < nLayer; k++)
1155 sbCqi.push_back (1);
1160 sbCqi = (*itCqi).second.m_higherLayerSelected.at (k).m_sbCqi;
1162 uint8_t cqi1 = sbCqi.at (0);
1164 if (sbCqi.size () > 1)
1166 cqi2 = sbCqi.at (1);
1169 if ((cqi1 > 0)||(cqi2 > 0))
1174 double achievableRate = 0.0;
1175 for (uint8_t j = 0; j < nLayer; j++)
1178 if (sbCqi.size () > j)
1190 if ( achievableRate > achievableRateMax )
1192 achievableRateMax = achievableRate;
1199 if ( rbgIndex == rbgNum)
1208 allocatedRbg.insert (rbgIndex);
1212 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1213 itMap = allocationMap.find ((*itMax).first);
1214 uint16_t RbgPerRnti;
1215 if (itMap == allocationMap.end ())
1218 std::vector <uint16_t> tempMap;
1219 tempMap.push_back (rbgIndex);
1220 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1221 itMap = allocationMap.find ((*itMax).first);
1225 (*itMap).second.push_back (rbgIndex);
1227 rbgMap.at (rbgIndex) =
true;
1229 RbgPerRnti = (*itMap).second.size();
1232 std::vector <uint8_t> worstCqi (2, 15);
1235 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1237 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1239 for (uint8_t j = 0; j < nLayer; j++)
1241 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1243 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1245 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1251 worstCqi.at (j) = 1;
1257 for (uint8_t j = 0; j < nLayer; j++)
1259 worstCqi.at (j) = 1;
1266 for (uint8_t j = 0; j < nLayer; j++)
1268 worstCqi.at (j) = 1;
1272 bytesTxedTmp = bytesTxed;
1274 for (uint8_t j = 0; j < nLayer; j++)
1277 bytesTxed += tbSize;
1283 if ( bytesTxed > budget )
1285 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1286 itMap = allocationMap.find ((*itMax).first);
1287 (*itMap).second.pop_back ();
1288 allocatedRbg.erase (rbgIndex);
1289 bytesTxed = bytesTxedTmp;
1291 rbgMap.at (rbgIndex) =
false;
1295 if ( bytesTxed <= (*itMax).second.tokenPoolSize )
1297 (*itMax).second.tokenPoolSize -= bytesTxed;
1301 (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
1302 (*itMax).second.tokenPoolSize = 0;
1303 if (
bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
1312 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1313 while (itMap != allocationMap.end ())
1317 newEl.
m_rnti = (*itMap).first;
1320 newDci.
m_rnti = (*itMap).first;
1328 lcActives = (uint16_t)65535;
1330 uint16_t RgbPerRnti = (*itMap).second.size ();
1331 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1333 std::map <uint16_t,uint8_t>::iterator itTxMode;
1337 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1340 std::vector <uint8_t> worstCqi (2, 15);
1343 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1345 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1347 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)) );
1348 for (uint8_t j = 0; j < nLayer; j++)
1350 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1352 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1354 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1360 worstCqi.at (j) = 1;
1366 for (uint8_t j = 0; j < nLayer; j++)
1368 worstCqi.at (j) = 1;
1375 for (uint8_t j = 0; j < nLayer; j++)
1377 worstCqi.at (j) = 1;
1380 for (uint8_t j = 0; j < nLayer; j++)
1382 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1384 uint32_t bytesTxed = 0;
1385 for (uint8_t j = 0; j < nLayer; j++)
1391 bytesTxed += tbSize;
1396 uint32_t rbgMask = 0;
1397 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1399 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1400 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1405 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1408 if (((*itBufReq).first.m_rnti == (*itMap).first)
1409 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1410 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1411 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1413 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1414 for (uint8_t j = 0; j < nLayer; j++)
1420 newRlcPduLe.push_back (newRlcEl);
1428 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1430 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1435 if ((*itBufReq).first.m_rnti > (*itMap).first)
1440 for (uint8_t j = 0; j < nLayer; j++)
1442 newDci.
m_ndi.push_back (1);
1443 newDci.
m_rv.push_back (0);
1446 newEl.
m_dci = newDci;
1495 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1500 std::map <uint16_t,uint8_t>::iterator it;
1501 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1506 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1513 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1515 std::map <uint16_t,uint32_t>::iterator itTimers;
1523 std::map <uint16_t,SbMeasResult_s>::iterator it;
1524 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1529 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1535 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1536 std::map <uint16_t,uint32_t>::iterator itTimers;
1554 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1568 double sinr = (*itCqi).second.at (i);
1575 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1577 (*itCqi).second.at (rb) = estimatedSinr;
1578 return (estimatedSinr);
1591 std::vector <bool> rbMap;
1592 uint16_t rbAllocatedNum = 0;
1593 std::set <uint16_t> rntiAllocated;
1594 std::vector <uint16_t> rbgAllocationMap;
1605 if (rbgAllocationMap.at (i) != 0)
1607 rbMap.at (i) =
true;
1617 std::map <uint16_t, uint8_t>::iterator itProcId;
1620 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
1623 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1632 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1635 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1639 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1646 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1648 if ((*itStat).second.at (harqId) >= 3)
1650 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1656 if (rbMap.at (j) ==
true)
1667 rbMap.at (j) =
true;
1668 rbgAllocationMap.at (j) = dci.
m_rnti;
1676 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1681 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1682 (*itStat).second.at (harqId) = 0;
1683 (*itHarq).second.at ((*itProcId).second) = dci;
1685 rntiAllocated.insert (dci.
m_rnti);
1694 std::map <uint16_t,uint32_t>::iterator it;
1699 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1701 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1724 int rbAllocated = 0;
1726 std::map <uint16_t, fdtbfqsFlowPerf_t>::iterator itStats;
1748 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1749 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1752 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1774 uldci.
m_rnti = (*it).first;
1776 bool allocated =
false;
1777 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1782 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1784 if (rbMap.at (j) ==
true)
1794 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1796 rbMap.at (j) =
true;
1798 rbgAllocationMap.at (j) = (*it).first;
1800 rbAllocated += rbPerFlow;
1831 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1841 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1848 double sinr = (*itCqi).second.at (i);
1853 if ((*itCqi).second.at (i) < minSinr)
1855 minSinr = (*itCqi).second.at (i);
1860 double s = log2 ( 1 + (
1861 std::pow (10, minSinr / 10 ) /
1862 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1876 rbgAllocationMap.at (i) = 0;
1902 std::map <uint16_t, uint8_t>::iterator itProcId;
1908 harqId = (*itProcId).second;
1914 (*itDci).second.at (harqId) = uldci;
1917 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);
1960 std::map <uint16_t,uint32_t>::iterator it;
1962 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
1973 uint32_t buffer = 0;
1974 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1976 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1981 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1986 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1991 (*it).second = buffer;
2034 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2035 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2036 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2042 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2046 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
2050 std::vector <double> newCqi;
2055 newCqi.push_back (sinr);
2064 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2071 (*itCqi).second.at (i) = sinr;
2072 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2074 std::map <uint16_t, uint32_t>::iterator itTimers;
2095 rnti = vsp->GetRnti ();
2098 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2103 std::vector <double> newCqi;
2107 newCqi.push_back (sinr);
2108 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2111 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2121 (*itCqi).second.at (j) = sinr;
2122 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2125 std::map <uint16_t, uint32_t>::iterator itTimers;
2138 NS_FATAL_ERROR (
"FdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2151 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2155 if ((*itP10).second == 0)
2158 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2160 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2162 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2174 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2178 if ((*itA30).second == 0)
2181 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2183 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2185 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2204 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2208 if ((*itUl).second == 0)
2211 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2212 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2213 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2214 (*itMap).second.clear ();
2216 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2233 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2238 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);
2241 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2243 (*it).second.m_rlcStatusPduSize = 0;
2245 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2247 (*it).second.m_rlcRetransmissionQueueSize = 0;
2249 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2251 uint32_t rlcOverhead;
2266 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2268 (*it).second.m_rlcTransmissionQueueSize = 0;
2272 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2278 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2287 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2290 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2291 if ((*it).second >= size)
2293 (*it).second -= size;
2302 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2310 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);