493 // restart from the first |
501 // restart from the first |
494 it = m_rlcBufferReq.begin (); |
502 it = m_rlcBufferReq.begin (); |
495 } |
503 } |
496 continue; |
504 continue; |
497 } |
505 } |
|
506 itTxMode = m_uesTxMode.find ((*it).m_rnti); |
|
507 if (itTxMode == m_uesTxMode.end()) |
|
508 { |
|
509 NS_FATAL_ERROR ("No Transmission Mode info on user " << (*it).m_rnti); |
|
510 } |
|
511 int nLayer = TransmissionModesLayers::TxMode2LayerNum ((*itTxMode).second); |
498 int lcNum = (*itLcRnti).second; |
512 int lcNum = (*itLcRnti).second; |
499 // create new BuildDataListElement_s for this RNTI |
513 // create new BuildDataListElement_s for this RNTI |
500 BuildDataListElement_s newEl; |
514 BuildDataListElement_s newEl; |
501 newEl.m_rnti = (*it).m_rnti; |
515 newEl.m_rnti = (*it).m_rnti; |
502 // create the DlDciListElement_s |
516 // create the DlDciListElement_s |
503 DlDciListElement_s newDci; |
517 DlDciListElement_s newDci; |
504 newDci.m_rnti = (*it).m_rnti; |
518 newDci.m_rnti = (*it).m_rnti; |
505 newDci.m_resAlloc = 0; |
519 newDci.m_resAlloc = 0; |
506 newDci.m_rbBitmap = 0; |
520 newDci.m_rbBitmap = 0; |
507 std::map <uint16_t,uint8_t>::iterator itCqi = m_p10CqiRxed.find (newEl.m_rnti); |
521 std::map <uint16_t,uint8_t>::iterator itCqi = m_p10CqiRxed.find (newEl.m_rnti); |
508 if (itCqi == m_p10CqiRxed.end ()) |
522 for (uint8_t i = 0; i < nLayer; i++) |
509 { |
523 { |
510 newDci.m_mcs.push_back (0); // no info on this user -> lowest MCS |
524 if (itCqi == m_p10CqiRxed.end ()) |
511 } |
525 { |
512 else |
526 newDci.m_mcs.push_back (0); // no info on this user -> lowest MCS |
513 { |
527 } |
514 newDci.m_mcs.push_back ( m_amc->GetMcsFromCqi ((*itCqi).second) ); |
528 else |
|
529 { |
|
530 newDci.m_mcs.push_back ( m_amc->GetMcsFromCqi ((*itCqi).second) ); |
|
531 } |
515 } |
532 } |
516 // group the LCs of this RNTI |
533 // group the LCs of this RNTI |
517 std::vector <struct RlcPduListElement_s> newRlcPduLe; |
534 std::vector <struct RlcPduListElement_s> newRlcPduLe; |
518 // int totRbg = lcNum * rbgPerFlow; |
535 // int totRbg = lcNum * rbgPerFlow; |
519 // totRbg = rbgNum / nTbs; |
536 // totRbg = rbgNum / nTbs; |
520 int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (0), rbgPerTb * rbgSize) / 8); |
537 int tbSize = (m_amc->GetTbSizeFromMcs (newDci.m_mcs.at (0), rbgPerTb * rbgSize) / 8); |
521 NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " LCs " << (uint16_t)(*itLcRnti).second << " bytes " << tbSize << " PRBs " << rbgPerTb * rbgSize << " mcs " << (uint16_t) newDci.m_mcs.at (0)); |
538 NS_LOG_DEBUG (this << "Allocate user " << newEl.m_rnti << " LCs " << (uint16_t)(*itLcRnti).second << " bytes " << tbSize << " PRBs " << rbgAllocated * rbgSize << "..." << (rbgAllocated* rbgSize) + (rbgPerTb * rbgSize) - 1 << " mcs " << (uint16_t) newDci.m_mcs.at (0) << " layers " << nLayer); |
522 uint16_t rlcPduSize = tbSize / lcNum; |
539 uint16_t rlcPduSize = tbSize / lcNum; |
523 for (int i = 0; i < lcNum ; i++) |
540 for (int i = 0; i < lcNum ; i++) |
524 { |
541 { |
525 RlcPduListElement_s newRlcEl; |
542 for (uint8_t j = 0; j < nLayer; j++) |
526 newRlcEl.m_logicalChannelIdentity = (*it).m_logicalChannelIdentity; |
543 { |
527 NS_LOG_DEBUG (this << "LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity << " size " << rlcPduSize << " ID " << (*it).m_rnti); |
544 RlcPduListElement_s newRlcEl; |
528 newRlcEl.m_size = rlcPduSize; |
545 newRlcEl.m_logicalChannelIdentity = (*it).m_logicalChannelIdentity; |
529 UpdateDlRlcBufferInfo ((*it).m_rnti, newRlcEl.m_logicalChannelIdentity, rlcPduSize); |
546 // NS_LOG_DEBUG (this << "LCID " << (uint32_t) newRlcEl.m_logicalChannelIdentity << " size " << rlcPduSize << " ID " << (*it).m_rnti << " layer " << (uint16_t)j); |
530 newRlcPduLe.push_back (newRlcEl); |
547 newRlcEl.m_size = rlcPduSize; |
|
548 UpdateDlRlcBufferInfo ((*it).m_rnti, newRlcEl.m_logicalChannelIdentity, rlcPduSize); |
|
549 newRlcPduLe.push_back (newRlcEl); |
|
550 } |
531 it++; |
551 it++; |
532 if (it == m_rlcBufferReq.end ()) |
552 if (it == m_rlcBufferReq.end ()) |
533 { |
553 { |
534 // restart from the first |
554 // restart from the first |
535 it = m_rlcBufferReq.begin (); |
555 it = m_rlcBufferReq.begin (); |
697 int cqi = 0; |
716 int cqi = 0; |
698 if (itCqi == m_ueCqi.end ()) |
717 if (itCqi == m_ueCqi.end ()) |
699 { |
718 { |
700 // no cqi info about this UE |
719 // no cqi info about this UE |
701 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD |
720 uldci.m_mcs = 0; // MCS 0 -> UL-AMC TBD |
702 //NS_LOG_DEBUG (this << " UE does not have ULCQI " << (*it).first ); |
721 NS_LOG_DEBUG (this << " UE does not have ULCQI " << (*it).first ); |
703 } |
722 } |
704 else |
723 else |
705 { |
724 { |
706 // take the lowest CQI value (worst RB) |
725 // take the lowest CQI value (worst RB) |
707 double minSinr = (*itCqi).second.at (uldci.m_rbStart); |
726 double minSinr = (*itCqi).second.at (uldci.m_rbStart); |
708 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++) |
727 for (uint16_t i = uldci.m_rbStart; i < uldci.m_rbStart + uldci.m_rbLen; i++) |
709 { |
728 { |
710 //NS_LOG_DEBUG (this << " UE " << (*it).first << " has CQI " << (*itCqi).second.at(i)); |
|
711 if ((*itCqi).second.at (i) < minSinr) |
729 if ((*itCqi).second.at (i) < minSinr) |
712 { |
730 { |
713 minSinr = (*itCqi).second.at (i); |
731 minSinr = (*itCqi).second.at (i); |
714 } |
732 } |
715 } |
733 } |
741 { |
759 { |
742 rbgAllocationMap.push_back ((*it).first); |
760 rbgAllocationMap.push_back ((*it).first); |
743 } |
761 } |
744 |
762 |
745 uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8); // MCS 0 -> UL-AMC TBD |
763 uldci.m_tbSize = (m_amc->GetTbSizeFromMcs (uldci.m_mcs, rbPerFlow) / 8); // MCS 0 -> UL-AMC TBD |
746 NS_LOG_DEBUG (this << " UE " << (*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); |
764 NS_LOG_DEBUG (this << " UL - UE " << (*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); |
747 UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize); |
765 UpdateUlRlcBufferInfo (uldci.m_rnti, uldci.m_tbSize); |
748 uldci.m_ndi = 1; |
766 uldci.m_ndi = 1; |
749 uldci.m_cceIndex = 0; |
767 uldci.m_cceIndex = 0; |
750 uldci.m_aggrLevel = 1; |
768 uldci.m_aggrLevel = 1; |
751 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF |
769 uldci.m_ueTxAntennaSelection = 3; // antenna selection OFF |
828 |
846 |
829 void |
847 void |
830 RrFfMacScheduler::DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) |
848 RrFfMacScheduler::DoSchedUlCqiInfoReq (const struct FfMacSchedSapProvider::SchedUlCqiInfoReqParameters& params) |
831 { |
849 { |
832 NS_LOG_FUNCTION (this); |
850 NS_LOG_FUNCTION (this); |
833 // NS_LOG_DEBUG (this << " RX SFNID " << params.m_sfnSf); |
851 NS_LOG_DEBUG (this << " RX SFNID " << params.m_sfnSf); |
834 // correlate info on UL-CQIs with previous scheduling -> calculate m_sfnSf of transmission |
|
835 uint32_t frameNo = (0x3FF & (params.m_sfnSf >> 4)); |
|
836 uint32_t subframeNo = (0xF & params.m_sfnSf); |
|
837 //NS_LOG_DEBUG (this << " sfn " << frameNo << " sbfn " << subframeNo); |
|
838 if (subframeNo <= m_schedTtiDelay) |
|
839 { |
|
840 frameNo--; |
|
841 subframeNo = (10 + subframeNo - m_schedTtiDelay) % 11; |
|
842 } |
|
843 else |
|
844 { |
|
845 subframeNo = (subframeNo - m_schedTtiDelay) % 11; |
|
846 } |
|
847 uint16_t sfnSf = ((0x3FF & frameNo) << 4) | (0xF & subframeNo); |
|
848 // NS_LOG_DEBUG (this << " Actual sfn " << frameNo << " sbfn " << subframeNo << " sfnSf " << sfnSf); |
852 // NS_LOG_DEBUG (this << " Actual sfn " << frameNo << " sbfn " << subframeNo << " sfnSf " << sfnSf); |
849 // retrieve the allocation for this subframe |
853 // retrieve the allocation for this subframe |
850 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap; |
854 std::map <uint16_t, std::vector <uint16_t> >::iterator itMap; |
851 std::map <uint16_t, std::vector <double> >::iterator itCqi; |
855 std::map <uint16_t, std::vector <double> >::iterator itCqi; |
852 itMap = m_allocationMaps.find (sfnSf); |
856 itMap = m_allocationMaps.find (params.m_sfnSf); |
853 if (itMap == m_allocationMaps.end ()) |
857 if (itMap == m_allocationMaps.end ()) |
854 { |
858 { |
855 NS_LOG_DEBUG (this << " Does not find info on allocation"); |
859 NS_LOG_DEBUG (this << " Does not find info on allocation"); |
856 return; |
860 return; |
857 } |
861 } |
858 for (uint32_t i = 0; i < (*itMap).second.size (); i++) |
862 for (uint32_t i = 0; i < (*itMap).second.size (); i++) |
859 { |
863 { |
860 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double |
864 // convert from fixed point notation Sxxxxxxxxxxx.xxx to double |
861 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i)); |
865 double sinr = LteFfConverter::fpS11dot3toDouble (params.m_ulCqi.m_sinr.at (i)); |
862 //NS_LOG_DEBUG (this << " UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr); |
866 // NS_LOG_DEBUG (this << " RB " << i << "UE " << (*itMap).second.at (i) << " SINRfp " << params.m_ulCqi.m_sinr.at (i) << " sinrdb " << sinr); |
863 itCqi = m_ueCqi.find ((*itMap).second.at (i)); |
867 itCqi = m_ueCqi.find ((*itMap).second.at (i)); |
864 if (itCqi == m_ueCqi.end ()) |
868 if (itCqi == m_ueCqi.end ()) |
865 { |
869 { |
866 // create a new entry |
870 // create a new entry |
867 std::vector <double> newCqi; |
871 std::vector <double> newCqi; |