5G-LENA nr-v4.0
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)
 
enum  SrBsrMachine : uint8_t { INACTIVE , TO_SEND , ACTIVE }
 States for the SR/BSR mechanism. More...
 
typedef void(* TxedUeMacCtrlMsgsTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, Ptr< NrControlMessage > ctrlMessage)
 
typedef void(* UeMacStateMachineTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, const enum SrBsrMachine srState, std::unordered_map< uint8_t, NrMacSapProvider::BufferStatusReportParameters > ulBsrReceived, int retx, std::string nameFunc)
 

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.
 
uint16_t GetBwpId () const
 Get the bwp id of this MAC.
 
uint16_t GetCellId () const
 Get the cell id of this MAC.
 
uint64_t GetImsi () const
 Get the IMSI.
 
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)
 
uint16_t GetRnti () const
 Get the RNTI.
 
NrUeCmacSapProviderGetUeCmacSapProvider ()
 Get the C MAC SAP provider (AKA the MAC representation for the RRC)
 
NrMacSapProviderGetUeMacSapProvider ()
 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 (NrUeCmacSapUser *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

virtual int64_t DoAssignStreams (int64_t stream)
 
void DoDispose () override
 DoDispose method inherited from Object.
 
void SetCurrentSlot (const SfnSf &sfn)
 Set the frame/subframe/slot counter.
 

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: 16
    • 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
  • RaResponseTimeout: Trace fired upon RA response timeout
    Callback signature: ns3::NrUeMac::RaResponseTimeoutTracedCallback
  • UeMacStateMachineTrace: UE MAC state machine trace
    Callback signature: ns3::NrUeMac::UeMacStateMachineTracedCallback

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

Definition at line 103 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 188 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 201 of file nr-ue-mac.h.

◆ UeMacStateMachineTracedCallback

typedef void(* ns3::NrUeMac::UeMacStateMachineTracedCallback) (const SfnSf sfnSf, const uint16_t nodeId, const uint16_t rnti, const uint8_t bwpId, const enum SrBsrMachine srState, std::unordered_map< uint8_t, NrMacSapProvider::BufferStatusReportParameters > ulBsrReceived, int retx, std::string nameFunc)

TracedCallback for Ue Mac State Machine.

Parameters
[in]sfnSfthe frame number, subframe number, slot number, VarTti
[in]nodeIdthe node ID
[in]rntithe RNTI
[in]bwpIdthe BWP ID
[in]srStatethe UE state within the state machine
[in]ulBsrReceivedthe amount of data stored in the buffer
[in]retx1 if it is new data, 0 if a retransmission is needed
[in]nameFuncthe name of the function where the trace is called

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

Member Enumeration Documentation

◆ SrBsrMachine

States for the SR/BSR mechanism.

The SR/BSR mechanism is based on a variable in which it is saved the state (INACTIVE/ACTIVE).

The machine is starting from the INACTIVE state. When the RLC notifies to MAC that there are new bytes in its queue (DoTransmitBufferStatusReport()), if the machine is in INACTIVE state, it enters the ACTIVE state. Entering the ACTIVE state means to send a SR, which is enqueued in the PHY layer. It will suffer slots of CTRL latency. If the state is already ACTIVE, then the BSR can be sent in the same slot as data. It means that the MAC prepares together the data and the BSR.

If the BSR is not sent (we don't have any data in the queue) and we don't have any more reserved space to send BSR, then the state goes back to the INACTIVE state.

Enumerator
INACTIVE 

no SR nor BSR.. initial state

TO_SEND 

We have to send the BSR when possible.

ACTIVE 

SR or BSR sent; now the source of information is the vector m_bsrReservedSpace.

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

Constructor & Destructor Documentation

◆ NrUeMac()

ns3::NrUeMac::NrUeMac ( )

NrUeMac constructor.

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

◆ ~NrUeMac()

ns3::NrUeMac::~NrUeMac ( )
override

Deconstructor.

Definition at line 246 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 1351 of file nr-ue-mac.cc.

References DoAssignStreams().

+ Here is the call graph for this function:

◆ DoAssignStreams()

int64_t ns3::NrUeMac::DoAssignStreams ( int64_t  stream)
protectedvirtual

Assign a fixed random variable stream number to the random variables used by this model.

Subclasses that override this method are expected to chain up to their parent's implementation and then set their own streams

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

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

Referenced by AssignStreams().

+ Here is the caller graph for this function:

◆ DoDispose()

void ns3::NrUeMac::DoDispose ( )
overrideprotected

DoDispose method inherited from Object.

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

◆ GetBwpId()

uint16_t ns3::NrUeMac::GetBwpId ( ) const

Get the bwp id of this MAC.

Returns
the bwp id

Definition at line 285 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

Get the cell id of this MAC.

Returns
the cell id

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

References ns3::NrPhySapProvider::GetCellId().

+ Here is the call graph for this function:

◆ GetImsi()

uint64_t ns3::NrUeMac::GetImsi ( ) const

Get the IMSI.

Returns
the IMSI

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

◆ 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 364 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 1147 of file nr-ue-mac.cc.

◆ GetRnti()

uint16_t ns3::NrUeMac::GetRnti ( ) const

Get the RNTI.

Returns
the RNTI

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

◆ GetTypeId()

TypeId ns3::NrUeMac::GetTypeId ( )
static

Get the Type id.

Returns
the type id

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

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

+ Here is the caller graph for this function:

◆ GetUeCmacSapProvider()

NrUeCmacSapProvider * 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 569 of file nr-ue-mac.cc.

◆ GetUeMacSapProvider()

NrMacSapProvider * 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 1318 of file nr-ue-mac.cc.

◆ SetCurrentSlot()

void ns3::NrUeMac::SetCurrentSlot ( const SfnSf sfn)
protected

Set the frame/subframe/slot counter.

Parameters
sfnthe SfnSf

Definition at line 323 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 344 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 1153 of file nr-ue-mac.cc.

◆ SetUeCmacSapUser()

void ns3::NrUeMac::SetUeCmacSapUser ( NrUeCmacSapUser s)

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

Parameters
sthe SAP pointer

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

Friends And Related Symbol Documentation

◆ MacUeMemberPhySapUser

friend class MacUeMemberPhySapUser
friend

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

◆ UeMemberNrMacSapProvider

friend class UeMemberNrMacSapProvider
friend

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

◆ UeMemberNrUeCmacSapProvider

friend class UeMemberNrUeCmacSapProvider
friend

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


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