5G-LENA nr-v3.3-159-ga6832aa7
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-mac-scheduler-tdma.h
1// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
2//
3// SPDX-License-Identifier: GPL-2.0-only
4
5#pragma once
6
7#include "nr-mac-scheduler-ns3.h"
8
9#include <functional>
10#include <memory>
11
12namespace ns3
13{
14
63{
64 friend class NrTestSchedulerAiCase;
65
66 public:
71 static TypeId GetTypeId();
72
80 ~NrMacSchedulerTdma() override;
81
82 protected:
83 BeamSymbolMap AssignDLRBG(uint32_t symAvail, const ActiveUeMap& activeDl) const override;
84
85 BeamSymbolMap AssignULRBG(uint32_t symAvail, const ActiveUeMap& activeUl) const override;
86 std::shared_ptr<DciInfoElementTdma> CreateDlDci(
87 PointInFTPlane* spoint,
88 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
89 uint32_t maxSym) const override;
90 std::shared_ptr<DciInfoElementTdma> CreateUlDci(
91 PointInFTPlane* spoint,
92 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
93 uint32_t maxSym) const override;
94
100 void ChangeDlBeam([[maybe_unused]] PointInFTPlane* spoint,
101 [[maybe_unused]] uint32_t symOfBeam) const override
102 {
103 }
104
110 void ChangeUlBeam([[maybe_unused]] PointInFTPlane* spoint,
111 [[maybe_unused]] uint32_t symOfBeam) const override
112 {
113 }
114
115 uint8_t GetTpc() const override;
116
122 virtual std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
124 GetUeCompareDlFn() const = 0;
125
131 virtual std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
133 GetUeCompareUlFn() const = 0;
134
148 const FTResources& assigned,
149 const FTResources& totalAssigned) const = 0;
150
164 const FTResources& assigned,
165 const FTResources& totalAssigned) const = 0;
166
174 const FTResources& notAssigned,
175 const FTResources& totalAssigned) const = 0;
176
184 const FTResources& notAssigned,
185 const FTResources& totalAssigned) const = 0;
186
196 virtual void BeforeDlSched(const UePtrAndBufferReq& ue,
197 const FTResources& assignableInIteration) const = 0;
198
208 virtual void BeforeUlSched(const UePtrAndBufferReq& ue,
209 const FTResources& assignableInIteration) const = 0;
210
217 virtual void CallNotifyDlFn(const std::vector<UePtrAndBufferReq>& ueVector) const
218 {
219 }
220
227 virtual void CallNotifyUlFn(const std::vector<UePtrAndBufferReq>& ueVector) const
228 {
229 }
230
231 private:
239 static std::vector<UePtrAndBufferReq> GetUeVectorFromActiveUeMap(const ActiveUeMap& activeUes);
240
241 private:
242 typedef std::function<void(const UePtrAndBufferReq&, const FTResources&)>
243 BeforeSchedFn;
247 typedef std::function<void(const UePtrAndBufferReq&, const FTResources&, const FTResources&)>
248 AfterSuccessfulAssignmentFn;
252 typedef std::function<void(const UePtrAndBufferReq&, const FTResources&, const FTResources&)>
253 AfterUnsuccessfulAssignmentFn;
254 typedef std::function<std::vector<uint16_t>&(const UePtr& ue)>
255 GetRBGFn;
256 typedef std::function<uint32_t&(const UePtr& ue)> GetTBSFn;
257 typedef std::function<std::vector<uint8_t>&(const UePtr& ue)>
258 GetSymFn;
259 typedef std::function<bool(const NrMacSchedulerNs3::UePtrAndBufferReq& lhs,
261 CompareUeFn;
262 typedef std::function<CompareUeFn()> GetCompareUeFn;
263 typedef std::function<void(std::vector<UePtrAndBufferReq>& ueVector)> CallNotifyFn;
264
265 BeamSymbolMap AssignRBGTDMA(uint32_t symAvail,
266 const ActiveUeMap& activeUe,
267 const std::string& type,
268 const BeforeSchedFn& BeforeSchedFn,
269 const GetCompareUeFn& GetCompareFn,
270 const GetTBSFn& GetTBSFn,
271 const GetRBGFn& GetRBGFn,
272 const GetSymFn& GetSymFn,
273 const AfterSuccessfulAssignmentFn& SuccessfulAssignmentFn,
274 const AfterUnsuccessfulAssignmentFn& UnSuccessfulAssignmentFn,
275 const CallNotifyFn& callNotifyFn) const;
276
277 std::shared_ptr<DciInfoElementTdma> CreateDci(
278 PointInFTPlane* spoint,
279 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
280 uint32_t tbs,
282 uint32_t mcs,
283 uint8_t rank,
284 Ptr<const ComplexMatrixArray> precMats,
285 uint8_t numSym) const;
286};
287
288} // namespace ns3
A general scheduler for nr in NS3.
std::unordered_map< BeamId, uint32_t, BeamIdHash > BeamSymbolMap
Map between a BeamId and the symbol assigned to that beam.
std::unordered_map< BeamId, std::vector< UePtrAndBufferReq >, BeamIdHash > ActiveUeMap
Map between a BeamId and a vector of UE (the UE are in that beam)
std::pair< UePtr, uint32_t > UePtrAndBufferReq
Pair between a pointer to NrMacSchedulerUeInfo and its buffer occupancy.
PointInFTPlane FTResources
Represent an amount of RBG/symbols that can be, or is, assigned.
The base for all the TDMA schedulers.
virtual std::function< bool(const NrMacSchedulerNs3::UePtrAndBufferReq &lhs, const NrMacSchedulerNs3::UePtrAndBufferReq &rhs)> GetUeCompareUlFn() const =0
Provide the comparison function to order the UE when scheduling UL.
std::shared_ptr< DciInfoElementTdma > CreateDlDci(PointInFTPlane *spoint, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo, uint32_t maxSym) const override
Create a DL DCI starting from spoint and spanning maxSym symbols.
NrMacSchedulerTdma()
NrMacSchedulerTdma constructor.
virtual void AssignedUlResources(const UePtrAndBufferReq &ue, const FTResources &assigned, const FTResources &totalAssigned) const =0
Update the UE representation after a symbol (DL) has been assigned to it.
virtual std::function< bool(const NrMacSchedulerNs3::UePtrAndBufferReq &lhs, const NrMacSchedulerNs3::UePtrAndBufferReq &rhs)> GetUeCompareDlFn() const =0
Provide the comparison function to order the UE when scheduling DL.
BeamSymbolMap AssignDLRBG(uint32_t symAvail, const ActiveUeMap &activeDl) const override
Assign the available DL RBG to the UEs.
static TypeId GetTypeId()
GetTypeId.
virtual void NotAssignedUlResources(const UePtrAndBufferReq &ue, const FTResources &notAssigned, const FTResources &totalAssigned) const =0
Update the UE representation after a symbol (UL) has been assigned to other UE.
virtual void NotAssignedDlResources(const UePtrAndBufferReq &ue, const FTResources &notAssigned, const FTResources &totalAssigned) const =0
Update the UE representation after a symbol (DL) has been assigned to other UE.
virtual void AssignedDlResources(const UePtrAndBufferReq &ue, const FTResources &assigned, const FTResources &totalAssigned) const =0
Update the UE representation after a symbol (DL) has been assigned to it.
BeamSymbolMap AssignULRBG(uint32_t symAvail, const ActiveUeMap &activeUl) const override
Assign the available UL RBG to the UEs.
virtual void BeforeUlSched(const UePtrAndBufferReq &ue, const FTResources &assignableInIteration) const =0
Prepare UE for the UL scheduling.
~NrMacSchedulerTdma() override
NrMacSchedulerTdma deconstructor.
uint8_t GetTpc() const override
Returns TPC command.
virtual void CallNotifyDlFn(const std::vector< UePtrAndBufferReq > &ueVector) const
Call the notify callback function in the OpenGymEnv class in the ns3-gym module for downlink.
virtual void CallNotifyUlFn(const std::vector< UePtrAndBufferReq > &ueVector) const
Call the notify callback function in the OpenGymEnv class in the ns3-gym module for uplink.
void ChangeUlBeam(PointInFTPlane *spoint, uint32_t symOfBeam) const override
Not doing anything, moving forward the spoint is done by CreateDci.
void ChangeDlBeam(PointInFTPlane *spoint, uint32_t symOfBeam) const override
Not doing anything, moving forward the spoint is done by CreateDci.
virtual void BeforeDlSched(const UePtrAndBufferReq &ue, const FTResources &assignableInIteration) const =0
Prepare UE for the DL scheduling.
std::shared_ptr< DciInfoElementTdma > CreateUlDci(PointInFTPlane *spoint, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo, uint32_t maxSym) const override
Create a UL DCI starting from spoint and spanning maxSym symbols.
DciFormat
Format of the DCI.
Point in the Frequency/Time plane.