23 #include <ns3/pointer.h>
26 #include <ns3/simulator.h>
27 #include <ns3/lte-amc.h>
28 #include <ns3/tdtbfq-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),
223 m_amc = CreateObject <LteAmc> ();
254 static TypeId tid =
TypeId (
"ns3::TdTbfqFfMacScheduler")
258 .AddAttribute (
"CqiTimerThreshold",
259 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
262 MakeUintegerChecker<uint32_t> ())
263 .AddAttribute (
"DebtLimit",
264 "Flow debt limit (default -625000 bytes)",
267 MakeIntegerChecker<int> ())
268 .AddAttribute (
"CreditLimit",
269 "Flow credit limit (default 625000 bytes)",
272 MakeUintegerChecker<uint32_t> ())
273 .AddAttribute (
"TokenPoolSize",
274 "The maximum value of flow token pool (default 1 bytes)",
277 MakeUintegerChecker<uint32_t> ())
278 .AddAttribute (
"CreditableThreshold",
279 "Threshold of flow credit (default 0 bytes)",
282 MakeUintegerChecker<uint32_t> ())
284 .AddAttribute (
"HarqEnabled",
285 "Activate/Deactivate the HARQ [by default is active].",
289 .AddAttribute (
"UlGrantMcs",
290 "The MCS of the UL grant, must be [0..15] (default 0)",
293 MakeUintegerChecker<uint8_t> ())
360 dlHarqPrcStatus.resize (8,0);
363 dlHarqProcessesTimer.resize (8,0);
366 dlHarqdci.resize (8);
369 dlHarqRlcPdu.resize (2);
370 dlHarqRlcPdu.at (0).resize (8);
371 dlHarqRlcPdu.at (1).resize (8);
375 ulHarqPrcStatus.resize (8,0);
378 ulHarqdci.resize (8);
393 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
413 m_flowStatsDl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsDl));
424 m_flowStatsUl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsUl));
431 m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
432 m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
446 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
447 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
482 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
483 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
486 if ((*it).first.m_rnti == params.
m_rnti)
512 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
520 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
524 (*it).second = params;
549 for (
int i = 0; i < 4; i++)
551 if (dlbandwidth < TdTbfqType0AllocationRbg[i])
564 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
568 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
569 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
570 || ((*it).second.m_rlcStatusPduSize > 0) ))
574 if ((*it).first.m_rnti > rnti)
597 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
599 uint8_t i = (*it).second;
604 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
605 if ((*itStat).second.at (i) == 0)
636 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
638 uint8_t i = (*it).second;
643 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
644 if ((*itStat).second.at (i) == 0)
647 (*itStat).second.at (i) = 1;
651 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
654 return ((*it).second);
663 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
672 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
673 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
676 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
678 (*itStat).second.at (i) = 0;
679 (*itTimers).second.at (i) = 0;
683 (*itTimers).second.at (i)++;
706 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
707 std::vector <bool> rbgMap;
708 uint16_t rbgAllocatedNum = 0;
709 std::set <uint16_t> rntiAllocated;
713 for (std::vector<bool>::iterator it = rbgMap.begin (); it != rbgMap.end (); it++)
724 std::map <uint16_t, uint8_t>::iterator itProcId;
727 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
731 uint16_t rbAllocatedNum = 0;
732 std::vector <bool> ulRbMap;
735 uint8_t maxContinuousUlBandwidth = 0;
736 uint8_t tmpMinBandwidth = 0;
737 uint16_t ffrRbStartOffset = 0;
738 uint16_t tmpFfrRbStartOffset = 0;
741 for (std::vector<bool>::iterator it = ulRbMap.begin (); it != ulRbMap.end (); it++)
746 if (tmpMinBandwidth > maxContinuousUlBandwidth)
748 maxContinuousUlBandwidth = tmpMinBandwidth;
749 ffrRbStartOffset = tmpFfrRbStartOffset;
755 if (tmpMinBandwidth == 0)
757 tmpFfrRbStartOffset = index;
764 if (tmpMinBandwidth > maxContinuousUlBandwidth)
766 maxContinuousUlBandwidth = tmpMinBandwidth;
767 ffrRbStartOffset = tmpFfrRbStartOffset;
771 uint16_t rbStart = 0;
772 rbStart = ffrRbStartOffset;
773 std::vector <struct RachListElement_s>::iterator itRach;
778 newRar.
m_rnti = (*itRach).m_rnti;
782 newRar.m_grant.m_rnti = newRar.m_rnti;
785 uint16_t tbSizeBits = 0;
787 while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < (ffrRbStartOffset + maxContinuousUlBandwidth)))
792 if (tbSizeBits < (*itRach).m_estimatedSize)
797 newRar.m_grant.m_rbStart = rbStart;
798 newRar.m_grant.m_rbLen = rbLen;
799 newRar.m_grant.m_tbSize = tbSizeBits / 8;
800 newRar.m_grant.m_hopping =
false;
801 newRar.m_grant.m_tpc = 0;
802 newRar.m_grant.m_cqiRequest =
false;
803 newRar.m_grant.m_ulDelay =
false;
804 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);
805 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
814 uldci.
m_rnti = newRar.m_rnti;
833 std::map <uint16_t, uint8_t>::iterator itProcId;
839 harqId = (*itProcId).second;
845 (*itDci).second.at (harqId) = uldci;
848 rbStart = rbStart + rbLen;
861 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
877 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
881 if (itRnti != rntiAllocated.end ())
887 std::vector <bool> retx;
888 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
892 retx.push_back (
false);
899 if (retx.at (0) || retx.at (1))
904 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
913 if (dci.
m_rv.size () == 1)
915 rv = dci.
m_rv.at (0);
919 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
925 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
931 (*it).second.at (harqId) = 0;
937 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
939 (*itRlcPdu).second.at (k).at (harqId).clear ();
945 std::vector <int> dciRbg;
948 for (
int j = 0; j < 32; j++)
952 dciRbg.push_back (j);
958 for (uint8_t j = 0; j < dciRbg.size (); j++)
960 if (rbgMap.at (dciRbg.at (j)) ==
true)
970 for (uint8_t j = 0; j < dciRbg.size (); j++)
972 rbgMap.at (dciRbg.at (j)) =
true;
973 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
977 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
983 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
984 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
985 std::vector <bool> rbgMapCopy = rbgMap;
986 while ((j < dciRbg.size ())&&(startRbg != rbgId))
988 if (rbgMapCopy.at (rbgId) ==
false)
990 rbgMapCopy.at (rbgId) =
true;
991 dciRbg.at (j) = rbgId;
994 rbgId = (rbgId + 1) % rbgNum;
996 if (j == dciRbg.size ())
999 uint32_t rbgMask = 0;
1000 for (uint16_t k = 0; k < dciRbg.size (); k++)
1002 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
1006 rbgMap = rbgMapCopy;
1007 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
1013 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
1021 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
1023 for (uint8_t j = 0; j < nLayers; j++)
1027 if (j >= dci.
m_ndi.size ())
1030 dci.
m_ndi.push_back (0);
1031 dci.
m_rv.push_back (0);
1032 dci.
m_mcs.push_back (0);
1034 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
1038 dci.
m_ndi.at (j) = 0;
1040 (*itHarq).second.at (harqId).m_rv.at (j)++;
1041 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
1047 dci.
m_ndi.at (j) = 0;
1048 dci.
m_rv.at (j) = 0;
1049 dci.
m_mcs.at (j) = 0;
1051 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
1054 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
1056 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
1057 for (uint8_t j = 0; j < nLayers; j++)
1061 if (j < dci.
m_ndi.size ())
1063 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
1068 if (rlcPduListPerLc.size () > 0)
1075 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
1080 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
1082 (*itHarqTimer).second.at (harqId) = 0;
1084 rntiAllocated.insert (rnti);
1101 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1110 if (rbgAllocatedNum == rbgNum)
1122 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1125 if ( (*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
1127 (*itStats).second.counter += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1128 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
1129 bankSize += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1133 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
1139 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
1140 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itMax =
m_flowStatsDl.end ();
1141 double metricMax = 0.0;
1142 bool firstRnti =
true;
1145 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1149 if (itRnti != rntiAllocated.end ())
1151 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1155 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1167 double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
1169 if (firstRnti ==
true)
1176 if (metric > metricMax)
1191 std::vector <uint16_t> tempMap;
1192 for (
int i = 0; i < rbgNum; i++)
1194 if ( rbgMap.at (i) ==
true)
1200 tempMap.push_back (i);
1201 rbgMap.at (i) =
true;
1203 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1210 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1211 while (itMap != allocationMap.end ())
1215 newEl.
m_rnti = (*itMap).first;
1218 newDci.
m_rnti = (*itMap).first;
1226 lcActives = (uint16_t)65535;
1228 uint16_t RgbPerRnti = (*itMap).second.size ();
1229 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1231 std::map <uint16_t,uint8_t>::iterator itTxMode;
1235 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1238 std::vector <uint8_t> worstCqi (2, 15);
1241 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1243 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1245 for (uint8_t j = 0; j < nLayer; j++)
1247 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1249 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1251 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1257 worstCqi.at (j) = 1;
1263 for (uint8_t j = 0; j < nLayer; j++)
1265 worstCqi.at (j) = 1;
1272 for (uint8_t j = 0; j < nLayer; j++)
1274 worstCqi.at (j) = 1;
1277 uint32_t bytesTxed = 0;
1278 for (uint8_t j = 0; j < nLayer; j++)
1280 newDci.
m_mcs.push_back (
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1281 int tbSize = (
m_amc->GetTbSizeFromMcs (newDci.
m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1283 bytesTxed += tbSize;
1288 uint32_t rbgMask = 0;
1289 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1291 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1292 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1297 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1300 if (((*itBufReq).first.m_rnti == (*itMap).first)
1301 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1302 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1303 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1305 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1306 for (uint8_t j = 0; j < nLayer; j++)
1312 newRlcPduLe.push_back (newRlcEl);
1320 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1322 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1327 if ((*itBufReq).first.m_rnti > (*itMap).first)
1332 for (uint8_t j = 0; j < nLayer; j++)
1334 newDci.
m_ndi.push_back (1);
1335 newDci.
m_rv.push_back (0);
1340 newEl.
m_dci = newDci;
1362 if ( bytesTxed <= (*itMax).second.tokenPoolSize )
1364 (*itMax).second.tokenPoolSize -= bytesTxed;
1368 (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
1369 (*itMax).second.tokenPoolSize = 0;
1370 if (
bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
1407 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1412 std::map <uint16_t,uint8_t>::iterator it;
1413 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1418 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1425 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1427 std::map <uint16_t,uint32_t>::iterator itTimers;
1435 std::map <uint16_t,SbMeasResult_s>::iterator it;
1436 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1441 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1447 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1448 std::map <uint16_t,uint32_t>::iterator itTimers;
1466 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1480 double sinr = (*itCqi).second.at (i);
1487 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1489 (*itCqi).second.at (rb) = estimatedSinr;
1490 return (estimatedSinr);
1504 std::vector <bool> rbMap;
1505 uint16_t rbAllocatedNum = 0;
1506 std::set <uint16_t> rntiAllocated;
1507 std::vector <uint16_t> rbgAllocationMap;
1518 for (std::vector<bool>::iterator it = rbMap.begin (); it != rbMap.end (); it++)
1532 if (rbgAllocationMap.at (i) != 0)
1534 rbMap.at (i) =
true;
1543 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1552 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1555 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1559 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1566 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1568 if ((*itStat).second.at (harqId) >= 3)
1570 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1576 if (rbMap.at (j) ==
true)
1587 rbMap.at (j) =
true;
1588 rbgAllocationMap.at (j) = dci.
m_rnti;
1596 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1601 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1602 (*itStat).second.at (harqId) = 0;
1603 (*itHarq).second.at ((*itProcId).second) = dci;
1605 rntiAllocated.insert (dci.
m_rnti);
1614 std::map <uint16_t,uint32_t>::iterator it;
1619 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1621 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1640 uint16_t tempRbPerFlow = (ffrUlBandwidth) / (nflows + rntiAllocated.size ());
1641 uint16_t rbPerFlow = (minContinuousUlBandwidth < tempRbPerFlow) ? minContinuousUlBandwidth : tempRbPerFlow;
1647 int rbAllocated = 0;
1649 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1671 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1672 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1675 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1698 uldci.
m_rnti = (*it).first;
1700 bool allocated =
false;
1701 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1706 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1708 if (rbMap.at (j) ==
true)
1721 NS_LOG_INFO (
this <<
"RNTI: "<< (*it).first<<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1724 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1726 rbMap.at (j) =
true;
1728 rbgAllocationMap.at (j) = (*it).first;
1730 rbAllocated += rbPerFlow;
1762 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1772 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1779 double sinr = (*itCqi).second.at (i);
1784 if ((*itCqi).second.at (i) < minSinr)
1786 minSinr = (*itCqi).second.at (i);
1791 double s = log2 ( 1 + (
1792 std::pow (10, minSinr / 10 ) /
1793 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1794 cqi =
m_amc->GetCqiFromSpectralEfficiency (s);
1807 rbgAllocationMap.at (i) = 0;
1833 std::map <uint16_t, uint8_t>::iterator itProcId;
1839 harqId = (*itProcId).second;
1845 (*itDci).second.at (harqId) = uldci;
1850 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << uldci.
m_rnti);
1852 (*itStat).second.at (harqId) = 0;
1855 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);
1898 std::map <uint16_t,uint32_t>::iterator it;
1900 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
1911 uint32_t buffer = 0;
1912 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1914 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1919 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1924 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1929 (*it).second = buffer;
1972 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1973 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1974 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
1980 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1984 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
1988 std::vector <double> newCqi;
1993 newCqi.push_back (sinr);
2002 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2009 (*itCqi).second.at (i) = sinr;
2010 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2012 std::map <uint16_t, uint32_t>::iterator itTimers;
2033 rnti = vsp->GetRnti ();
2036 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2041 std::vector <double> newCqi;
2045 newCqi.push_back (sinr);
2046 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2049 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2059 (*itCqi).second.at (j) = sinr;
2060 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2063 std::map <uint16_t, uint32_t>::iterator itTimers;
2076 NS_FATAL_ERROR (
"TdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2089 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2093 if ((*itP10).second == 0)
2096 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2098 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2100 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2112 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2116 if ((*itA30).second == 0)
2119 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2121 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2123 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2142 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2146 if ((*itUl).second == 0)
2149 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2150 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2151 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2152 (*itMap).second.clear ();
2154 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2171 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2176 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);
2179 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2181 (*it).second.m_rlcStatusPduSize = 0;
2183 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2185 (*it).second.m_rlcRetransmissionQueueSize = 0;
2187 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2189 uint32_t rlcOverhead;
2204 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2206 (*it).second.m_rlcTransmissionQueueSize = 0;
2210 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2216 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2225 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2228 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2229 if ((*it).second >= size)
2231 (*it).second -= size;
2240 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2248 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
void DoSchedUlNoiseInterferenceReq(const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters ¶ms)
void RefreshUlCqiMaps(void)
std::vector< struct UlInfoListElement_s > m_ulInfoList
See section 4.3.1 dlDciListElement.
void DoCschedLcReleaseReq(const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters ¶ms)
TdTbfqFfMacScheduler * m_scheduler
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
Smart pointer class similar to boost::intrusive_ptr.
Service Access Point (SAP) offered by the eNodeB RRC instance to the Frequency Reuse algorithm instan...
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
virtual void DoDispose(void)
Destructor implementation.
void DoSchedDlRlcBufferReq(const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters ¶ms)
AttributeValue implementation for Boolean.
TdTbfqFfMacScheduler * m_scheduler
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void DoCschedUeConfigReq(const struct FfMacCschedSapProvider::CschedUeConfigReqParameters ¶ms)
virtual void ReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms)=0
ReportUlCqiInfo.
Parameters of the CSCHED_UE_CONFIG_CNF primitive.
Parameters of the CSCHED_UE_RELEASE_REQ primitive.
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
friend class TdTbfqSchedulerMemberCschedSapProvider
void DoSchedDlRachInfoReq(const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters ¶ms)
virtual bool IsDlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in DL.
TdTbfqSchedulerMemberCschedSapProvider()
uint32_t burstCredit
the number of token borrow or given to token bank
virtual bool IsUlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in UL.
FfMacSchedSapProvider * m_schedSapProvider
enum ns3::UlCqi_s::Type_e m_type
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
friend class TdTbfqSchedulerMemberSchedSapProvider
std::vector< UlDciListElement_s > UlHarqProcessesDciBuffer_t
uint32_t maxTokenPoolSize
current size of token pool (byte)
std::vector< struct LogicalChannelConfigListElement_s > m_logicalChannelConfigList
std::vector< uint16_t > m_sinr
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
std::vector< uint8_t > DlHarqProcessesTimer_t
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
virtual ~TdTbfqFfMacScheduler()
Destructor.
Hold a signed integer type.
virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters ¶ms)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
std::vector< uint8_t > m_mcs
TdTbfqSchedulerMemberSchedSapProvider()
See section 4.3.2 ulDciListElement.
std::vector< struct UlDciListElement_s > m_dciList
void DoCschedLcConfigReq(const struct FfMacCschedSapProvider::CschedLcConfigReqParameters ¶ms)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Fatal error handling.
See section 4.3.10 buildRARListElement.
Parameters of the CSCHED_UE_CONFIG_UPDATE_IND primitive.
Parameters of the CSCHED_LC_RELEASE_REQ primitive.
int counter
maximum size of token pool (byte)
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
virtual uint8_t GetTpc(uint16_t rnti)=0
GetTpc.
virtual void CschedLcConfigReq(const struct CschedLcConfigReqParameters ¶ms)
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
std::vector< std::vector< struct RlcPduListElement_s > > m_rlcPduList
uint8_t m_transmissionMode
Implements the SCHED SAP and CSCHED SAP for a Time Domain Token Bank Fair Queue scheduler.
std::vector< struct RachListElement_s > m_rachList
Parameters of the SCHED_DL_TRIGGER_REQ primitive.
uint8_t m_logicalChannelIdentity
FfMacCschedSapUser * m_cschedSapUser
TdTbfqFfMacScheduler()
Constructor.
void DoSchedUlTriggerReq(const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters ¶ms)
virtual void SchedUlNoiseInterferenceReq(const struct SchedUlNoiseInterferenceReqParameters ¶ms)
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
Ptr< const AttributeAccessor > MakeIntegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters ¶ms)
void RefreshDlCqiMaps(void)
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
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
void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters ¶ms)
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
Parameters of the SCHED_UL_TRIGGER_REQ primitive.
int debtLimit
the maximum number of tokens connection i can borrow from the bank each time
Hold an unsigned integer type.
virtual void SetLteFfrSapProvider(LteFfrSapProvider *s)
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
static uint8_t TxMode2LayerNum(uint8_t txMode)
std::map< uint16_t, uint32_t > m_a30CqiTimers
virtual void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters ¶ms)
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
std::vector< uint8_t > m_ndi
virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters ¶ms)
void DoSchedDlCqiInfoReq(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters ¶ms)
void DoSchedDlMacBufferReq(const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters ¶ms)
virtual void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters ¶ms)=0
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
std::vector< uint8_t > m_logicalChannelIdentity
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Parameters of the SCHED_UL_NOISE_INTERFERENCE_REQ primitive.
uint8_t m_logicalChannelIdentity
std::vector< struct CqiListElement_s > m_cqiList
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
std::vector< struct DlInfoListElement_s > m_dlInfoList
FfMacSchedSapUser * m_schedSapUser
virtual void ReportDlCqiInfo(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters ¶ms)=0
ReportDlCqiInfo.
virtual LteFfrSapUser * GetLteFfrSapUser()
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
virtual void SchedDlConfigInd(const struct SchedDlConfigIndParameters ¶ms)=0
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
set the user part of the FfMacSchedSap that this Scheduler will interact with.
Parameters of the API primitives.
int8_t m_pdcchPowerOffset
std::vector< uint16_t > m_tbsSize
See section 4.3.9 rlcPDU_ListElement.
uint64_t tokenGenerationRate
packet arrival rate( byte/s)
virtual void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters ¶ms)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::map< uint16_t, std::vector< double > > m_ueCqi
Ptr< const AttributeChecker > MakeBooleanChecker(void)
virtual void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters ¶ms)
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
virtual void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters ¶ms)
Parameters of the CSCHED_LC_CONFIG_REQ primitive.
std::vector< uint8_t > m_rv
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
std::map< uint16_t, uint8_t > m_p10CqiRxed
virtual std::vector< bool > GetAvailableUlRbg()=0
Get vector of available RB in UL for this Cell.
virtual uint8_t GetMinContinuousUlBandwidth()=0
GetMinContinuousUlBandwidth.
virtual void SchedUlConfigInd(const struct SchedUlConfigIndParameters ¶ms)=0
static Time Now(void)
Return the current simulation virtual time.
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
uint32_t creditableThreshold
counter threshold that the flow cannot further borrow tokens from bank
UlCqiFilter_t m_ulCqiFilter
uint32_t tokenPoolSize
token generation rate ( byte/s )
This abstract base class identifies the interface by means of which the helper object can plug on the...
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
set the user part of the FfMacCschedSap that this Scheduler will interact with.
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void CschedUeConfigReq(const struct CschedUeConfigReqParameters ¶ms)
uint8_t m_nrOfPdcchOfdmSymbols
void DoCschedUeReleaseReq(const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters ¶ms)
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
std::vector< struct MacCeListElement_s > m_macCeList
Parameters of the API primitives.
std::map< uint16_t, tdtbfqsFlowPerf_t > m_flowStatsDl
std::vector< struct RachListElement_s > m_rachList
static double fpS11dot3toDouble(uint16_t val)
bool m_harqOn
m_harqOn when false inhibit te HARQ mechanisms (by default active)
static const int TdTbfqType0AllocationRbg[4]
virtual void SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters ¶ms)
std::map< uint16_t, uint8_t > m_uesTxMode
std::vector< uint8_t > UlHarqProcessesStatus_t
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
std::map< uint16_t, uint32_t > m_ueCqiTimers
std::vector< uint8_t > DlHarqProcessesStatus_t
Parameters of the SCHED_UL_CQI_INFO_REQ primitive.
static uint32_t BsrId2BufferSize(uint8_t val)
uint8_t m_transmissionMode
Template for the implementation of the LteFfrSapUser as a member of an owner class of type C to which...
virtual void SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters ¶ms)
Parameters of the API primitives.
Parameters of the SCHED_UL_MAC_CTRL_INFO_REQ primitive.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual std::vector< bool > GetAvailableDlRbg()=0
Get vector of available RBG in DL for this Cell.
virtual void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters ¶ms)
int LcActivePerFlow(uint16_t rnti)
uint32_t m_cqiTimersThreshold
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
Parameters of the SCHED_UL_SR_INFO_REQ primitive.
LteFfrSapUser * m_ffrSapUser
void DoSchedUlCqiInfoReq(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms)
void DoCschedCellConfigReq(const struct FfMacCschedSapProvider::CschedCellConfigReqParameters ¶ms)
virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters ¶ms)
FfMacCschedSapProvider * m_cschedSapProvider
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
Parameters of the SCHED_DL_RACH_INFO_REQ primitive.
uint32_t m_creditableThreshold
Parameters of the SCHED_UL_CONFIG_IND primitive.
void DoSchedDlPagingBufferReq(const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters ¶ms)
Parameters of the CSCHED_UE_CONFIG_REQ primitive.
virtual void SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters ¶ms)
uint64_t packetArrivalRate
LteFfrSapProvider * m_ffrSapProvider
void DoSchedUlMacCtrlInfoReq(const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters ¶ms)
std::vector< uint16_t > m_rachAllocationMap
struct DlDciListElement_s m_dci
std::vector< struct BuildRarListElement_s > m_buildRarList
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
std::map< uint16_t, uint32_t > m_ceBsrRxed
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
void DoSchedDlTriggerReq(const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters ¶ms)
std::map< uint16_t, uint32_t > m_p10CqiTimers
TypeId SetParent(TypeId tid)
int GetRbgSize(int dlbandwidth)
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
std::vector< struct BuildDataListElement_s > m_buildDataList
std::map< uint16_t, tdtbfqsFlowPerf_t > m_flowStatsUl
uint8_t m_ueTxAntennaSelection
static TypeId GetTypeId(void)
See section 4.3.8 builDataListElement.