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"
23class NrSchedGeneralTestCase;
24class NrMacSchedulerHarqRr;
25class NrMacSchedulerSrsDefault;
26class NrMacSchedulerLcAlgorithm;
27class NrFhSchedSapUser;
28class NrFhSchedSapProvider;
236 friend class NrTestSchedulerAiCase;
362 using HarqVectorIteratorList = std::vector<HarqVectorIterator>;
379 typedef std::unordered_map<BeamId, HarqVectorIteratorList, BeamIdHash>
ActiveHarqMap;
591 const std::unordered_map<uint16_t, UePtr>& ueMap,
592 std::vector<DlHarqInfo>* dlHarqToRetransmit,
593 const std::vector<DlHarqInfo>& dlHarqFeedback,
608 const std::unordered_map<uint16_t, UePtr>& ueMap,
609 std::vector<UlHarqInfo>* ulHarqToRetransmit,
610 const std::vector<UlHarqInfo>& ulHarqFeedback,
655 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
656 uint32_t maxSym)
const = 0;
670 const std::shared_ptr<NrMacSchedulerUeInfo>& ueInfo,
671 uint32_t maxSym)
const = 0;
737 AllocElem() =
delete;
741 AllocElem(
const AllocElem& o) =
default;
751 AllocElem(uint16_t rnti,
757 const std::vector<bool>& rbgMask)
760 m_symStart(symStart),
770 uint8_t m_symStart{0};
774 std::vector<bool> m_rbgMask;
789 SlotElem(
const SlotElem& o) =
default;
795 SlotElem(uint8_t totUlSym)
796 : m_totUlSym(totUlSym)
801 std::vector<AllocElem> m_ulAllocations;
804 void BSRReceivedFromUe(
const MacCeElement& bsr);
806 template <
typename T>
807 std::vector<T> MergeHARQ(std::vector<T>* existingFeedbacks,
808 const std::vector<T>& inFeedbacks,
809 const std::string& mode)
const;
811 void ResetExpiredHARQ(uint16_t rnti, NrMacHarqVector* harq);
813 template <
typename T>
814 void ProcessHARQFeedbacks(std::vector<T>* harqInfo,
815 const NrMacSchedulerUeInfo::GetHarqVectorFn& GetHarqVectorFn,
816 const std::string& direction)
const;
818 void ScheduleDl(
const NrMacSchedSapProvider::SchedDlTriggerReqParameters& params,
819 const std::vector<DlHarqInfo>& dlHarqInfo);
821 void ScheduleUl(
const NrMacSchedSapProvider::SchedUlTriggerReqParameters& params,
822 const std::vector<UlHarqInfo>& ulHarqInfo);
824 uint8_t AppendCtrlSym(uint8_t symStart,
825 uint8_t numSymToAllocate,
827 std::deque<VarTtiAllocInfo>* allocations)
const;
828 uint8_t PrependCtrlSym(uint8_t symStart,
829 uint8_t numSymToAllocate,
831 std::deque<VarTtiAllocInfo>* allocations)
const;
834 const NrMacSchedulerUeInfo::GetLCGFn& GetLCGFn,
835 const NrMacSchedulerUeInfo::GetHarqVectorFn& GetHarqVector,
836 const std::string& mode)
const;
838 const std::vector<DlHarqInfo>& dlHarqFeedback)
const;
840 const std::vector<UlHarqInfo>& ulHarqFeedback)
const;
842 uint8_t DoScheduleDlData(PointInFTPlane* spoint,
845 SlotAllocInfo* slotAlloc)
const;
846 uint8_t DoScheduleUlData(PointInFTPlane* spoint,
849 SlotAllocInfo* slotAlloc)
const;
850 uint8_t DoScheduleUlMsg3(PointInFTPlane* sPoint, uint8_t symAvail, SlotAllocInfo* slotAlloc);
851 void DoScheduleUlSr(PointInFTPlane* spoint,
const std::list<uint16_t>& rntiList)
const;
852 uint8_t DoScheduleDl(
const std::vector<DlHarqInfo>& dlHarqFeedback,
855 const SfnSf& dlSfnSf,
856 const SlotElem& ulAllocations,
857 SlotAllocInfo* allocInfo);
858 uint8_t DoScheduleUl(
const std::vector<UlHarqInfo>& ulHarqFeedback,
860 SlotAllocInfo* allocInfo,
862 uint8_t DoScheduleSrs(PointInFTPlane* spoint, SlotAllocInfo* allocInfo);
864 static const unsigned m_macHdrSize = 0;
865 static const uint32_t m_subHdrSize = 4;
866 static const unsigned m_rlcHdrSize = 3;
896 bool DoesFhAllocationFit(uint16_t bwpId, uint32_t mcs, uint32_t nRegs, uint8_t dlRank)
const;
903 void CallNrFhControlForMapUpdate(
904 const std::deque<VarTtiAllocInfo>& allocation,
905 const std::unordered_map<uint16_t, std::shared_ptr<NrMacSchedulerUeInfo>>& ueMap);
907 std::unordered_map<uint16_t, std::shared_ptr<NrMacSchedulerUeInfo>>
914 std::map<uint64_t, SlotElem> m_ulAllocationMap;
916 bool m_fixedMcsDl{
false};
917 bool m_fixedMcsUl{
false};
918 uint8_t m_startMcsDl{0};
919 uint8_t m_startMcsUl{0};
920 int8_t m_maxDlMcs{0};
921 Time m_cqiTimersThreshold;
923 uint8_t m_rachUlGrantMcs{0};
924 uint8_t m_ulRachBwpIndex{
927 NrMacSchedulerCQIManagement m_cqiManagement;
929 std::vector<DlHarqInfo>
930 m_dlHarqToRetransmit;
931 std::vector<UlHarqInfo>
932 m_ulHarqToRetransmit;
934 std::list<uint16_t> m_srList;
936 std::vector<struct nr::RachListElement_s> m_rachList;
938 uint16_t m_bandwidth{0};
939 uint8_t m_dlCtrlSymbols{0};
940 uint8_t m_ulCtrlSymbols{0};
941 uint8_t m_srsCtrlSymbols{0};
942 bool m_enableSrsInUlSlots{
true};
943 bool m_enableSrsInFSlots{
true};
945 std::vector<bool> m_dlNotchedRbgsMask;
946 std::vector<bool> m_ulNotchedRbgsMask;
948 std::unique_ptr<NrMacSchedulerHarqRr> m_schedHarq;
950 Ptr<NrMacSchedulerSrsDefault> m_schedulerSrs;
951 Ptr<NrMacSchedulerLcAlgorithm>
953 TypeId m_schedLcType;
955 uint32_t m_srsSlotCounter{0};
957 friend NrSchedGeneralTestCase;
959 bool m_enableHarqReTx{
true};
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.
bool IsHarqReTxEnable() const
Is HARQ ReTx enable function.
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.
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.
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.