5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-scheduler-ue-info-qos.h
1// Copyright (c) 2022 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#pragma once
6
7#include "nr-mac-scheduler-ue-info-rr.h"
8
9namespace ns3
10{
23{
24 public:
31 NrMacSchedulerUeInfoQos(float alpha, uint16_t rnti, BeamId beamId, const GetRbPerRbgFn& fn)
32 : NrMacSchedulerUeInfo(rnti, beamId, fn),
33 m_alpha(alpha)
34 {
35 }
36
53
70
79
88
98 void UpdateDlQosMetric(const NrMacSchedulerNs3::FTResources& totAssigned, double timeWindow);
99
109 void UpdateUlQosMetric(const NrMacSchedulerNs3::FTResources& totAssigned, double timeWindow);
110
115 void CalculatePotentialTPutDl(const NrMacSchedulerNs3::FTResources& assignableInIteration);
116
121 void CalculatePotentialTPutUl(const NrMacSchedulerNs3::FTResources& assignableInIteration);
122
135 {
136 double lQoSMetric = CalculateDlWeight(lue);
137 double rQoSMetric = CalculateDlWeight(rue);
138
139 NS_ASSERT_MSG(lQoSMetric > 0, "Weight must be greater than zero");
140 NS_ASSERT_MSG(rQoSMetric > 0, "Weight must be greater than zero");
141
142 return (lQoSMetric > rQoSMetric);
143 }
144
157 {
158 double weight = 0;
159 auto uePtr = dynamic_cast<NrMacSchedulerUeInfoQos*>(ue.first.get());
160
161 for (const auto& ueLcg : ue.first->m_dlLCG)
162 {
163 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
164
165 for (const auto lcId : ueActiveLCs)
166 {
167 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
168 double delayBudgetFactor = 1.0;
169
170 if (LCPtr->m_resourceType == nr::LogicalChannelConfigListElement_s::QBT_DGBR)
171 {
172 delayBudgetFactor =
173 CalculateDelayBudgetFactor(LCPtr->m_delayBudget.GetMilliSeconds(),
174 LCPtr->m_rlcTransmissionQueueHolDelay);
175 }
176 weight += (100 - LCPtr->m_priority) *
177 std::pow(uePtr->m_potentialTputDl, uePtr->m_alpha) /
178 std::max(1E-9, uePtr->m_avgTputDl) * delayBudgetFactor;
179 NS_ASSERT_MSG(weight > 0, "Weight must be greater than zero");
180 }
181 }
182 return weight;
183 }
184
198 static double CalculateDelayBudgetFactor(uint64_t pdb, uint16_t hol)
199 {
200 double denominator = hol >= pdb ? 0.1 : static_cast<double>(pdb) - static_cast<double>(hol);
201 double delayBudgetFactor = static_cast<double>(pdb) / denominator;
202
203 return delayBudgetFactor;
204 }
205
224 {
225 auto luePtr = dynamic_cast<NrMacSchedulerUeInfoQos*>(lue.first.get());
226 auto ruePtr = dynamic_cast<NrMacSchedulerUeInfoQos*>(rue.first.get());
227
228 double leftP = CalculateUlMinPriority(lue);
229 double rightP = CalculateUlMinPriority(rue);
230 NS_ABORT_IF(leftP == 0);
231 NS_ABORT_IF(rightP == 0);
232
233 double lQoSMetric = (100 - leftP) * std::pow(luePtr->m_potentialTputUl, luePtr->m_alpha) /
234 std::max(1E-9, luePtr->m_avgTputUl);
235 double rQoSMetric = (100 - rightP) * std::pow(ruePtr->m_potentialTputUl, ruePtr->m_alpha) /
236 std::max(1E-9, ruePtr->m_avgTputUl);
237
238 return (lQoSMetric > rQoSMetric);
239 }
240
253 {
254 uint8_t ueMinPriority = 100;
255
256 for (const auto& ueLcg : ue.first->m_dlLCG)
257 {
258 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
259
260 for (const auto lcId : ueActiveLCs)
261 {
262 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
263
264 if (ueMinPriority > LCPtr->m_priority)
265 {
266 ueMinPriority = LCPtr->m_priority;
267 }
268
269 ue.first->PrintLcInfo(ue.first->m_rnti,
270 ueLcg.first,
271 lcId,
272 LCPtr->m_qci,
273 LCPtr->m_priority,
274 ueMinPriority);
275 }
276 }
277 return ueMinPriority;
278 }
279
292 {
293 uint8_t ueMinPriority = 100;
294
295 for (const auto& ueLcg : ue.first->m_ulLCG)
296 {
297 std::vector<uint8_t> ueActiveLCs = ueLcg.second->GetActiveLCIds();
298
299 for (const auto lcId : ueActiveLCs)
300 {
301 std::unique_ptr<NrMacSchedulerLC>& LCPtr = ueLcg.second->GetLC(lcId);
302
303 if (ueMinPriority > LCPtr->m_priority)
304 {
305 ueMinPriority = LCPtr->m_priority;
306 }
307
308 ue.first->PrintLcInfo(ue.first->m_rnti,
309 ueLcg.first,
310 lcId,
311 LCPtr->m_qci,
312 LCPtr->m_priority,
313 ueMinPriority);
314 }
315 }
316 return ueMinPriority;
317 }
318
319 double m_currTputDl{0.0};
320 double m_avgTputDl{0.0};
321 double m_lastAvgTputDl{0.0};
322 double m_potentialTputDl{0.0};
324 float m_alpha{0.0};
325
326 double m_currTputUl{0.0};
327 double m_avgTputUl{0.0};
328 double m_lastAvgTputUl{0.0};
329 double m_potentialTputUl{0.0};
331};
332
333} // namespace ns3
Representation of a beam id.
Definition beam-id.h:26
std::pair< UePtr, uint32_t > UePtrAndBufferReq
Pair between a pointer to NrMacSchedulerUeInfo and its buffer occupancy.
The representation of an user for any Mac scheduler.
virtual void ResetDlSchedInfo()
Reset DL information.
virtual void ResetUlMetric()
ResetUlMetric.
virtual void ResetDlMetric()
ResetDlMetric.
virtual void ResetUlSchedInfo()
Reset UL information.
UE representation for a QoS-based scheduler.
static uint8_t CalculateDlMinPriority(const NrMacSchedulerNs3::UePtrAndBufferReq &ue)
This function calculates the min Priority for the DL.
static bool CompareUeWeightsUl(const NrMacSchedulerNs3::UePtrAndBufferReq &lue, const NrMacSchedulerNs3::UePtrAndBufferReq &rue)
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns ...
double m_currTputDl
Current slot throughput in downlink.
double m_currTputUl
Current slot throughput in uplink.
double m_avgTputDl
Average throughput in downlink during all the slots.
void ResetUlSchedInfo() override
Reset UL QoS scheduler info.
void ResetDlSchedInfo() override
Reset DL QoS scheduler info.
static double CalculateDlWeight(const NrMacSchedulerNs3::UePtrAndBufferReq &ue)
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns ...
void UpdateUlQosMetric(const NrMacSchedulerNs3::FTResources &totAssigned, double timeWindow)
Update the QoS metric for uplink.
double m_avgTputUl
Average throughput in uplink during all the slots.
double m_lastAvgTputDl
Last average throughput in downlink.
double m_lastAvgTputUl
Last average throughput in uplink.
NrMacSchedulerUeInfoQos(float alpha, uint16_t rnti, BeamId beamId, const GetRbPerRbgFn &fn)
NrMacSchedulerUeInfoQos constructor.
static double CalculateDelayBudgetFactor(uint64_t pdb, uint16_t hol)
This function calculates the Delay Budget Factor for the case of DC-GBR LC. This value will then be u...
void UpdateDlQosMetric(const NrMacSchedulerNs3::FTResources &totAssigned, double timeWindow)
Update the QoS metric for downlink.
static uint8_t CalculateUlMinPriority(const NrMacSchedulerNs3::UePtrAndBufferReq &ue)
This function calculates the min Priority for the UL.
void CalculatePotentialTPutUl(const NrMacSchedulerNs3::FTResources &assignableInIteration)
Calculate the Potential throughput for uplink.
void ResetDlMetric() override
Reset the DL avg Th to the last value.
void CalculatePotentialTPutDl(const NrMacSchedulerNs3::FTResources &assignableInIteration)
Calculate the Potential throughput for downlink.
void ResetUlMetric() override
Reset the UL avg Th to the last value.
static bool CompareUeWeightsDl(const NrMacSchedulerNs3::UePtrAndBufferReq &lue, const NrMacSchedulerNs3::UePtrAndBufferReq &rue)
comparison function object (i.e. an object that satisfies the requirements of Compare) which returns ...
std::unique_ptr< NrMacSchedulerLC > LCPtr
Unique pointer to an instance of NrMacSchedulerLC.
Point in the Frequency/Time plane.