5G-LENA nr-v3.3-120-gdac69c56
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-scheduler-lc-rr.cc
1// Copyright (c) 2023 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#include "nr-mac-scheduler-lc-rr.h"
6
7#include "ns3/log.h"
8
9namespace ns3
10{
11
12NS_LOG_COMPONENT_DEFINE("NrMacSchedulerLcRR");
13NS_OBJECT_ENSURE_REGISTERED(NrMacSchedulerLcRR);
14
17{
18 NS_LOG_FUNCTION(this);
19}
20
24
25TypeId
27{
28 static TypeId tid = TypeId("ns3::NrMacSchedulerLcRR")
29 .SetParent<NrMacSchedulerLcAlgorithm>()
30 .AddConstructor<NrMacSchedulerLcRR>();
31 return tid;
32}
33
34std::vector<NrMacSchedulerLcAlgorithm::Assignation>
35NrMacSchedulerLcRR::AssignBytesToDlLC(const std::unordered_map<uint8_t, LCGPtr>& ueLCG,
36 uint32_t tbs,
37 [[maybe_unused]] Time slotPeriod) const
38{
39 return AssignBytesToLC(ueLCG, tbs);
40}
41
42std::vector<NrMacSchedulerLcAlgorithm::Assignation>
43NrMacSchedulerLcRR::AssignBytesToUlLC(const std::unordered_map<uint8_t, LCGPtr>& ueLCG,
44 uint32_t tbs) const
45{
46 return AssignBytesToLC(ueLCG, tbs);
47}
48
49std::vector<NrMacSchedulerLcAlgorithm::Assignation>
50NrMacSchedulerLcRR::AssignBytesToLC(const std::unordered_map<uint8_t, LCGPtr>& ueLCG,
51 uint32_t tbs) const
52{
53 NS_LOG_FUNCTION(this);
54 GetFirst GetLCGID;
55 GetSecond GetLCG;
56
57 std::vector<NrMacSchedulerLcAlgorithm::Assignation> ret;
58
59 NS_LOG_INFO("To distribute: " << tbs << " bytes over " << ueLCG.size() << " LCG");
60
61 uint32_t activeLc = 0;
62 for (const auto& lcg : ueLCG)
63 {
64 std::vector<uint8_t> lcs = GetLCG(lcg)->GetLCId();
65 for (const auto& lcId : lcs)
66 {
67 if (GetLCG(lcg)->GetTotalSizeOfLC(lcId) > 0)
68 {
69 ++activeLc;
70 }
71 }
72 }
73
74 if (activeLc == 0)
75 {
76 return ret;
77 }
78
79 uint32_t amountPerLC = tbs / activeLc;
80 NS_LOG_INFO("Total LC: " << activeLc << " each one will receive " << amountPerLC << " bytes");
81
82 for (const auto& lcg : ueLCG)
83 {
84 std::vector<uint8_t> lcs = GetLCG(lcg)->GetLCId();
85 for (const auto& lcId : lcs)
86 {
87 if (GetLCG(lcg)->GetTotalSizeOfLC(lcId) > 0)
88 {
89 NS_LOG_INFO("Assigned to LCID " << static_cast<uint32_t>(lcId) << " inside LCG "
90 << static_cast<uint32_t>(GetLCGID(lcg))
91 << " an amount of " << amountPerLC << " B");
92 ret.emplace_back(GetLCGID(lcg), lcId, amountPerLC);
93 }
94 }
95 }
96
97 return ret;
98}
99
100}; // namespace ns3
This class is the interface for the creation of various scheduling algorithms for the distribution of...
std::vector< Assignation > AssignBytesToUlLC(const std::unordered_map< uint8_t, LCGPtr > &ueLCG, uint32_t tbs) const override
Method to decide how to distribute the assigned bytes to the different LCs for the UL direction....
std::vector< Assignation > AssignBytesToDlLC(const std::unordered_map< uint8_t, LCGPtr > &ueLCG, uint32_t tbs, Time slotPeriod) const override
Method to decide how to distribute the assigned bytes to the different LCs for the DL direction....
NrMacSchedulerLcRR()
NrMacSchedulerLcRR constructor.
~NrMacSchedulerLcRR() override
NrMacSchedulerLcRR deconstructor.
static TypeId GetTypeId()
Get the type ID.