5G-LENA
nr-v3.0-29-g83cc959
The 5G/NR module for the ns-3 simulator
|
The MAC class for the UE. More...
#include "nr-ue-mac.h"
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. More... | |
uint8_t | GetNumHarqProcess () const |
Please remember that this number is obtained by the GNB, the UE cannot configure it. More... | |
NrUePhySapUser * | GetPhySapUser () |
Get the PHY SAP User (AKA the MAC representation for the PHY) More... | |
LteUeCmacSapProvider * | GetUeCmacSapProvider () |
Get the C MAC SAP provider (AKA the MAC representation for the RRC) More... | |
LteMacSapProvider * | GetUeMacSapProvider () |
Get the Mac SAP provider (AKA the MAC representation for the RLC) More... | |
void | SetNumHarqProcess (uint8_t numHarqProcesses) |
Sets the number of HARQ processes. Called by the helper at the moment of UE attachment. More... | |
void | SetPhySapProvider (NrPhySapProvider *ptr) |
Set PHY SAP provider (AKA the PHY representation for the MAC) More... | |
void | SetUeCmacSapUser (LteUeCmacSapUser *s) |
Set the C MAC SAP user (AKA the RRC representation for the MAC) More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the Type id. More... | |
Protected Member Functions | |
void | DoDispose () override |
DoDispose method inherited from Object. | |
uint16_t | GetBwpId () const |
Get the bwp id of this MAC. More... | |
uint16_t | GetCellId () const |
Get the cell id of this MAC. More... | |
Friends | |
class | MacUeMemberPhySapUser |
class | UeMemberNrMacSapProvider |
class | UeMemberNrUeCmacSapProvider |
The MAC class for the UE.
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.
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.
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.
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.
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.
ns3::NrUeMac is accessible through the following paths with Config::Set and Config::Connect:
/NodeList/[i]/DeviceList/[i]/$ns3::NrNetDevice/$ns3::NrUeNetDevice/ComponentCarrierMapUe/[i]/NrUeMac
/NodeList/[i]/DeviceList/[i]/$ns3::NrUeNetDevice/ComponentCarrierMapUe/[i]/NrUeMac
Size of this type is 368 bytes (on a 64-bit architecture).
Definition at line 105 of file nr-ue-mac.h.
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.
[in] | sfnSf | Frame number, subframe number, slot number, VarTti |
[in] | nodeId | the node ID |
[in] | rnti | the RNTI |
[in] | bwpId | the BWP ID |
[in] | ctrlMessage | the pointer to msg to get the msg type |
Definition at line 165 of file nr-ue-mac.h.
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.
[in] | sfnSf | the frame number, subframe number, slot number, VarTti |
[in] | nodeId | the node ID |
[in] | rnti | the RNTI |
[in] | bwpId | the BWP ID |
[in] | ctrlMessage | the pointer to msg to get the msg type |
Definition at line 178 of file nr-ue-mac.h.
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.
stream | first stream index to use |
Definition at line 1108 of file nr-ue-mac.cc.
|
protected |
Get the bwp id of this MAC.
Definition at line 279 of file nr-ue-mac.cc.
References ns3::NrPhySapProvider::GetBwpId().
|
protected |
Get the cell id of this MAC.
Definition at line 292 of file nr-ue-mac.cc.
References ns3::NrPhySapProvider::GetCellId().
uint8_t ns3::NrUeMac::GetNumHarqProcess | ( | ) | const |
Please remember that this number is obtained by the GNB, the UE cannot configure it.
Definition at line 340 of file nr-ue-mac.cc.
Referenced by SetNumHarqProcess().
NrUePhySapUser * ns3::NrUeMac::GetPhySapUser | ( | ) |
Get the PHY SAP User (AKA the MAC representation for the PHY)
Definition at line 1012 of file nr-ue-mac.cc.
|
static |
Get the Type id.
Definition at line 207 of file nr-ue-mac.cc.
Referenced by ns3::NrHelper::NrHelper().
LteUeCmacSapProvider * ns3::NrUeMac::GetUeCmacSapProvider | ( | ) |
Get the C MAC SAP provider (AKA the MAC representation for the RRC)
Definition at line 500 of file nr-ue-mac.cc.
LteMacSapProvider * ns3::NrUeMac::GetUeMacSapProvider | ( | ) |
Get the Mac SAP provider (AKA the MAC representation for the RLC)
Definition at line 1094 of file nr-ue-mac.cc.
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.
numHarqProcesses | the maximum number of harq processes |
Definition at line 320 of file nr-ue-mac.cc.
References GetNumHarqProcess().
void ns3::NrUeMac::SetPhySapProvider | ( | NrPhySapProvider * | ptr | ) |
Set PHY SAP provider (AKA the PHY representation for the MAC)
ptr | the PHY SAP provider (AKA the PHY representation for the MAC) |
Definition at line 1018 of file nr-ue-mac.cc.
void ns3::NrUeMac::SetUeCmacSapUser | ( | LteUeCmacSapUser * | s | ) |
Set the C MAC SAP user (AKA the RRC representation for the MAC)
s | the SAP pointer |
Definition at line 494 of file nr-ue-mac.cc.