LcgScheduler.h Source File

Simu5G: LcgScheduler.h Source File
Simu5G
LcgScheduler.h
1//
2// Simu5G
3//
4// Copyright (C) 2012-2021 Giovanni Nardini, Giovanni Stea, Antonio Virdis et al. (University of Pisa)
5// Copyright (C) 2022-2026 Giovanni Nardini, Giovanni Stea et al. (University of Pisa)
6//
7// This file is part of a software released under the license included in file
8// "license.pdf". Please read LICENSE and README files before using it.
9// The above files and the present reference are part of the software itself,
10// and cannot be removed from it.
11//
12
13#ifndef _LTE_LCGSCHEDULER_H_
14#define _LTE_LCGSCHEDULER_H_
15
16#include "simu5g/common/LteCommon.h"
17#include "simu5g/stack/mac/LteMacUe.h"
18
19namespace simu5g {
20
21using namespace omnetpp;
22
25class LteMacPdu;
28typedef std::map<MacCid, unsigned int> ScheduleList;
29
43{
44
45 protected:
49 template<typename T, typename S>
50 struct SortedDesc
51 {
53 T x_;
56
58 bool operator<(const SortedDesc& y) const
59 {
60 return score_ < y.score_;
61 }
62
63 public:
64 SortedDesc(const T x, const S score) : x_(x), score_(score)
65 {
66 }
67 };
68
69 struct StatusElem
70 {
71 unsigned int occupancy_;
72 unsigned int sentData_;
73 unsigned int sentSdus_;
74 };
75
77 opp_component_ptr<LteMacUe> mac_;
78
81
82 // schedule List - returned by reference on scheduler invocation
83 ScheduleList scheduleList_;
84
85 // scheduled bytes list
86 ScheduleList scheduledBytesList_;
87
88 // For NR-SO (no RLC concatenation) connections: the per-PDU payload sizes that
89 // fill the grant, so the MAC issues one SDU request per planned PDU and the MAC
90 // PDU multiplexes them. Empty/absent for LTE-FI connections (one concatenated PDU).
91 std::map<MacCid, std::vector<unsigned int>> scheduledSoPduSizes_;
92
94 typedef std::list<MacCid> CidList;
95
96 // scheduling status map
97 std::map<MacCid, StatusElem> statusMap_;
98
99 // per-LCG rotation of the round-robin's starting position across schedule()
100 // calls, so the first-served granularity bias does not stick to one connection
101 std::map<unsigned short, size_t> rrStart_;
102
103 public:
104
108 LcgScheduler(LteMacUe *mac);
109 LcgScheduler(const LcgScheduler& other) { operator=(other); }
110 LcgScheduler& operator=(const LcgScheduler& other);
114 virtual ~LcgScheduler() {}
115
120 inline virtual void setUeUlScheduler(LteSchedulerUeUl *ueScheduler)
121 {
122 ueScheduler_ = ueScheduler;
123 }
124
125 /* Executes the LCG scheduling algorithm
126 * @param availableBytes
127 * @return # of scheduled sdus per cid
128 */
129 virtual ScheduleList& schedule(unsigned int availableBytes, Direction grantDir = UL);
130
131 /* After the scheduling, returns the amount of bytes
132 * scheduled for each connection
133 */
134 virtual ScheduleList& getScheduledBytesList();
135
136 /* After scheduling, returns the planned per-PDU payload sizes for an NR-SO
137 * connection (one SDU request per entry), or nullptr for LTE-FI connections.
138 */
139 virtual const std::vector<unsigned int> *getScheduledSoPduSizes(MacCid cid) const;
140
141 protected:
142
149 virtual bool checkForPendingAdditionalBsr(Direction grantDir, Lcg lcg) { return false; }
150};
151
152} //namespace simu5g
153
154#endif
155
Definition LcgScheduler.h:43
LcgScheduler(LteMacUe *mac)
virtual ~LcgScheduler()
Definition LcgScheduler.h:114
virtual void setUeUlScheduler(LteSchedulerUeUl *ueScheduler)
Definition LcgScheduler.h:120
virtual bool checkForPendingAdditionalBsr(Direction grantDir, Lcg lcg)
Definition LcgScheduler.h:149
std::list< MacCid > CidList
Cid List.
Definition LcgScheduler.h:94
opp_component_ptr< LteMacUe > mac_
MAC module, used to get parameters from NED.
Definition LcgScheduler.h:77
LteSchedulerUeUl * ueScheduler_
Associated LteSchedulerUeUl (it is the one who creates the LteScheduler)
Definition LcgScheduler.h:80
Definition LteSchedulerUeUl.h:32
Definition LteTypes.h:153
Definition AlertReceiver.h:24
Definition LcgScheduler.h:51
S score_
Score value.
Definition LcgScheduler.h:55
bool operator<(const SortedDesc &y) const
Comparison operator to enable sorting.
Definition LcgScheduler.h:58
T x_
Connection identifier.
Definition LcgScheduler.h:53