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")
256 .AddConstructor<TdTbfqFfMacScheduler> ()
257 .AddAttribute (
"CqiTimerThreshold",
258 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
261 MakeUintegerChecker<uint32_t> ())
262 .AddAttribute (
"DebtLimit",
263 "Flow debt limit (default -625000 bytes)",
266 MakeIntegerChecker<int> ())
267 .AddAttribute (
"CreditLimit",
268 "Flow credit limit (default 625000 bytes)",
271 MakeUintegerChecker<uint32_t> ())
272 .AddAttribute (
"TokenPoolSize",
273 "The maximum value of flow token pool (default 1 bytes)",
276 MakeUintegerChecker<uint32_t> ())
277 .AddAttribute (
"CreditableThreshold",
278 "Threshold of flow credit (default 0 bytes)",
281 MakeUintegerChecker<uint32_t> ())
283 .AddAttribute (
"HarqEnabled",
284 "Activate/Deactivate the HARQ [by default is active].",
288 .AddAttribute (
"UlGrantMcs",
289 "The MCS of the UL grant, must be [0..15] (default 0)",
292 MakeUintegerChecker<uint8_t> ())
359 dlHarqPrcStatus.resize (8,0);
362 dlHarqProcessesTimer.resize (8,0);
365 dlHarqdci.resize (8);
368 dlHarqRlcPdu.resize (2);
369 dlHarqRlcPdu.at (0).resize (8);
370 dlHarqRlcPdu.at (1).resize (8);
374 ulHarqPrcStatus.resize (8,0);
377 ulHarqdci.resize (8);
392 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
412 m_flowStatsDl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsDl));
423 m_flowStatsUl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsUl));
430 m_flowStatsDl[(*it).first].tokenGenerationRate = mbrDlInBytes;
431 m_flowStatsUl[(*it).first].tokenGenerationRate = mbrUlInBytes;
445 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
446 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
481 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
482 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
485 if ((*it).first.m_rnti == params.
m_rnti)
511 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
519 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
523 (*it).second = params;
548 for (
int i = 0; i < 4; i++)
550 if (dlbandwidth < TdTbfqType0AllocationRbg[i])
563 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
567 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
568 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
569 || ((*it).second.m_rlcStatusPduSize > 0) ))
573 if ((*it).first.m_rnti > rnti)
596 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
598 uint8_t i = (*it).second;
603 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
604 if ((*itStat).second.at (i) == 0)
635 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
637 uint8_t i = (*it).second;
642 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
643 if ((*itStat).second.at (i) == 0)
646 (*itStat).second.at (i) = 1;
650 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
653 return ((*it).second);
662 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
671 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
672 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
675 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
677 (*itStat).second.at (i) = 0;
678 (*itTimers).second.at (i) = 0;
682 (*itTimers).second.at (i)++;
705 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
706 std::vector <bool> rbgMap;
707 uint16_t rbgAllocatedNum = 0;
708 std::set <uint16_t> rntiAllocated;
712 for (std::vector<bool>::iterator it = rbgMap.begin (); it != rbgMap.end (); it++)
723 std::map <uint16_t, uint8_t>::iterator itProcId;
726 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
730 uint16_t rbAllocatedNum = 0;
731 std::vector <bool> ulRbMap;
734 uint8_t maxContinuousUlBandwidth = 0;
735 uint8_t tmpMinBandwidth = 0;
736 uint16_t ffrRbStartOffset = 0;
737 uint16_t tmpFfrRbStartOffset = 0;
740 for (std::vector<bool>::iterator it = ulRbMap.begin (); it != ulRbMap.end (); it++)
745 if (tmpMinBandwidth > maxContinuousUlBandwidth)
747 maxContinuousUlBandwidth = tmpMinBandwidth;
748 ffrRbStartOffset = tmpFfrRbStartOffset;
754 if (tmpMinBandwidth == 0)
756 tmpFfrRbStartOffset = index;
763 if (tmpMinBandwidth > maxContinuousUlBandwidth)
765 maxContinuousUlBandwidth = tmpMinBandwidth;
766 ffrRbStartOffset = tmpFfrRbStartOffset;
770 uint16_t rbStart = 0;
771 rbStart = ffrRbStartOffset;
772 std::vector <struct RachListElement_s>::iterator itRach;
777 newRar.
m_rnti = (*itRach).m_rnti;
781 newRar.m_grant.m_rnti = newRar.m_rnti;
784 uint16_t tbSizeBits = 0;
786 while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < (ffrRbStartOffset + maxContinuousUlBandwidth)))
791 if (tbSizeBits < (*itRach).m_estimatedSize)
796 newRar.m_grant.m_rbStart = rbStart;
797 newRar.m_grant.m_rbLen = rbLen;
798 newRar.m_grant.m_tbSize = tbSizeBits / 8;
799 newRar.m_grant.m_hopping =
false;
800 newRar.m_grant.m_tpc = 0;
801 newRar.m_grant.m_cqiRequest =
false;
802 newRar.m_grant.m_ulDelay =
false;
803 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);
804 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
813 uldci.
m_rnti = newRar.m_rnti;
832 std::map <uint16_t, uint8_t>::iterator itProcId;
838 harqId = (*itProcId).second;
844 (*itDci).second.at (harqId) = uldci;
847 rbStart = rbStart + rbLen;
860 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
876 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
880 if (itRnti != rntiAllocated.end ())
886 std::vector <bool> retx;
887 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
891 retx.push_back (
false);
898 if (retx.at (0) || retx.at (1))
903 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
912 if (dci.
m_rv.size () == 1)
914 rv = dci.
m_rv.at (0);
918 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
924 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
930 (*it).second.at (harqId) = 0;
936 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
938 (*itRlcPdu).second.at (k).at (harqId).clear ();
944 std::vector <int> dciRbg;
947 for (
int j = 0; j < 32; j++)
951 dciRbg.push_back (j);
957 for (uint8_t j = 0; j < dciRbg.size (); j++)
959 if (rbgMap.at (dciRbg.at (j)) ==
true)
969 for (uint8_t j = 0; j < dciRbg.size (); j++)
971 rbgMap.at (dciRbg.at (j)) =
true;
972 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
976 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
982 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
983 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
984 std::vector <bool> rbgMapCopy = rbgMap;
985 while ((j < dciRbg.size ())&&(startRbg != rbgId))
987 if (rbgMapCopy.at (rbgId) ==
false)
989 rbgMapCopy.at (rbgId) =
true;
990 dciRbg.at (j) = rbgId;
993 rbgId = (rbgId + 1) % rbgNum;
995 if (j == dciRbg.size ())
998 uint32_t rbgMask = 0;
999 for (uint16_t k = 0; k < dciRbg.size (); k++)
1001 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
1005 rbgMap = rbgMapCopy;
1006 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
1012 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
1020 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
1022 for (uint8_t j = 0; j < nLayers; j++)
1026 if (j >= dci.
m_ndi.size ())
1029 dci.
m_ndi.push_back (0);
1030 dci.
m_rv.push_back (0);
1031 dci.
m_mcs.push_back (0);
1033 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
1037 dci.
m_ndi.at (j) = 0;
1039 (*itHarq).second.at (harqId).m_rv.at (j)++;
1040 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
1046 dci.
m_ndi.at (j) = 0;
1047 dci.
m_rv.at (j) = 0;
1048 dci.
m_mcs.at (j) = 0;
1050 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
1053 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
1055 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
1056 for (uint8_t j = 0; j < nLayers; j++)
1060 if (j < dci.
m_ndi.size ())
1062 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
1067 if (rlcPduListPerLc.size () > 0)
1074 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
1079 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
1081 (*itHarqTimer).second.at (harqId) = 0;
1083 rntiAllocated.insert (rnti);
1100 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1109 if (rbgAllocatedNum == rbgNum)
1121 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1124 if ( (*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
1126 (*itStats).second.counter += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1127 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
1128 bankSize += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1132 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
1138 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
1139 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itMax =
m_flowStatsDl.end ();
1140 double metricMax = 0.0;
1141 bool firstRnti =
true;
1144 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1148 if (itRnti != rntiAllocated.end ())
1150 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1154 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1166 double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
1168 if (firstRnti ==
true)
1175 if (metric > metricMax)
1190 std::vector <uint16_t> tempMap;
1191 for (
int i = 0; i < rbgNum; i++)
1193 if ( rbgMap.at (i) ==
true)
1199 tempMap.push_back (i);
1200 rbgMap.at (i) =
true;
1202 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1209 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1210 while (itMap != allocationMap.end ())
1214 newEl.
m_rnti = (*itMap).first;
1217 newDci.
m_rnti = (*itMap).first;
1225 lcActives = (uint16_t)65535;
1227 uint16_t RgbPerRnti = (*itMap).second.size ();
1228 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1230 std::map <uint16_t,uint8_t>::iterator itTxMode;
1234 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1237 std::vector <uint8_t> worstCqi (2, 15);
1240 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1242 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1244 for (uint8_t j = 0; j < nLayer; j++)
1246 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1248 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1250 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1256 worstCqi.at (j) = 1;
1262 for (uint8_t j = 0; j < nLayer; j++)
1264 worstCqi.at (j) = 1;
1271 for (uint8_t j = 0; j < nLayer; j++)
1273 worstCqi.at (j) = 1;
1276 uint32_t bytesTxed = 0;
1277 for (uint8_t j = 0; j < nLayer; j++)
1279 newDci.
m_mcs.push_back (
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1280 int tbSize = (
m_amc->GetTbSizeFromMcs (newDci.
m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1282 bytesTxed += tbSize;
1287 uint32_t rbgMask = 0;
1288 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1290 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1291 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1296 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1299 if (((*itBufReq).first.m_rnti == (*itMap).first)
1300 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1301 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1302 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1304 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1305 for (uint8_t j = 0; j < nLayer; j++)
1311 newRlcPduLe.push_back (newRlcEl);
1319 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1321 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1326 if ((*itBufReq).first.m_rnti > (*itMap).first)
1331 for (uint8_t j = 0; j < nLayer; j++)
1333 newDci.
m_ndi.push_back (1);
1334 newDci.
m_rv.push_back (0);
1339 newEl.
m_dci = newDci;
1361 if ( bytesTxed <= (*itMax).second.tokenPoolSize )
1363 (*itMax).second.tokenPoolSize -= bytesTxed;
1367 (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
1368 (*itMax).second.tokenPoolSize = 0;
1369 if (
bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
1406 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1411 std::map <uint16_t,uint8_t>::iterator it;
1412 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1417 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1424 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1426 std::map <uint16_t,uint32_t>::iterator itTimers;
1434 std::map <uint16_t,SbMeasResult_s>::iterator it;
1435 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1440 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1446 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1447 std::map <uint16_t,uint32_t>::iterator itTimers;
1465 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1479 double sinr = (*itCqi).second.at (i);
1486 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1488 (*itCqi).second.at (rb) = estimatedSinr;
1489 return (estimatedSinr);
1503 std::vector <bool> rbMap;
1504 uint16_t rbAllocatedNum = 0;
1505 std::set <uint16_t> rntiAllocated;
1506 std::vector <uint16_t> rbgAllocationMap;
1517 for (std::vector<bool>::iterator it = rbMap.begin (); it != rbMap.end (); it++)
1531 if (rbgAllocationMap.at (i) != 0)
1533 rbMap.at (i) =
true;
1542 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1551 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1554 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1558 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1565 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1567 if ((*itStat).second.at (harqId) >= 3)
1569 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1575 if (rbMap.at (j) ==
true)
1586 rbMap.at (j) =
true;
1587 rbgAllocationMap.at (j) = dci.
m_rnti;
1595 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1600 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1601 (*itStat).second.at (harqId) = 0;
1602 (*itHarq).second.at ((*itProcId).second) = dci;
1604 rntiAllocated.insert (dci.
m_rnti);
1613 std::map <uint16_t,uint32_t>::iterator it;
1618 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1620 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1639 uint16_t tempRbPerFlow = (ffrUlBandwidth) / (nflows + rntiAllocated.size ());
1640 uint16_t rbPerFlow = (minContinuousUlBandwidth < tempRbPerFlow) ? minContinuousUlBandwidth : tempRbPerFlow;
1646 int rbAllocated = 0;
1648 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1670 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1671 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1674 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1697 uldci.
m_rnti = (*it).first;
1699 bool allocated =
false;
1700 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1705 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1707 if (rbMap.at (j) ==
true)
1720 NS_LOG_INFO (
this <<
"RNTI: "<< (*it).first<<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1723 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1725 rbMap.at (j) =
true;
1727 rbgAllocationMap.at (j) = (*it).first;
1729 rbAllocated += rbPerFlow;
1761 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1771 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1778 double sinr = (*itCqi).second.at (i);
1783 if ((*itCqi).second.at (i) < minSinr)
1785 minSinr = (*itCqi).second.at (i);
1790 double s = log2 ( 1 + (
1791 std::pow (10, minSinr / 10 ) /
1792 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1793 cqi =
m_amc->GetCqiFromSpectralEfficiency (s);
1806 rbgAllocationMap.at (i) = 0;
1832 std::map <uint16_t, uint8_t>::iterator itProcId;
1838 harqId = (*itProcId).second;
1844 (*itDci).second.at (harqId) = uldci;
1849 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << uldci.
m_rnti);
1851 (*itStat).second.at (harqId) = 0;
1854 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);
1897 std::map <uint16_t,uint32_t>::iterator it;
1899 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
1910 uint32_t buffer = 0;
1911 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1913 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1918 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1923 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1928 (*it).second = buffer;
1971 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1972 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1973 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
1979 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1983 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
1987 std::vector <double> newCqi;
1992 newCqi.push_back (sinr);
2001 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2008 (*itCqi).second.at (i) = sinr;
2009 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2011 std::map <uint16_t, uint32_t>::iterator itTimers;
2032 rnti = vsp->GetRnti ();
2035 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2040 std::vector <double> newCqi;
2044 newCqi.push_back (sinr);
2045 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2048 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2058 (*itCqi).second.at (j) = sinr;
2059 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2062 std::map <uint16_t, uint32_t>::iterator itTimers;
2075 NS_FATAL_ERROR (
"TdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2088 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2092 if ((*itP10).second == 0)
2095 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2097 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2099 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2111 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2115 if ((*itA30).second == 0)
2118 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2120 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2122 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2141 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2145 if ((*itUl).second == 0)
2148 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2149 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2150 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2151 (*itMap).second.clear ();
2153 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2170 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2175 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);
2178 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2180 (*it).second.m_rlcStatusPduSize = 0;
2182 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2184 (*it).second.m_rlcRetransmissionQueueSize = 0;
2186 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2188 uint32_t rlcOverhead;
2203 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2205 (*it).second.m_rlcTransmissionQueueSize = 0;
2209 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2215 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2224 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2227 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2228 if ((*it).second >= size)
2230 (*it).second -= size;
2239 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2247 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.