5G-LENA nr-v3.0-32-g83aee33
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
nr-gnb-mac.h
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
3// Copyright (c) 2019 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4//
5// SPDX-License-Identifier: GPL-2.0-only
6
7#ifndef NR_ENB_MAC_H
8#define NR_ENB_MAC_H
9
10#include "nr-mac-pdu-info.h"
11#include "nr-mac-sched-sap.h"
12#include "nr-mac-scheduler.h"
13#include "nr-phy-mac-common.h"
14#include "nr-phy-sap.h"
15
16#include <ns3/lte-ccm-mac-sap.h>
17#include <ns3/lte-enb-cmac-sap.h>
18#include <ns3/lte-mac-sap.h>
19#include <ns3/traced-callback.h>
20
21namespace ns3
22{
23
24class NrControlMessage;
25class NrRarMessage;
26class BeamId;
27
49class NrGnbMac : public Object
50{
51 friend class NrGnbMacMemberEnbCmacSapProvider;
52 friend class NrMacEnbMemberPhySapUser;
53 friend class NrMacMemberMacCschedSapUser;
54 friend class NrMacMemberMacSchedSapUser;
55 friend class EnbMacMemberLteMacSapProvider<NrGnbMac>;
56 friend class MemberLteCcmMacSapProvider<NrGnbMac>;
57
58 public:
63 static TypeId GetTypeId();
67 NrGnbMac();
71 ~NrGnbMac() override;
72
79 void SetNumRbPerRbg(uint32_t rbgSize);
80
90 uint32_t GetNumRbPerRbg() const;
91
96 void SetNumHarqProcess(uint8_t numHarqProcess);
97
101 uint8_t GetNumHarqProcess() const;
102
107 virtual uint8_t GetDlCtrlSyms() const;
108
113 virtual uint8_t GetUlCtrlSyms() const;
114
124 virtual void DoSlotDlIndication(const SfnSf& sfnSf, LteNrTddSlotType type);
125
135 virtual void DoSlotUlIndication(const SfnSf& sfnSf, LteNrTddSlotType type);
136
141 virtual void SetCurrentSfn(const SfnSf& sfn);
142
143 void SetForwardUpCallback(Callback<void, Ptr<Packet>> cb);
144
145 NrGnbPhySapUser* GetPhySapUser();
146 void SetPhySapProvider(NrPhySapProvider* ptr);
147
148 NrMacSchedSapUser* GetNrMacSchedSapUser();
149 void SetNrMacSchedSapProvider(NrMacSchedSapProvider* ptr);
150
151 NrMacCschedSapUser* GetNrMacCschedSapUser();
152 void SetNrMacCschedSapProvider(NrMacCschedSapProvider* ptr);
153
154 LteMacSapProvider* GetMacSapProvider();
155 LteEnbCmacSapProvider* GetEnbCmacSapProvider();
156
157 void SetEnbCmacSapUser(LteEnbCmacSapUser* s);
158
163 LteCcmMacSapProvider* GetLteCcmMacSapProvider();
164
169 void SetLteCcmMacSapUser(LteCcmMacSapUser* s);
170
176 void BeamChangeReport(BeamId beamId, uint8_t rnti);
177
192 typedef void (*SchedulingTracedCallback)(uint32_t frameNum,
193 uint32_t subframeNum,
194 uint32_t slotNum,
195 uint8_t symStart,
196 uint8_t numSym,
197 uint32_t tbSize,
198 uint32_t mcs,
199 uint32_t rnti,
200 uint8_t bwpId);
201
208 typedef void (*SrTracedCallback)(const uint8_t bwpId, const uint16_t rnti);
209
222 typedef void (*RxedGnbMacCtrlMsgsTracedCallback)(const SfnSf sfn,
223 const uint16_t nodeId,
224 const uint16_t rnti,
225 const uint8_t bwpId,
226 Ptr<NrControlMessage>);
227
240 typedef void (*TxedGnbMacCtrlMsgsTracedCallback)(const SfnSf sfn,
241 const uint16_t nodeId,
242 const uint16_t rnti,
243 const uint8_t bwpId,
244 Ptr<NrControlMessage>);
245
246 protected:
250 void DoDispose() override;
255 uint16_t GetBwpId() const;
256
261 uint16_t GetCellId() const;
262
267 std::shared_ptr<DciInfoElementTdma> GetDlCtrlDci() const;
268
273 std::shared_ptr<DciInfoElementTdma> GetUlCtrlDci() const;
274
275 private:
276 void ReceiveRachPreamble(uint32_t raId);
277 void DoReceiveRachPreamble(uint32_t raId);
278 void ReceiveBsrMessage(MacCeElement bsr);
279 void DoReportMacCeToScheduler(MacCeListElement_s bsr);
284 void DoReportSrToScheduler(uint16_t rnti);
285 void DoReceivePhyPdu(Ptr<Packet> p);
286 void DoReceiveControlMessage(Ptr<NrControlMessage> msg);
287 virtual void DoSchedConfigIndication(NrMacSchedSapUser::SchedConfigIndParameters ind);
288 // forwarded from LteMacSapProvider
289 void DoTransmitPdu(LteMacSapProvider::TransmitPduParameters);
290 void DoReportBufferStatus(LteMacSapProvider::ReportBufferStatusParameters);
292 // forwarded from NrMacCchedSapUser
293 void DoCschedCellConfigCnf(NrMacCschedSapUser::CschedCellConfigCnfParameters params);
294 void DoCschedUeConfigCnf(NrMacCschedSapUser::CschedUeConfigCnfParameters params);
295 void DoCschedLcConfigCnf(NrMacCschedSapUser::CschedLcConfigCnfParameters params);
296 void DoCschedLcReleaseCnf(NrMacCschedSapUser::CschedLcReleaseCnfParameters params);
297 void DoCschedUeReleaseCnf(NrMacCschedSapUser::CschedUeReleaseCnfParameters params);
298 void DoCschedUeConfigUpdateInd(NrMacCschedSapUser::CschedUeConfigUpdateIndParameters params);
299 void DoCschedCellConfigUpdateInd(
301 // forwarded from LteEnbCmacSapProvider
302 void DoConfigureMac(uint16_t ulBandwidth, uint16_t dlBandwidth);
303 void DoAddUe(uint16_t rnti);
304 void DoRemoveUe(uint16_t rnti);
305 void DoAddLc(LteEnbCmacSapProvider::LcInfo lcinfo, LteMacSapUser* msu);
306 void DoReconfigureLc(LteEnbCmacSapProvider::LcInfo lcinfo);
307 void DoReleaseLc(uint16_t rnti, uint8_t lcid);
308 void UeUpdateConfigurationReq(LteEnbCmacSapProvider::UeConfig params);
309 LteEnbCmacSapProvider::RachConfig DoGetRachConfig();
310 LteEnbCmacSapProvider::AllocateNcRaPreambleReturnValue DoAllocateNcRaPreamble(uint16_t rnti);
311
316 void DoDlHarqFeedback(const DlHarqInfo& params);
321 void DoUlHarqFeedback(const UlHarqInfo& params);
322
329 void SendRar(const std::vector<BuildRarListElement_s>& rarList);
330
331 private:
332 struct NrDlHarqProcessInfo
333 {
334 Ptr<PacketBurst> m_pktBurst;
335 // maintain list of LCs contained in this TB
336 // used to signal HARQ failure to RLC handlers
337 std::vector<uint8_t> m_lcidList;
338 };
339
340 typedef std::vector<NrDlHarqProcessInfo> NrDlHarqProcessesBuffer_t;
341
342 LteMacSapProvider* m_macSapProvider;
343 LteEnbCmacSapProvider* m_cmacSapProvider;
344 LteEnbCmacSapUser* m_cmacSapUser;
345 NrPhySapProvider* m_phySapProvider{nullptr};
346 NrGnbPhySapUser* m_phySapUser;
347
348 NrMacSchedSapProvider* m_macSchedSapProvider;
349 NrMacSchedSapUser* m_macSchedSapUser;
350 NrMacCschedSapProvider* m_macCschedSapProvider;
351 NrMacCschedSapUser* m_macCschedSapUser;
352
353 // Sap For ComponentCarrierManager 'Uplink case'
354 LteCcmMacSapProvider* m_ccmMacSapProvider;
355 LteCcmMacSapUser* m_ccmMacSapUser;
356
357 int32_t m_numRbPerRbg{-1};
358
359 uint8_t m_numHarqProcess{20};
360
361 std::unordered_map<uint32_t, struct NrMacPduInfo> m_macPduMap;
362
363 Callback<void, Ptr<Packet>> m_forwardUpCallback;
364
365 std::vector<DlCqiInfo> m_dlCqiReceived;
366 std::vector<NrMacSchedSapProvider::SchedUlCqiInfoReqParameters> m_ulCqiReceived;
367 std::vector<MacCeElement> m_ulCeReceived; // CE received (BSR up to now)
368
369 std::unordered_map<uint8_t, uint32_t> m_receivedRachPreambleCount;
370
371 std::unordered_map<uint16_t, std::unordered_map<uint8_t, LteMacSapUser*>> m_rlcAttached;
372
373 std::vector<DlHarqInfo> m_dlHarqInfoReceived; // DL HARQ feedback received
374 std::vector<UlHarqInfo> m_ulHarqInfoReceived; // UL HARQ feedback received
375 std::unordered_map<uint16_t, NrDlHarqProcessesBuffer_t>
376 m_miDlHarqProcessesPackets; // Packet under transmission of the DL HARQ process
377
378 TracedCallback<NrSchedulingCallbackInfo> m_dlScheduling;
379 TracedCallback<NrSchedulingCallbackInfo> m_ulScheduling;
380
381 std::list<uint16_t> m_srRntiList;
382
383 std::unordered_map<uint8_t, uint32_t> m_rapIdRntiMap;
384
385 TracedCallback<uint8_t, uint16_t> m_srCallback;
386
387 uint16_t m_bandwidthInRbg{0};
388
389 SfnSf m_currentSlot;
390
396 TracedCallback<SfnSf, uint16_t, uint16_t, uint8_t, Ptr<const NrControlMessage>>
397 m_macRxedCtrlMsgsTrace;
398
404 TracedCallback<SfnSf, uint16_t, uint16_t, uint8_t, Ptr<const NrControlMessage>>
405 m_macTxedCtrlMsgsTrace;
406
410 TracedCallback<const DlHarqInfo&> m_dlHarqFeedback;
411};
412
413} // namespace ns3
414
415#endif /* NR_ENB_MAC_H */
Representation of a beam id.
Definition beam-id.h:28
The MAC class for the gnb.
Definition nr-gnb-mac.h:50
virtual uint8_t GetUlCtrlSyms() const
Retrieve the number of UL ctrl symbols configured in the scheduler.
uint8_t GetNumHarqProcess() const
virtual void DoSlotDlIndication(const SfnSf &sfnSf, LteNrTddSlotType type)
Perform DL scheduling decision for the indicated slot.
void(* SrTracedCallback)(const uint8_t bwpId, const uint16_t rnti)
Definition nr-gnb-mac.h:208
void(* RxedGnbMacCtrlMsgsTracedCallback)(const SfnSf sfn, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage >)
Definition nr-gnb-mac.h:222
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(* SchedulingTracedCallback)(uint32_t frameNum, uint32_t subframeNum, uint32_t slotNum, uint8_t symStart, uint8_t numSym, uint32_t tbSize, uint32_t mcs, uint32_t rnti, uint8_t bwpId)
Definition nr-gnb-mac.h:192
void SetNumHarqProcess(uint8_t numHarqProcess)
Sets the number of HARQ processes.
~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.
NrGnbMac()
NrGnbMac constructor.
uint16_t GetCellId() const
Get the cell id of this MAC.
void SetLteCcmMacSapUser(LteCcmMacSapUser *s)
Set the ComponentCarrierManager SAP user.
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.
LteCcmMacSapProvider * GetLteCcmMacSapProvider()
Get the gNB-ComponentCarrierManager SAP User.
virtual uint8_t GetDlCtrlSyms() const
Retrieve the number of DL ctrl symbols configured in the scheduler.
static TypeId GetTypeId()
Get the TypeId.
void(* TxedGnbMacCtrlMsgsTracedCallback)(const SfnSf sfn, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage >)
Definition nr-gnb-mac.h:240
void DoDispose() override
DoDispose method inherited from Object.
SAP interface between the ENB PHY and the ENB MAC.
Definition nr-phy-sap.h:157
Provides the CSCHED SAP.
The SAP interface between MAC and scheduler.
The Interface between Scheduler and MAC.
SAP interface between the MAC and the PHY.
Definition nr-phy-sap.h:38
The SfnSf class.
Definition sfnsf.h:34
LteNrTddSlotType
Available TDD slot types. Ordering is important.
A struct that contains info for the DL HARQ.
See section 4.3.14 macCEListElement.
The SchedConfigIndParameters struct.
A struct that contains info for the UL HARQ.