5#define NS_LOG_APPEND_CONTEXT \
8 std::clog << " [ CellId " << GetCellId() << ", bwpId " << GetBwpId() << "] "; \
10#include "nr-mac-scheduler-cqi-management.h"
15#include <ns3/nr-spectrum-value-helper.h>
20NS_LOG_COMPONENT_DEFINE(
"NrMacSchedulerCQIManagement");
25 [[maybe_unused]]
const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo)
const
27 NS_LOG_FUNCTION(
this);
29 NS_ABORT_MSG(
"SB CQI Type is not supported");
34 uint32_t expirationTime,
35 [[maybe_unused]] uint32_t tbs,
37 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
38 const std::vector<uint8_t>& rbgMask,
40 const Ptr<const SpectrumModel>& model)
const
42 NS_LOG_FUNCTION(
this);
43 NS_ASSERT(!rbgMask.empty());
45 NS_LOG_INFO(
"Computing SB CQI for UE " << ueInfo->m_rnti);
47 ueInfo->m_ulCqi.m_sinr = params.
m_ulCqi.m_sinr;
49 ueInfo->m_ulCqi.m_timer = expirationTime;
51 std::vector<int> rbAssignment(params.
m_ulCqi.m_sinr.size(), 0);
53 for (uint32_t i = 0; i < rbgMask.size(); ++i)
55 if (rbgMask.at(i) == 1)
57 for (uint32_t k = 0; k < numRbPerRbg; ++k)
59 rbAssignment[i * numRbPerRbg + k] = 1;
64 SpectrumValue specVals(model);
65 Values::iterator specIt = specVals.ValuesBegin();
67 std::stringstream out;
69 for (uint32_t ichunk = 0; ichunk < model->GetNumBands(); ichunk++)
71 NS_ASSERT(specIt != specVals.ValuesEnd());
72 if (rbAssignment[ichunk] == 1)
74 *specIt = ueInfo->m_ulCqi.m_sinr.at(ichunk);
75 out << ueInfo->m_ulCqi.m_sinr.at(ichunk) <<
" ";
86 NS_LOG_INFO(
"Values of SINR to pass to the AMC: " << out.str());
89 ueInfo->m_ulCqi.m_wbCqi = GetAmcUl()->CreateCqiFeedbackWbTdma(specVals, ueInfo->m_ulMcs);
90 NS_LOG_DEBUG(
"Calculated MCS for RNTI " << ueInfo->m_rnti <<
" is " << ueInfo->m_ulMcs);
96 NS_LOG_FUNCTION(
this);
103 NS_LOG_FUNCTION(
this);
108NrMacSchedulerCQIManagement::InstallGetStartMcsDlFn(
const std::function<uint8_t()>& fn)
110 NS_LOG_FUNCTION(
this);
111 m_getStartMcsDl = fn;
115NrMacSchedulerCQIManagement::InstallGetStartMcsUlFn(
const std::function<uint8_t()>& fn)
117 NS_LOG_FUNCTION(
this);
118 m_getStartMcsUl = fn;
122NrMacSchedulerCQIManagement::InstallGetNrAmcDlFn(
const std::function<Ptr<const NrAmc>()>& fn)
124 NS_LOG_FUNCTION(
this);
129NrMacSchedulerCQIManagement::InstallGetNrAmcUlFn(
const std::function<Ptr<const NrAmc>()>& fn)
131 NS_LOG_FUNCTION(
this);
137 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
138 uint32_t expirationTime,
139 int8_t maxDlMcs)
const
141 NS_LOG_FUNCTION(
this);
144 ueInfo->m_dlCqi.m_wbCqi = info.
m_wbCqi;
145 ueInfo->m_dlCqi.m_timer = expirationTime;
146 ueInfo->m_dlCqi.m_wbCqi = info.
m_wbCqi;
148 std::min(
static_cast<uint8_t
>(GetAmcDl()->GetMcsFromCqi(ueInfo->m_dlCqi.m_wbCqi)),
149 static_cast<uint8_t
>(maxDlMcs));
150 NS_LOG_INFO(
"Calculated MCS for UE " << ueInfo->m_rnti <<
" is "
151 <<
static_cast<uint32_t
>(ueInfo->m_dlMcs));
153 NS_LOG_INFO(
"Updated WB CQI of UE "
154 << ueInfo->m_rnti <<
" to " <<
static_cast<uint32_t
>(ueInfo->m_dlCqi.m_wbCqi)
155 <<
". It will expire in " << ueInfo->m_dlCqi.m_timer <<
" slots.");
160 NS_ASSERT(info.
m_ri > 0);
161 ueInfo->m_dlRank = info.
m_ri;
170 const std::unordered_map<uint16_t, std::shared_ptr<NrMacSchedulerUeInfo>>& ueMap)
const
172 NS_LOG_FUNCTION(
this);
174 for (
const auto& itUe : ueMap)
176 const std::shared_ptr<NrMacSchedulerUeInfo>& ue = itUe.second;
178 if (ue->m_dlCqi.m_timer == 0)
180 ue->m_dlCqi.m_wbCqi = 1;
182 ue->m_dlMcs = GetStartMcsDl();
186 ue->m_dlCqi.m_timer -= 1;
193 const std::unordered_map<uint16_t, std::shared_ptr<NrMacSchedulerUeInfo>>& ueMap)
const
195 NS_LOG_FUNCTION(
this);
197 for (
const auto& itUe : ueMap)
199 const std::shared_ptr<NrMacSchedulerUeInfo>& ue = itUe.second;
201 if (ue->m_ulCqi.m_timer == 0)
203 ue->m_ulCqi.m_wbCqi = 1;
205 ue->m_ulMcs = GetStartMcsUl();
209 ue->m_ulCqi.m_timer -= 1;
215NrMacSchedulerCQIManagement::GetBwpId()
const
221NrMacSchedulerCQIManagement::GetCellId()
const
223 return m_getCellId();
227NrMacSchedulerCQIManagement::GetStartMcsDl()
const
229 return m_getStartMcsDl();
233NrMacSchedulerCQIManagement::GetStartMcsUl()
const
235 return m_getStartMcsUl();
239NrMacSchedulerCQIManagement::GetAmcDl()
const
245NrMacSchedulerCQIManagement::GetAmcUl()
const
void RefreshUlCqiMaps(const std::unordered_map< uint16_t, std::shared_ptr< NrMacSchedulerUeInfo > > &m_ueMap) const
Refresh the UL CQI for all the UE.
void InstallGetCellIdFn(const std::function< uint16_t()> &fn)
Install a function to retrieve the cell id.
void RefreshDlCqiMaps(const std::unordered_map< uint16_t, std::shared_ptr< NrMacSchedulerUeInfo > > &m_ueMap) const
Refresh the DL CQI for all the UE.
void UlSBCQIReported(uint32_t expirationTime, uint32_t tbs, const NrMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo, const std::vector< uint8_t > &rbgMask, uint32_t numRbPerRbg, const Ptr< const SpectrumModel > &model) const
An UL SB CQI has been reported for the specified UE.
void InstallGetBwpIdFn(const std::function< uint16_t()> &fn)
Install a function to retrieve the bwp id.
void DlSBCQIReported(const DlCqiInfo &info, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo) const
SB CQI reported.
void DlWBCQIReported(const DlCqiInfo &info, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo, uint32_t expirationTime, int8_t maxDlMcs) const
A wideband CQI has been reported for the specified UE.
Ptr< const ComplexMatrixArray > m_optPrecMat
Precoding matrix for each RB.
uint8_t m_wbCqi
Wideband CQI.
uint8_t m_ri
the rank indicator, or simply the rank number
The SchedUlCqiInfoReqParameters struct.
struct UlCqiInfo m_ulCqi
UL CQI.
enum ns3::NrMacSchedulerUeInfo::CqiInfo::CqiType WB
CQI type.