NR PUSCH FDD Scheduling

This example shows the scheduling functionality of the medium access control (MAC) layer of the 5G New Radio (NR) stack. The scheduling strategy assigns physical uplink shared channel (PUSCH) resources to a set of static user equipments (UEs) connected to a gNB. The scheduling strategy controls the frequency-time resource sharing among the UEs. The example uses frequency division duplexing (FDD) mode. Hence, uplink (UL) transmission uses all the slots. This example also shows the functionality of the radio link control (RLC) layer in unacknowledged mode (UM). The example abstracts the physical layer and adopts a probability-based approach by using the assumed UL channel quality indicator (CQI) values to model packet reception failures. The performance of the scheduling strategy is evaluated in terms of achieved MAC throughput and the fairness in resource sharing.

Introduction

This example shows how a scheduling strategy (controlled by the gNB) assigns UL resources among the UEs. The table summarizes various operations at gNB and UEs modeled in this example to facilitate UL transmission.

The scheduler runs every p slots to assign the UL resources, where p is the configured periodicity of the scheduler. In each run, the number of slots scheduled is equal to the periodicity of scheduler run, p. The first slot, among the p slots to be scheduled in a run, is the next upcoming slot which satisfies the PUSCH preparation time capability of UEs. For example, the figure shows the way scheduler selects the slots during two consecutive runs. It assumes scheduler periodicity (p) as 3 slots. Hence, the scheduler runs after every 3 slots, and schedules resources for 3 slots. PUSCH preparation time capability for all the UEs is assumed as greater than 1 slot (14 symbols) but less than 2 slots (28 symbols).

  • Run-1: When scheduler runs at the start of Slot-A, it schedules 3 slots starting from Slot-C, because for Slot-A and Slot-B the UEs do not get enough PUSCH preparation time (UEs gets a time of 0 symbols at start of Slot-A and 14 symbols at start of Slot-B). For Slot-C, UEs get 28 symbols for PUSCH preparation and this satisfies the PUSCH preparation time capability. Hence, Slot-C, D, and E are scheduled in this run.

  • Run-2: When scheduler runs at the start of Slot-D, it schedules the next 3 contiguous slots starting from Slot-F (Slot-F, G, and H).

You can choose any one of the implemented scheduling strategies: proportional fair (PF), best CQI, or round robin (RR). The various supported inputs to the UL scheduler are listed along with the scheduling strategies that consider them.

The two control packets, the buffer status report (BSR) and UL assignment, are assumed to be sent out of band without the need of resources for transmission.

Demodulation reference signal (DM-RS) is not modeled in this example. Two symbols in a slot are kept unused across the frequency domain of the resource allocations.

This example models:

  • Slot based UL scheduling. UL scheduler ensures that the UEs get the required PUSCH preparation time.

  • Noncontiguous allocation of frequency-domain resources in terms of resource block groups (RBGs).

  • Configurable subcarrier spacing (15, 30, 60 kHz) resulting in different slot durations.

  • Asynchronous UL hybrid automatic repeat request (HARQ) mechanism.

  • UL reception success/failure detection by UEs using new data indicator (NDI) flag present in UL assignment.

  • Multiple logical channels to support different application traffic patterns.

  • Logical channel prioritization (LCP) at UE to distribute the received UL assignment among logical channels.

  • Periodic UL application traffic pattern.

  • RLC operating in UM mode.

Scenario Configuration

For the simulation, set these key configuration parameters:

  • Simulation time

  • Number of UEs

  • Distance of UEs from gNB (affects the UL CQI values for UEs)

  • Application traffic pattern at UEs to generate traffic

  • RLC configuration for Tx and Rx entities at UEs and gNB respectively

  • Logical channel configuration of UEs and gNB

  • Scheduling strategy: PF, Best CQI, RR

  • Periodicity of BSRs sent by UEs to inform gNB about pending buffer amount

  • PUSCH preparation time for UEs

  • PUSCH bandwidth in terms of number of resource blocks (RBs)

  • Subcarrier spacing: 15, 30, 60 (kHz)

  • RBG size configuration type

  • Initial UL channel quality and its update mechanism

  • Relation of successful reception probability with channel quality

rng('default'); % Reset the random number generator
simParameters = []; % Clear the simParameters variable
simParameters.NumFramesSim = 200; % Simulation time in terms of number of 10 ms frames

% Number of UEs in the simulation. UEs are assumed to have sequential radio
% network temporary identifiers (RNTIs) from 1 to NumUEs. If you change the
% number of UEs, ensure that the simulation parameters
% simParameters.UEDistance and simParameters.PacketPeriodicityUEs are
% array of length equal to NumUEs; and simParameters.PacketSizesUEs,
% properties of simParameters.RLCConfig, and simParameters.LCHConfig
% consists of number of rows equal to numUEs.
simParameters.NumUEs = 4;
% Number of logical channels in each UE. If you change the number of
% logical channels, ensure that the simulation parameters
% simParameters.PacketSizesUEs, properties of simParameters.RLCConfig, and
% simParameters.LCHConfig consists of number of columns equal to
% NumLogicalChannels.
simParameters.NumLogicalChannels = 3;
simParameters.UEDistance = [100; 250; 700; 750]; % Distance of UEs from gNB (in meters)

% Set the application traffic pattern for UEs. For example, the vector
% element value 50 at position 4 represents that for each of the logical
% channels of UE-4, a packet is generated every 50 ms
simParameters.PacketPeriodicityUEs = [50; 60; 60; 50]; % Periodicity at which UEs generate packets in logical channels (in ms)
% The N-by-P matrix represents the size of packet generated by
% the UE in each logical channel, where 'N' represents the number of UEs
% and 'P' represents the number of logical channels. For example, the value
% 1000 at position (4, 1) represents a packet of size 1000 bytes generated by
% UE-4 for logical channel id 1
simParameters.PacketSizesUEs = [3000 4000 100000;
    500  25000 60000;
    2000 80000 4000;
    1000 20000 4000];

% RLC configuration
% Each property of RLCConfig must be an N-by-P matrix, where 'N' represents the number of UEs
% and 'P' represents the number of logical channels. A matrix element at position
% (i, j) corresponds to property value of a UE with RNTI value 'i' and logical channel id 'j'.
% Sequence number field length (in bits) to be used by each UE for their logical channels
simParameters.RLCConfig.SNFieldLength = [6 6 12;
    6 6 12;
    6 12 6;
    6 6 12];
% Reassembly timer to be used by each UE for their logical channels
simParameters.RLCConfig.ReassemblyTimer = [5 10 15;
    5  5 10;
    5  5  5;
    5 10 15];
% Max buffer length of each logical channel (to model Tx buffer overflow)
simParameters.RLCConfig.MaxTxBufferLength = [10240 10240 1024000;
    1024 102400 204800;
    10240 10240 10240;
    10240 102400 102400];

% Logical channel configuration
% Each property of LCHConfig must be an N-by-P matrix, where 'N' represents the number of UEs
% and 'P' represents the number of logical channels. A matrix element at position
% (i, j) corresponds to property value of a UE with RNTI value 'i' and logical channel id 'j'.
% Mapping between logical channel and logical channel group id
simParameters.LCHConfig.LCGID = [1 3 2;
    1 2 2;
    1 2 3;
    5 1 2];
% Priority of each logical channel
simParameters.LCHConfig.Priority = [1 5 8;
    1 1 6;
    4 10 4;
    10 11 13];
% Prioritized bitrate (in kilo bytes per second) of each logical channel
simParameters.LCHConfig.PBR = [8 16 32;
    8 128 32;
    8 16 32;
    8 16 32];
% Bucket size duration (in ms) of each logical channel
simParameters.LCHConfig.BSD = [5 10 50;
    5 20 20;
    5 5 5;
    5 10 20];

% MAC configuration
% Set the scheduler run periodicity in terms of number of slots. Value must be
% less than the number of slots in a 10 ms frame
simParameters.SchedulerPeriodicity = 4;
simParameters.SchedulerStrategy = 'PF'; % Supported scheduling strategies: 'PF', 'RR' and 'BestCQI'
% Moving average weight parameter within the range [0, 1] calculates
% average data rate for a UE. The value is used in the PF scheduling strategy.
% Parameter value closer to 1 implies more weight on the instantaneous
% data rate. Parameter value closer to 0 implies more weight on the past
% data rate
% AverageDataRate = ((1 - MovingAvgDataRateWeight) * PastDataRate) + (MovingAvgDataRateWeight * InstantaneousDataRate)
simParameters.MovingAvgDataRateWeight = 0.5;
simParameters.BSRPeriodicity = 5; % In ms
simParameters.EnableHARQ = true; % Flag to enable or disable HARQ. If disabled, there are no retransmissions
simParameters.NumHARQ = 16; % Number of HARQ processes in each UE
% PUSCH preparation time. gNB ensures that PUSCH assignment is received at
% UEs PUSCHPrepTime ahead of the transmission time
simParameters.PUSCHPrepTime = 200; % In microseconds
% Maximum RBs allotted to a UE in a slot for a PUSCH transmission (limit is
% applicable for new PUSCH assignments and not for the retransmissions)
simParameters.RBAllocationLimitUL = 15;

% Physical layer and channel configuration
% RB count for 5 MHz band with 15 kHz subcarrier spacing (SCS). The complete
% UL bandwidth is assumed to be allotted for PUSCH
simParameters.NumRBs = 25;
simParameters.SCS = 15;
% Set the RBG size configuration to 1 (configuration-1 RBG table) or 2
% (configuration-2 RBG table) as defined in 3GPP TS 38.214 Section
% 5.1.2.2.1
simParameters.RBGSizeConfig = 1;

% Configure parameters to update channel conditions for the UEs. Channel
% quality is periodically improved or deteriorated by CQIDelta every
% channelUpdatePeriodicity seconds for all RBs of a UE. Whether channel
% conditions for a particular UE improve or deteriorate is randomly
% determined: RBCQI = RBCQI +/- CQIDelta
simParameters.ChannelUpdatePeriodicity = 0.5; % In sec
simParameters.CQIDelta = 1;
% Mapping between distance from gNB (first column in meters) and maximum
% achievable UL CQI value (second column). For example, if a UE is 700
% meters away from the gNB, it can achieve a maximum CQI value of 10 as the
% distance falls within the [501, 800] meters range, as per the mapping. Set
% the distance in increasing order and the achievable CQI value in decreasing
% order
simParameters.CQIvsDistance = [
    200  15;
    500  12;
    800  10;
    1000  8;
    1200  7];
% Expression to calculate reception success probability of a PUSCH packet
% based on the channel quality. 'x' represents the average CQI of the RBs
% over which the PUSCH packet is received
simParameters.CQISuccessProb = '.4 + (x/20)';

% Logging and visualization configuration
% Flag to enable or disable run time CQI visualization
simParameters.CQIVisualization = true;
% Flag to enable or disable run time visualization of RB assignment. If enabled,
% then for slot based scheduling it updates every frame (10 ms) to show RB
% allocation to the UEs for different slots of the last frame.
simParameters.RBVisualization = true;

% The output metrics plots are updated NumMetricsSteps times during
% simulation
simParameters.NumMetricsSteps = 20;

% MAT-files used for post simulation visualization
simParameters.ParametersLogFile = 'simParameters'; % For logging the simulation parameters
simParameters.SimulationLogFile = 'simulationLogs'; % For logging the simulation logs

hNRULSchedulingValidateConfig(simParameters); % Validate the simulation configuration

Derived Parameters

Based on the primary configuration parameters, compute the derived parameters.

% Slot duration for the selected SCS and number of slots in a 10 ms frame
slotDuration = 1/(simParameters.SCS/15); % Slot duration in ms
numSlotsFrame = 10/slotDuration; % Number of slots in 10 ms frame
numSlotsSim = simParameters.NumFramesSim * numSlotsFrame; % Number of slots in the simulation

% Packet periodicities of UEs in terms of number of slots
appPeriodicityUEsSlots = simParameters.PacketPeriodicityUEs ./ slotDuration;

% Maximum RLC SDU length (in bytes)
simParameters.maxRLCSDULength = 9000;

% RLC entity direction. Value 0 represents downlink only, 1
% represents UL only and 2 represents both UL and downlink
% direction. Setting entity direction to have only UL
simParameters.RLCConfig.EntityDir = ones(simParameters.NumUEs, simParameters.NumLogicalChannels);

% Logical channel id
simParameters.LCHConfig.LCID = ones(simParameters.NumUEs, simParameters.NumLogicalChannels) .* (1:simParameters.NumLogicalChannels);

% Construct information for RLC logger
lchInfo = repmat(struct('LCID',[],'EntityDir',[]), [simParameters.NumUEs 1]);
for idx=1:simParameters.NumUEs
    lchInfo(idx).LCID = simParameters.LCHConfig.LCID(idx, :);
    lchInfo(idx).EntityDir = simParameters.RLCConfig.EntityDir(idx, :);
end

% Periodicity of channel update in terms of number of slots
channelUpdatePeriodicitySlots = floor((simParameters.ChannelUpdatePeriodicity * 1000)/...
    slotDuration);
% Find maximum achievable CQI value for UEs based on their distance from
% the gNB
maxUECQIs = zeros(simParameters.NumUEs, 1); % To store the maximum achievable CQI value for UEs
for ueIdx = 1:simParameters.NumUEs
    % Based on the distance of the UE from gNB, find matching row in
    % CQIvsDistance mapping
    matchingRowIdx = find(simParameters.CQIvsDistance(:, 1) > simParameters.UEDistance(ueIdx));
    if isempty(matchingRowIdx)
        maxUECQIs(ueIdx) = simParameters.CQIvsDistance(end, 2);
    else
        maxUECQIs(ueIdx) = simParameters.CQIvsDistance(matchingRowIdx(1), 2);
    end
end

% Interval at which metrics visualization updates in terms of number of
% slots. Make sure that MetricsStepSize is an integer
simParameters.MetricsStepSize = ceil(numSlotsSim / simParameters.NumMetricsSteps);
if mod(numSlotsSim, simParameters.NumMetricsSteps) ~= 0
    % Update the NumMetricsSteps parameter if numSlotsSim is not
    % completely divisible by it
    simParameters.NumMetricsSteps = floor(numSlotsSim / simParameters.MetricsStepSize);
end

gNB and UEs Setup

Create the gNB and UE objects, initialize the UL channel condition information for UEs at gNB, and set up the logical channels at gNB and UE. The helper classes hNRGNB.m and hNRUE.m create gNB and UE node respectively, containing the RLC and MAC layer. For MAC layer, hNRGNB.m uses the helper class hNRGNBMAC.m to implement the gNB MAC functionality and hNRUE.m uses hNRUEMAC.m to implement the UE MAC functionality. Scheduler is implemented in hNRGNBMACScheduler.m. For RLC layer, both hNRGNB.m and hNRUE.m use hNRUMTransmitter.m to implement the functionality of the RLC transmitter and hNRUMReceiver.m to implement the functionality of the RLC receiver.

gNB = hNRGNB(simParameters); % Create the gNB node
scheduler = hNRGNBMACScheduler(simParameters); % Create MAC scheduler
addScheduler(gNB, scheduler); % Add scheduler to gNB

% Create and store UE node objects
UEs = cell(simParameters.NumUEs, 1);
for ueIdx=1:simParameters.NumUEs
    UEs{ueIdx} = hNRUE(simParameters, ueIdx);
end

% Define UL channel quality as an N-by-P matrix, where N is the number
% of UEs and P is the number of RBs in the carrier bandwidth. The initial
% value of CQI for each RB, for each UE, is given randomly and is limited
% by the maximum achievable CQI value corresponding to the distance of the
% UE from gNB. Update the defined channel quality information to UEs and
% gNB
uplinkChannelQuality = zeros(simParameters.NumUEs, simParameters.NumRBs); % To store current UL CQI values on the RBs for different UEs
for ueIdx = 1:simParameters.NumUEs
    % Assign random CQI values for the RBs, limited by the maximum achievable CQI value
    uplinkChannelQuality(ueIdx, :) = randi([1 maxUECQIs(ueIdx)], 1, simParameters.NumRBs);
    % Update the UL CQI values at gNB (UL direction is represented as 1)
    updateChannelQualityStatus(gNB, uplinkChannelQuality(ueIdx, :), 1, ueIdx);
end

% Setup logical channels
for ueIdx=1:simParameters.NumUEs
    for lcid = 1:simParameters.NumLogicalChannels
        % Create RLC channel configuration structure
        rlcChannelConfigStruct.LCID = simParameters.LCHConfig.LCID(ueIdx, lcid);
        rlcChannelConfigStruct.SnFieldLength = simParameters.RLCConfig.SNFieldLength(ueIdx, lcid);
        rlcChannelConfigStruct.MaxTxBufferLength = simParameters.RLCConfig.MaxTxBufferLength(ueIdx, lcid);
        rlcChannelConfigStruct.ReassemblyTime = simParameters.RLCConfig.ReassemblyTimer(ueIdx, lcid);
        rlcChannelConfigStruct.EntityDir = simParameters.RLCConfig.EntityDir(ueIdx, lcid);
        rlcChannelConfigStruct.LCGID = simParameters.LCHConfig.LCGID(ueIdx, lcid);
        rlcChannelConfigStruct.Priority = simParameters.LCHConfig.Priority(ueIdx, lcid);
        rlcChannelConfigStruct.PBR = simParameters.LCHConfig.PBR(ueIdx, lcid);
        rlcChannelConfigStruct.BucketSizeDuration = simParameters.LCHConfig.BSD(ueIdx, lcid);
        
        % Setup logical channel at gNB for the UE
        configureLogicalChannel(gNB, ueIdx, rlcChannelConfigStruct);
        % Setup logical channel at UE
        configureLogicalChannel(UEs{ueIdx}, ueIdx, rlcChannelConfigStruct);
    end
end

% Initialize buffers to exchange packets between UEs and gNB
hNRPacketExchangeBuffer(simParameters);

Processing Loop

Simulation is run slot by slot. In each slot, these operations are executed:

  • Update channel conditions: Update UL CQI values at RBs for each UE based on the channel update periodicity.

  • Run the scheduler: If the scheduler is set to run in this slot (based on its configured periodicity), assign UL resources to UEs. In one scheduler run, resources of multiple upcoming slots can be scheduled. For each scheduled slot, assignments of RBs for retransmissions are performed first, followed by assignments for new transmission (if there are any RBs left). A UE is limited to a maximum of 1 PUSCH assignment per slot.

  • Control Tx (gNB): Create and send UL assignments based on the assignments done by respective schedulers.

  • Generate application traffic: Generate UL traffic as per the configured periodicity of application traffic pattern.

  • Data Tx (UE): UEs send UL MAC packets adhering to the UL assignments received in earlier slots (if any for this slot).

  • Control Tx (UE): Based on the configured BSR periodicity, UEs send the BSR to convey the pending buffer amount.

  • Control Rx (gNB): Receive BSR from UEs and store the information which is used when the scheduler runs next.

  • Data Rx (gNB): Receive UL MAC packets from the UEs scheduled to transmit in this slot. If a reception fails, create the retransmission context for the particular UE, which is used for assignments for retransmissions when the scheduler runs next.

  • Control Rx (UE): UEs receive their respective UL assignments for upcoming slots. UEs process the UL assignment and store the information to be used for the PUSCH transmission.

  • Logging and Visualization: The output of operations at gNB and UEs are used for logging and visualization.

% To store the following UE metrics for each slot: throughput bytes
% transmitted, goodput bytes transmitted, and pending buffer amount bytes.
% The number of goodput bytes is calculated by excluding the retransmissions from the total
% transmissions
UEMetrics = zeros(simParameters.NumUEs, 3);

% To store the RLC statistics for each slot
ueRLCStats = cell(simParameters.NumUEs, 1);
gNBRLCStats = cell(simParameters.NumUEs, 1);

% Create an object for MAC scheduling information visualization and logging (UL direction is represented as 1)
simSchedulingLogger = hNRSchedulingLogger(simParameters, 1);
% Create an object for RLC visualization and logging (UL direction is represented as 1)
simRLCLogger = hNRRLCLogger(simParameters, lchInfo, 1);

symbolNum = 0;
% Run processing loop
for slotNum = 1:numSlotsSim
    
    % Update the UL channel quality for UEs periodically
    if mod(slotNum, channelUpdatePeriodicitySlots) == 0
        for ueIdx = 1:simParameters.NumUEs
            CQIRBs = getChannelQualityStatus(gNB, 1, ueIdx); % Current CQI values
            % Update CQI values for RBs by randomly increasing or
            % decreasing current values by CQIDelta, limited by
            % the minimum and maximum achievable CQI index value. You can
            % customize the updating of CQI values as necessary.
            updateType = [1 -1]; % Improvement/deterioration
            channelQualityChange  = updateType(randi(length(updateType)));
            updatedCQIs = min(max(CQIRBs + simParameters.CQIDelta*channelQualityChange, 1), maxUECQIs(ueIdx));
            % Update the UL channel quality at gNB for the UE (UL direction is represented as 1)
            updateChannelQualityStatus(gNB, updatedCQIs, 1, ueIdx);
        end
    end
    
    % Run the gNB scheduler. Check whether the scheduler is set to run in
    % the slot. If yes, schedule the resources and send the corresponding
    % UL assignments
    resourceAssignments = runULSchedulerFDD(gNB);
    if ~isempty(resourceAssignments)
        controlTx(gNB, resourceAssignments, []);
    end
    
    % Run the UE operations
    HARQProcessStatus = zeros(simParameters.NumUEs, simParameters.NumHARQ); % To store last sent HARQ process NDI flag
    for ueIdx = 1:simParameters.NumUEs % For all UEs
        
        % Generate UL traffic if UL packet generation periodicity is reached for the UE
        if mod(slotNum-1, appPeriodicityUEsSlots(ueIdx)) == 0
            % Receive UL data for the UE from upper layers based on
            % UL application traffic pattern
            for lcid = 1:simParameters.NumLogicalChannels
                % Divide application packet into multiple RLC SDUs if it is
                % bigger than maximum RLC SDU size
                numRLCSDU = floor(simParameters.PacketSizesUEs(ueIdx, lcid) / simParameters.maxRLCSDULength);
                rlcSDU = randi([0 255], simParameters.maxRLCSDULength, 1);
                for i = 1:numRLCSDU % Generate UL packets of max RLC SDU size (if any)
                    receiveRLCSDU(UEs{ueIdx}, ueIdx, lcid , rlcSDU);
                end
                if mod(simParameters.PacketSizesUEs(ueIdx, lcid),simParameters.maxRLCSDULength) ~= 0
                    % Generate UL packet which is smaller than maxRLCSDULength
                    rlcSDU = randi([0 255], mod(simParameters.PacketSizesUEs(ueIdx, lcid),simParameters.maxRLCSDULength), 1);
                    receiveRLCSDU(UEs{ueIdx}, ueIdx, lcid , rlcSDU);
                end
            end
        end
        
        % UE sends the PUSCH packet if it is a Tx slot (as conveyed by gNB in
        % earlier received UL assignments).
        dataTx(UEs{ueIdx});
        
        % UE sends BSR packet, if scheduled to send in this slot
        controlTx(UEs{ueIdx});
        
        % For logging
        % Read throughput and goodput bytes transmitted for this UE in the current TTI
        [UEMetrics(ueIdx, 1), UEMetrics(ueIdx, 2)] = getCurrTTIBytes(UEs{ueIdx});
        % Read pending UL buffer (in bytes) on UE
        UEMetrics(ueIdx, 3) = getBufferStatus(UEs{ueIdx});
        % Read the last received NDI flags for UE HARQ processes (UL direction is represented as 1)
        HARQProcessStatus(ueIdx, :) = getLastNDIFlagHarq(UEs{ueIdx}, 1);
        % Read the UL channel quality at gNB for each of the UEs (UL direction is represented as 1)
        uplinkChannelQuality(ueIdx, :) = getChannelQualityStatus(gNB, 1, ueIdx);
    end
    
    % Run the Rx operation at gNB for simultaneous reception of packets
    controlRx(gNB); % Receive BSRs
    
    % Receive UL MAC packets from UEs that are scheduled to transmit in
    % this slot. Return the information of Rx success/failure
    rxResultUEs = dataRx(gNB);
    
    % Run the Rx operation at UEs for simultaneous reception of packets
    for ueIdx = 1:simParameters.NumUEs % For all UEs
        controlRx(UEs{ueIdx}); % Receive UL assignments, if any sent by gNB
    end
    
    % RLC statistics of each UE
    for ueIdx = 1:simParameters.NumUEs
        ueRLCStats{ueIdx} = getRLCStatistics(UEs{ueIdx}, ueIdx);
        gNBRLCStats{ueIdx} = getRLCStatistics(gNB, ueIdx);
    end
    
    % Update uplink logs based on the current slot run of UEs and gNB. Logs are
    % updated in each slot
    logScheduling(simSchedulingLogger,  symbolNum + 1, resourceAssignments, UEMetrics, uplinkChannelQuality, HARQProcessStatus, rxResultUEs, 1);
    % Update RLC statistics logs
    logRLCStats(simRLCLogger, ueRLCStats, gNBRLCStats);
    
    % If RB Visualization flag is set, update the RB assignment grid at the
    % last slot of each frame
    if simParameters.RBVisualization && mod(slotNum, numSlotsFrame) == 0
        plotRBGrids(simSchedulingLogger);
    end
    
    % If CQI Visualization flag is set, update the CQI grid at the last
    % slot of each frame
    if simParameters.CQIVisualization && mod(slotNum, numSlotsFrame) == 0
        plotCQIRBGrids(simSchedulingLogger);
    end
    
    % Plot MAC scheduling performance, RLC throughput metrics at every metricsStepSize slots
    if mod(slotNum, simParameters.MetricsStepSize) == 0
        plotMetrics(simSchedulingLogger);
        plotMetrics(simRLCLogger);
    end
    
    tickGranularity = 14; % Number of symbols in a slot
    % Advance timer ticks for gNB and UEs by 'tickGranularity' symbols
    advanceTimer(gNB, tickGranularity);
    for ueIdx = 1:simParameters.NumUEs % For all UEs
        advanceTimer(UEs{ueIdx}, tickGranularity);
    end
    
    % Symbol number in the simulation
    symbolNum = symbolNum + tickGranularity;
end

Simulation Visualization

The four types of run-time visualization shown are:

  • Display of CQI values for UEs over the PUSCH bandwidth: For details, see the 'Channel Quality Visualization' figure for more details.

  • Display of resource grid assignment to UEs: The 2-D time-frequency grid updates every 10 ms (frame length) and shows the RB allocation to the UEs in the previous frame. The HARQ process for the PUSCH assignments is also shown alongside with the RNTI of the UEs. New transmissions are shown in black and retransmissions are shown in blue using the HARQ process ID of each UE, a retransmission assignment can be mapped to its previously failed transmission. For details, see the 'Resource Grid Allocation' figure for more details.

  • Display of uplink metrics plots: The 'Uplink Scheduler Performance Metrics' figure includes plots of the: UL throughput (per UE and cell), UL goodput (per UE and cell), resource share percentage among UEs (out of the total UL resources) to convey the fairness of scheduling, and pending UL buffer status of the UEs to show whether UEs are getting sufficient resources. The performance metrics plots update for every metricsStepSize slots.

  • Display of RLC metrics plot: The 'RLC throughput visualization' figure represents the throughput of RLC layer (per logical channel) for the selected UE. The RLC metrics plot update for every metricsStepSize slots.

Simulation Logs

The parameters used for the simulation and simulation logs are saved in MAT files for post-simulation analysis and visualization. The simulation parameters are saved in a MAT file with the filename as the value of configuration parameter simParameters.ParametersLogFile. The per time step logs, scheduling assignment logs and RLC logs are saved in MAT file simParameters.SimulationLogFile. After the simulation, open the file to load timeStepLogs, schedulingAssignmentLogs and rlcLogs in the workspace.

Time step logs: The table shows a sample time step entry. Each row of the table represents a slot.

Each row of the table represents a slot and contains the following information:

  • Frame: Frame number.

  • Slot: Slot number in the frame.

  • RBG Allocation Bitmap: N-by-P bitmap matrix, where N is the number of UEs and P is the number of RBGs. If an RBG is assigned to a particular UE, the corresponding bit is set to 1. For example, [ 0 0 1 1 0 1 0 1 0 1 0 0 0; 1 1 0 0 0 0 0 0 0 0 1 0 0; 0 0 0 0 1 0 1 0 1 0 0 1 1; 0 0 0 0 0 0 0 0 0 0 0 0 0] means that the UL bandwidth has 13 RBGs and UE-1 is assigned RBG indices: 2, 3, 5, 7 and 9; UE-2 is assigned the RBG indices 0, 1 and 10; UE-3 is assigned the RBG indices 4, 6, 8, 11 and 12 and UE-4 is not assigned any RBG.

  • MCS: Row vector of length N, where N is the number of UEs. Each value corresponds to the modulation and coding scheme (MCS) index for the PUSCH transmission. For example, [10 12 8 -1] means that only UE-1, UE-2, and UE-3 are assigned UL resources for this slot and use MCS values 10, 12, and 8, respectively.

  • HARQ Process: Row vector of length N, where N is the number of UEs. The value is the HARQ process ID used by UE for the PUSCH transmission. For example, [0 3 6 -1] means that only UE-1, UE-2, and UE-3 are assigned UL resources for this slot and use the HARQ process IDs 0, 3, and 6, respectively.

  • NDI: Row vector of length N, where N is the number of UEs. The value is the NDI flag value in the UL assignment for PUSCH transmission. For example, [0 0 1 -1] means that only UE-1, UE-2, and UE-3 are assigned UL resources for this slot and use the NDI flag values (which determine whether a new transmission or a retransmission is used) 0, 0, and 1, respectively.

  • Tx Type: Tx Type specifies the transmission type (new transmission or retransmission). Row vector of length N, where N is the number of UEs. Possible values are either 'newTx', 'reTx', or 'noTx'. 'noTx' means that the UE is not allotted PUSCH resources. For example, ['newTx' 'newTx' 'reTx' 'noTx'] means that only UE-1, UE-2, and UE-3 are assigned UL resources for this slot. UE-1 and UE-2 transmit a new packet from the specified HARQ process, while UE-3 retransmits the packet in the buffer of the specified HARQ process.

  • CQI for UEs: N-by-P matrix, where N is the number of UEs and P is the number of RBs in the bandwidth. A matrix element at position (i, j) corresponds to the UL CQI value for UE with RNTI i at RB j.

  • HARQ NDI Status: N-by-P matrix, where N is the number of UEs and P is the number of HARQ processes on UEs. A matrix element at position (i, j) is the last received NDI flag at UE i for HARQ process ID j. For new transmissions, this value and the NDI flag in the PUSCH assignment must toggle. For example, in slot 1 of frame 5 described in the scheduling log, UE-1 uses the HARQ ID 0 and the last NDI flag value for HARQ ID 0 at UE-1 is 1. To indicate a new transmission, the NDI flag values changes to 0 in the PUSCH assignment.

  • Throughput Bytes: Row vector of length N, where N is the number of UEs. The values represent MAC bytes transmitted by UEs in this slot.

  • Goodput Bytes: Row vector of length N, where N is the number of UEs. The values represent new transmission MAC bytes transmitted by UEs in this slot.

  • Buffer Status of UEs: Row vector of length N, where N is the number of UEs. The values represent the amount of pending buffers at UEs.

  • Rx Success/Failure: Row vector of length N, where N is the number of UEs. The possible values are either 'RxSuccess', 'RxFailure', or 'noRx'. 'noRx' means that gNB is not expecting Rx from the UE. For example, ['RxSuccess' 'RxSuccess' 'RxFailure' 'noRx'] means that packets from UE-1 and UE-2 are received successfully, while the packet from UE-3 was either not received or was corrupted. UE-4 was not scheduled for this slot.

Scheduling assignment logs: Information of all the scheduling assignments and related information is logged in this file. The table shows sample log entries.

RLC logs: Each row in the RLC logs represents a slot and contains this information:

  • Frame: Frame number.

  • Slot: Slot number in the frame.

  • UE RLC statistics: N-by-P cell, where N is the product of the number of UEs and the number of logical channels, and P is the number of statistics collected. Each row represents statistics of a logical channel in a UE.

  • gNB RLC statistics: N-by-P cell, where N is the product of the number of UEs and the number of logical channels, and P is the number of statistics collected. Each row represents statistics of a logical channel of a UE at gNB.

The last row contains the cumulative RLC statistics of the entire simulation.

The table shows a sample entry in UE RLC statistics. Similar logs are available in gNB RLC statistics.

Each row of the table represents a logical channel of a UE and contains:

  • RNTI: Radio network temporary identifier of a UE.

  • LCID: Logical channel identifier.

  • TxPDCPPDU: Number of PDUs sent by packet data convergence protocol (PDCP) to RLC layer.

  • TxPDCPPDUBytes: Number of bytes sent by PDCP to RLC layer.

  • TxRLCSDUDiscarded: Number of RLC SDUs discarded by RLC layer due to Tx buffer overflow.

  • TxRLCSDUDiscardedBytes: Number of discarded bytes by RLC layer due to Tx buffer overflow.

  • TxRLCPDU: Number of PDUs sent by RLC to MAC layer.

  • TxRLCPDUBytes: Number of bytes sent by RLC to MAC layer.

  • RxPDCPPDU: Number of PDUs received by PDCP from RLC layer.

  • RxPDCPPDUBytes: Number of bytes received by PDCP from RLC layer.

  • RxRLCPDU: Number of PDUs received by RLC from MAC layer.

  • RxRLCPDUBytes: Number of bytes received by RLC from MAC layer.

  • RxRLCPDUDuplicate: Number of duplicate PDUs received by RLC from MAC layer.

  • RxRLCPDUDuplicateBytes: Number of duplicate bytes received by RLC from MAC layer.

  • RxRLCPDUDropped: Number of received PDUs dropped by RLC from MAC layer.

  • RxRLCPDUDroppedBytes: Number of dropped bytes by RLC received from MAC layer.

  • TimerReassemblyTimedOut: Number of times the reassembly timer expired.

You can run the script NewRadioPUSCHSchedulingLogVisualization.m to get a post simulation visualization of logs. In post simulation script, you get the variable isLogReplay, which provides these options to visualize 'Resource Grid Allocation' and 'Channel Quality Visualization' figures.

  • Set isLogReplay to true for a replay of the simulation logs.

  • Set isLogReplay to false to analyze the simulation logs and input the frame number to visualize the scheduling information of the particular frame.

% Read the logs and write them to MAT-files
[~, ulTimeStepLogs] = getSchedulingLogs(simSchedulingLogger); % UL time step scheduling logs
schedulingGrantLogs = getGrantLogs(simSchedulingLogger); % DCI message log
% RLC statistics logs
rlcLogs = getRLCLogs(simRLCLogger);
save(simParameters.SimulationLogFile, 'ulTimeStepLogs', 'schedulingGrantLogs', 'rlcLogs'); % Save simulation logs in a MAT-file
save(simParameters.ParametersLogFile, 'simParameters'); % Save simulation parameters in a MAT-file

Further Exploration

You can modify the existing UL scheduling functionality to schedule resources of a slot. The scheduling of UL resources of a slot is implemented in scheduleULResourcesSlot function of hNRGNBMACScheduler. Populate the output uplinkGrants of this function with an array of valid UL scheduling assignments. Each element in this structure array is PUSCH assignment for a UE. The PUSCH assignment structure has these fields:

  • RNTI: Assignment is for this UE. This field is not part of the actual assignment packet sent to UEs.

  • Type: Whether assignment is for new transmission ('newTx'), retransmission ('reTx') or no assignment ('noTx'). This field is not part of actual assignment packet sent to UEs, as NDI field is sufficient to convey that.

  • HARQIndex: Selected UL UE HARQ process ID.

  • RBGAllocationBitmap: Frequency-domain resource assignment. A bitmap of resource-block-groups of the PUSCH bandwidth. Value 1 indicates RBG is assigned to the UE.

  • StartSymbol: Start symbol of PUSCH assignment resources. Keep at 0.

  • NumSymbols: Number of symbols in PUSCH assignment. Keep at 14.

  • SlotOffset: Slot offset of PUSCH assignments with respect to the current slot.

  • MCS: Selected modulation and coding scheme.

  • NDI: New data indicator flag.

  • RV: Redundancy version.

The figure shows UL resources of a slot being distributed in four PUSCH assignments. It also shows content of the first assignment.

Setting the property scheduleULResourcesSlot enables you to control the assignment of all the RBGs of a slot at once. You can also control the assignment of each RBG of a TTI. For reference, you can see the existing scheduling strategies present in the helper functions hNRSchedulingStrategyBestCQI.m, hNRSchedulingStrategyPF.m, and hNRSchedulingStrategyRR.m. The scheduling strategy function is called once for each of the remaining RBGs, after assignments for retransmissions are completed. The function takes a structure as an input and returns the selected UE to which the RBG is assigned and the corresponding MCS index. To write a custom scheduling strategy, use the information in the input structure to set the output. The input structure contains these fields:

  • eligibleUEs: RNTI of the eligible UEs contending for the RBG.

  • slotNum: Slot number in the frame to be scheduled.

  • RBGIndex: RBG index in the slotNum to be scheduled.

  • RBGSize: Size of the RBG in terms of number of RBs.

  • cqiRBG: UL channel quality of RBG. N-by-P matrix with UL CQI values for eligible UEs on different RBs of the RBG. N is the number of eligible UEs and P is RBGSize.

  • pastDataRate: Row vector of length N containing the historical achieved data rate of UEs. N is the number of eligible UEs.

  • bufferStatus Row vector of length N containing pending buffer status for UEs. N is the number of eligible UEs.

  • mcsRBG: N-by-2 matrix containing the MCS index and corresponding efficiency (suitable as per the CQI values on the RBs of RBG). N is the number of eligible UEs. Efficiency is bits/symbol, taking into consideration both the modulation scheme and coding rate.

  • ttiDur: TTI duration in ms.

  • UEs: RNTI of all the UEs.

  • lastSelectedUE: The RNTI of UE which was assigned the last scheduled RBG.

A scheduling strategy can use a subset of the preceding fields to make a decision. To implement a custom scheduling strategy, create the function file NewStrategy.m and in the scenario configuration, set the parameter simParameters.SchedulerStrategy to 'NewStrategy'. Follow the template of existing strategies for the function signature.

Based on the chosen scheduling strategy, this example shows the assignment of UL resources to multiple UEs by the gNB. The physical layer is abstracted in the example. A run-time visualization display of the resource grid gives detailed information about the RBs allocated to each UE in different slots of the frame and the HARQ process ID assigned for transmission. Scheduling performance is analyzed based on run-time plots of MAC throughput, MAC goodput, resource share fairness, and pending buffer status of the UEs. A more thorough post-simulation analysis by using the saved logs gives a detailed picture of the operations happening on a per-slot basis.

Appendix

The example uses these helper functions and classes:

References

[1] 3GPP TS 38.214. “NR; Physical layer procedures for data.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

[2] 3GPP TS 38.321. “NR; Medium Access Control (MAC) protocol specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

[3] 3GPP TS 38.322. “NR; Radio Link Control (RLC) protocol specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

Related Topics