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>
144 : m_scheduler (scheduler)
219 : m_cschedSapUser (0),
224 m_amc = CreateObject <LteAmc> ();
252 static TypeId tid =
TypeId (
"ns3::TdTbfqFfMacScheduler")
254 .AddConstructor<TdTbfqFfMacScheduler> ()
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, tdtbfqsFlowPerf_t>::iterator it;
398 m_flowStatsDl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_t> (params.
m_rnti, flowStatsDl));
409 m_flowStatsUl.insert (std::pair<uint16_t, tdtbfqsFlowPerf_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;
699 std::map <uint16_t, uint8_t>::iterator itProcId;
702 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
707 uint16_t rbStart = 0;
708 std::vector <struct RachListElement_s>::iterator itRach;
713 newRar.
m_rnti = (*itRach).m_rnti;
717 newRar.m_grant.m_rnti = newRar.m_rnti;
720 uint16_t tbSizeBits = 0;
727 if (tbSizeBits < (*itRach).m_estimatedSize)
732 newRar.m_grant.m_rbStart = rbStart;
733 newRar.m_grant.m_rbLen = rbLen;
734 newRar.m_grant.m_tbSize = tbSizeBits / 8;
735 newRar.m_grant.m_hopping =
false;
736 newRar.m_grant.m_tpc = 0;
737 newRar.m_grant.m_cqiRequest =
false;
738 newRar.m_grant.m_ulDelay =
false;
739 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);
740 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
744 rbStart = rbStart + rbLen;
750 uldci.
m_rnti = newRar.m_rnti;
769 std::map <uint16_t, uint8_t>::iterator itProcId;
775 harqId = (*itProcId).second;
781 (*itDci).second.at (harqId) = uldci;
796 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
812 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
816 if (itRnti != rntiAllocated.end ())
822 std::vector <bool> retx;
823 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
827 retx.push_back (
false);
834 if (retx.at (0) || retx.at (1))
839 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
848 if (dci.
m_rv.size () == 1)
850 rv = dci.
m_rv.at (0);
854 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
860 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
866 (*it).second.at (harqId) = 0;
872 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
874 (*itRlcPdu).second.at (k).at (harqId).clear ();
880 std::vector <int> dciRbg;
883 for (
int j = 0; j < 32; j++)
887 dciRbg.push_back (j);
893 for (uint8_t j = 0; j < dciRbg.size (); j++)
895 if (rbgMap.at (dciRbg.at (j)) ==
true)
905 for (uint8_t j = 0; j < dciRbg.size (); j++)
907 rbgMap.at (dciRbg.at (j)) =
true;
908 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
912 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
918 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
919 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
920 std::vector <bool> rbgMapCopy = rbgMap;
921 while ((j < dciRbg.size ())&&(startRbg != rbgId))
923 if (rbgMapCopy.at (rbgId) ==
false)
925 rbgMapCopy.at (rbgId) =
true;
926 dciRbg.at (j) = rbgId;
931 if (j == dciRbg.size ())
934 uint32_t rbgMask = 0;
935 for (uint16_t k = 0; k < dciRbg.size (); k++)
937 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
942 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
947 dlInfoListUntxed.push_back (params.
m_dlInfoList.at (i));
948 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
956 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
958 for (uint8_t j = 0; j < nLayers; j++)
962 if (j >= dci.
m_ndi.size ())
965 dci.
m_ndi.push_back (0);
966 dci.
m_rv.push_back (0);
967 dci.
m_mcs.push_back (0);
969 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
973 dci.
m_ndi.at (j) = 0;
975 (*itHarq).second.at (harqId).m_rv.at (j)++;
976 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
982 dci.
m_ndi.at (j) = 0;
984 dci.
m_mcs.at (j) = 0;
986 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
989 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
991 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
992 for (uint8_t j = 0; j < nLayers; j++)
996 if (j < dci.
m_ndi.size ())
998 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
1003 if (rlcPduListPerLc.size () > 0)
1010 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
1015 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
1017 (*itHarqTimer).second.at (harqId) = 0;
1019 rntiAllocated.insert (rnti);
1036 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1045 if (rbgAllocatedNum == rbgNum)
1057 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1060 if ( (*itStats).second.tokenGenerationRate / 1000 + (*itStats).second.tokenPoolSize > (*itStats).second.maxTokenPoolSize )
1062 (*itStats).second.counter += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1063 (*itStats).second.tokenPoolSize = (*itStats).second.maxTokenPoolSize;
1064 bankSize += (*itStats).second.tokenGenerationRate / 1000 - ( (*itStats).second.maxTokenPoolSize - (*itStats).second.tokenPoolSize );
1068 (*itStats).second.tokenPoolSize += (*itStats).second.tokenGenerationRate / 1000;
1074 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator it;
1075 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itMax =
m_flowStatsDl.end ();
1076 double metricMax = 0.0;
1077 bool firstRnti =
true;
1080 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1084 if (itRnti != rntiAllocated.end ())
1086 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1090 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1102 double metric = ( ( (double)(*it).second.counter ) / ( (double)(*it).second.tokenGenerationRate ) );
1104 if (firstRnti ==
true)
1111 if (metric > metricMax)
1126 std::vector <uint16_t> tempMap;
1127 for (
int i = 0; i < rbgNum; i++)
1129 if ( rbgMap.at (i) ==
true)
1132 tempMap.push_back (i);
1133 rbgMap.at (i) =
true;
1135 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1142 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1143 while (itMap != allocationMap.end ())
1147 newEl.
m_rnti = (*itMap).first;
1150 newDci.
m_rnti = (*itMap).first;
1158 lcActives = (uint16_t)65535;
1160 uint16_t RgbPerRnti = (*itMap).second.size ();
1161 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1163 std::map <uint16_t,uint8_t>::iterator itTxMode;
1167 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1170 std::vector <uint8_t> worstCqi (2, 15);
1173 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1175 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1177 for (uint8_t j = 0; j < nLayer; j++)
1179 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1181 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1183 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1189 worstCqi.at (j) = 1;
1195 for (uint8_t j = 0; j < nLayer; j++)
1197 worstCqi.at (j) = 1;
1204 for (uint8_t j = 0; j < nLayer; j++)
1206 worstCqi.at (j) = 1;
1209 uint32_t bytesTxed = 0;
1210 for (uint8_t j = 0; j < nLayer; j++)
1212 newDci.
m_mcs.push_back (
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1213 int tbSize = (
m_amc->GetTbSizeFromMcs (newDci.
m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1215 bytesTxed += tbSize;
1220 uint32_t rbgMask = 0;
1221 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1223 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1224 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1229 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1232 if (((*itBufReq).first.m_rnti == (*itMap).first)
1233 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1234 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1235 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1237 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1238 for (uint8_t j = 0; j < nLayer; j++)
1244 newRlcPduLe.push_back (newRlcEl);
1252 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1254 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1259 if ((*itBufReq).first.m_rnti > (*itMap).first)
1264 for (uint8_t j = 0; j < nLayer; j++)
1266 newDci.
m_ndi.push_back (1);
1267 newDci.
m_rv.push_back (0);
1270 newEl.
m_dci = newDci;
1292 if ( bytesTxed <= (*itMax).second.tokenPoolSize )
1294 (*itMax).second.tokenPoolSize -= bytesTxed;
1298 (*itMax).second.counter = (*itMax).second.counter - ( bytesTxed - (*itMax).second.tokenPoolSize );
1299 (*itMax).second.tokenPoolSize = 0;
1300 if (
bankSize <= ( bytesTxed - (*itMax).second.tokenPoolSize ))
1336 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1341 std::map <uint16_t,uint8_t>::iterator it;
1342 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1347 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1354 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1356 std::map <uint16_t,uint32_t>::iterator itTimers;
1364 std::map <uint16_t,SbMeasResult_s>::iterator it;
1365 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1370 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1376 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1377 std::map <uint16_t,uint32_t>::iterator itTimers;
1395 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1409 double sinr = (*itCqi).second.at (i);
1416 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1418 (*itCqi).second.at (rb) = estimatedSinr;
1419 return (estimatedSinr);
1432 std::vector <bool> rbMap;
1433 uint16_t rbAllocatedNum = 0;
1434 std::set <uint16_t> rntiAllocated;
1435 std::vector <uint16_t> rbgAllocationMap;
1446 if (rbgAllocationMap.at (i) != 0)
1448 rbMap.at (i) =
true;
1457 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1466 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1469 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1473 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1480 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1482 if ((*itStat).second.at (harqId) >= 3)
1484 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1490 if (rbMap.at (j) ==
true)
1501 rbMap.at (j) =
true;
1502 rbgAllocationMap.at (j) = dci.
m_rnti;
1510 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1515 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1516 (*itStat).second.at (harqId) = 0;
1517 (*itHarq).second.at ((*itProcId).second) = dci;
1519 rntiAllocated.insert (dci.
m_rnti);
1528 std::map <uint16_t,uint32_t>::iterator it;
1533 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1535 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1558 int rbAllocated = 0;
1560 std::map <uint16_t, tdtbfqsFlowPerf_t>::iterator itStats;
1582 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1583 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1586 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1608 uldci.
m_rnti = (*it).first;
1610 bool allocated =
false;
1611 NS_LOG_INFO (
this <<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1616 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1618 if (rbMap.at (j) ==
true)
1628 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1630 rbMap.at (j) =
true;
1632 rbgAllocationMap.at (j) = (*it).first;
1634 rbAllocated += rbPerFlow;
1665 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1675 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1682 double sinr = (*itCqi).second.at (i);
1687 if ((*itCqi).second.at (i) < minSinr)
1689 minSinr = (*itCqi).second.at (i);
1694 double s = log2 ( 1 + (
1695 std::pow (10, minSinr / 10 ) /
1696 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1697 cqi =
m_amc->GetCqiFromSpectralEfficiency (s);
1710 rbgAllocationMap.at (i) = 0;
1736 std::map <uint16_t, uint8_t>::iterator itProcId;
1742 harqId = (*itProcId).second;
1748 (*itDci).second.at (harqId) = uldci;
1751 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);
1794 std::map <uint16_t,uint32_t>::iterator it;
1796 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
1807 uint32_t buffer = 0;
1808 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1810 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1815 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1820 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1825 (*it).second = buffer;
1868 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1869 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1870 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
1876 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
1880 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
1884 std::vector <double> newCqi;
1889 newCqi.push_back (sinr);
1898 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
1905 (*itCqi).second.at (i) = sinr;
1906 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
1908 std::map <uint16_t, uint32_t>::iterator itTimers;
1929 rnti = vsp->GetRnti ();
1932 std::map <uint16_t, std::vector <double> >::iterator itCqi;
1937 std::vector <double> newCqi;
1941 newCqi.push_back (sinr);
1942 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
1945 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
1955 (*itCqi).second.at (j) = sinr;
1956 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
1959 std::map <uint16_t, uint32_t>::iterator itTimers;
1972 NS_FATAL_ERROR (
"TdTbfqFfMacScheduler supports only PUSCH and SRS UL-CQIs");
1985 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
1989 if ((*itP10).second == 0)
1992 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
1994 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
1996 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2008 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2012 if ((*itA30).second == 0)
2015 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2017 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2019 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2038 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2042 if ((*itUl).second == 0)
2045 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2046 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2047 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2048 (*itMap).second.clear ();
2050 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2067 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2072 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);
2075 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2077 (*it).second.m_rlcStatusPduSize = 0;
2079 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2081 (*it).second.m_rlcRetransmissionQueueSize = 0;
2083 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2085 uint32_t rlcOverhead;
2100 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2102 (*it).second.m_rlcTransmissionQueueSize = 0;
2106 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2112 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2121 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2124 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2125 if ((*it).second >= size)
2127 (*it).second -= size;
2136 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2144 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
#define NS_LOG_FUNCTION(parameters)
NS_LOG_COMPONENT_DEFINE("TdTbfqFfMacScheduler")
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void DoSchedDlRlcBufferReq(const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters ¶ms)
TdTbfqFfMacScheduler * m_scheduler
void DoCschedUeConfigReq(const struct FfMacCschedSapProvider::CschedUeConfigReqParameters ¶ms)
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)
TdTbfqSchedulerMemberCschedSapProvider()
uint32_t burstCredit
the number of token borrow or given to token bank
FfMacSchedSapProvider * m_schedSapProvider
enum ns3::UlCqi_s::Type_e m_type
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)
virtual ~TdTbfqFfMacScheduler()
Destructor.
Hold a signed integer type.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters ¶ms)
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)
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 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
#define NS_FATAL_ERROR(msg)
fatal error handling
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
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
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.
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)
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
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)
std::map< uint16_t, std::vector< double > > m_ueCqi
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 void SchedUlConfigInd(const struct SchedUlConfigIndParameters ¶ms)=0
static Time Now(void)
Return the "current simulation 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)
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)
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
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)
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.
int TdTbfqType0AllocationRbg[4]
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)
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
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
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.