22 #include <ns3/pointer.h>
25 #include <ns3/simulator.h>
26 #include <ns3/lte-amc.h>
27 #include <ns3/pf-ff-mac-scheduler.h>
28 #include <ns3/lte-vendor-specific-parameters.h>
29 #include <ns3/boolean.h>
142 : m_scheduler (scheduler)
217 : m_cschedSapUser (0),
222 m_amc = CreateObject <LteAmc> ();
257 .AddAttribute (
"CqiTimerThreshold",
258 "The number of TTIs a CQI is valid (default 1000 - 1 sec.)",
261 MakeUintegerChecker<uint32_t> ())
262 .AddAttribute (
"HarqEnabled",
263 "Activate/Deactivate the HARQ [by default is active].",
267 .AddAttribute (
"UlGrantMcs",
268 "The MCS of the UL grant, must be [0..15] (default 0)",
271 MakeUintegerChecker<uint8_t> ())
338 dlHarqPrcStatus.resize (8,0);
341 dlHarqProcessesTimer.resize (8,0);
344 dlHarqdci.resize (8);
347 dlHarqRlcPdu.resize (2);
348 dlHarqRlcPdu.at (0).resize (8);
349 dlHarqRlcPdu.at (1).resize (8);
353 ulHarqPrcStatus.resize (8,0);
356 ulHarqdci.resize (8);
371 std::map <uint16_t, pfsFlowPerf_t>::iterator it;
402 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
403 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
438 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it =
m_rlcBufferReq.begin ();
439 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator temp;
442 if ((*it).first.m_rnti == params.
m_rnti)
468 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
476 m_rlcBufferReq.insert (std::pair <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters> (flow, params));
480 (*it).second = params;
505 for (
int i = 0; i < 4; i++)
520 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
524 if (((*it).first.m_rnti == rnti) && (((*it).second.m_rlcTransmissionQueueSize > 0)
525 || ((*it).second.m_rlcRetransmissionQueueSize > 0)
526 || ((*it).second.m_rlcStatusPduSize > 0) ))
530 if ((*it).first.m_rnti > rnti)
553 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
555 uint8_t i = (*it).second;
560 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
561 if ((*itStat).second.at (i) == 0)
592 NS_FATAL_ERROR (
"No Process Id Statusfound for this RNTI " << rnti);
594 uint8_t i = (*it).second;
599 while ( ((*itStat).second.at (i) != 0)&&(i != (*it).second));
600 if ((*itStat).second.at (i) == 0)
603 (*itStat).second.at (i) = 1;
607 NS_FATAL_ERROR (
"No HARQ process available for RNTI " << rnti <<
" check before update with HarqProcessAvailability");
610 return ((*it).second);
619 std::map <uint16_t, DlHarqProcessesTimer_t>::iterator itTimers;
628 NS_LOG_DEBUG (
this <<
" Reset HARQ proc " << i <<
" for RNTI " << (*itTimers).first);
629 std::map <uint16_t, DlHarqProcessesStatus_t>::iterator itStat =
m_dlHarqProcessesStatus.find ((*itTimers).first);
632 NS_FATAL_ERROR (
"No Process Id Status found for this RNTI " << (*itTimers).first);
634 (*itStat).second.at (i) = 0;
635 (*itTimers).second.at (i) = 0;
639 (*itTimers).second.at (i)++;
662 std::map <uint16_t, std::vector <uint16_t> > allocationMap;
663 std::vector <bool> rbgMap;
664 uint16_t rbgAllocatedNum = 0;
665 std::set <uint16_t> rntiAllocated;
669 for (std::vector<bool>::iterator it = rbgMap.begin (); it != rbgMap.end (); it++)
680 std::map <uint16_t, uint8_t>::iterator itProcId;
683 (*itProcId).second = ((*itProcId).second + 1) %
HARQ_PROC_NUM;
688 uint16_t rbAllocatedNum = 0;
689 std::vector <bool> ulRbMap;
692 uint8_t maxContinuousUlBandwidth = 0;
693 uint8_t tmpMinBandwidth = 0;
694 uint16_t ffrRbStartOffset = 0;
695 uint16_t tmpFfrRbStartOffset = 0;
698 for (std::vector<bool>::iterator it = ulRbMap.begin (); it != ulRbMap.end (); it++)
703 if (tmpMinBandwidth > maxContinuousUlBandwidth)
705 maxContinuousUlBandwidth = tmpMinBandwidth;
706 ffrRbStartOffset = tmpFfrRbStartOffset;
712 if (tmpMinBandwidth == 0)
714 tmpFfrRbStartOffset = index;
721 if (tmpMinBandwidth > maxContinuousUlBandwidth)
723 maxContinuousUlBandwidth = tmpMinBandwidth;
724 ffrRbStartOffset = tmpFfrRbStartOffset;
728 uint16_t rbStart = 0;
729 rbStart = ffrRbStartOffset;
730 std::vector <struct RachListElement_s>::iterator itRach;
735 newRar.
m_rnti = (*itRach).m_rnti;
739 newRar.m_grant.m_rnti = newRar.m_rnti;
742 uint16_t tbSizeBits = 0;
744 while ((tbSizeBits < (*itRach).m_estimatedSize) && (rbStart + rbLen < (ffrRbStartOffset + maxContinuousUlBandwidth)))
749 if (tbSizeBits < (*itRach).m_estimatedSize)
754 newRar.m_grant.m_rbStart = rbStart;
755 newRar.m_grant.m_rbLen = rbLen;
756 newRar.m_grant.m_tbSize = tbSizeBits / 8;
757 newRar.m_grant.m_hopping =
false;
758 newRar.m_grant.m_tpc = 0;
759 newRar.m_grant.m_cqiRequest =
false;
760 newRar.m_grant.m_ulDelay =
false;
761 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);
762 for (uint16_t i = rbStart; i < rbStart + rbLen; i++)
771 uldci.
m_rnti = newRar.m_rnti;
790 std::map <uint16_t, uint8_t>::iterator itProcId;
796 harqId = (*itProcId).second;
802 (*itDci).second.at (harqId) = uldci;
805 rbStart = rbStart + rbLen;
818 NS_LOG_INFO (
this <<
" Received DL-HARQ feedback");
834 std::vector <struct DlInfoListElement_s> dlInfoListUntxed;
838 if (itRnti != rntiAllocated.end ())
844 std::vector <bool> retx;
845 NS_LOG_INFO (
this <<
" Processing DLHARQ feedback");
849 retx.push_back (
false);
856 if (retx.at (0) || retx.at (1))
861 NS_LOG_INFO (
this <<
" HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId);
870 if (dci.
m_rv.size () == 1)
872 rv = dci.
m_rv.at (0);
876 rv = (dci.
m_rv.at (0) > dci.
m_rv.at (1) ? dci.
m_rv.at (0) : dci.
m_rv.at (1));
882 NS_LOG_INFO (
"Maximum number of retransmissions reached -> drop process");
888 (*it).second.at (harqId) = 0;
894 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
896 (*itRlcPdu).second.at (k).at (harqId).clear ();
902 std::vector <int> dciRbg;
905 for (
int j = 0; j < 32; j++)
909 dciRbg.push_back (j);
915 for (uint8_t j = 0; j < dciRbg.size (); j++)
917 if (rbgMap.at (dciRbg.at (j)) ==
true)
927 for (uint8_t j = 0; j < dciRbg.size (); j++)
929 rbgMap.at (dciRbg.at (j)) =
true;
930 NS_LOG_INFO (
"RBG " << dciRbg.at (j) <<
" assigned");
934 NS_LOG_INFO (
this <<
" Send retx in the same RBGs");
940 uint8_t rbgId = (dciRbg.at (dciRbg.size () - 1) + 1) % rbgNum;
941 uint8_t startRbg = dciRbg.at (dciRbg.size () - 1);
942 std::vector <bool> rbgMapCopy = rbgMap;
943 while ((j < dciRbg.size ())&&(startRbg != rbgId))
945 if (rbgMapCopy.at (rbgId) ==
false)
947 rbgMapCopy.at (rbgId) =
true;
948 dciRbg.at (j) = rbgId;
951 rbgId = (rbgId + 1) % rbgNum;
953 if (j == dciRbg.size ())
956 uint32_t rbgMask = 0;
957 for (uint16_t k = 0; k < dciRbg.size (); k++)
959 rbgMask = rbgMask + (0x1 << dciRbg.at (k));
964 NS_LOG_INFO (
this <<
" Move retx in RBGs " << dciRbg.size ());
970 NS_LOG_INFO (
this <<
" No resource for this retx -> buffer it");
978 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << rnti);
980 for (uint8_t j = 0; j < nLayers; j++)
984 if (j >= dci.
m_ndi.size ())
987 dci.
m_ndi.push_back (0);
988 dci.
m_rv.push_back (0);
989 dci.
m_mcs.push_back (0);
991 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no txed (MIMO transition)");
995 dci.
m_ndi.at (j) = 0;
997 (*itHarq).second.at (harqId).m_rv.at (j)++;
998 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" RV " << (uint16_t)dci.
m_rv.at (j));
1004 dci.
m_ndi.at (j) = 0;
1005 dci.
m_rv.at (j) = 0;
1006 dci.
m_mcs.at (j) = 0;
1008 NS_LOG_INFO (
this <<
" layer " << (uint16_t)j <<
" no retx");
1011 for (uint16_t k = 0; k < (*itRlcPdu).second.at (0).at (dci.
m_harqProcess).size (); k++)
1013 std::vector <struct RlcPduListElement_s> rlcPduListPerLc;
1014 for (uint8_t j = 0; j < nLayers; j++)
1018 if (j < dci.
m_ndi.size ())
1020 rlcPduListPerLc.push_back ((*itRlcPdu).second.at (j).at (dci.
m_harqProcess).at (k));
1025 if (rlcPduListPerLc.size () > 0)
1032 (*itHarq).second.at (harqId).
m_rv = dci.
m_rv;
1037 NS_FATAL_ERROR (
"Unable to find HARQ timer for RNTI " << (uint16_t)rnti);
1039 (*itHarqTimer).second.at (harqId) = 0;
1041 rntiAllocated.insert (rnti);
1058 for (uint16_t k = 0; k < (*itRlcPdu).second.size (); k++)
1067 if (rbgAllocatedNum == rbgNum)
1079 for (
int i = 0; i < rbgNum; i++)
1081 NS_LOG_INFO (
this <<
" ALLOCATION for RBG " << i <<
" of " << rbgNum);
1082 if (rbgMap.at (i) ==
false)
1084 std::map <uint16_t, pfsFlowPerf_t>::iterator it;
1085 std::map <uint16_t, pfsFlowPerf_t>::iterator itMax =
m_flowStatsDl.end ();
1086 double rcqiMax = 0.0;
1092 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1096 if (itRnti != rntiAllocated.end ())
1098 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ tx" << (uint16_t)(*it).first);
1102 NS_LOG_DEBUG (
this <<
" RNTI discared for HARQ id" << (uint16_t)(*it).first);
1106 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1108 std::map <uint16_t,uint8_t>::iterator itTxMode;
1112 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*it).first);
1115 std::vector <uint8_t> sbCqi;
1118 for (uint8_t k = 0; k < nLayer; k++)
1120 sbCqi.push_back (1);
1125 sbCqi = (*itCqi).second.m_higherLayerSelected.at (i).m_sbCqi;
1127 uint8_t cqi1 = sbCqi.at (0);
1129 if (sbCqi.size () > 1)
1131 cqi2 = sbCqi.at (1);
1134 if ((cqi1 > 0)||(cqi2 > 0))
1139 double achievableRate = 0.0;
1141 for (uint8_t k = 0; k < nLayer; k++)
1143 if (sbCqi.size () > k)
1145 mcs =
m_amc->GetMcsFromCqi (sbCqi.at (k));
1152 achievableRate += ((
m_amc->GetTbSizeFromMcs (mcs, rbgSize) / 8) / 0.001);
1155 double rcqi = achievableRate / (*it).second.lastAveragedThroughput;
1156 NS_LOG_INFO (
this <<
" RNTI " << (*it).first <<
" MCS " << (uint32_t)mcs <<
" achievableRate " << achievableRate <<
" avgThr " << (*it).second.lastAveragedThroughput <<
" RCQI " << rcqi);
1174 rbgMap.at (i) =
true;
1175 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
1176 itMap = allocationMap.find ((*itMax).first);
1177 if (itMap == allocationMap.end ())
1180 std::vector <uint16_t> tempMap;
1181 tempMap.push_back (i);
1182 allocationMap.insert (std::pair <uint16_t, std::vector <uint16_t> > ((*itMax).first, tempMap));
1186 (*itMap).second.push_back (i);
1188 NS_LOG_INFO (
this <<
" UE assigned " << (*itMax).first);
1194 std::map <uint16_t, pfsFlowPerf_t>::iterator itStats;
1197 (*itStats).second.lastTtiBytesTrasmitted = 0;
1202 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap = allocationMap.begin ();
1203 while (itMap != allocationMap.end ())
1207 newEl.
m_rnti = (*itMap).first;
1210 newDci.
m_rnti = (*itMap).first;
1218 lcActives = (uint16_t)65535;
1220 uint16_t RgbPerRnti = (*itMap).second.size ();
1221 std::map <uint16_t,SbMeasResult_s>::iterator itCqi;
1223 std::map <uint16_t,uint8_t>::iterator itTxMode;
1227 NS_FATAL_ERROR (
"No Transmission Mode info on user " << (*itMap).first);
1230 std::vector <uint8_t> worstCqi (2, 15);
1233 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1235 if ((*itCqi).second.m_higherLayerSelected.size () > (*itMap).second.at (k))
1237 NS_LOG_INFO (
this <<
" RBG " << (*itMap).second.at (k) <<
" CQI " << (uint16_t)((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (0)) );
1238 for (uint8_t j = 0; j < nLayer; j++)
1240 if ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.size () > j)
1242 if (((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j)) < worstCqi.at (j))
1244 worstCqi.at (j) = ((*itCqi).second.m_higherLayerSelected.at ((*itMap).second.at (k)).m_sbCqi.at (j));
1250 worstCqi.at (j) = 1;
1256 for (uint8_t j = 0; j < nLayer; j++)
1258 worstCqi.at (j) = 1;
1265 for (uint8_t j = 0; j < nLayer; j++)
1267 worstCqi.at (j) = 1;
1270 for (uint8_t j = 0; j < nLayer; j++)
1272 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" CQI selected " << (uint16_t)worstCqi.at (j));
1274 uint32_t bytesTxed = 0;
1275 for (uint8_t j = 0; j < nLayer; j++)
1277 newDci.
m_mcs.push_back (
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1278 int tbSize = (
m_amc->GetTbSizeFromMcs (newDci.
m_mcs.at (j), RgbPerRnti * rbgSize) / 8);
1280 NS_LOG_INFO (
this <<
" Layer " << (uint16_t)j <<
" MCS selected" <<
m_amc->GetMcsFromCqi (worstCqi.at (j)));
1281 bytesTxed += tbSize;
1286 uint32_t rbgMask = 0;
1287 for (uint16_t k = 0; k < (*itMap).second.size (); k++)
1289 rbgMask = rbgMask + (0x1 << (*itMap).second.at (k));
1290 NS_LOG_INFO (
this <<
" Allocated RBG " << (*itMap).second.at (k));
1295 std::map <LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator itBufReq;
1298 if (((*itBufReq).first.m_rnti == (*itMap).first)
1299 && (((*itBufReq).second.m_rlcTransmissionQueueSize > 0)
1300 || ((*itBufReq).second.m_rlcRetransmissionQueueSize > 0)
1301 || ((*itBufReq).second.m_rlcStatusPduSize > 0) ))
1303 std::vector <struct RlcPduListElement_s> newRlcPduLe;
1304 for (uint8_t j = 0; j < nLayer; j++)
1310 newRlcPduLe.push_back (newRlcEl);
1318 NS_FATAL_ERROR (
"Unable to find RlcPdcList in HARQ buffer for RNTI " << (*itMap).first);
1320 (*itRlcPdu).second.at (j).at (newDci.
m_harqProcess).push_back (newRlcEl);
1325 if ((*itBufReq).first.m_rnti > (*itMap).first)
1330 for (uint8_t j = 0; j < nLayer; j++)
1332 newDci.
m_ndi.push_back (1);
1333 newDci.
m_rv.push_back (0);
1338 newEl.
m_dci = newDci;
1362 std::map <uint16_t, pfsFlowPerf_t>::iterator it;
1366 (*it).second.lastTtiBytesTrasmitted = bytesTxed;
1367 NS_LOG_INFO (
this <<
" UE total bytes txed " << (*it).second.lastTtiBytesTrasmitted);
1385 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted;
1387 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 /
m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTrasmitted / 0.001));
1388 NS_LOG_INFO (
this <<
" UE total bytes " << (*itStats).second.totalBytesTransmitted);
1389 NS_LOG_INFO (
this <<
" UE average throughput " << (*itStats).second.lastAveragedThroughput);
1390 (*itStats).second.lastTtiBytesTrasmitted = 0;
1415 for (
unsigned int i = 0; i < params.
m_cqiList.size (); i++)
1420 std::map <uint16_t,uint8_t>::iterator it;
1421 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1426 m_p10CqiRxed.insert ( std::pair<uint16_t, uint8_t > (rnti, params.
m_cqiList.at (i).m_wbCqi.at (0)) );
1433 (*it).second = params.
m_cqiList.at (i).m_wbCqi.at (0);
1435 std::map <uint16_t,uint32_t>::iterator itTimers;
1443 std::map <uint16_t,SbMeasResult_s>::iterator it;
1444 uint16_t rnti = params.
m_cqiList.at (i).m_rnti;
1449 m_a30CqiRxed.insert ( std::pair<uint16_t, SbMeasResult_s > (rnti, params.
m_cqiList.at (i).m_sbMeasResult) );
1455 (*it).second = params.
m_cqiList.at (i).m_sbMeasResult;
1456 std::map <uint16_t,uint32_t>::iterator itTimers;
1474 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find (rnti);
1488 double sinr = (*itCqi).second.at (i);
1495 double estimatedSinr = (sinrNum > 0) ? (sinrSum / sinrNum) : DBL_MAX;
1497 (*itCqi).second.at (rb) = estimatedSinr;
1498 return (estimatedSinr);
1512 std::vector <bool> rbMap;
1513 uint16_t rbAllocatedNum = 0;
1514 std::set <uint16_t> rntiAllocated;
1515 std::vector <uint16_t> rbgAllocationMap;
1525 for (std::vector<bool>::iterator it = rbMap.begin (); it != rbMap.end (); it++)
1539 if (rbgAllocationMap.at (i) != 0)
1541 rbMap.at (i) =
true;
1551 for (uint16_t i = 0; i < params.
m_ulInfoList.size (); i++)
1560 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1563 NS_LOG_INFO (
this <<
" UL-HARQ retx RNTI " << rnti <<
" harqId " << (uint16_t)harqId <<
" i " << i <<
" size " << params.
m_ulInfoList.size ());
1567 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1574 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << rnti);
1576 if ((*itStat).second.at (harqId) >= 3)
1578 NS_LOG_INFO (
"Max number of retransmissions reached (UL)-> drop process");
1584 if (rbMap.at (j) ==
true)
1595 rbMap.at (j) =
true;
1596 rbgAllocationMap.at (j) = dci.
m_rnti;
1604 NS_LOG_INFO (
"Cannot allocate retx due to RACH allocations for UE " << rnti);
1609 (*itStat).second.at ((*itProcId).second) = (*itStat).second.at (harqId) + 1;
1610 (*itStat).second.at (harqId) = 0;
1611 (*itHarq).second.at ((*itProcId).second) = dci;
1613 rntiAllocated.insert (dci.
m_rnti);
1622 std::map <uint16_t,uint32_t>::iterator it;
1627 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1629 if (((*it).second > 0)&&(itRnti == rntiAllocated.end ()))
1648 uint16_t tempRbPerFlow = (ffrUlBandwidth) / (nflows + rntiAllocated.size ());
1649 uint16_t rbPerFlow = (minContinuousUlBandwidth < tempRbPerFlow) ? minContinuousUlBandwidth : tempRbPerFlow;
1656 int rbAllocated = 0;
1658 std::map <uint16_t, pfsFlowPerf_t>::iterator itStats;
1680 std::set <uint16_t>::iterator itRnti = rntiAllocated.find ((*it).first);
1681 if ((itRnti != rntiAllocated.end ())||((*it).second == 0))
1684 NS_LOG_DEBUG (
this <<
" UE already allocated in HARQ -> discared, RNTI " << (*it).first);
1707 uldci.
m_rnti = (*it).first;
1709 bool allocated =
false;
1715 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1717 if (rbMap.at (j) ==
true)
1730 NS_LOG_INFO (
this <<
"RNTI: "<< (*it).first<<
" RB Allocated " << rbAllocated <<
" rbPerFlow " << rbPerFlow <<
" flows " << nflows);
1733 for (uint16_t j = rbAllocated; j < rbAllocated + rbPerFlow; j++)
1735 rbMap.at (j) =
true;
1737 rbgAllocationMap.at (j) = (*it).first;
1739 rbAllocated += rbPerFlow;
1771 std::map <uint16_t, std::vector <double> >::iterator itCqi =
m_ueCqi.find ((*it).first);
1781 double minSinr = (*itCqi).second.at (uldci.
m_rbStart);
1788 double sinr = (*itCqi).second.at (i);
1793 if ((*itCqi).second.at (i) < minSinr)
1795 minSinr = (*itCqi).second.at (i);
1800 double s = log2 ( 1 + (
1801 std::pow (10, minSinr / 10 ) /
1802 ( (-std::log (5.0 * 0.00005 )) / 1.5) ));
1803 cqi =
m_amc->GetCqiFromSpectralEfficiency (s);
1816 rbgAllocationMap.at (i) = 0;
1842 std::map <uint16_t, uint8_t>::iterator itProcId;
1848 harqId = (*itProcId).second;
1854 (*itDci).second.at (harqId) = uldci;
1859 NS_LOG_ERROR (
"No info find in HARQ buffer for UE (might change eNB) " << uldci.
m_rnti);
1861 (*itStat).second.at (harqId) = 0;
1864 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);
1870 (*itStats).second.lastTtiBytesTrasmitted = uldci.
m_tbSize;
1874 NS_LOG_DEBUG (
this <<
" No Stats for this allocated UE");
1898 (*itStats).second.totalBytesTransmitted += (*itStats).second.lastTtiBytesTrasmitted;
1900 (*itStats).second.lastAveragedThroughput = ((1.0 - (1.0 /
m_timeWindow)) * (*itStats).second.lastAveragedThroughput) + ((1.0 /
m_timeWindow) * (double)((*itStats).second.lastTtiBytesTrasmitted / 0.001));
1901 NS_LOG_INFO (
this <<
" UE total bytes " << (*itStats).second.totalBytesTransmitted);
1902 NS_LOG_INFO (
this <<
" UE average throughput " << (*itStats).second.lastAveragedThroughput);
1903 (*itStats).second.lastTtiBytesTrasmitted = 0;
1930 std::map <uint16_t,uint32_t>::iterator it;
1932 for (
unsigned int i = 0; i < params.
m_macCeList.size (); i++)
1943 uint32_t buffer = 0;
1944 for (uint8_t lcg = 0; lcg < 4; ++lcg)
1946 uint8_t bsrId = params.
m_macCeList.at (i).m_macCeValue.m_bufferStatus.at (lcg);
1951 NS_LOG_LOGIC (
this <<
"RNTI=" << rnti <<
" buffer=" << buffer);
1956 m_ceBsrRxed.insert ( std::pair<uint16_t, uint32_t > (rnti, buffer));
1961 (*it).second = buffer;
2006 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap;
2007 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2008 NS_LOG_DEBUG (
this <<
" Collect PUSCH CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2014 for (uint32_t i = 0; i < (*itMap).second.size (); i++)
2018 itCqi =
m_ueCqi.find ((*itMap).second.at (i));
2022 std::vector <double> newCqi;
2027 newCqi.push_back (sinr);
2036 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > ((*itMap).second.at (i), newCqi));
2043 (*itCqi).second.at (i) = sinr;
2044 NS_LOG_DEBUG (
this <<
" RNTI " << (*itMap).second.at (i) <<
" RB " << i <<
" SINR " << sinr);
2046 std::map <uint16_t, uint32_t>::iterator itTimers;
2059 NS_LOG_DEBUG (
this <<
" Collect SRS CQIs of Frame no. " << (params.
m_sfnSf >> 4) <<
" subframe no. " << (0xF & params.
m_sfnSf));
2068 rnti = vsp->GetRnti ();
2071 std::map <uint16_t, std::vector <double> >::iterator itCqi;
2076 std::vector <double> newCqi;
2080 newCqi.push_back (sinr);
2081 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" new SRS-CQI for RB " << j <<
" value " << sinr);
2084 m_ueCqi.insert (std::pair <uint16_t, std::vector <double> > (rnti, newCqi));
2094 (*itCqi).second.at (j) = sinr;
2095 NS_LOG_INFO (
this <<
" RNTI " << rnti <<
" update SRS-CQI for RB " << j <<
" value " << sinr);
2098 std::map <uint16_t, uint32_t>::iterator itTimers;
2111 NS_FATAL_ERROR (
"PfFfMacScheduler supports only PUSCH and SRS UL-CQIs");
2124 std::map <uint16_t,uint32_t>::iterator itP10 =
m_p10CqiTimers.begin ();
2128 if ((*itP10).second == 0)
2131 std::map <uint16_t,uint8_t>::iterator itMap =
m_p10CqiRxed.find ((*itP10).first);
2133 NS_LOG_INFO (
this <<
" P10-CQI expired for user " << (*itP10).first);
2135 std::map <uint16_t,uint32_t>::iterator temp = itP10;
2147 std::map <uint16_t,uint32_t>::iterator itA30 =
m_a30CqiTimers.begin ();
2151 if ((*itA30).second == 0)
2154 std::map <uint16_t,SbMeasResult_s>::iterator itMap =
m_a30CqiRxed.find ((*itA30).first);
2156 NS_LOG_INFO (
this <<
" A30-CQI expired for user " << (*itA30).first);
2158 std::map <uint16_t,uint32_t>::iterator temp = itA30;
2177 std::map <uint16_t,uint32_t>::iterator itUl =
m_ueCqiTimers.begin ();
2181 if ((*itUl).second == 0)
2184 std::map <uint16_t, std::vector <double> >::iterator itMap =
m_ueCqi.find ((*itUl).first);
2185 NS_ASSERT_MSG (itMap !=
m_ueCqi.end (),
" Does not find CQI report for user " << (*itUl).first);
2186 NS_LOG_INFO (
this <<
" UL-CQI exired for user " << (*itUl).first);
2187 (*itMap).second.clear ();
2189 std::map <uint16_t,uint32_t>::iterator temp = itUl;
2206 std::map<LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters>::iterator it;
2211 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);
2214 if (((*it).second.m_rlcStatusPduSize > 0) && (size >= (*it).second.m_rlcStatusPduSize))
2216 (*it).second.m_rlcStatusPduSize = 0;
2218 else if (((*it).second.m_rlcRetransmissionQueueSize > 0) && (size >= (*it).second.m_rlcRetransmissionQueueSize))
2220 (*it).second.m_rlcRetransmissionQueueSize = 0;
2222 else if ((*it).second.m_rlcTransmissionQueueSize > 0)
2224 uint32_t rlcOverhead;
2239 if ((*it).second.m_rlcTransmissionQueueSize <= size - rlcOverhead)
2241 (*it).second.m_rlcTransmissionQueueSize = 0;
2245 (*it).second.m_rlcTransmissionQueueSize -= size - rlcOverhead;
2251 NS_LOG_ERROR (
this <<
" Does not find DL RLC Buffer Report of UE " << rnti);
2260 std::map <uint16_t,uint32_t>::iterator it =
m_ceBsrRxed.find (rnti);
2263 NS_LOG_INFO (
this <<
" UE " << rnti <<
" size " << size <<
" BSR " << (*it).second);
2264 if ((*it).second >= size)
2266 (*it).second -= size;
2275 NS_LOG_ERROR (
this <<
" Does not find BSR report info of UE " << rnti);
2283 NS_LOG_FUNCTION (
this <<
" RNTI " << rnti <<
" txMode " << (uint16_t)txMode);
friend class PfSchedulerMemberCschedSapProvider
std::vector< struct UlInfoListElement_s > m_ulInfoList
See section 4.3.1 dlDciListElement.
void RefreshDlCqiMaps(void)
void DoSchedUlCqiInfoReq(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms)
PfFfMacScheduler * m_scheduler
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 "...
void DoSchedUlTriggerReq(const struct FfMacSchedSapProvider::SchedUlTriggerReqParameters ¶ms)
virtual void SetLteFfrSapProvider(LteFfrSapProvider *s)
Set the Provider part of the LteFfrSap that this Scheduler will interact with.
AttributeValue implementation for Boolean.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual void ReportUlCqiInfo(const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms)=0
ReportUlCqiInfo.
std::map< LteFlowId_t, FfMacSchedSapProvider::SchedDlRlcBufferReqParameters > m_rlcBufferReq
void DoSchedUlMacCtrlInfoReq(const struct FfMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters ¶ms)
void DoSchedDlCqiInfoReq(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters ¶ms)
Parameters of the CSCHED_UE_CONFIG_CNF primitive.
Parameters of the CSCHED_UE_RELEASE_REQ primitive.
uint32_t m_cqiTimersThreshold
virtual bool IsDlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in DL.
virtual bool IsUlRbgAvailableForUe(int i, uint16_t rnti)=0
Check if UE can be served on i-th RB in UL.
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...
std::map< uint16_t, pfsFlowPerf_t > m_flowStatsUl
Implements the SCHED SAP and CSCHED SAP for a Proportional Fair scheduler.
std::vector< UlDciListElement_s > UlHarqProcessesDciBuffer_t
std::map< uint16_t, std::vector< double > > m_ueCqi
virtual void SchedDlRachInfoReq(const struct SchedDlRachInfoReqParameters ¶ms)
std::vector< struct LogicalChannelConfigListElement_s > m_logicalChannelConfigList
std::vector< uint16_t > m_sinr
PfSchedulerMemberCschedSapProvider()
std::vector< uint8_t > DlHarqProcessesTimer_t
virtual FfMacSchedSapProvider * GetFfMacSchedSapProvider()
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
int LcActivePerFlow(uint16_t rnti)
uint8_t HarqProcessAvailability(uint16_t rnti)
Return the availability of free process for the RNTI specified.
virtual void SchedDlCqiInfoReq(const struct SchedDlCqiInfoReqParameters ¶ms)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)
CSCHED_CELL_CONFIG_REQ.
std::vector< uint8_t > m_mcs
See section 4.3.2 ulDciListElement.
std::map< uint16_t, UlHarqProcessesStatus_t > m_ulHarqProcessesStatus
std::map< uint16_t, pfsFlowPerf_t > m_flowStatsDl
std::vector< struct UlDciListElement_s > m_dciList
virtual ~PfFfMacScheduler()
Destructor.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
See section 4.3.10 buildRARListElement.
Parameters of the CSCHED_UE_CONFIG_UPDATE_IND primitive.
virtual void SetFfMacSchedSapUser(FfMacSchedSapUser *s)
set the user part of the FfMacSchedSap that this Scheduler will interact with.
virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters ¶ms)
Parameters of the CSCHED_LC_RELEASE_REQ primitive.
virtual uint8_t GetTpc(uint16_t rnti)=0
GetTpc.
std::vector< std::vector< struct RlcPduListElement_s > > m_rlcPduList
uint8_t m_transmissionMode
Parameters of the SCHED_DL_TRIGGER_REQ primitive.
double EstimateUlSinr(uint16_t rnti, uint16_t rb)
uint8_t m_logicalChannelIdentity
void UpdateDlRlcBufferInfo(uint16_t rnti, uint8_t lcid, uint16_t size)
void TransmissionModeConfigurationUpdate(uint16_t rnti, uint8_t txMode)
PfFfMacScheduler()
Constructor.
unsigned int lastTtiBytesTrasmitted
virtual FfMacCschedSapProvider * GetFfMacCschedSapProvider()
LteFfrSapUser * m_ffrSapUser
std::vector< RlcPduList_t > DlHarqRlcPduListBuffer_t
Parameters of the SCHED_DL_MAC_BUFFER_REQ primitive.
std::map< uint16_t, uint32_t > m_a30CqiTimers
Parameters of the SCHED_DL_PAGING_BUFFER_REQ primitive.
static const int PfType0AllocationRbg[4]
virtual void CschedUeConfigUpdateInd(const struct CschedUeConfigUpdateIndParameters ¶ms)=0
std::vector< struct VendorSpecificListElement_s > m_vendorSpecificList
void DoSchedUlNoiseInterferenceReq(const struct FfMacSchedSapProvider::SchedUlNoiseInterferenceReqParameters ¶ms)
void DoSchedDlMacBufferReq(const struct FfMacSchedSapProvider::SchedDlMacBufferReqParameters ¶ms)
std::vector< struct RachListElement_s > m_rachList
Service Access Point (SAP) offered by the Frequency Reuse algorithm instance to the MAC Scheduler ins...
FfMacSchedSapProvider * m_schedSapProvider
Parameters of the SCHED_UL_TRIGGER_REQ primitive.
Hold an unsigned integer type.
virtual void SchedUlMacCtrlInfoReq(const struct SchedUlMacCtrlInfoReqParameters ¶ms)
std::map< uint16_t, DlHarqProcessesTimer_t > m_dlHarqProcessesTimer
static uint8_t TxMode2LayerNum(uint8_t txMode)
std::vector< uint8_t > m_ndi
int GetRbgSize(int dlbandwidth)
std::map< uint16_t, uint32_t > m_ueCqiTimers
std::vector< DlInfoListElement_s > m_dlInfoListBuffered
virtual void CschedUeConfigCnf(const struct CschedUeConfigCnfParameters ¶ms)=0
std::vector< uint8_t > m_logicalChannelIdentity
FfMacSchedSapUser * m_schedSapUser
#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
virtual void DoDispose(void)
Destructor implementation.
std::map< uint16_t, SbMeasResult_s > m_a30CqiRxed
bool m_harqOn
m_harqOn when false inhibit te HARQ mechanisms (by default active)
std::map< uint16_t, DlHarqRlcPduListBuffer_t > m_dlHarqProcessesRlcPduListBuffer
std::vector< struct DlInfoListElement_s > m_dlInfoList
virtual void SchedDlPagingBufferReq(const struct SchedDlPagingBufferReqParameters ¶ms)
virtual void ReportDlCqiInfo(const struct FfMacSchedSapProvider::SchedDlCqiInfoReqParameters ¶ms)=0
ReportDlCqiInfo.
std::map< uint16_t, DlHarqProcessesDciBuffer_t > m_dlHarqProcessesDciBuffer
std::map< uint16_t, uint8_t > m_p10CqiRxed
void DoCschedLcConfigReq(const struct FfMacCschedSapProvider::CschedLcConfigReqParameters ¶ms)
virtual void SchedDlConfigInd(const struct SchedDlConfigIndParameters ¶ms)=0
virtual void CschedLcReleaseReq(const struct CschedLcReleaseReqParameters ¶ms)
Parameters of the API primitives.
int8_t m_pdcchPowerOffset
void DoCschedUeReleaseReq(const struct FfMacCschedSapProvider::CschedUeReleaseReqParameters ¶ms)
std::vector< uint16_t > m_tbsSize
See section 4.3.9 rlcPDU_ListElement.
FfMacCschedSapProvider::CschedCellConfigReqParameters m_cschedCellConfig
FfMacCschedSapUser * m_cschedSapUser
std::map< uint16_t, uint8_t > m_dlHarqCurrentProcessId
Ptr< const AttributeChecker > MakeBooleanChecker(void)
virtual LteFfrSapUser * GetLteFfrSapUser()
friend class PfSchedulerMemberSchedSapProvider
std::vector< DlDciListElement_s > DlHarqProcessesDciBuffer_t
virtual void SchedUlNoiseInterferenceReq(const struct SchedUlNoiseInterferenceReqParameters ¶ms)
Parameters of the CSCHED_LC_CONFIG_REQ primitive.
void DoCschedCellConfigReq(const struct FfMacCschedSapProvider::CschedCellConfigReqParameters ¶ms)
std::vector< uint8_t > m_rv
static TypeId GetTypeId(void)
void DoSchedUlSrInfoReq(const struct FfMacSchedSapProvider::SchedUlSrInfoReqParameters ¶ms)
std::map< uint16_t, std::vector< uint16_t > > m_allocationMaps
void UpdateUlRlcBufferInfo(uint16_t rnti, uint16_t size)
std::map< uint16_t, uint32_t > m_p10CqiTimers
std::map< uint16_t, uint32_t > m_ceBsrRxed
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.
void DoSchedDlRachInfoReq(const struct FfMacSchedSapProvider::SchedDlRachInfoReqParameters ¶ms)
UlCqiFilter_t m_ulCqiFilter
std::map< uint16_t, uint8_t > m_ulHarqCurrentProcessId
PfFfMacScheduler * m_scheduler
This abstract base class identifies the interface by means of which the helper object can plug on the...
void DoSchedDlTriggerReq(const struct FfMacSchedSapProvider::SchedDlTriggerReqParameters ¶ms)
FfMacCschedSapProvider * m_cschedSapProvider
#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 SchedDlMacBufferReq(const struct SchedDlMacBufferReqParameters ¶ms)
uint8_t m_nrOfPdcchOfdmSymbols
Parameters of the SCHED_DL_CQI_INFO_REQ primitive.
std::vector< struct MacCeListElement_s > m_macCeList
std::vector< uint16_t > m_rachAllocationMap
Parameters of the API primitives.
std::vector< struct RachListElement_s > m_rachList
static double fpS11dot3toDouble(uint16_t val)
double lastAveragedThroughput
void RefreshHarqProcesses()
Refresh HARQ processes according to the timers.
std::map< uint16_t, DlHarqProcessesStatus_t > m_dlHarqProcessesStatus
std::vector< uint8_t > UlHarqProcessesStatus_t
unsigned long totalBytesTransmitted
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...
void RefreshUlCqiMaps(void)
Parameters of the API primitives.
LteFfrSapProvider * m_ffrSapProvider
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 SchedUlCqiInfoReq(const struct SchedUlCqiInfoReqParameters ¶ms)
std::map< uint16_t, UlHarqProcessesDciBuffer_t > m_ulHarqProcessesDciBuffer
virtual void SchedDlRlcBufferReq(const struct SchedDlRlcBufferReqParameters ¶ms)
virtual void CschedUeConfigReq(const struct CschedUeConfigReqParameters ¶ms)
Parameters of the SCHED_UL_SR_INFO_REQ primitive.
virtual void SchedUlSrInfoReq(const struct SchedUlSrInfoReqParameters ¶ms)
void DoCschedLcReleaseReq(const struct FfMacCschedSapProvider::CschedLcReleaseReqParameters ¶ms)
virtual void CschedUeReleaseReq(const struct CschedUeReleaseReqParameters ¶ms)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
Parameters of the SCHED_DL_RACH_INFO_REQ primitive.
virtual void CschedLcConfigReq(const struct CschedLcConfigReqParameters ¶ms)
Parameters of the SCHED_UL_CONFIG_IND primitive.
virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters ¶ms)
virtual void SetFfMacCschedSapUser(FfMacCschedSapUser *s)
set the user part of the FfMacCschedSap that this Scheduler will interact with.
Parameters of the CSCHED_UE_CONFIG_REQ primitive.
struct DlDciListElement_s m_dci
std::vector< struct BuildRarListElement_s > m_buildRarList
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void DoSchedDlPagingBufferReq(const struct FfMacSchedSapProvider::SchedDlPagingBufferReqParameters ¶ms)
a unique identifier for an interface.
uint8_t UpdateHarqProcessId(uint16_t rnti)
Update and return a new process Id for the RNTI specified.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
std::map< uint16_t, uint8_t > m_uesTxMode
void DoCschedUeConfigReq(const struct FfMacCschedSapProvider::CschedUeConfigReqParameters ¶ms)
void DoSchedDlRlcBufferReq(const struct FfMacSchedSapProvider::SchedDlRlcBufferReqParameters ¶ms)
std::vector< struct BuildDataListElement_s > m_buildDataList
uint8_t m_ueTxAntennaSelection
See section 4.3.8 builDataListElement.
PfSchedulerMemberSchedSapProvider()