Skip to content

MAC Layer

pablop edited this page Oct 23, 2026 · 7 revisions

The MAC layer module is the key component of our implementation, as it allows to test different scheduling schemes or approaches suitable for the specific applications or use cases tested. The MAC layer represents a more detailed implementation of the resource allocation procedures. Such procedures were obtained from 3GPP 38.214 and 3GPP 38.211 specifications. According to such specification, a resource allocation grid is created using the info selected by the user in the config file, such as:

  • Bandwidth.
  • FDD/TDD multiplexing modes/configuration.
  • Resource allocation type.
  • Resource allocation configuration.
  • Numerology.

The resource allocation grid is divided in frequency and time. In frequency, the eNB/gNB has a fixed bandwidth assigned for transmission/reception. The total bandwidth is divided into subcarriers and Resource Blocks. In time, the scheduling time is limited and subdivided into frames, subframes and slots.

Numerology.png

The result is a time-frequency resource grid with small units which are arbitrarily assigned to different UEs by the scheduler. The Resource Elements (REs) are organized in Physical Resource Blocks (PRBs) of 14 symbols in the time domain and 12 subcarriers in the frequency domain. The PRBs can be grouped in Resource Block Groups (RBGs) according to the resource allocation configuration.

Grid.png

The PRBs/RBGs are assigned to the most optimal UEs according to a selected metric. In each time step, a metric value is calculated for each UE and each PRB/RBG. Such metric type is selected by the emulator user and can be custom-implemented. Current metric IDs are described in Metric Estimation.

We have implemented the resource allocation model in a very modular manner so the potential users can implement their own specific resource allocation techniques or configuration such as network slicing. Once the metrics for all the UEs and PRBs/RBGs are obtained, each PRB/RBG is assigned to the UE with the highest obtained metric for such PRB/RBG.

The resource allocation can be distributed along the time axis in two manners:

  • Localized: allocates all the contiguous slots along the time axis to the same UE, within a subframe.
  • Distributed: free allocation along the time axis. Gives more allocation freedom, but greater overhead.

Along the frequency axis, it can be organized in RBGs of different sizes:

TypeAllocation.png

Once the Resource Allocation Grid is built for each transmission direction, it presents the following distribution:

MACSimplified.svg

The MAC layer module is also in charge of determining which modulation should be used for each UE and PRB/RBG according to the simulated Channel Quality Measurements in the PHY Layer. Adaptive Modulation and Coding (AMC) dynamically adjusts the OFDM modulation order, coding method and coding rate of symbols to maximize throughput of the entire link transmission system.

AMC.svg

This SNR-CQI calculation can be done in two different modes, selected by the emulator's user using the config file:

  • Wideband: the SNR, and therefore the CQI, is estimated for the entire bandwidth. One single CQI value is given by each UE.
  • Sub-band: the bandwidth is divided in subbands. Different SNR/CQI values are estimated by the UE for each sub-band.

The selected modulation determines how many bits can be sent in each PRB/RBG for each UE, which is also used to estimate some of the metrics. Each modulation scheme provides a different bit order:

  • QPSK: 2 bits.
  • 16QAM: 4 bits.
  • 64QAM: 6 bits.
  • 256QAM: 8 bits.

Once the assignment is done, a Transport Block Size in bits is obtained for each assigned pair of UE-PRB/RBG, which is the length of the block that has to be provided by the RLC/PDCP layer. The TBS for each PRB/RBG is estimated according to 3GPP 38.306-v16.6.0:

Bitrate.png

Finally, the implemented MAC layer considers both FDD and TDD communication.

  • FDD: the total bandwidth is divided in two, uplink and downlink. Consequently, the total available bandwidth for each transmission direction resource allocation grid is divided by two.
  • TDD: both grids are built with the total available bandwidth, but time slots are alternatively assigned to one transmission direction at a time.

In the emulator, both FDD and TDD perform identical resource allocation steps. Only the amount of DL/UL allocated bits in each time step changes. The TDD Handler estimates how many OFDM symbols are assigned to each transmission direction in the current subframe and informs the scheduler of the number of OFDM symbols assigned for UL and DL.

TDDPattern.png

The MAC Layer basic class is the Resource Block class, which we instantiate as many times as RBs/RBGs in the Resource Allocation grid, according to the selected configuration parameters. We build two grids, one for each transmission direction UL/DL. The grids are handled by the MAC layer, and the UL and DL grid steps can run concurrently if multi-threading is enabled by the user.

GridStep.svg

The configuration parameters used by the MAC layer are:

[MACLayer]
metric_type: 5
log_freq: 10
log_mac: true
mimo_layers: 1
n_ofdm_syms: 14
n_re_freq: 12
numerology: 1
max_rtx_ul: 4
max_rtx_dl: 4
mcs_tables: true
scheduling_mode: 0
scheduling_type: 1
scheduling_config: 1
duplexing_type: 0
n_dl_slots: 7
n_ul_slots: 3
transition_c: 54
ratio_DL_UL: 0.7

Which define:

  • metric_type: selected metric type. 1 BET, 4 MT, 5 RR and 6 PF are described in Metric Estimation.
  • pf_alpha, throughput_time_window_ms, throughput_intra_tti_update: PF and BET parameters; see Configuration File.
  • harq_model: legacy_bler or disabled.
  • log_freq: period between logs in ms.
  • log_mac: enable/disable MAC layer logging.
  • mimo_layers: number of available MIMO layers.
  • n_ofdm_syms: number of OFDM symbols per slot.
  • n_re_freq: number of subcarriers per resource block.
  • numerology: chosen numerology or subcarrier spacing.
  • max_rtx_ul / max_rtx_dl: maximum HARQ retransmissions for UL/DL.
  • mcs_tables: use custom MCS-BLER-SINR curves for estimating MCS indexes.
  • scheduling_mode: scheduling mode, 0 distributed or 1 localized.
  • scheduling_type: 0 groups frequency RBs in RBGs, 1 keeps frequency RBs ungrouped.
  • scheduling_config: configuration for scheduling type 0.
  • duplexing_type: 0 TDD, 1 FDD.
  • n_dl_slots: number of DL slots within a TDD configuration pattern.
  • n_ul_slots: number of UL slots within a TDD configuration pattern.
  • transition_c: transition configuration which determines the DL/UL Resource Elements available within the transition slot.
  • ratio_DL_UL: DL/UL resource ratio used by the scheduler.

Runtime control at the MAC layer

Two things the scheduler now reads from the per-UE control state (Runtime Control):

  • Priority is applied in phy_layer::get_metric, on top of the value produced by the metric, instead of inside the metric itself. See Metric Estimation.
  • A UE is a candidate only if it is attached, has data, has a positive bits per symbol and has tokens left in its rate bucket. The bucket is refilled once per TTI, and a UE without tokens simply does not compete for the RBG.

The round robin rotation runs over the attached UEs, using a dense rank rather than the UE id and the total count, so that a detached UE does not take a turn. Without this, its slot would not go unused: max_metric_handler::evaluate accepts a metric of 0.0, so the last candidate with data would take it.

HARQ and packet errors

harq_model: legacy_bler is the default. A transport block fails with a probability taken from the embedded MCS-BLER-SINR table and is retried up to max_rtx_ul / max_rtx_dl times, after which the packets are dropped and counted in the drop counters. The retry timers are the rtx_* and air_delay_* keys of the [PHYLayer] section. harq_model: disabled turns every transmission into a success, for ablation only. The table is not a calibrated NR receiver model: it supports repeatable comparative experiments, not predictions of absolute BLER. Provenance, the failure law and the accounting contract are in docs/harq-legacy-bler.md.

Clone this wiki locally