5G-LENA nr-v3.3-120-gdac69c56
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-scheduler-tdma-pf.cc
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-mac-scheduler-tdma-pf.h"
6
7#include "nr-mac-scheduler-ue-info-pf.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("NrMacSchedulerTdmaPF");
18NS_OBJECT_ENSURE_REGISTERED(NrMacSchedulerTdmaPF);
19
20TypeId
22{
23 static TypeId tid =
24 TypeId("ns3::NrMacSchedulerTdmaPF")
25 .SetParent<NrMacSchedulerTdmaRR>()
26 .AddConstructor<NrMacSchedulerTdmaPF>()
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<double>(0, 1))
34 .AddAttribute(
35 "LastAvgTPutWeight",
36 "Weight of the last average throughput in the average throughput calculation",
37 DoubleValue(99),
38 MakeDoubleAccessor(&NrMacSchedulerTdmaPF::SetTimeWindow,
40 MakeDoubleChecker<double>(0));
41 return tid;
42}
43
46{
47 NS_LOG_FUNCTION(this);
48}
49
50void
52{
53 NS_LOG_FUNCTION(this);
54 m_alpha = v;
55}
56
57double
59{
60 NS_LOG_FUNCTION(this);
61 return m_alpha;
62}
63
64void
66{
67 NS_LOG_FUNCTION(this);
68 m_timeWindow = v;
69}
70
71double
73{
74 NS_LOG_FUNCTION(this);
75 return m_timeWindow;
76}
77
78std::shared_ptr<NrMacSchedulerUeInfo>
81{
82 NS_LOG_FUNCTION(this);
83 return std::make_shared<NrMacSchedulerUeInfoPF>(
84 m_alpha,
85 params.m_rnti,
86 params.m_beamId,
87 std::bind(&NrMacSchedulerTdmaPF::GetNumRbPerRbg, this));
88}
89
90std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
96
97std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
103
104void
106 [[maybe_unused]] const FTResources& assigned,
107 const FTResources& totAssigned) const
108{
109 NS_LOG_FUNCTION(this);
110 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoPF>(ue.first);
111 uePtr->UpdateDlPFMetric(totAssigned, m_timeWindow);
112}
113
114void
117 [[maybe_unused]] const NrMacSchedulerNs3::FTResources& notAssigned,
118 const NrMacSchedulerNs3::FTResources& totAssigned) const
119{
120 NS_LOG_FUNCTION(this);
121 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoPF>(ue.first);
122 uePtr->UpdateDlPFMetric(totAssigned, m_timeWindow);
123}
124
125void
127 [[maybe_unused]] const FTResources& assigned,
128 const FTResources& totAssigned) const
129{
130 NS_LOG_FUNCTION(this);
131 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoPF>(ue.first);
132 uePtr->UpdateUlPFMetric(totAssigned, m_timeWindow);
133}
134
135void
138 [[maybe_unused]] const NrMacSchedulerNs3::FTResources& notAssigned,
139 const NrMacSchedulerNs3::FTResources& totAssigned) const
140{
141 NS_LOG_FUNCTION(this);
142 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoPF>(ue.first);
143 uePtr->UpdateUlPFMetric(totAssigned, m_timeWindow);
144}
145
146void
148 const FTResources& assignableInIteration) const
149{
150 NS_LOG_FUNCTION(this);
151 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoPF>(ue.first);
152 uePtr->CalculatePotentialTPutDl(assignableInIteration);
153}
154
155void
157 const FTResources& assignableInIteration) const
158{
159 NS_LOG_FUNCTION(this);
160 auto uePtr = std::dynamic_pointer_cast<NrMacSchedulerUeInfoPF>(ue.first);
161 uePtr->CalculatePotentialTPutUl(assignableInIteration);
162}
163
164} // 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.
static TypeId GetTypeId()
GetTypeId.
void BeforeDlSched(const UePtrAndBufferReq &ue, const FTResources &assignableInIteration) const override
Calculate the potential throughput for the DL based on the available resources.
double GetFairnessIndex() const
Get the value of attribute "FairnessIndex".
void NotAssignedUlResources(const UePtrAndBufferReq &ue, const FTResources &notAssigned, const FTResources &totAssigned) const override
Update UL metrics by calling NrMacSchedulerUeInfoPF::UpdatePFUlMetric.
void BeforeUlSched(const UePtrAndBufferReq &ue, const FTResources &assignableInIteration) const override
Calculate the potential throughput for the UL based on the available resources.
void SetFairnessIndex(double v)
Set the value of attribute "FairnessIndex".
void AssignedUlResources(const UePtrAndBufferReq &ue, const FTResources &assigned, const FTResources &totAssigned) const override
Update UL metrics by calling NrMacSchedulerUeInfoPF::UpdatePFUlMetric.
double GetTimeWindow() const
Get the attribute "LastAvgTPutWeight".
NrMacSchedulerTdmaPF()
NrMacSchedulerTdmaPF constructor.
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.
void AssignedDlResources(const UePtrAndBufferReq &ue, const FTResources &assigned, const FTResources &totAssigned) const override
Update DL metrics by calling NrMacSchedulerUeInfoPF::UpdatePFDlMetric.
void NotAssignedDlResources(const UePtrAndBufferReq &ue, const FTResources &notAssigned, const FTResources &totAssigned) const override
Update DL metrics by calling NrMacSchedulerUeInfoPF::UpdatePFDlMetric.
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.
std::shared_ptr< NrMacSchedulerUeInfo > CreateUeRepresentation(const NrMacCschedSapProvider::CschedUeConfigReqParameters &params) const override
Create an UE representation of the type NrMacSchedulerUeInfoPF.
void SetTimeWindow(double v)
Set the attribute "LastAvgTPutWeight".
Assign entire symbols 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.