5#define NS_LOG_APPEND_CONTEXT \
8 std::clog << " [ CellId " << GetCellId() << ", bwpId " << GetBwpId() << "] "; \
11#include "nr-gnb-mac.h"
15#include "nr-control-messages.h"
16#include "nr-mac-header-fs-ul.h"
17#include "nr-mac-header-vs.h"
18#include "nr-mac-pdu-info.h"
19#include "nr-mac-sched-sap.h"
20#include "nr-mac-scheduler.h"
21#include "nr-mac-short-bsr-ce.h"
22#include "nr-phy-mac-common.h"
23#include "nr-radio-bearer-tag.h"
26#include <ns3/spectrum-model.h>
27#include <ns3/uinteger.h>
33NS_LOG_COMPONENT_DEFINE(
"NrGnbMac");
35NS_OBJECT_ENSURE_REGISTERED(NrGnbMac);
41class NrGnbMacMemberGnbCmacSapProvider :
public NrGnbCmacSapProvider
44 NrGnbMacMemberGnbCmacSapProvider(NrGnbMac* mac);
47 void ConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth)
override;
48 void AddUe(uint16_t rnti)
override;
49 void RemoveUe(uint16_t rnti)
override;
50 void AddLc(LcInfo lcinfo, NrMacSapUser* msu)
override;
51 void ReconfigureLc(LcInfo lcinfo)
override;
52 void ReleaseLc(uint16_t rnti, uint8_t lcid)
override;
53 void UeUpdateConfigurationReq(UeConfig params)
override;
54 RachConfig GetRachConfig()
override;
55 AllocateNcRaPreambleReturnValue AllocateNcRaPreamble(uint16_t rnti)
override;
61NrGnbMacMemberGnbCmacSapProvider::NrGnbMacMemberGnbCmacSapProvider(NrGnbMac* mac)
67NrGnbMacMemberGnbCmacSapProvider::ConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth)
69 m_mac->DoConfigureMac(ulBandwidth, dlBandwidth);
73NrGnbMacMemberGnbCmacSapProvider::AddUe(uint16_t rnti)
79NrGnbMacMemberGnbCmacSapProvider::RemoveUe(uint16_t rnti)
81 m_mac->DoRemoveUe(rnti);
85NrGnbMacMemberGnbCmacSapProvider::AddLc(LcInfo lcinfo, NrMacSapUser* msu)
87 m_mac->DoAddLc(lcinfo, msu);
91NrGnbMacMemberGnbCmacSapProvider::ReconfigureLc(LcInfo lcinfo)
93 m_mac->DoReconfigureLc(lcinfo);
97NrGnbMacMemberGnbCmacSapProvider::ReleaseLc(uint16_t rnti, uint8_t lcid)
99 m_mac->DoReleaseLc(rnti, lcid);
103NrGnbMacMemberGnbCmacSapProvider::UeUpdateConfigurationReq(UeConfig params)
105 m_mac->UeUpdateConfigurationReq(params);
108NrGnbCmacSapProvider::RachConfig
109NrGnbMacMemberGnbCmacSapProvider::GetRachConfig()
111 return m_mac->DoGetRachConfig();
114NrGnbCmacSapProvider::AllocateNcRaPreambleReturnValue
115NrGnbMacMemberGnbCmacSapProvider::AllocateNcRaPreamble(uint16_t rnti)
117 return m_mac->DoAllocateNcRaPreamble(rnti);
123class NrMacGnbMemberPhySapUser :
public NrGnbPhySapUser
126 NrMacGnbMemberPhySapUser(NrGnbMac* mac);
128 void ReceivePhyPdu(Ptr<Packet> p)
override;
130 void ReceiveControlMessage(Ptr<NrControlMessage> msg)
override;
132 void SlotDlIndication(
const SfnSf&, LteNrTddSlotType)
override;
134 void SlotUlIndication(
const SfnSf&, LteNrTddSlotType)
override;
136 void SetCurrentSfn(
const SfnSf&)
override;
138 void UlCqiReport(NrMacSchedSapProvider::SchedUlCqiInfoReqParameters cqi)
override;
140 void ReceiveRachPreamble(uint32_t raId)
override;
142 void UlHarqFeedback(UlHarqInfo params)
override;
144 void BeamChangeReport(BeamId beamId, uint8_t rnti)
override;
146 uint32_t GetNumRbPerRbg()
const override;
148 std::shared_ptr<DciInfoElementTdma> GetDlCtrlDci()
const override;
149 std::shared_ptr<DciInfoElementTdma> GetUlCtrlDci()
const override;
151 uint8_t GetDlCtrlSymbols()
const override;
157NrMacGnbMemberPhySapUser::NrMacGnbMemberPhySapUser(NrGnbMac* mac)
163NrMacGnbMemberPhySapUser::ReceivePhyPdu(Ptr<Packet> p)
165 m_mac->DoReceivePhyPdu(p);
169NrMacGnbMemberPhySapUser::ReceiveControlMessage(Ptr<NrControlMessage> msg)
171 m_mac->DoReceiveControlMessage(msg);
175NrMacGnbMemberPhySapUser::SlotDlIndication(
const SfnSf& sfn, LteNrTddSlotType type)
177 m_mac->DoSlotDlIndication(sfn, type);
181NrMacGnbMemberPhySapUser::SlotUlIndication(
const SfnSf& sfn, LteNrTddSlotType type)
183 m_mac->DoSlotUlIndication(sfn, type);
187NrMacGnbMemberPhySapUser::SetCurrentSfn(
const SfnSf& sfn)
189 m_mac->SetCurrentSfn(sfn);
193NrMacGnbMemberPhySapUser::UlCqiReport(NrMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi)
195 m_mac->DoUlCqiReport(ulcqi);
199NrMacGnbMemberPhySapUser::ReceiveRachPreamble(uint32_t raId)
201 m_mac->ReceiveRachPreamble(raId);
205NrMacGnbMemberPhySapUser::UlHarqFeedback(UlHarqInfo params)
207 m_mac->DoUlHarqFeedback(params);
211NrMacGnbMemberPhySapUser::BeamChangeReport(BeamId beamId, uint8_t rnti)
213 m_mac->BeamChangeReport(beamId, rnti);
217NrMacGnbMemberPhySapUser::GetNumRbPerRbg()
const
219 return m_mac->GetNumRbPerRbg();
222std::shared_ptr<DciInfoElementTdma>
223NrMacGnbMemberPhySapUser::GetDlCtrlDci()
const
225 return m_mac->GetDlCtrlDci();
228std::shared_ptr<DciInfoElementTdma>
229NrMacGnbMemberPhySapUser::GetUlCtrlDci()
const
231 return m_mac->GetUlCtrlDci();
235NrMacGnbMemberPhySapUser::GetDlCtrlSymbols()
const
237 return m_mac->GetDlCtrlSyms();
242class NrMacMemberMacSchedSapUser :
public NrMacSchedSapUser
245 NrMacMemberMacSchedSapUser(NrGnbMac* mac);
246 void SchedConfigInd(
const struct SchedConfigIndParameters& params)
override;
247 Ptr<const SpectrumModel> GetSpectrumModel()
const override;
248 uint32_t GetNumRbPerRbg()
const override;
249 uint8_t GetNumHarqProcess()
const override;
250 uint16_t GetBwpId()
const override;
251 uint16_t GetCellId()
const override;
252 uint32_t GetSymbolsPerSlot()
const override;
253 Time GetSlotPeriod()
const override;
254 void BuildRarList(SlotAllocInfo& slotAllocInfo)
override;
260NrMacMemberMacSchedSapUser::NrMacMemberMacSchedSapUser(NrGnbMac* mac)
267NrMacMemberMacSchedSapUser::SchedConfigInd(
const struct SchedConfigIndParameters& params)
269 m_mac->DoSchedConfigIndication(params);
272Ptr<const SpectrumModel>
273NrMacMemberMacSchedSapUser::GetSpectrumModel()
const
275 return m_mac->m_phySapProvider
276 ->GetSpectrumModel();
281NrMacMemberMacSchedSapUser::GetNumRbPerRbg()
const
283 return m_mac->GetNumRbPerRbg();
287NrMacMemberMacSchedSapUser::GetNumHarqProcess()
const
289 return m_mac->GetNumHarqProcess();
293NrMacMemberMacSchedSapUser::GetBwpId()
const
295 return m_mac->GetBwpId();
299NrMacMemberMacSchedSapUser::GetCellId()
const
301 return m_mac->GetCellId();
305NrMacMemberMacSchedSapUser::GetSymbolsPerSlot()
const
307 return m_mac->m_phySapProvider->GetSymbolsPerSlot();
311NrMacMemberMacSchedSapUser::GetSlotPeriod()
const
313 return m_mac->m_phySapProvider->GetSlotPeriod();
319 m_mac->DoBuildRarList(slotAllocInfo);
322class NrMacMemberMacCschedSapUser :
public NrMacCschedSapUser
325 NrMacMemberMacCschedSapUser(NrGnbMac* mac);
327 void CschedCellConfigCnf(
328 const struct NrMacCschedSapUser::CschedCellConfigCnfParameters& params)
override;
329 void CschedUeConfigCnf(
330 const struct NrMacCschedSapUser::CschedUeConfigCnfParameters& params)
override;
331 void CschedLcConfigCnf(
332 const struct NrMacCschedSapUser::CschedLcConfigCnfParameters& params)
override;
333 void CschedLcReleaseCnf(
334 const struct NrMacCschedSapUser::CschedLcReleaseCnfParameters& params)
override;
335 void CschedUeReleaseCnf(
336 const struct NrMacCschedSapUser::CschedUeReleaseCnfParameters& params)
override;
337 void CschedUeConfigUpdateInd(
338 const struct NrMacCschedSapUser::CschedUeConfigUpdateIndParameters& params)
override;
339 void CschedCellConfigUpdateInd(
340 const struct NrMacCschedSapUser::CschedCellConfigUpdateIndParameters& params)
override;
346NrMacMemberMacCschedSapUser::NrMacMemberMacCschedSapUser(NrGnbMac* mac)
352NrMacMemberMacCschedSapUser::CschedCellConfigCnf(
const struct CschedCellConfigCnfParameters& params)
354 m_mac->DoCschedCellConfigCnf(params);
358NrMacMemberMacCschedSapUser::CschedUeConfigCnf(
const struct CschedUeConfigCnfParameters& params)
360 m_mac->DoCschedUeConfigCnf(params);
364NrMacMemberMacCschedSapUser::CschedLcConfigCnf(
const struct CschedLcConfigCnfParameters& params)
366 m_mac->DoCschedLcConfigCnf(params);
370NrMacMemberMacCschedSapUser::CschedLcReleaseCnf(
const struct CschedLcReleaseCnfParameters& params)
372 m_mac->DoCschedLcReleaseCnf(params);
376NrMacMemberMacCschedSapUser::CschedUeReleaseCnf(
const struct CschedUeReleaseCnfParameters& params)
378 m_mac->DoCschedUeReleaseCnf(params);
382NrMacMemberMacCschedSapUser::CschedUeConfigUpdateInd(
383 const struct CschedUeConfigUpdateIndParameters& params)
385 m_mac->DoCschedUeConfigUpdateInd(params);
389NrMacMemberMacCschedSapUser::CschedCellConfigUpdateInd(
390 const struct CschedCellConfigUpdateIndParameters& params)
392 m_mac->DoCschedCellConfigUpdateInd(params);
399 TypeId(
"ns3::NrGnbMac")
401 .AddConstructor<NrGnbMac>()
404 "Number of resource blocks per resource block group.",
406 MakeUintegerAccessor(&NrGnbMac::SetNumRbPerRbg, &NrGnbMac::GetNumRbPerRbg),
407 MakeUintegerChecker<uint32_t>())
410 "Number of concurrent stop-and-wait Hybrid ARQ processes per user",
412 MakeUintegerAccessor(&NrGnbMac::SetNumHarqProcess, &NrGnbMac::GetNumHarqProcess),
413 MakeUintegerChecker<uint8_t>())
414 .AddTraceSource(
"DlScheduling",
415 "Information regarding DL scheduling.",
416 MakeTraceSourceAccessor(&NrGnbMac::m_dlScheduling),
417 "ns3::NrGnbMac::DlSchedulingTracedCallback")
418 .AddTraceSource(
"UlScheduling",
419 "Information regarding UL scheduling.",
420 MakeTraceSourceAccessor(&NrGnbMac::m_ulScheduling),
421 "ns3::NrGnbMac::SchedulingTracedCallback")
422 .AddTraceSource(
"SrReq",
423 "Information regarding received scheduling request.",
424 MakeTraceSourceAccessor(&NrGnbMac::m_srCallback),
425 "ns3::NrGnbMac::SrTracedCallback")
426 .AddTraceSource(
"GnbMacRxedCtrlMsgsTrace",
427 "Gnb MAC Rxed Control Messages Traces.",
428 MakeTraceSourceAccessor(&NrGnbMac::m_macRxedCtrlMsgsTrace),
429 "ns3::NrMacRxTrace::RxedGnbMacCtrlMsgsTracedCallback")
430 .AddTraceSource(
"GnbMacTxedCtrlMsgsTrace",
431 "Gnb MAC Txed Control Messages Traces.",
432 MakeTraceSourceAccessor(&NrGnbMac::m_macTxedCtrlMsgsTrace),
433 "ns3::NrMacRxTrace::TxedGnbMacCtrlMsgsTracedCallback")
434 .AddTraceSource(
"DlHarqFeedback",
436 MakeTraceSourceAccessor(&NrGnbMac::m_dlHarqFeedback),
437 "ns3::NrGnbMac::DlHarqFeedbackTracedCallback")
438 .AddAttribute(
"NumberOfRaPreambles",
439 "How many random access preambles are available for the contention based "
442 MakeUintegerAccessor(&NrGnbMac::SetNumberOfRaPreambles),
443 MakeUintegerChecker<uint8_t>(4, 64))
444 .AddAttribute(
"PreambleTransMax",
445 "Maximum number of random access preamble transmissions",
447 MakeUintegerAccessor(&NrGnbMac::SetPreambleTransMax),
448 MakeUintegerChecker<uint8_t>(3, 200))
450 "RaResponseWindowSize",
451 "Length of the window for the reception of the random access response (RAR); "
452 "the resulting RAR timeout is this value + 5 ms",
454 MakeUintegerAccessor(&NrGnbMac::SetRaResponseWindowSize),
455 MakeUintegerChecker<uint8_t>(2, 10))
456 .AddAttribute(
"ConnEstFailCount",
457 "How many time T300 timer can expire on the same cell",
459 MakeUintegerAccessor(&NrGnbMac::SetConnEstFailCount),
460 MakeUintegerChecker<uint8_t>(1, 4));
467 NS_LOG_FUNCTION(
this);
468 m_cmacSapProvider =
new NrGnbMacMemberGnbCmacSapProvider(
this);
470 m_phySapUser =
new NrMacGnbMemberPhySapUser(
this);
471 m_macSchedSapUser =
new NrMacMemberMacSchedSapUser(
this);
472 m_macCschedSapUser =
new NrMacMemberMacCschedSapUser(
this);
483 m_dlCqiReceived.clear();
484 m_ulCqiReceived.clear();
485 m_ulCeReceived.clear();
486 m_miDlHarqProcessesPackets.clear();
487 delete m_macSapProvider;
488 delete m_cmacSapProvider;
489 delete m_macSchedSapUser;
490 delete m_macCschedSapUser;
492 delete m_ccmMacSapProvider;
496NrGnbMac::SetNumberOfRaPreambles(uint8_t numberOfRaPreambles)
498 m_numberOfRaPreambles = numberOfRaPreambles;
502NrGnbMac::SetPreambleTransMax(uint8_t preambleTransMax)
504 m_preambleTransMax = preambleTransMax;
508NrGnbMac::SetRaResponseWindowSize(uint8_t raResponseWindowSize)
510 m_raResponseWindowSize = raResponseWindowSize;
514NrGnbMac::SetConnEstFailCount(uint8_t connEstFailCount)
516 m_connEstFailCount = connEstFailCount;
522 NS_ABORT_MSG_IF(m_numRbPerRbg != -1,
"This attribute can not be reconfigured");
523 m_numRbPerRbg = rbgSize;
529 return m_numRbPerRbg;
535 m_numHarqProcess = numHarqProcess;
544 return m_numHarqProcess;
560NrGnbMac::ReceiveRachPreamble(uint32_t raId)
562 Ptr<NrRachPreambleMessage> rachMsg = Create<NrRachPreambleMessage>();
566 ++m_receivedRachPreambleCount[raId];
570NrGnbMac::GetMacSapProvider()
572 return m_macSapProvider;
576NrGnbMac::GetGnbCmacSapProvider()
578 return m_cmacSapProvider;
582NrGnbMac::SetGnbCmacSapUser(NrGnbCmacSapUser* s)
596 NS_LOG_FUNCTION(
this);
597 return m_ccmMacSapProvider;
603 NS_LOG_FUNCTION(
this);
604 m_currentSlot = sfnSf;
610 NS_LOG_FUNCTION(
this);
611 NS_LOG_LOGIC(
"Perform things on DL, slot on the air: " << sfnSf);
620 m_dlCqiReceived.begin(),
621 m_dlCqiReceived.end());
622 m_dlCqiReceived.erase(m_dlCqiReceived.begin(), m_dlCqiReceived.end());
624 m_macSchedSapProvider->SchedDlCqiInfoReq(dlCqiInfoReq);
626 for (
const auto& v : dlCqiInfoReq.
m_cqiList)
628 Ptr<NrDlCqiMessage> msg = Create<NrDlCqiMessage>();
640 if (!m_dlHarqInfoReceived.empty())
644 m_dlHarqInfoReceived.clear();
648 Ptr<NrDlHarqFeedbackMessage> msg = Create<NrDlHarqFeedbackMessage>();
649 msg->SetDlHarqFeedback(v);
655 for (
const auto& ue : m_rlcAttached)
658 params.m_rnti = ue.first;
660 params.m_transmissionMode = 0;
662 m_macCschedSapProvider->CschedUeConfigReq(params);
670NrGnbMac::ProcessRaPreambles(
const SfnSf& sfnSf)
672 NS_LOG_FUNCTION(
this);
677 for (
auto it = m_receivedRachPreambleCount.begin(); it != m_receivedRachPreambleCount.end();
680 NS_LOG_INFO(
this <<
" preambleId " <<
static_cast<uint32_t
>(it->first) <<
": " << it->second
682 NS_ASSERT(it->second != 0);
685 NS_LOG_INFO(
"preambleId " <<
static_cast<uint32_t
>(it->first) <<
": collision"
686 <<
" at: " << Simulator::Now().As(Time::MS));
693 std::map<uint8_t, NcRaPreambleInfo>::iterator jt =
694 m_allocatedNcRaPreambleMap.find(it->first);
695 if (jt != m_allocatedNcRaPreambleMap.end())
697 rnti = jt->second.rnti;
698 NS_LOG_INFO(
"preambleId previously allocated for NC based RA, RNTI ="
699 <<
static_cast<uint32_t
>(rnti) <<
", sending RAR"
700 <<
" at: " << Simulator::Now().As(Time::MS));
705 NS_LOG_INFO(
"preambleId " <<
static_cast<uint32_t
>(it->first)
706 <<
": allocated T-C-RNTI " <<
static_cast<uint32_t
>(rnti)
708 <<
" at: " << Simulator::Now().As(Time::MS));
711 NS_LOG_INFO(
"Informing MAC scheduler of the RACH preamble for "
712 <<
static_cast<uint16_t
>(it->first) <<
" in slot " << sfnSf);
713 nr::RachListElement_s rachLe;
714 rachLe.m_rnti = rnti;
715 rachLe.m_estimatedSize = 144;
716 rachInfoReqParams.
m_rachList.push_back(rachLe);
717 m_rapIdRntiMap.insert(std::pair<uint16_t, uint32_t>(rnti, it->first));
721 m_receivedRachPreambleCount.clear();
728 NS_LOG_FUNCTION(
this);
729 NS_LOG_LOGIC(
"Perform things on UL, slot on the air: " << sfnSf);
731 if (!m_receivedRachPreambleCount.empty())
733 ProcessRaPreambles(sfnSf);
738 for (
auto& i : m_ulCqiReceived)
742 m_macSchedSapProvider->SchedUlCqiInfoReq(i);
744 m_ulCqiReceived.clear();
749 params.
m_snfSf = m_currentSlot;
750 params.
m_srList.insert(params.
m_srList.begin(), m_srRntiList.begin(), m_srRntiList.end());
751 m_srRntiList.clear();
755 for (
const auto& v : params.
m_srList)
757 Ptr<NrSRMessage> msg = Create<NrSRMessage>();
764 if (!m_ulCeReceived.empty())
769 m_ulCeReceived.begin(),
770 m_ulCeReceived.end());
771 m_ulCeReceived.erase(m_ulCeReceived.begin(), m_ulCeReceived.end());
772 m_macSchedSapProvider->SchedUlMacCtrlInfoReq(ulMacReq);
776 Ptr<NrBsrMessage> msg = Create<NrBsrMessage>();
788 if (!m_ulHarqInfoReceived.empty())
792 m_ulHarqInfoReceived.clear();
799NrGnbMac::SetForwardUpCallback(Callback<
void, Ptr<Packet>> cb)
801 m_forwardUpCallback = cb;
805NrGnbMac::ReceiveBsrMessage(MacCeElement bsr)
807 NS_LOG_FUNCTION(
this);
811 nr::MacCeListElement_s mcle;
812 mcle.m_rnti = bsr.m_rnti;
813 mcle.m_macCeValue.m_bufferStatus = bsr.m_macCeValue.m_bufferStatus;
814 mcle.m_macCeValue.m_crnti = bsr.m_macCeValue.m_crnti;
815 mcle.m_macCeValue.m_phr = bsr.m_macCeValue.m_phr;
816 mcle.m_macCeValue.m_bufferStatus = bsr.m_macCeValue.m_bufferStatus;
818 if (bsr.m_macCeType == MacCeElement::BSR)
820 mcle.m_macCeType = nr::MacCeListElement_s::BSR;
822 else if (bsr.m_macCeType == MacCeElement::CRNTI)
824 mcle.m_macCeType = nr::MacCeListElement_s::CRNTI;
826 else if (bsr.m_macCeType == MacCeElement::PHR)
828 mcle.m_macCeType = nr::MacCeListElement_s::PHR;
835NrGnbMac::DoReportMacCeToScheduler(nr::MacCeListElement_s bsr)
837 NS_LOG_FUNCTION(
this);
838 NS_LOG_DEBUG(
this <<
" bsr Size " << (uint16_t)m_ulCeReceived.size());
845 mce.m_rnti = bsr.m_rnti;
846 mce.m_macCeValue.m_bufferStatus = bsr.m_macCeValue.m_bufferStatus;
847 mce.m_macCeValue.m_crnti = bsr.m_macCeValue.m_crnti;
848 mce.m_macCeValue.m_phr = bsr.m_macCeValue.m_phr;
849 mce.m_macCeValue.m_bufferStatus = bsr.m_macCeValue.m_bufferStatus;
851 if (bsr.m_macCeType == nr::MacCeListElement_s::BSR)
853 mce.m_macCeType = MacCeElement::BSR;
855 else if (bsr.m_macCeType == nr::MacCeListElement_s::CRNTI)
857 mce.m_macCeType = MacCeElement::CRNTI;
859 else if (bsr.m_macCeType == nr::MacCeListElement_s::PHR)
861 mce.m_macCeType = MacCeElement::PHR;
864 for (
const auto& v : bsr.m_macCeValue.m_bufferStatus)
869 m_ulCeReceived.push_back(
871 NS_LOG_DEBUG(
" Reported by UE " <<
static_cast<uint32_t
>(bsr.m_macCeValue.m_crnti) <<
" size "
872 << size <<
" bsr vector ize after push_back "
873 <<
static_cast<uint32_t
>(m_ulCeReceived.size()));
877NrGnbMac::DoReportSrToScheduler(uint16_t rnti)
879 NS_LOG_FUNCTION(
this);
880 m_srRntiList.push_back(rnti);
885NrGnbMac::DoReceivePhyPdu(Ptr<Packet> p)
887 NS_LOG_FUNCTION(
this);
889 NrRadioBearerTag tag;
890 p->RemovePacketTag(tag);
892 uint16_t rnti = tag.GetRnti();
893 auto rntiIt = m_rlcAttached.find(rnti);
895 NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(),
"could not find RNTI" << rnti);
898 NrMacHeaderFsUl header;
899 p->PeekHeader(header);
904 NrMacShortBsrCe bsrHeader;
905 p->RemoveHeader(bsrHeader);
910 bsr.m_macCeType = MacCeElement::BSR;
912 bsr.m_macCeValue.m_bufferStatus.resize(4);
913 bsr.m_macCeValue.m_bufferStatus[0] = bsrHeader.m_bufferSizeLevel_0;
914 bsr.m_macCeValue.m_bufferStatus[1] = bsrHeader.m_bufferSizeLevel_1;
915 bsr.m_macCeValue.m_bufferStatus[2] = bsrHeader.m_bufferSizeLevel_2;
916 bsr.m_macCeValue.m_bufferStatus[3] = bsrHeader.m_bufferSizeLevel_3;
918 ReceiveBsrMessage(bsr);
924 NrMacHeaderVs macHeader;
925 p->RemoveHeader(macHeader);
927 auto lcidIt = rntiIt->second.find(macHeader.GetLcId());
928 if (lcidIt == rntiIt->second.end())
930 NS_LOG_DEBUG(
"Discarding PDU addressed to non-existent LCID " << macHeader.GetLcId());
934 NrMacSapUser::ReceivePduParameters rxParams;
936 rxParams.lcid = macHeader.GetLcId();
937 rxParams.rnti = rnti;
939 if (rxParams.p->GetSize())
941 (*lcidIt).second->ReceivePdu(rxParams);
946NrGnbMac::GetPhySapUser()
952NrGnbMac::SetPhySapProvider(NrPhySapProvider* ptr)
954 m_phySapProvider = ptr;
958NrGnbMac::GetNrMacSchedSapUser()
960 return m_macSchedSapUser;
964NrGnbMac::SetNrMacSchedSapProvider(NrMacSchedSapProvider* ptr)
966 m_macSchedSapProvider = ptr;
970NrGnbMac::GetNrMacCschedSapUser()
972 return m_macCschedSapUser;
976NrGnbMac::SetNrMacCschedSapProvider(NrMacCschedSapProvider* ptr)
978 m_macCschedSapProvider = ptr;
982NrGnbMac::DoUlCqiReport(NrMacSchedSapProvider::SchedUlCqiInfoReqParameters ulcqi)
984 if (ulcqi.m_ulCqi.m_type == UlCqiInfo::PUSCH)
986 NS_LOG_DEBUG(
this <<
" gNB rxed an PUSCH UL-CQI");
988 else if (ulcqi.m_ulCqi.m_type == UlCqiInfo::SRS)
990 NS_LOG_DEBUG(
this <<
" gNB rxed an SRS UL-CQI");
992 NS_LOG_INFO(
"*** UL CQI report SINR "
994 <<
" slot: " << m_currentSlot);
997 m_ulCqiReceived.push_back(ulcqi);
1001NrGnbMac::DoReceiveControlMessage(Ptr<NrControlMessage> msg)
1003 NS_LOG_FUNCTION(
this << msg);
1005 switch (msg->GetMessageType())
1009 Ptr<NrSRMessage> sr = DynamicCast<NrSRMessage>(msg);
1014 Ptr<NrDlCqiMessage> cqi = DynamicCast<NrDlCqiMessage>(msg);
1015 DlCqiInfo cqiElement = cqi->GetDlCqi();
1016 NS_ASSERT(cqiElement.m_rnti != 0);
1017 m_dlCqiReceived.push_back(cqiElement);
1021 Ptr<NrDlHarqFeedbackMessage> dlharq = DynamicCast<NrDlHarqFeedbackMessage>(msg);
1022 DoDlHarqFeedback(dlharq->GetDlHarqFeedback());
1026 NS_LOG_WARN(
"Control message not supported/expected");
1031NrGnbMac::DoUlHarqFeedback(
const UlHarqInfo& params)
1033 NS_LOG_FUNCTION(
this);
1034 m_ulHarqInfoReceived.push_back(params);
1038NrGnbMac::DoDlHarqFeedback(
const DlHarqInfo& params)
1040 NS_LOG_FUNCTION(
this);
1042 std::unordered_map<uint16_t, NrDlHarqProcessesBuffer_t>::iterator it =
1043 m_miDlHarqProcessesPackets.find(params.m_rnti);
1044 NS_ASSERT(it != m_miDlHarqProcessesPackets.end());
1046 if (params.m_harqStatus == DlHarqInfo::ACK)
1049 Ptr<PacketBurst> emptyBuf = CreateObject<PacketBurst>();
1050 (*it).second.at(params.m_harqProcessId).m_pktBurst = emptyBuf;
1051 NS_LOG_DEBUG(
this <<
" HARQ-ACK UE RNTI" << params.m_rnti <<
" HARQ Process ID "
1052 << (uint16_t)params.m_harqProcessId);
1056 NS_LOG_DEBUG(
this <<
" HARQ-NACK UE RNTI" << params.m_rnti <<
" HARQ Process ID "
1057 << (uint16_t)params.m_harqProcessId);
1061 NS_FATAL_ERROR(
" HARQ functionality not implemented");
1065 m_dlHarqFeedback(params);
1067 m_dlHarqInfoReceived.push_back(params);
1071NrGnbMac::DoReportBufferStatus(NrMacSapProvider::ReportBufferStatusParameters params)
1073 NS_LOG_FUNCTION(
this);
1074 NrMacSchedSapProvider::SchedDlRlcBufferReqParameters schedParams;
1075 schedParams.m_logicalChannelIdentity = params.lcid;
1076 schedParams.m_rlcRetransmissionHolDelay = params.retxQueueHolDelay;
1077 schedParams.m_rlcRetransmissionQueueSize = params.retxQueueSize;
1078 schedParams.m_rlcStatusPduSize = params.statusPduSize;
1079 schedParams.m_rlcTransmissionQueueHolDelay = params.txQueueHolDelay;
1080 schedParams.m_rlcTransmissionQueueSize = params.txQueueSize;
1081 schedParams.m_rnti = params.rnti;
1083 NS_LOG_INFO(
"Reporting RLC buffer status update to MAC Scheduler for RNTI="
1084 << params.rnti <<
", LCID=" << (uint32_t)params.lcid <<
", Transmission Queue Size="
1085 << params.txQueueSize <<
", Transmission Queue HOL Delay=" << params.txQueueHolDelay
1086 <<
", Retransmission Queue Size=" << params.retxQueueSize
1087 <<
", Retransmission Queue HOL delay=" << params.retxQueueHolDelay
1088 <<
", PDU Size=" << params.statusPduSize);
1090 m_macSchedSapProvider->SchedDlRlcBufferReq(schedParams);
1095NrGnbMac::DoTransmitPdu(NrMacSapProvider::TransmitPduParameters params)
1098 uint32_t tbMapKey = ((params.rnti & 0xFFFF) << 8) | (params.harqProcessId & 0xFF);
1099 auto harqIt = m_miDlHarqProcessesPackets.find(params.rnti);
1100 auto it = m_macPduMap.find(tbMapKey);
1102 if (it == m_macPduMap.end())
1104 NS_FATAL_ERROR(
"No MAC PDU storage element found for this TB UID/RNTI");
1107 NrMacHeaderVs header;
1108 header.SetLcId(params.lcid);
1109 header.SetSize(params.pdu->GetSize());
1111 params.pdu->AddHeader(header);
1113 NrRadioBearerTag bearerTag(params.rnti, params.lcid, 0);
1114 params.pdu->AddPacketTag(bearerTag);
1116 harqIt->second.at(params.harqProcessId).m_pktBurst->AddPacket(params.pdu);
1118 it->second.m_used += params.pdu->GetSize();
1119 NS_ASSERT_MSG(it->second.m_dci->m_tbSize >= it->second.m_used,
1120 "DCI OF " << it->second.m_dci->m_tbSize <<
" total used " << it->second.m_used);
1122 NS_LOG_INFO(
"Sending MAC PDU to PHY Layer");
1125 it->second.m_dci->m_symStart,
1130NrGnbMac::DoBuildRarList(SlotAllocInfo& slotAllocInfo)
1132 NS_LOG_FUNCTION(
this);
1134 if (!HasMsg3Allocations(slotAllocInfo))
1139 for (
const auto& varTti : slotAllocInfo.m_varTtiAllocInfo)
1143 NrBuildRarListElement_s rarElement;
1144 rarElement.ulMsg3Dci = varTti.m_dci;
1146 auto itRaPreambleId = m_rapIdRntiMap.find(rarElement.ulMsg3Dci->m_rnti);
1147 NS_ABORT_IF(itRaPreambleId == m_rapIdRntiMap.end());
1148 NS_LOG_INFO(
"In slot " << m_currentSlot
1149 <<
" gNB MAC pass to PHY the RAR message for RNTI "
1150 << rarElement.ulMsg3Dci->m_rnti <<
" RA preamble ID "
1151 << itRaPreambleId->second <<
" at:" << Simulator::Now());
1152 rarElement.raPreambleId = itRaPreambleId->second;
1154 slotAllocInfo.m_buildRarList.push_back(rarElement);
1158 if (!slotAllocInfo.m_buildRarList.empty())
1160 m_rapIdRntiMap.clear();
1161 NS_LOG_DEBUG(
"Sending RAR message to UE.");
1165 NS_LOG_DEBUG(
"No RAR messages to be sent.");
1170NrGnbMac::HasMsg3Allocations(
const SlotAllocInfo& slotInfo)
1172 for (
const auto& varTti : slotInfo.m_varTtiAllocInfo)
1183NrGnbMac::DoSchedConfigIndication(NrMacSchedSapUser::SchedConfigIndParameters ind)
1185 NS_ASSERT(ind.m_sfnSf.GetNumerology() == m_currentSlot.
GetNumerology());
1186 std::stable_sort(ind.m_slotAllocInfo.m_varTtiAllocInfo.begin(),
1187 ind.m_slotAllocInfo.m_varTtiAllocInfo.end());
1189 if (ind.m_slotAllocInfo.ContainsDataAllocation())
1191 NS_LOG_INFO(
"New scheduled allocation: " << ind.m_slotAllocInfo);
1195 for (
auto& varTtiAllocInfo : ind.m_slotAllocInfo.m_varTtiAllocInfo)
1200 uint16_t rnti = varTtiAllocInfo.m_dci->m_rnti;
1201 auto rntiIt = m_rlcAttached.find(rnti);
1202 NS_ABORT_MSG_IF(rntiIt == m_rlcAttached.end(),
1203 "Scheduled UE " << rnti <<
" not attached");
1206 auto dciElem = varTtiAllocInfo.m_dci;
1207 uint8_t harqId = dciElem->m_harqProcess;
1209 if (ind.m_slotAllocInfo.ContainsDataAllocation())
1211 NS_LOG_INFO(
"New scheduled data TX in DL for HARQ Process ID: "
1212 << (uint32_t)harqId <<
", Var. TTI from symbol "
1213 << (uint32_t)varTtiAllocInfo.m_dci->m_symStart <<
" to "
1214 << (uint32_t)varTtiAllocInfo.m_dci->m_symStart +
1215 (uint32_t)varTtiAllocInfo.m_dci->m_numSym
1217 <<
" TB of size " << varTtiAllocInfo.m_dci->m_tbSize <<
" with MCS "
1218 << varTtiAllocInfo.m_dci->m_mcs);
1222 if (dciElem->m_ndi == 1)
1225 std::vector<RlcPduInfo>& rlcPduInfo = varTtiAllocInfo.m_rlcPduInfo;
1226 NS_ASSERT(!rlcPduInfo.empty());
1227 NrMacPduInfo macPduInfo(ind.m_sfnSf, dciElem);
1229 uint32_t tbMapKey = ((rnti & 0xFFFF) << 8) | (harqId & 0xFF);
1230 std::pair<std::unordered_map<uint32_t, struct NrMacPduInfo>::iterator,
bool>
1231 mapRet = m_macPduMap.insert(
1232 std::pair<uint32_t, struct NrMacPduInfo>(tbMapKey, macPduInfo));
1235 NS_FATAL_ERROR(
"MAC PDU map element exists");
1239 std::unordered_map<uint16_t, NrDlHarqProcessesBuffer_t>::iterator harqIt =
1240 m_miDlHarqProcessesPackets.find(rnti);
1241 NS_ASSERT(harqIt != m_miDlHarqProcessesPackets.end());
1242 Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
1243 harqIt->second.at(harqId).m_pktBurst = pb;
1244 harqIt->second.at(harqId).m_lcidList.clear();
1246 std::unordered_map<uint32_t, struct NrMacPduInfo>::iterator pduMapIt = mapRet.first;
1248 for (
auto& j : rlcPduInfo)
1250 NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(),
"could not find RNTI" << rnti);
1251 std::unordered_map<uint8_t, NrMacSapUser*>::iterator lcidIt =
1252 rntiIt->second.find(j.m_lcid);
1253 NS_ASSERT_MSG(lcidIt != rntiIt->second.end(),
1254 "could not find LCID" << std::to_string(j.m_lcid));
1255 NS_LOG_INFO(
"Notifying RLC of TX opportunity for HARQ Process ID "
1256 << (
unsigned int)harqId <<
" LC ID " << std::to_string(+j.m_lcid)
1257 << (
unsigned int)j.m_size);
1259 (*lcidIt).second->NotifyTxOpportunity(
1260 NrMacSapUser::TxOpportunityParameters((j.m_size),
1266 harqIt->second.at(harqId).m_lcidList.push_back(j.m_lcid);
1269 m_macPduMap.erase(pduMapIt);
1272 traceInfo.
m_frameNum = ind.m_sfnSf.GetFrame();
1274 traceInfo.
m_slotNum = ind.m_sfnSf.GetSlot();
1276 traceInfo.
m_numSym = dciElem->m_numSym;
1277 traceInfo.
m_tbSize = dciElem->m_tbSize;
1278 traceInfo.
m_mcs = dciElem->m_mcs;
1279 traceInfo.
m_rnti = dciElem->m_rnti;
1281 traceInfo.
m_ndi = dciElem->m_ndi;
1282 traceInfo.
m_rv = dciElem->m_rv;
1283 traceInfo.
m_harqId = dciElem->m_harqProcess;
1284 m_dlScheduling(traceInfo);
1288 NS_LOG_INFO(
"DL retransmission");
1289 if (dciElem->m_tbSize > 0)
1291 std::unordered_map<uint16_t, NrDlHarqProcessesBuffer_t>::iterator it =
1292 m_miDlHarqProcessesPackets.find(rnti);
1293 NS_ASSERT(it != m_miDlHarqProcessesPackets.end());
1294 Ptr<PacketBurst> pb = it->second.at(harqId).m_pktBurst;
1295 for (std::list<Ptr<Packet>>::const_iterator j = pb->Begin(); j != pb->End();
1298 Ptr<Packet> pkt = (*j)->Copy();
1301 dciElem->m_symStart,
1313 auto dciElem = varTtiAllocInfo.m_dci;
1315 traceInfo.
m_frameNum = ind.m_sfnSf.GetFrame();
1317 traceInfo.
m_slotNum = ind.m_sfnSf.GetSlot();
1319 traceInfo.
m_numSym = dciElem->m_numSym;
1320 traceInfo.
m_tbSize = dciElem->m_tbSize;
1321 traceInfo.
m_mcs = dciElem->m_mcs;
1322 traceInfo.
m_rnti = dciElem->m_rnti;
1324 traceInfo.
m_ndi = dciElem->m_ndi;
1325 traceInfo.
m_rv = dciElem->m_rv;
1326 traceInfo.
m_harqId = dciElem->m_harqProcess;
1327 m_ulScheduling(traceInfo);
1337NrGnbMac::DoConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth)
1339 NS_LOG_FUNCTION(
this);
1344 m_bandwidthInRbg = bw_in_rbg;
1346 NS_LOG_DEBUG(
"Mac configured. Attributes:"
1348 <<
"\t NumRbPerRbg: " << m_numRbPerRbg << std::endl
1349 <<
"\t NumHarqProcess: " << +m_numHarqProcess << std::endl
1350 <<
"Physical properties: " << std::endl
1351 <<
"\t Bandwidth provided: " << ulBandwidth * 1000 * 100 <<
" Hz" << std::endl
1352 <<
"\t that corresponds to " << bw_in_rbg <<
" RBG, as we have "
1356 NrMacCschedSapProvider::CschedCellConfigReqParameters params;
1358 params.m_ulBandwidth = m_bandwidthInRbg;
1359 params.m_dlBandwidth = m_bandwidthInRbg;
1368 params.m_rnti = rnti;
1370 params.m_transmissionMode =
1372 m_macCschedSapProvider->CschedUeConfigReq(params);
1378 if (m_phySapProvider)
1380 return m_phySapProvider->
GetBwpId();
1391 if (m_phySapProvider)
1401std::shared_ptr<DciInfoElementTdma>
1404 NS_LOG_FUNCTION(
this);
1407 NS_ASSERT(bwInRbg > 0);
1408 std::vector<uint8_t> rbgBitmask(bwInRbg, 1);
1410 return std::make_shared<DciInfoElementTdma>(0,
1417std::shared_ptr<DciInfoElementTdma>
1420 NS_LOG_FUNCTION(
this);
1422 NS_ASSERT(m_bandwidthInRbg > 0);
1423 std::vector<uint8_t> rbgBitmask(m_bandwidthInRbg, 1);
1425 return std::make_shared<DciInfoElementTdma>(0,
1433NrGnbMac::DoAddUe(uint16_t rnti)
1435 NS_LOG_FUNCTION(
this <<
" rnti=" << rnti);
1436 std::unordered_map<uint8_t, NrMacSapUser*> empty;
1437 std::pair<std::unordered_map<uint16_t, std::unordered_map<uint8_t, NrMacSapUser*>>::iterator,
1439 ret = m_rlcAttached.insert(
1440 std::pair<uint16_t, std::unordered_map<uint8_t, NrMacSapUser*>>(rnti, empty));
1441 NS_ASSERT_MSG(ret.second,
"element already present, RNTI already existed");
1444 params.m_rnti = rnti;
1446 params.m_transmissionMode =
1448 m_macCschedSapProvider->CschedUeConfigReq(params);
1451 NrDlHarqProcessesBuffer_t buf;
1453 buf.resize(harqNum);
1454 for (uint16_t i = 0; i < harqNum; i++)
1456 Ptr<PacketBurst> pb = CreateObject<PacketBurst>();
1457 buf.at(i).m_pktBurst = pb;
1459 m_miDlHarqProcessesPackets.insert(std::pair<uint16_t, NrDlHarqProcessesBuffer_t>(rnti, buf));
1463NrGnbMac::DoRemoveUe(uint16_t rnti)
1465 NS_LOG_FUNCTION(
this <<
" rnti=" << rnti);
1466 NrMacCschedSapProvider::CschedUeReleaseReqParameters params;
1467 params.m_rnti = rnti;
1468 m_macCschedSapProvider->CschedUeReleaseReq(params);
1469 m_miDlHarqProcessesPackets.erase(rnti);
1470 m_rlcAttached.erase(rnti);
1473 auto jt = m_allocatedNcRaPreambleMap.begin();
1474 while (jt != m_allocatedNcRaPreambleMap.end())
1476 if (jt->second.rnti == rnti)
1478 auto it = m_receivedRachPreambleCount.find(jt->first);
1479 if (it != m_receivedRachPreambleCount.end())
1481 m_receivedRachPreambleCount.erase(it->first);
1483 jt = m_allocatedNcRaPreambleMap.erase(jt);
1493NrGnbMac::DoAddLc(NrGnbCmacSapProvider::LcInfo lcinfo, NrMacSapUser* msu)
1495 NS_LOG_FUNCTION(
this);
1496 NS_LOG_FUNCTION(
this);
1498 std::unordered_map<uint16_t, std::unordered_map<uint8_t, NrMacSapUser*>>::iterator rntiIt =
1499 m_rlcAttached.find(lcinfo.rnti);
1500 NS_ASSERT_MSG(rntiIt != m_rlcAttached.end(),
"RNTI not found");
1501 std::unordered_map<uint8_t, NrMacSapUser*>::iterator lcidIt = rntiIt->second.find(lcinfo.lcId);
1502 if (lcidIt == rntiIt->second.end())
1504 rntiIt->second.insert(std::pair<uint8_t, NrMacSapUser*>(lcinfo.lcId, msu));
1508 NS_LOG_ERROR(
"LC already exists");
1515 if (lcinfo.lcId != 0)
1517 struct NrMacCschedSapProvider::CschedLcConfigReqParameters params;
1518 params.m_rnti = lcinfo.rnti;
1519 params.m_reconfigureFlag =
false;
1521 struct nr::LogicalChannelConfigListElement_s lccle;
1522 lccle.m_logicalChannelIdentity = lcinfo.lcId;
1523 lccle.m_logicalChannelGroup = lcinfo.lcGroup;
1524 lccle.m_direction = nr::LogicalChannelConfigListElement_s::DIR_BOTH;
1525 lccle.m_qci = lcinfo.qci;
1526 lccle.m_eRabMaximulBitrateUl = lcinfo.mbrUl;
1527 lccle.m_eRabMaximulBitrateDl = lcinfo.mbrDl;
1528 lccle.m_eRabGuaranteedBitrateUl = lcinfo.gbrUl;
1529 lccle.m_eRabGuaranteedBitrateDl = lcinfo.gbrDl;
1532 lcinfo.resourceType);
1534 params.m_logicalChannelConfigList.push_back(lccle);
1536 m_macCschedSapProvider->CschedLcConfigReq(params);
1541NrGnbMac::DoReconfigureLc(NrGnbCmacSapProvider::LcInfo lcinfo)
1543 NS_FATAL_ERROR(
"not implemented");
1547NrGnbMac::DoReleaseLc(uint16_t rnti, uint8_t lcid)
1550 std::unordered_map<uint16_t, std::unordered_map<uint8_t, NrMacSapUser*>>::iterator rntiIt =
1551 m_rlcAttached.find(rnti);
1552 rntiIt->second.erase(lcid);
1554 struct NrMacCschedSapProvider::CschedLcReleaseReqParameters params;
1555 params.m_rnti = rnti;
1556 params.m_logicalChannelIdentity.push_back(lcid);
1557 m_macCschedSapProvider->CschedLcReleaseReq(params);
1561NrGnbMac::UeUpdateConfigurationReq(NrGnbCmacSapProvider::UeConfig params)
1563 NS_LOG_FUNCTION(
this);
1565 NrMacCschedSapProvider::CschedUeConfigReqParameters req;
1566 req.m_rnti = params.m_rnti;
1567 req.m_transmissionMode = params.m_transmissionMode;
1568 req.m_beamId = m_phySapProvider->
GetBeamId(params.m_rnti);
1569 req.m_reconfigureFlag =
true;
1570 m_macCschedSapProvider->CschedUeConfigReq(req);
1573NrGnbCmacSapProvider::RachConfig
1574NrGnbMac::DoGetRachConfig()
1576 NS_LOG_FUNCTION(
this);
1577 struct NrGnbCmacSapProvider::RachConfig rc;
1578 rc.numberOfRaPreambles = m_numberOfRaPreambles;
1579 rc.preambleTransMax = m_preambleTransMax;
1580 rc.raResponseWindowSize = m_raResponseWindowSize;
1581 rc.connEstFailCount = m_connEstFailCount;
1585NrGnbCmacSapProvider::AllocateNcRaPreambleReturnValue
1586NrGnbMac::DoAllocateNcRaPreamble(uint16_t rnti)
1590 for (preambleId = m_numberOfRaPreambles; preambleId < 64; ++preambleId)
1592 std::map<uint8_t, NcRaPreambleInfo>::iterator it =
1593 m_allocatedNcRaPreambleMap.find(preambleId);
1605 if ((it != m_allocatedNcRaPreambleMap.end()) && (it->second.expiryTime < Simulator::Now()))
1614 if ((it == m_allocatedNcRaPreambleMap.end()) || (it->second.expiryTime < Simulator::Now()))
1617 NcRaPreambleInfo preambleInfo;
1618 uint32_t expiryIntervalMs =
1619 (uint32_t)m_preambleTransMax * ((uint32_t)m_raResponseWindowSize + 5);
1621 preambleInfo.expiryTime = Simulator::Now() + MilliSeconds(expiryIntervalMs);
1622 preambleInfo.rnti = rnti;
1623 NS_LOG_INFO(
"allocated preamble for NC based RA: preamble "
1624 << preambleId <<
", RNTI " << preambleInfo.rnti <<
", exiryTime "
1625 << preambleInfo.expiryTime);
1626 m_allocatedNcRaPreambleMap[preambleId] =
1631 NrGnbCmacSapProvider::AllocateNcRaPreambleReturnValue ret;
1635 ret.raPreambleId = preambleId;
1636 ret.raPrachMaskIndex = 0;
1641 ret.raPreambleId = 0;
1642 ret.raPrachMaskIndex = 0;
1652NrGnbMac::DoCschedCellConfigCnf(NrMacCschedSapUser::CschedCellConfigCnfParameters params)
1654 NS_LOG_FUNCTION(
this);
1658NrGnbMac::DoCschedUeConfigCnf(NrMacCschedSapUser::CschedUeConfigCnfParameters params)
1660 NS_LOG_FUNCTION(
this);
1664NrGnbMac::DoCschedLcConfigCnf(NrMacCschedSapUser::CschedLcConfigCnfParameters params)
1666 NS_LOG_FUNCTION(
this);
1672NrGnbMac::DoCschedLcReleaseCnf(NrMacCschedSapUser::CschedLcReleaseCnfParameters params)
1674 NS_LOG_FUNCTION(
this);
1678NrGnbMac::DoCschedUeReleaseCnf(NrMacCschedSapUser::CschedUeReleaseCnfParameters params)
1680 NS_LOG_FUNCTION(
this);
1684NrGnbMac::DoCschedUeConfigUpdateInd(NrMacCschedSapUser::CschedUeConfigUpdateIndParameters params)
1686 NS_LOG_FUNCTION(
this);
1688 NrGnbCmacSapUser::UeConfig ueConfigUpdate;
1689 ueConfigUpdate.m_rnti = params.m_rnti;
1690 ueConfigUpdate.m_transmissionMode = params.m_transmissionMode;
1695NrGnbMac::DoCschedCellConfigUpdateInd(
1696 NrMacCschedSapUser::CschedCellConfigUpdateIndParameters params)
1698 NS_LOG_FUNCTION(
this);
Representation of a beam id.
GnbMacMemberNrMacSapProvider class.
MemberNrCcmMacSapProvider class.
Service Access Point (SAP) offered by the component carrier manager (CCM) by MAC to CCM.
Service Access Point (SAP) offered by MAC to the component carrier manager (CCM).
virtual void UlReceiveSr(uint16_t rnti, uint8_t componentCarrierId)=0
The MAC received a SR.
virtual void UlReceiveMacCe(nr::MacCeListElement_s bsr, uint8_t componentCarrierId)=0
When the Primary Component carrier receive a buffer status report it is sent to the CCM.
@ DL_HARQ
DL HARQ feedback.
@ SR
Scheduling Request: asking for space.
virtual void RrcConfigurationUpdateInd(UeConfig params)=0
virtual uint16_t AllocateTemporaryCellRnti()=0
virtual bool IsRandomAccessCompleted(uint16_t rnti)=0
Is random access completed function.
virtual uint8_t GetUlCtrlSyms() const
Retrieve the number of UL ctrl symbols configured in the scheduler.
uint8_t GetNumHarqProcess() const
NrCcmMacSapProvider * GetNrCcmMacSapProvider()
Get the gNB-ComponentCarrierManager SAP User.
virtual void DoSlotDlIndication(const SfnSf &sfnSf, LteNrTddSlotType type)
Perform DL scheduling decision for the indicated slot.
std::shared_ptr< DciInfoElementTdma > GetUlCtrlDci() const
Get a DCI for the UL CTRL symbol.
uint16_t GetBwpId() const
Get the bwp id of this MAC.
void SetNumRbPerRbg(uint32_t rbgSize)
Sets the number of RBs per RBG. Currently it can be configured by the user, while in the future it wi...
void SetNumHarqProcess(uint8_t numHarqProcess)
Sets the number of HARQ processes.
void SetNrCcmMacSapUser(NrCcmMacSapUser *s)
Set the ComponentCarrierManager SAP user.
~NrGnbMac() override
~NrGnbMac
std::shared_ptr< DciInfoElementTdma > GetDlCtrlDci() const
Get a DCI for the DL CTRL symbol.
void BeamChangeReport(BeamId beamId, uint8_t rnti)
A Beam for a user has changed.
uint16_t GetCellId() const
Get the cell id of this MAC.
uint32_t GetNumRbPerRbg() const
virtual void SetCurrentSfn(const SfnSf &sfn)
Set the current sfn.
virtual void DoSlotUlIndication(const SfnSf &sfnSf, LteNrTddSlotType type)
Perform UL scheduling decision for the indicated slot.
virtual uint8_t GetDlCtrlSyms() const
Retrieve the number of DL ctrl symbols configured in the scheduler.
void DoDispose() override
DoDispose method inherited from Object.
virtual void CschedCellConfigReq(const struct CschedCellConfigReqParameters ¶ms)=0
CSCHED_CELL_CONFIG_REQ.
virtual void SchedDlRachInfoReq(const SchedDlRachInfoReqParameters ¶ms)=0
SCHED_DL_RACH_INFO_REQ.
virtual uint8_t GetDlCtrlSyms() const =0
Retrieve the number of DL ctrl symbols configured in the scheduler.
virtual void SchedUlSrInfoReq(const SchedUlSrInfoReqParameters ¶ms)=0
Provides scheduling request reception information to the scheduler.
virtual void SchedUlTriggerReq(const struct SchedUlTriggerReqParameters ¶ms)=0
Starts the UL MAC scheduler for this subframe.
virtual void SchedDlTriggerReq(const struct SchedDlTriggerReqParameters ¶ms)=0
Starts the DL MAC scheduler for this subframe.
virtual uint8_t GetUlCtrlSyms() const =0
Retrieve the number of UL ctrl symbols configured in the scheduler.
virtual BeamId GetBeamId(uint8_t rnti) const =0
Get the beam ID from the RNTI specified. Not in any standard.
virtual void SendMacPdu(const Ptr< Packet > &p, const SfnSf &sfn, uint8_t symStart, uint16_t rnti)=0
Send a Mac PDU.
virtual uint16_t GetCellId() const =0
Retrieve the cell id.
virtual uint32_t GetRbNum() const =0
Retrieve the number of resource blocks.
virtual void SetSlotAllocInfo(const SlotAllocInfo &slotAllocInfo)=0
Set a SlotAllocInfo inside the PHY allocations.
virtual uint16_t GetBwpId() const =0
Retrieve the bandwidth part id.
uint8_t GetNumerology() const
GetNumerology.
static double fpS11dot3toDouble(uint16_t val)
LteNrTddSlotType
Available TDD slot types. Ordering is important.
NrSchedulingCallbackInfo structure.
uint32_t m_tbSize
TB size.
uint8_t m_ndi
New data indicator.
uint8_t m_symStart
starting symbol index
uint8_t m_subframeNum
subframe number
uint16_t m_frameNum
frame number
uint8_t m_bwpId
Bandwidth Part ID.
uint16_t m_slotNum
slot number
uint8_t m_numSym
number of symbols
@ CTRL
Used for DL/UL CTRL.
@ SRS
Used for SRS (it would be like DCI format 2_3)
enum ns3::DlHarqInfo::HarqStatus NACK
HARQ status.
The SchedDlCqiInfoReqParameters struct.
std::vector< struct DlCqiInfo > m_cqiList
cqi list
std::vector< struct nr::RachListElement_s > m_rachList
RACH list.
DL HARQ information to be used when scheduling UL data.
std::vector< struct DlHarqInfo > m_dlHarqInfoList
DL HARQ info list.
LteNrTddSlotType m_slotType
Indicate the type of slot requested.
The SchedUlMacCtrlInfoReqParameters struct.
std::vector< struct MacCeElement > m_macCeList
MacCeElement list.
SR received from MAC, to pass to schedulers.
std::vector< uint16_t > m_srList
List of RNTI which asked for a SR.
SfnSf m_snfSf
SnfSf in which the sr where received.
UL HARQ information to be used when scheduling UL data.
std::vector< struct UlHarqInfo > m_ulHarqInfoList
UL HARQ info list.
LteNrTddSlotType m_slotType
Indicate the type of slot requested.
The SlotAllocInfo struct.
QosBearerType_e
QosBearerType enum.