5G-LENA nr-v3.0-33-g7aea1e4
The 5G/NR module for the ns-3 simulator
Loading...
Searching...
No Matches
ns3::NrUeMac Class Reference

The MAC class for the UE. More...

#include "nr-ue-mac.h"

+ Inheritance diagram for ns3::NrUeMac:
+ Collaboration diagram for ns3::NrUeMac:

Public Types

typedef void(* RxedUeMacCtrlMsgsTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage > ctrlMessage)
 
typedef void(* TxedUeMacCtrlMsgsTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage > ctrlMessage)
 

Public Member Functions

 NrUeMac ()
 NrUeMac constructor.
 
 ~NrUeMac () override
 Deconstructor.
 
int64_t AssignStreams (int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model. Returns the number of streams (possibly zero) that have been assigned.
 
uint8_t GetNumHarqProcess () const
 Please remember that this number is obtained by the GNB, the UE cannot configure it.
 
NrUePhySapUserGetPhySapUser ()
 Get the PHY SAP User (AKA the MAC representation for the PHY)
 
LteUeCmacSapProvider * GetUeCmacSapProvider ()
 Get the C MAC SAP provider (AKA the MAC representation for the RRC)
 
LteMacSapProvider * GetUeMacSapProvider ()
 Get the Mac SAP provider (AKA the MAC representation for the RLC)
 
void SetNumHarqProcess (uint8_t numHarqProcesses)
 Sets the number of HARQ processes. Called by the helper at the moment of UE attachment.
 
void SetPhySapProvider (NrPhySapProvider *ptr)
 Set PHY SAP provider (AKA the PHY representation for the MAC)
 
void SetUeCmacSapUser (LteUeCmacSapUser *s)
 Set the C MAC SAP user (AKA the RRC representation for the MAC)
 

Static Public Member Functions

static TypeId GetTypeId ()
 Get the Type id.
 

Protected Member Functions

void DoDispose () override
 DoDispose method inherited from Object.
 
uint16_t GetBwpId () const
 Get the bwp id of this MAC.
 
uint16_t GetCellId () const
 Get the cell id of this MAC.
 

Friends

class MacUeMemberPhySapUser
 
class UeMemberNrMacSapProvider
 
class UeMemberNrUeCmacSapProvider
 

Detailed Description

The MAC class for the UE.

General information

The UE MAC has not much freedom, as it is directed by the GNB at which it is attached to. For the attachment phase, we follow (more or less) what is happening in LENA. After the UE is attached, the things become different.

Scheduling Request

When a RLC (please remember, there are as many RLC as many bearer the UE has) tells the UE that there is some data in its queue, the UE MAC activates the SR state machine. So, the UE sends a control message (called Scheduling Request) to the PHY, that in turn has to deliver it to the GNB. This message says that the UE has some data to transmit (without indicating the precise quantity).

The GNB then allocates some data (a quantity that is implementation-defined) to the UE, in which it can transmit data and a SHORT_BSR.

Response to a DCI

When the UE receives an UL_DCI, it can use a part of it to send a Control Element. The most used control element (and, by the way, the only we support right now) is SHORT_BSR, in which the UE informs the GNB of its buffer status. The rest of the bytes can be used to send data.

In the standard, the UE is allowed to send a single PDU in response to a single UL DCI. Such PDU can be formed by one or more subPDU, each one consisting in a header and a data (the data is optional). However, due to limitations in serialization/deserialization of packets in the ns-3 simulator, we are bending a little the definition. The MAC is allowed to send as many PDU as it wants, but these PDU (that are, in fact, packets) should be enqueued in the PHY at the same frame/subframe/slot/symbol. The PHY will use the concept of PacketBurst to consider all these PDUs as a single, big, PDU. Practically speaking, the result is the same as grouping these subPDU in a single PDU, just that the single PDU is in reality a PacketBurst. As the order in a PacketBurst cannot be maintained, it is impossible to respect the standard at the ordering part (DL and UL PDU are formed in an opposite way, with CE at the beginning or at the end of the PDU).

The action of sending a subPDU to the PHY is done by the method DoTransmitPdu(). However, the MAC has to evaluate the received TBS, in light of how many Logical Channel ID are active, and what data they have to transmit. In doing all this, the MAC has to keep in consideration that each subPDU will have a header prefixed, which is an overhead, using bytes that were originally supposed to be assigned to data.

The core of this small "scheduling" is done in method SendNewData(), in which the MAC will try to send as many status-subPDUs as possible, then will try to send as many as retx-subPDUs as possible, and finally as many as tx-subPDUs as possible. At the end of all the subPDUs, it will be sent a SHORT_BSR, to indicate to the GNB the new status of the RLC queues. As the SHORT_BSR is a CE and is treated in the same way as data, it may be lost. Please note that the code subtract the amount of bytes devoted to the SHORT_BSR from the available ones, so there will always be a space to send it. The only exception (theoretically possible) is when the status PDUs use all the available space; in this case, a rework of the code will be needed.

The SHORT_BSR is not reflecting the standard, but it is the same data that was sent in LENA, indicating the status of 4 LCG at once with an 8-bit value. Making this part standard-compliant is a good novice exercise.

Configuration

The user can configure the class using the method NrHelper::SetUeMacAttribute(), or by directly calling SetAttribute on the MAC pointer. The list of attributes is reported below, in the Attributes section.

CTRL-trace Traces for CTRL messages

The class has two attributes that signals to the eventual listener the transmission or the reception of CTRL messages. One is UeMacRxedCtrlMsgsTrace, and the other is UeMacTxedCtrlMsgsTrace. For what regards the PHY, you will find more information in the NrUePhy class documentation.

Config Paths

ns3::NrUeMac is accessible through the following paths with Config::Set and Config::Connect:

Attributes

  • NumHarqProcess: Number of concurrent stop-and-wait Hybrid ARQ processes per user
    • Set with class: ns3::UintegerValue
    • Underlying type: uint8_t 0:255
    • Initial value: 20
    • Flags: construct write read

TraceSources

  • UeMacRxedCtrlMsgsTrace: Ue MAC Control Messages Traces.
    Callback signature: ns3::NrMacRxTrace::RxedUeMacCtrlMsgsTracedCallback
  • UeMacTxedCtrlMsgsTrace: Ue MAC Control Messages Traces.
    Callback signature: ns3::NrMacRxTrace::TxedUeMacCtrlMsgsTracedCallback

Size of this type is 368 bytes (on a 64-bit architecture).

Definition at line 105 of file nr-ue-mac.h.

Member Typedef Documentation

◆ RxedUeMacCtrlMsgsTracedCallback

typedef void(* ns3::NrUeMac::RxedUeMacCtrlMsgsTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage > ctrlMessage)

TracedCallback signature for Ue Mac Received Control Messages.

Parameters
[in]sfnSfFrame number, subframe number, slot number, VarTti
[in]nodeIdthe node ID
[in]rntithe RNTI
[in]bwpIdthe BWP ID
[in]ctrlMessagethe pointer to msg to get the msg type

Definition at line 165 of file nr-ue-mac.h.

◆ TxedUeMacCtrlMsgsTracedCallback

typedef void(* ns3::NrUeMac::TxedUeMacCtrlMsgsTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage > ctrlMessage)

TracedCallback signature for Ue Mac Transmitted Control Messages.

Parameters
[in]sfnSfthe frame number, subframe number, slot number, VarTti
[in]nodeIdthe node ID
[in]rntithe RNTI
[in]bwpIdthe BWP ID
[in]ctrlMessagethe pointer to msg to get the msg type

Definition at line 178 of file nr-ue-mac.h.

Constructor & Destructor Documentation

◆ NrUeMac()

ns3::NrUeMac::NrUeMac ( )

NrUeMac constructor.

Definition at line 230 of file nr-ue-mac.cc.

◆ ~NrUeMac()

ns3::NrUeMac::~NrUeMac ( )
override

Deconstructor.

Definition at line 240 of file nr-ue-mac.cc.

Member Function Documentation

◆ AssignStreams()

int64_t ns3::NrUeMac::AssignStreams ( int64_t  stream)

Assign a fixed random variable stream number to the random variables used by this model. Returns the number of streams (possibly zero) that have been assigned.

Parameters
streamfirst stream index to use
Returns
the number of stream indices assigned by this model

Definition at line 1108 of file nr-ue-mac.cc.

◆ DoDispose()

void ns3::NrUeMac::DoDispose ( )
overrideprotected

DoDispose method inherited from Object.

Definition at line 245 of file nr-ue-mac.cc.

◆ GetBwpId()

uint16_t ns3::NrUeMac::GetBwpId ( ) const
protected

Get the bwp id of this MAC.

Returns
the bwp id

Definition at line 279 of file nr-ue-mac.cc.

References ns3::NrPhySapProvider::GetBwpId().

+ Here is the call graph for this function:

◆ GetCellId()

uint16_t ns3::NrUeMac::GetCellId ( ) const
protected

Get the cell id of this MAC.

Returns
the cell id

Definition at line 292 of file nr-ue-mac.cc.

References ns3::NrPhySapProvider::GetCellId().

+ Here is the call graph for this function:

◆ GetNumHarqProcess()

uint8_t ns3::NrUeMac::GetNumHarqProcess ( ) const

Please remember that this number is obtained by the GNB, the UE cannot configure it.

Returns
number of HARQ processes

Definition at line 340 of file nr-ue-mac.cc.

Referenced by SetNumHarqProcess().

+ Here is the caller graph for this function:

◆ GetPhySapUser()

NrUePhySapUser * ns3::NrUeMac::GetPhySapUser ( )

Get the PHY SAP User (AKA the MAC representation for the PHY)

Returns
the PHY SAP User (AKA the MAC representation for the PHY)

Definition at line 1012 of file nr-ue-mac.cc.

◆ GetTypeId()

TypeId ns3::NrUeMac::GetTypeId ( )
static

Get the Type id.

Returns
the type id

Definition at line 207 of file nr-ue-mac.cc.

Referenced by ns3::NrHelper::NrHelper().

+ Here is the caller graph for this function:

◆ GetUeCmacSapProvider()

LteUeCmacSapProvider * ns3::NrUeMac::GetUeCmacSapProvider ( )

Get the C MAC SAP provider (AKA the MAC representation for the RRC)

Returns
C MAC SAP provider (AKA the MAC representation for the RRC)

Definition at line 500 of file nr-ue-mac.cc.

◆ GetUeMacSapProvider()

LteMacSapProvider * ns3::NrUeMac::GetUeMacSapProvider ( )

Get the Mac SAP provider (AKA the MAC representation for the RLC)

Returns
the Mac SAP provider (AKA the MAC representation for the RLC)

Definition at line 1094 of file nr-ue-mac.cc.

◆ SetNumHarqProcess()

void ns3::NrUeMac::SetNumHarqProcess ( uint8_t  numHarqProcess)

Sets the number of HARQ processes. Called by the helper at the moment of UE attachment.

Sets the number of HARQ processes.

Parameters
numHarqProcessesthe maximum number of harq processes

Definition at line 320 of file nr-ue-mac.cc.

References GetNumHarqProcess().

+ Here is the call graph for this function:

◆ SetPhySapProvider()

void ns3::NrUeMac::SetPhySapProvider ( NrPhySapProvider ptr)

Set PHY SAP provider (AKA the PHY representation for the MAC)

Parameters
ptrthe PHY SAP provider (AKA the PHY representation for the MAC)

Definition at line 1018 of file nr-ue-mac.cc.

◆ SetUeCmacSapUser()

void ns3::NrUeMac::SetUeCmacSapUser ( LteUeCmacSapUser *  s)

Set the C MAC SAP user (AKA the RRC representation for the MAC)

Parameters
sthe SAP pointer

Definition at line 494 of file nr-ue-mac.cc.

Friends And Related Symbol Documentation

◆ MacUeMemberPhySapUser

friend class MacUeMemberPhySapUser
friend

Definition at line 109 of file nr-ue-mac.h.

◆ UeMemberNrMacSapProvider

friend class UeMemberNrMacSapProvider
friend

Definition at line 108 of file nr-ue-mac.h.

◆ UeMemberNrUeCmacSapProvider

friend class UeMemberNrUeCmacSapProvider
friend

Definition at line 107 of file nr-ue-mac.h.


The documentation for this class was generated from the following files: