8#include "nr-fh-sched-sap.h"
9#include "nr-mac-harq-vector.h"
10#include "nr-mac-scheduler-cqi-management.h"
11#include "nr-mac-scheduler-lcg.h"
12#include "nr-mac-scheduler-ue-info.h"
13#include "nr-mac-scheduler.h"
14#include "nr-phy-mac-common.h"
16#include "ns3/traced-callback.h"
25class NrSchedGeneralTestCase;
26class NrSchedOfdmaSymbolPerBeamTestCase;
27class NrMacSchedulerHarqRr;
28class NrMacSchedulerSrsDefault;
29class NrMacSchedulerLcAlgorithm;
30class NrFhSchedSapUser;
31class NrFhSchedSapProvider;
239 friend class NrTestSchedulerAiCase;
240 friend class NrSchedOfdmaSymbolPerBeamTestCase;
353 bool IsMaxSrsReached()
const override;
367 using HarqVectorIteratorList = std::vector<HarqVectorIterator>;
384 typedef std::unordered_map<BeamId, HarqVectorIteratorList, BeamIdHash>
ActiveHarqMap;
596 const std::unordered_map<uint16_t, UePtr>& ueMap,
597 std::vector<DlHarqInfo>* dlHarqToRetransmit,
598 const std::vector<DlHarqInfo>& dlHarqFeedback,
613 const std::unordered_map<uint16_t, UePtr>& ueMap,
614 std::vector<UlHarqInfo>* ulHarqToRetransmit,
615 const std::vector<UlHarqInfo>& ulHarqFeedback,
660 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
661 uint32_t maxSym)
const = 0;
675 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
676 uint32_t maxSym)
const = 0;
744 AllocElem() =
delete;
748 AllocElem(
const AllocElem& o) =
default;
758 AllocElem(uint16_t rnti,
764 const std::vector<bool>& rbgMask)
767 m_symStart(symStart),
777 uint8_t m_symStart{0};
781 std::vector<bool> m_rbgMask;
796 SlotElem(
const SlotElem& o) =
default;
802 SlotElem(uint8_t totUlSym)
803 : m_totUlSym(totUlSym)
808 std::vector<AllocElem> m_ulAllocations;
811 void BSRReceivedFromUe(
const MacCeElement& bsr);
813 template <
typename T>
814 std::vector<T> MergeHARQ(std::vector<T>* existingFeedbacks,
815 const std::vector<T>& inFeedbacks,
816 const std::string& mode)
const;
818 void ResetExpiredHARQ(uint16_t rnti, NrMacHarqVector* harq);
820 template <
typename T>
821 void ProcessHARQFeedbacks(std::vector<T>* harqInfo,
822 const NrMacSchedulerUeInfo::GetHarqVectorFn& GetHarqVectorFn,
823 const std::string& direction)
const;
825 void ScheduleDl(
const NrMacSchedSapProvider::SchedDlTriggerReqParameters& params,
826 const std::vector<DlHarqInfo>& dlHarqInfo);
828 void ScheduleUl(
const NrMacSchedSapProvider::SchedUlTriggerReqParameters& params,
829 const std::vector<UlHarqInfo>& ulHarqInfo);
831 uint8_t AppendCtrlSym(uint8_t symStart,
832 uint8_t numSymToAllocate,
834 std::deque<VarTtiAllocInfo>* allocations)
const;
835 uint8_t PrependCtrlSym(uint8_t symStart,
836 uint8_t numSymToAllocate,
838 std::deque<VarTtiAllocInfo>* allocations)
const;
841 const NrMacSchedulerUeInfo::GetLCGFn& GetLCGFn,
842 const NrMacSchedulerUeInfo::GetHarqVectorFn& GetHarqVector,
843 const std::string& mode)
const;
845 const std::vector<DlHarqInfo>& dlHarqFeedback)
const;
847 const std::vector<UlHarqInfo>& ulHarqFeedback)
const;
849 uint8_t DoScheduleDlData(PointInFTPlane* spoint,
852 SlotAllocInfo* slotAlloc)
const;
853 uint8_t DoScheduleUlData(PointInFTPlane* spoint,
856 SlotAllocInfo* slotAlloc)
const;
857 uint8_t DoScheduleUlMsg3(PointInFTPlane* sPoint, uint8_t symAvail, SlotAllocInfo* slotAlloc);
858 void DoScheduleUlSr(PointInFTPlane* spoint,
const std::list<uint16_t>& rntiList)
const;
859 uint8_t DoScheduleDl(
const std::vector<DlHarqInfo>& dlHarqFeedback,
862 const SfnSf& dlSfnSf,
863 const SlotElem& ulAllocations,
864 SlotAllocInfo* allocInfo);
865 uint8_t DoScheduleUl(
const std::vector<UlHarqInfo>& ulHarqFeedback,
867 SlotAllocInfo* allocInfo,
869 uint8_t DoScheduleSrs(PointInFTPlane* spoint, SlotAllocInfo* allocInfo);
871 static const unsigned m_macHdrSize = 0;
872 static const uint32_t m_subHdrSize = 4;
873 static const unsigned m_rlcHdrSize = 3;
903 bool DoesFhAllocationFit(uint16_t bwpId, uint32_t mcs, uint32_t nRegs, uint8_t dlRank)
const;
910 void CallNrFhControlForMapUpdate(
911 const std::deque<VarTtiAllocInfo>& allocation,
912 const std::unordered_map<uint16_t, std::shared_ptr<NrMacSchedulerUeInfo>>& ueMap);
914 std::unordered_map<uint16_t, std::shared_ptr<NrMacSchedulerUeInfo>>
921 std::map<uint64_t, SlotElem> m_ulAllocationMap;
923 bool m_fixedMcsDl{
false};
924 bool m_fixedMcsUl{
false};
925 uint8_t m_startMcsDl{0};
926 uint8_t m_startMcsUl{0};
927 int8_t m_maxDlMcs{0};
928 Time m_cqiTimersThreshold;
930 uint8_t m_rachUlGrantMcs{0};
931 uint8_t m_ulRachBwpIndex{
934 NrMacSchedulerCQIManagement m_cqiManagement;
936 std::vector<DlHarqInfo>
937 m_dlHarqToRetransmit;
938 std::vector<UlHarqInfo>
939 m_ulHarqToRetransmit;
941 std::list<uint16_t> m_srList;
943 std::vector<struct nr::RachListElement_s> m_rachList;
945 uint16_t m_bandwidth{0};
946 uint8_t m_dlCtrlSymbols{0};
947 uint8_t m_ulCtrlSymbols{0};
948 uint8_t m_srsCtrlSymbols{0};
949 bool m_enableSrsInUlSlots{
true};
950 bool m_enableSrsInFSlots{
true};
952 std::vector<bool> m_dlNotchedRbgsMask;
953 std::vector<bool> m_ulNotchedRbgsMask;
955 std::unique_ptr<NrMacSchedulerHarqRr> m_schedHarq;
957 Ptr<NrMacSchedulerSrsDefault> m_schedulerSrs;
958 Ptr<NrMacSchedulerLcAlgorithm>
960 TypeId m_schedLcType;
962 uint32_t m_srsSlotCounter{0};
964 friend NrSchedGeneralTestCase;
966 bool m_enableHarqReTx{
true};
968 TracedCallback<uint16_t, uint16_t, const std::shared_ptr<NrMacSchedulerUeInfo>&>
969 m_csiFeedbackReceived;
Service Access Point (SAP) offered by the FhControl instance to the MAC Scheduler instance.
Service Access Point (SAP) offered by the MAC Scheduler instance to the FhControl instance.
std::unordered_map< uint8_t, HarqProcess >::iterator iterator
iterator of the map
Interface for all the nr schedulers.
A general scheduler for nr in NS3.
bool IsSrsInUlSlots() const
Check if the UL slots are allowed for SRS transmission.
void DoCschedUeConfigReq(const NrMacCschedSapProvider::CschedUeConfigReqParameters ¶ms) override
Register an UE.
NrMacSchedulerNs3()
NrMacSchedulerNs3 default constructor.
uint8_t GetUlCtrlSyms() const override
Retrieve the number of UL ctrl symbols configured in the scheduler.
std::unordered_map< BeamId, HarqVectorIteratorList, BeamIdHash > ActiveHarqMap
Map between a beamID and the HARQ of that beam.
virtual std::shared_ptr< NrMacSchedulerUeInfo > CreateUeRepresentation(const NrMacCschedSapProvider::CschedUeConfigReqParameters ¶ms) const =0
Create an UE representation for the scheduler.
Ptr< NrAmc > m_ulAmc
AMC pointer.
uint8_t GetStartMcsDl() const
Get the DL MCS starting value.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model....
void DoCschedUeReleaseReq(const NrMacCschedSapProvider::CschedUeReleaseReqParameters ¶ms) override
Release an UE.
void DoSchedUlTriggerReq(const NrMacSchedSapProvider::SchedUlTriggerReqParameters ¶ms) override
Decide how to fill the frequency/time of a UL slot.
NrMacSchedulerUeInfo::McsCsiSource m_mcsCsiSource
CSI information source for DL MCS estimation.
void SetSrsInFSlots(bool v)
Set if the F slots are allowed for SRS transmission.
virtual void ChangeDlBeam(PointInFTPlane *spoint, uint32_t symOfBeam) const =0
Perform a custom operation on the starting point each time all the UE of a DL beam have been schedule...
void SetRachUlGrantMcs(uint8_t v)
Sets the default RACH UL grant MCS.
virtual BeamSymbolMap AssignDLRBG(uint32_t symAvail, const ActiveUeMap &activeDl) const =0
Assign the DL RBG to the active UE, and return the distribution of symbols per beam.
virtual void SortUlHarq(ActiveHarqMap *activeUlHarq) const
Sort the UL HARQ retransmission.
NrFhSchedSapUser * GetNrFhSchedSapUser() override
void SetSrsCtrlSyms(uint8_t v)
Set the number of UL SRS symbols.
void DoCschedLcReleaseReq(const NrMacCschedSapProvider::CschedLcReleaseReqParameters ¶ms) override
Release a LC.
void SetFixedDlMcs(bool v)
Set if the MCS in DL is fixed (in case, it will take the starting value)
virtual void ChangeUlBeam(PointInFTPlane *spoint, uint32_t symOfBeam) const =0
Perform a custom operation on the starting point each time all the UE of an UL beam have been schedul...
NrFhSchedSapProvider * m_nrFhSchedSapProvider
FH Control SAP provider.
Ptr< NrAmc > m_dlAmc
AMC pointer.
bool IsSrsInFSlots() const
Check if the F slots are allowed for SRS transmission.
void SetUlCtrlSyms(uint8_t v)
Set the number of UL ctrl symbols.
uint8_t GetSrsCtrlSyms() const
Get the configured value for the SRS symbols.
bool m_activeUlAi
Flag for activating AI for uplink.
virtual uint8_t ScheduleUlHarq(NrMacSchedulerNs3::PointInFTPlane *startingPoint, uint8_t symAvail, const std::unordered_map< uint16_t, UePtr > &ueMap, std::vector< UlHarqInfo > *ulHarqToRetransmit, const std::vector< UlHarqInfo > &ulHarqFeedback, SlotAllocInfo *slotAlloc) const
Giving the input, append to slotAlloc the allocations for the DL HARQ retransmissions.
void InstallUlAmc(const Ptr< NrAmc > &ulAmc)
Install the AMC for the DL part.
Ptr< const NrAmc > GetDlAmc() const
Get the AMC for DL.
void SetSrsInUlSlots(bool v)
Set if the UL slots are allowed for SRS transmission (if True, UL and F slots may carry SRS,...
void SetStartMcsUl(uint8_t v)
Set the starting value for the UL MCS.
std::vector< bool > GetUlNotchedRbgMask() const
Get the notched (blank) RBGs Mask for the UL.
uint8_t GetStartMcsUl() const
Get the DL MCS starting value.
std::unordered_map< BeamId, uint32_t, BeamIdHash > BeamSymbolMap
Map between a BeamId and the symbol assigned to that beam.
void DoSchedSetMcs(uint32_t mcs) override
Set a fixed MCS.
void DoCschedLcConfigReq(const NrMacCschedSapProvider::CschedLcConfigReqParameters ¶ms) override
Configure a logical channel for a UE.
void DoSchedDlCqiInfoReq(const NrMacSchedSapProvider::SchedDlCqiInfoReqParameters ¶ms) override
Received a DL CQI message.
virtual std::shared_ptr< DciInfoElementTdma > CreateUlDci(PointInFTPlane *spoint, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo, uint32_t maxSym) const =0
Create a DCI for the specified UE for UL data.
void DoSchedUlCqiInfoReq(const NrMacSchedSapProvider::SchedUlCqiInfoReqParameters ¶ms) override
Received a UL CQI message.
uint16_t GetBwpId() const
Get the bwp id of this MAC.
void DoCschedCellConfigReq(const NrMacCschedSapProvider::CschedCellConfigReqParameters ¶ms) override
Cell configuration.
void SetStartMcsDl(uint8_t v)
Set the starting value for the DL MCS.
void SetLcSched(const TypeId &type)
Set LC Scheduler Algorithm model type.
virtual BeamSymbolMap AssignULRBG(uint32_t symAvail, const ActiveUeMap &activeUl) const =0
Assign the UL RBG to the active UE, and return the distribution of symbols per beam.
NrFhSchedSapUser * m_nrFhSchedSapUser
FH Control SAP user.
NrMacSchedulerNs3(const NrMacSchedulerNs3 &other)=delete
NrMacSchedulerNs3 copy constructor (deleted)
static TypeId GetTypeId()
GetTypeId.
bool DoesFhAllocationFit(uint16_t bwpId, uint32_t mcs, uint32_t nRegs, uint8_t dlRank) const
Returns a boolean indicating whether the current allocation can fit in the available FH bandwidth (wh...
Time GetCqiTimerThreshold() const
Get the CqiTimerThreshold.
bool m_activeDlAi
Flag for activating AI for downlink.
void SetUlNotchedRbgMask(const std::vector< bool > &ulNotchedRbgsMask)
Set the notched (blank) RBGs Mask for the UL.
std::unordered_map< BeamId, std::vector< UePtrAndBufferReq >, BeamIdHash > ActiveUeMap
Map between a BeamId and a vector of UE (the UE are in that beam)
bool IsUlMcsFixed() const
Check if the MCS in UL is fixed.
std::vector< bool > GetDlNotchedRbgMask() const
Get the notched (blank) RBGs Mask for the DL.
void InstallDlAmc(const Ptr< NrAmc > &dlAmc)
Install the AMC for the DL part.
~NrMacSchedulerNs3() override
NrMacSchedulerNs3 deconstructor.
virtual void SortDlHarq(ActiveHarqMap *activeDlHarq) const
Sort the DL HARQ retransmission.
void SetFixedUlMcs(bool v)
Set if the MCS in UL is fixed (in case, it will take the starting value)
virtual uint8_t GetTpc() const =0
Returns TPC command.
void DoSchedDlRlcBufferReq(const NrMacSchedSapProvider::SchedDlRlcBufferReqParameters ¶ms) override
RLC informs of DL data.
void DoSchedDlRachInfoReq(const NrMacSchedSapProvider::SchedDlRachInfoReqParameters ¶ms) override
RACH information.
void EnableHarqReTx(bool enableFlag)
Enable HARQ ReTx function.
virtual std::shared_ptr< DciInfoElementTdma > CreateDlDci(PointInFTPlane *spoint, const std::shared_ptr< NrMacSchedulerUeInfo > &ueInfo, uint32_t maxSym) const =0
Create a DCI for the specified UE for DL data.
void DoSchedDlTriggerReq(const NrMacSchedSapProvider::SchedDlTriggerReqParameters ¶ms) override
Decide how to fill the frequency/time of a DL slot.
void SetNrFhSchedSapProvider(NrFhSchedSapProvider *s) override
void DoSchedUlMacCtrlInfoReq(const NrMacSchedSapProvider::SchedUlMacCtrlInfoReqParameters ¶ms) override
Evaluate different types of control messages (only BSR for the moment)
virtual uint8_t ScheduleDlHarq(NrMacSchedulerNs3::PointInFTPlane *startingPoint, uint8_t symAvail, const ActiveHarqMap &activeDlHarq, const std::unordered_map< uint16_t, UePtr > &ueMap, std::vector< DlHarqInfo > *dlHarqToRetransmit, const std::vector< DlHarqInfo > &dlHarqFeedback, SlotAllocInfo *slotAlloc) const
Giving the input, append to slotAlloc the allocations for the DL HARQ retransmissions.
virtual LCPtr CreateLC(const nr::LogicalChannelConfigListElement_s &config) const
Create a logical channel starting from a configuration.
uint16_t GetBandwidthInRbg() const
bool IsDlMcsFixed() const
Check if the MCS in DL is fixed.
virtual LCGPtr CreateLCG(const nr::LogicalChannelConfigListElement_s &config) const
Create a logical channel group starting from a configuration.
void DoSchedUlSrInfoReq(const NrMacSchedSapProvider::SchedUlSrInfoReqParameters ¶ms) override
Save the SR list into m_srList.
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.
uint16_t GetCellId() const
Get the cell id of this MAC.
void SetDlCtrlSyms(uint8_t v)
Set the number of DL ctrl symbols.
void SetMaxDlMcs(int8_t v)
Set the maximum index for the DL MCS.
Ptr< const NrAmc > GetUlAmc() const
Get the AMC for UL.
uint8_t GetFhControlMethod() const
Get the FH Control Method.
bool IsHarqReTxEnable() const override
Is HARQ ReTx enable function.
uint8_t GetDlCtrlSyms() const override
Retrieve the number of DL ctrl symbols configured in the scheduler.
int8_t GetMaxDlMcs() const
Get the maximum DL MCS index.
void SetCqiTimerThreshold(const Time &v)
Set the CqiTimerThreshold.
PointInFTPlane FTResources
Represent an amount of RBG/symbols that can be, or is, assigned.
void SetDlNotchedRbgMask(const std::vector< bool > &dlNotchedRbgsMask)
Set the notched (blank) RBGs Mask for the DL.
std::unique_ptr< NrMacSchedulerLC > LCPtr
Unique pointer to an instance of NrMacSchedulerLC.
std::unique_ptr< NrMacSchedulerLCG > LCGPtr
LCGPtr unique pointer to a LCG.
LteNrTddSlotType
Available TDD slot types. Ordering is important.
Calculate the hash of a BeamId.
DciFormat
Format of the DCI.
The SchedDlCqiInfoReqParameters struct.
DL HARQ information to be used when scheduling UL data.
The SchedUlCqiInfoReqParameters struct.
The SchedUlMacCtrlInfoReqParameters struct.
SR received from MAC, to pass to schedulers.
UL HARQ information to be used when scheduling UL data.
Point in the Frequency/Time plane.
PointInFTPlane(uint32_t rbg, uint8_t sym)
PointInFTPlane constructor.
uint32_t m_rbg
Represent the starting RBG.
uint8_t m_sym
Represent the starting symbol.
The SlotAllocInfo struct.
See section 4.3.4 logicalChannelConfigListElement.