LteScheduler.h Source File

Simu5G: LteScheduler.h Source File
Simu5G
LteScheduler.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_LTESCHEDULER_H_
14#define _LTE_LTESCHEDULER_H_
15
16#include "simu5g/common/LteCommon.h"
17#include "simu5g/stack/mac/LteMacEnb.h"
18
19namespace simu5g {
20
21using namespace omnetpp;
22
24class LteSchedulerEnb;
25
29template<typename T, typename S>
30struct SortedDesc
31{
33 T x_;
36
38 bool operator<(const SortedDesc& y) const
39 {
40 if (score_ < y.score_)
41 return true;
42 if (score_ == y.score_)
43 return uniform(getEnvir()->getRNG(0), 0, 1) < 0.5;
44 return false;
45 }
46
47 public:
49 {
50 }
51
52 SortedDesc(const T x, const S score) : x_(x), score_(score)
53 {
54 }
55
56};
57
60class LteScheduler
61{
62 protected:
63
65 opp_component_ptr<LteMacEnb> mac_;
66
68 opp_component_ptr<Binder> binder_;
69
71 LteSchedulerEnb *eNbScheduler_ = nullptr;
72
74 Direction direction_;
75
77 ActiveSet *activeConnectionSet_ = nullptr;
78
80 ActiveSet activeConnectionTempSet_;
81
83 ActiveSet carrierActiveConnectionSet_;
84
86 GHz carrierFrequency_;
87
89 BandLimitVector bandLimit_;
90
92 BandLimitVector slotRacBandLimit_;
93
95 BandLimitVector slotRtxBandLimit_;
96
98 BandLimitVector slotReqGrantBandLimit_;
99
101 typedef std::list<MacCid> CidList;
102
104 unsigned int numerologyIndex_;
105
107 unsigned int maxSchedulingPeriodCounter_;
108 unsigned int currentSchedulingPeriodCounter_;
109
110 public:
111
115 LteScheduler(Binder *binder) : binder_(binder)
116 {
117 }
118
122 virtual ~LteScheduler()
123 {
124 }
125
130 virtual void setEnbScheduler(LteSchedulerEnb *eNbScheduler);
131
136 virtual void setCarrierFrequency(GHz carrierFrequency);
137
138 /*
139 * Initializes band limit for this scheduler
140 */
141 virtual void initializeBandLimit();
142
143 /*
144 * Set the period counter
145 */
146 virtual void initializeSchedulerPeriodCounter(NumerologyIndex maxNumerologyIndex);
147
148 /*
149 * Handle the period counter
150 */
151 virtual unsigned int decreaseSchedulerPeriodCounter();
152
156 GHz getCarrierFrequency() { return carrierFrequency_; };
157
161 void setNumerologyIndex(unsigned int numerologyIndex) { numerologyIndex_ = numerologyIndex; }
162
163 // Scheduling functions ********************************************************************
164
177
178 virtual void schedule();
179
180 virtual void prepareSchedule()
181 {
182 }
183
184 virtual void commitSchedule()
185 {
186 }
187
188 // *****************************************************************************************
189
191 virtual unsigned int requestGrant(MacCid cid, unsigned int bytes, bool& terminate, bool& active, bool& eligible, std::vector<BandLimit> *bandLim = nullptr);
192
194 virtual unsigned int requestGrantBackground(MacCid bgCid, unsigned int bytes, bool& terminate, bool& active, bool& eligible, std::vector<BandLimit> *bandLim = nullptr);
195
197 virtual bool scheduleRetransmissions();
198
200 virtual bool scheduleRacRequests();
201
202 virtual void notifyActiveConnection(MacCid activeCid)
203 {
204 }
205
206 virtual void updateSchedulingInfo()
207 {
208 }
209
210 protected:
211
212 /*
213 * Prepare the set of active connections on this carrier
214 * Used by scheduling modules
215 */
216 virtual void buildCarrierActiveConnectionSet();
217
218};
219
220} //namespace
221
222#endif // _LTE_LTESCHEDULER_H_
Definition AlertReceiver.h:24
unsigned short NumerologyIndex
Numerology Index.
Definition LteCommon.h:205
Definition LteScheduler.h:31
unsigned int score_
Definition LteScheduler.h:35
bool operator<(const SortedDesc &y) const
Comparison operator to enable sorting.
Definition LteScheduler.h:38
MacCid x_
Definition LteScheduler.h:33