![]() |
5G-LENA nr-v4.0
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) |
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. | |
NrUePhySapUser * | GetPhySapUser () |
Get the PHY SAP User (AKA the MAC representation for the PHY) | |
uint16_t | GetRnti () const |
Get the RNTI. | |
NrUeCmacSapProvider * | GetUeCmacSapProvider () |
Get the C MAC SAP provider (AKA the MAC representation for the RRC) | |
NrMacSapProvider * | 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 (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 |
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 472 bytes (on a 64-bit architecture).
Definition at line 103 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 188 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 201 of file nr-ue-mac.h.
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.
[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] | srState | the UE state within the state machine |
[in] | ulBsrReceived | the amount of data stored in the buffer |
[in] | retx | 1 if it is new data, 0 if a retransmission is needed |
[in] | nameFunc | the name of the function where the trace is called |
Definition at line 218 of file nr-ue-mac.h.
enum ns3::NrUeMac::SrBsrMachine : uint8_t |
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.
ns3::NrUeMac::NrUeMac | ( | ) |
NrUeMac constructor.
Definition at line 236 of file nr-ue-mac.cc.
|
override |
Deconstructor.
Definition at line 246 of file nr-ue-mac.cc.
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 1351 of file nr-ue-mac.cc.
References DoAssignStreams().
|
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
stream | first stream index to use |
Definition at line 1357 of file nr-ue-mac.cc.
Referenced by AssignStreams().
|
overrideprotected |
DoDispose method inherited from Object.
Definition at line 251 of file nr-ue-mac.cc.
uint16_t ns3::NrUeMac::GetBwpId | ( | ) | const |
Get the bwp id of this MAC.
Definition at line 285 of file nr-ue-mac.cc.
References ns3::NrPhySapProvider::GetBwpId().
uint16_t ns3::NrUeMac::GetCellId | ( | ) | const |
Get the cell id of this MAC.
Definition at line 298 of file nr-ue-mac.cc.
References ns3::NrPhySapProvider::GetCellId().
uint64_t ns3::NrUeMac::GetImsi | ( | ) | const |
uint8_t ns3::NrUeMac::GetNumHarqProcess | ( | ) | const |
Please remember that this number is obtained by the GNB, the UE cannot configure it.
Definition at line 364 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 1147 of file nr-ue-mac.cc.
uint16_t ns3::NrUeMac::GetRnti | ( | ) | const |
|
static |
Get the Type id.
Definition at line 205 of file nr-ue-mac.cc.
Referenced by ns3::NrHelper::NrHelper().
NrUeCmacSapProvider * ns3::NrUeMac::GetUeCmacSapProvider | ( | ) |
Get the C MAC SAP provider (AKA the MAC representation for the RRC)
Definition at line 569 of file nr-ue-mac.cc.
NrMacSapProvider * ns3::NrUeMac::GetUeMacSapProvider | ( | ) |
Get the Mac SAP provider (AKA the MAC representation for the RLC)
Definition at line 1318 of file nr-ue-mac.cc.
|
protected |
Set the frame/subframe/slot counter.
sfn | the SfnSf |
Definition at line 323 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 344 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 1153 of file nr-ue-mac.cc.
void ns3::NrUeMac::SetUeCmacSapUser | ( | NrUeCmacSapUser * | s | ) |
Set the C MAC SAP user (AKA the RRC representation for the MAC)
s | the SAP pointer |
Definition at line 563 of file nr-ue-mac.cc.
|
friend |
Definition at line 107 of file nr-ue-mac.h.
|
friend |
Definition at line 106 of file nr-ue-mac.h.
|
friend |
Definition at line 105 of file nr-ue-mac.h.