5G-LENA nr-v3.3-120-gdac69c56
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-scheduler-ofdma-qos.cc
1// Copyright (c) 2022 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-mac-scheduler-ofdma-qos.h"
6
7#include "nr-mac-scheduler-ue-info-qos.h"
8
9#include "ns3/double.h"
10#include "ns3/log.h"
11
12#include <algorithm>
13
14namespace ns3
15{
16
17NS_LOG_COMPONENT_DEFINE("NrMacSchedulerOfdmaQos");
18NS_OBJECT_ENSURE_REGISTERED(NrMacSchedulerOfdmaQos);
19
20TypeId
22{
23 static TypeId tid =
24 TypeId("ns3::NrMacSchedulerOfdmaQos")
25 .SetParent<NrMacSchedulerOfdmaRR>()
26 .AddConstructor<NrMacSchedulerOfdmaQos>()
27 .AddAttribute("FairnessIndex",
28 "Value (between 0 and 1) that defines the PF metric (1 is the "
29 "traditional 3GPP PF, 0 is RR in throughput",
30 DoubleValue(1),
33 MakeDoubleChecker<float>(0, 1))
34 .AddAttribute(
35 "LastAvgTPutWeight",
36 "Weight of the last average throughput in the average throughput calculation",
37 DoubleValue(99),
38 MakeDoubleAccessor(&NrMacSchedulerOfdmaQos::SetTimeWindow,
40 MakeDoubleChecker<float>(0));
41 return tid;
42}
43
48
49void
51{
52 NS_LOG_FUNCTION(this);
53 m_alpha = v;
54}
55
56double
58{
59 NS_LOG_FUNCTION(this);
60 return m_alpha;
61}
62
63void
65{
66 NS_LOG_FUNCTION(this);
67 m_timeWindow = v;
68}
69
70double
72{
73 NS_LOG_FUNCTION(this);
74 return m_timeWindow;
75}
76
77std::shared_ptr<NrMacSchedulerUeInfo>
80{
81 NS_LOG_FUNCTION(this);
82 return std::make_shared<NrMacSchedulerUeInfoQos>(
83 m_alpha,
84 params.m_rnti,
85 params.m_beamId,
87}
88
89std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
95
96std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
102
103void
105 [[maybe_unused]] const FTResources& assigned,
106 const FTResources& totAssigned) const
107{
108 NS_LOG_FUNCTION(this);
109 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoQos>(ue.first);
110 uePtr->UpdateDlQosMetric(totAssigned, m_timeWindow);
111}
112
113void
116 [[maybe_unused]] const NrMacSchedulerNs3::FTResources& assigned,
117 const NrMacSchedulerNs3::FTResources& totAssigned) const
118{
119 NS_LOG_FUNCTION(this);
120 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoQos>(ue.first);
121 uePtr->UpdateDlQosMetric(totAssigned, m_timeWindow);
122}
123
124void
126 [[maybe_unused]] const FTResources& assigned,
127 const FTResources& totAssigned) const
128{
129 NS_LOG_FUNCTION(this);
130 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoQos>(ue.first);
131 uePtr->UpdateUlQosMetric(totAssigned, m_timeWindow);
132}
133
134void
137 [[maybe_unused]] const NrMacSchedulerNs3::FTResources& assigned,
138 const NrMacSchedulerNs3::FTResources& totAssigned) const
139{
140 NS_LOG_FUNCTION(this);
141 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoQos>(ue.first);
142 uePtr->UpdateUlQosMetric(totAssigned, m_timeWindow);
143}
144
145void
147 const FTResources& assignableInIteration) const
148{
149 NS_LOG_FUNCTION(this);
150 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoQos>(ue.first);
151 uePtr->CalculatePotentialTPutDl(assignableInIteration);
152}
153
154void
156 const FTResources& assignableInIteration) const
157{
158 NS_LOG_FUNCTION(this);
159 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoQos>(ue.first);
160 uePtr->CalculatePotentialTPutUl(assignableInIteration);
161}
162
163} // namespace ns3
uint64_t GetNumRbPerRbg() const
Private function that is used to get the number of resource blocks per resource block group and also ...
std::pair< UePtr, uint32_t > UePtrAndBufferReq
Pair between a pointer to NrMacSchedulerUeInfo and its buffer occupancy.
void SetTimeWindow(double v)
Set the attribute "LastAvgTPutWeight".
NrMacSchedulerOfdmaQos()
NrMacSchedulerOfdmaQos constructor.
void BeforeUlSched(const UePtrAndBufferReq &ue, const FTResources &assignableInIteration) const override
Calculate the potential throughput for the UL based on the available resources.
void AssignedDlResources(const UePtrAndBufferReq &ue, const FTResources &assigned, const FTResources &totAssigned) const override
Update the UE representation after a symbol (DL) has been assigned to it.
void SetFairnessIndex(double v)
Set the value of attribute "FairnessIndex".
void NotAssignedDlResources(const UePtrAndBufferReq &ue, const FTResources &notAssigned, const FTResources &totalAssigned) const override
Update DL metrics by calling NrMacSchedulerUeInfoQos::UpdateQosDlMetric.
std::function< bool(const NrMacSchedulerNs3::UePtrAndBufferReq &lhs, const NrMacSchedulerNs3::UePtrAndBufferReq &rhs)> GetUeCompareDlFn() const override
Return the comparison function to sort DL UE according to the scheduler policy.
std::shared_ptr< NrMacSchedulerUeInfo > CreateUeRepresentation(const NrMacCschedSapProvider::CschedUeConfigReqParameters &params) const override
Create an UE representation of the type NrMacSchedulerUeInfoQos.
void BeforeDlSched(const UePtrAndBufferReq &ue, const FTResources &assignableInIteration) const override
Calculate the potential throughput for the DL based on the available resources.
void AssignedUlResources(const UePtrAndBufferReq &ue, const FTResources &assigned, const FTResources &totAssigned) const override
Update the UE representation after a symbol (UL) has been assigned to it.
double GetTimeWindow() const
Get the attribute "LastAvgTPutWeight".
double GetFairnessIndex() const
Get the value of attribute "FairnessIndex".
std::function< bool(const NrMacSchedulerNs3::UePtrAndBufferReq &lhs, const NrMacSchedulerNs3::UePtrAndBufferReq &rhs)> GetUeCompareUlFn() const override
Return the comparison function to sort UL UE according to the scheduler policy.
void NotAssignedUlResources(const UePtrAndBufferReq &ue, const FTResources &notAssigned, const FTResources &totalAssigned) const override
Update UL metrics by calling NrMacSchedulerUeInfoQos::UpdateQosUlMetric.
Assign frequencies in a round-robin fashion.
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 ...
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 ...
Point in the Frequency/Time plane.