Main Content

NR PUSCH FDD Scheduling

This example evaluates the throughput and resource share fairness performance of an uplink (UL) scheduling strategy in frequency division duplexing (FDD) mode with radio link control (RLC) layer integrated. The UL scheduling strategy assigns the physical uplink shared channel resources (PUSCH) resources to a set of user equipments (UEs) connected to a gNB. The example uses unacknowledged mode (UM) of RLC layer and a passthrough physical (PHY) layer. The passthrough PHY layer does not involve any physical layer processing and adopts a probability-based approach to model packet reception failures. The example logs the events in the simulation and also shows the run time visualizations to observe the network performance.

Introduction

This example shows how a scheduling strategy (controlled by the gNB) assigns UL resources among the UEs. The example considers the following operations within the gNB and UEs that facilitate UL transmissions and receptions.

The complete PUSCH packet is transmitted in the first symbol of its allocated symbol set. Receiver processes the packet in the symbol just after the last symbol in the allocated symbol set.

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) of 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. However, one symbol is kept unused for it in the PUSCH assignments.

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 resulting in different slot durations.

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

  • UL reception success or 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

  • RBG size configuration type

  • Initial UL channel quality and its update mechanism

rng('default'); % Reset the random number generator
simParameters = []; % Clear the simulation parameters
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 10 at index 4 represents that for each of the logical
% channels of UE-4, a packet is generated every 10 ms
simParameters.PacketPeriodicityUEs = [30; 20; 30; 10]; % 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 index (4, 1) represents a packet of size 1000 bytes generated by
% UE-4 for logical channel ID 1
simParameters.PacketSizesUEs = [4000 6000 8000;
    500  8000 8000;
    12000 8000 4000;
    1000 8000 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 (SN) 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 number of service data units (SDUs) in the Tx buffer of each logical channel (to model Tx buffer overflow)
simParameters.RLCConfig.MaxTxBufferSDUs = [4 3 11;
    3 5 4;
    6 1 3;
    11 6 26];

% Logical channel (LCH) 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 (LCG) 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 bit rate (PBR) of each logical channel (in kilo bytes per second)
simParameters.LCHConfig.PBR = [8 16 32;
    8 128 32;
    8 16 32;
    8 16 32];
% Bucket size duration (BSD) of each logical channel (in ms)
simParameters.LCHConfig.BSD = [5 10 50;
    5 20 20;
    5 5 5;
    5 10 20];

% Medium access control (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;

% PHY 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; % kHz
simParameters.ULBandwidth = 5e6; % Hz
simParameters.ULCarrierFreq = 2.515e9; % Hz
% 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];

% 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.

simParameters.NCellID = 1; % Physical cell ID
simParameters.DLCarrierFreq = 2.635e9; % Hz
simParameters.DLBandwidth = 10e6; % Hz
simParameters.GNBPosition = [0 0 0]; % Position of gNB in (x,y,z) coordinates
% 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
% directions. Setting entity direction to have only UL
simParameters.RLCConfig.EntityDir = ones(simParameters.NumUEs, simParameters.NumLogicalChannels);

% Logical channel id (logical channel ID of data radio bearers starts from 4) 
simParameters.LCHConfig.LCID = ones(simParameters.NumUEs, simParameters.NumLogicalChannels) .* (4:4+simParameters.NumLogicalChannels-1);

% 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

% 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

% Define initial 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
simParameters.InitialChannelQualityUL = 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
    simParameters.InitialChannelQualityUL(ueIdx, :) = randi([1 maxUECQIs(ueIdx)], 1, simParameters.NumRBs);
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 nodes 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. Schedulers are implemented in hNRSchedulerRoundRobin.m (Round robin), hNRSchedulerProportionalFair.m (Proportional fair), hNRSchedulerBestCQI.m (Best CQI) . All the schedulers inherit from the base class hNRScheduler.m which contains the core scheduling functionality. For RLC layer, both hNRGNB.m and hNRUE.m use hNRUMEntity.m to implement the functionality of the RLC transmitter and receiver. Passthrough PHY layer for UE and gNB is implemented in hNRUEPassThroughPhy.m and hNRGNBPassThroughPhy.m, respectively.

simParameters.Position = simParameters.GNBPosition;
gNB = hNRGNB(simParameters); % Create gNB node
% Create and add scheduler
switch(simParameters.SchedulerStrategy)
    case 'RR' % Round robin scheduler
        scheduler = hNRSchedulerRoundRobin(simParameters);
    case 'PF' % Proportional fair scheduler
        scheduler = hNRSchedulerProportionalFair(simParameters);
    case 'BestCQI' % Best CQI scheduler
        scheduler = hNRSchedulerBestCQI(simParameters);
end
addScheduler(gNB, scheduler); % Add scheduler to gNB

gNB.PhyEntity = hNRGNBPassThroughPhy(simParameters); % Create passthrough PHY
configurePhy(gNB, simParameters);
setPhyInterface(gNB); % Set the interface to PHY layer

% Create the set of UE nodes
UEs = cell(simParameters.NumUEs, 1);
for ueIdx = 1:simParameters.NumUEs
    simParameters.Position = [simParameters.UEDistance(ueIdx) 0 0]; % Position of UE
    UEs{ueIdx} = hNRUE(simParameters, ueIdx);
    simParameters.InitialChannelQualityDL = simParameters.InitialChannelQualityUL;
    UEs{ueIdx}.PhyEntity = hNRUEPassThroughPhy(simParameters, ueIdx); % Add passthrough PHY
    configurePhy(UEs{ueIdx}, simParameters);
    setPhyInterface(UEs{ueIdx}); % Set the interface to PHY layer
    
    % Initialize the UL CQI values at gNB
    updateChannelQuality(gNB, simParameters.InitialChannelQualityUL(ueIdx, :), 1, ueIdx); % 1 for UL

    % Setup logical channels
    for lcIdx = 1:simParameters.NumLogicalChannels
        % Create RLC channel configuration structure
        rlcChannelConfigStruct.EntityType = simParameters.RLCConfig.EntityDir(ueIdx, lcIdx);
        rlcChannelConfigStruct.LogicalChannelID = simParameters.LCHConfig.LCID(ueIdx, lcIdx);
        rlcChannelConfigStruct.SeqNumFieldLength = simParameters.RLCConfig.SNFieldLength(ueIdx, lcIdx);
        rlcChannelConfigStruct.MaxTxBufferSDUs = simParameters.RLCConfig.MaxTxBufferSDUs(ueIdx, lcIdx);
        rlcChannelConfigStruct.ReassemblyTimer = simParameters.RLCConfig.ReassemblyTimer(ueIdx, lcIdx);
        rlcChannelConfigStruct.EntityType = simParameters.RLCConfig.EntityDir(ueIdx, lcIdx);
        rlcChannelConfigStruct.LCGID = simParameters.LCHConfig.LCGID(ueIdx, lcIdx);
        rlcChannelConfigStruct.Priority = simParameters.LCHConfig.Priority(ueIdx, lcIdx);
        rlcChannelConfigStruct.PBR = simParameters.LCHConfig.PBR(ueIdx, lcIdx);
        rlcChannelConfigStruct.BSD = simParameters.LCHConfig.BSD(ueIdx, lcIdx);
        
        % Setup logical channel at gNB for the UE
        configureLogicalChannel(gNB, ueIdx, rlcChannelConfigStruct);
        % Setup logical channel at UE
        configureLogicalChannel(UEs{ueIdx}, ueIdx, rlcChannelConfigStruct);
        
        % Add data traffic pattern generators to UE nodes. Application data
        % is pumped to RLC layer as per the installed traffic pattern
        packetSize = simParameters.PacketSizesUEs(ueIdx, lcIdx);
        % Calculate the data rate (in kbps) of On-Off traffic pattern using
        % packet size (in bytes) and packet interval (in ms)
        dataRate = ceil(1000/simParameters.PacketPeriodicityUEs(ueIdx)) * packetSize * 8e-3;
        % Limit the size of the generated application packet to the maximum
        % RLC SDU size. The maximum supported RLC SDU size is 9000 bytes
        if packetSize > simParameters.maxRLCSDULength
            packetSize = simParameters.maxRLCSDULength;
        end
        % Create an object for On-Off network traffic pattern and add it to the
        % specified UE. This object generates the uplink (UL) data traffic on the UE
        app = networkTrafficOnOff('PacketSize', packetSize, 'GeneratePacket', true, ...
            'OnTime', simParameters.NumFramesSim/100, 'OffTime', 0, 'DataRate', dataRate);
        UEs{ueIdx}.addApplication(ueIdx, simParameters.LCHConfig.LCID(ueIdx, lcIdx), app);
    end
end

% Setup the UL and DL packet distribution mechanism
simParameters.MaxReceivers = simParameters.NumUEs;
% Create DL packet distribution object
dlPacketDistributionObj = hNRPacketDistribution(simParameters, 0);
% Create UL packet distribution object
ulPacketDistributionObj = hNRPacketDistribution(simParameters, 1);
hNRSetUpPacketDistribution(simParameters, gNB, UEs, dlPacketDistributionObj, ulPacketDistributionObj);

Processing Loop

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

  • Run the MAC and PHY layers of gNB

  • Run the MAC and PHY layers of UEs

  • Layer specific logging and visualization

  • Advance the timer for the nodes. Every 1 ms it also sends trigger to application and RLC layers. Application layer and RLC layer execute their scheduled operations based on 1 ms timer trigger.

% 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
UESlotMetrics = zeros(simParameters.NumUEs, 3);

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

% To store current UL CQI values on the RBs for different UEs
uplinkChannelQuality = zeros(simParameters.NumUEs, simParameters.NumRBs);

% To store last received NDI values for UL HARQ processes
HARQProcessStatus = zeros(simParameters.NumUEs, simParameters.NumHARQ);

% 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
    
    % Run MAC and PHY layers of gNB
    run(gNB.MACEntity);
    run(gNB.PhyEntity);
    
    % Run MAC and PHY layers of UEs
    for ueIdx = 1:simParameters.NumUEs
        % Read the last received NDI flags for HARQ processes for
        % logging (Reading it before it gets overwritten by run function of MAC)
        HARQProcessStatus(ueIdx, :) = getLastNDIFlagHarq(UEs{ueIdx}.MACEntity, 1); % 1 for UL
        run(UEs{ueIdx}.MACEntity); 
        run(UEs{ueIdx}.PhyEntity);
    end
    
    % RLC logging
    for ueIdx = 1:simParameters.NumUEs % For all UEs
        % Get RLC statistics
        ueRLCStats{ueIdx} = getRLCStatistics(UEs{ueIdx}, ueIdx);
        gNBRLCStats{ueIdx} = getRLCStatistics(gNB, ueIdx);
    end
    logRLCStats(simRLCLogger, ueRLCStats, gNBRLCStats); % Update RLC statistics logs
    
    % MAC logging
    % Read UL assignments done by gNB MAC scheduler at current time.
    % Resource assignments returned by a scheduler is empty, if UL
    % scheduler was not scheduled to run at the current time or no
    % resources got scheduled
    resourceAssignmentsUL = getCurrentSchedulingAssignments(gNB.MACEntity);
    for ueIdx = 1:simParameters.NumUEs
        % Read the UL channel quality at gNB for each of the UEs for logging
        uplinkChannelQuality(ueIdx,:) = getChannelQuality(gNB, 1, ueIdx); % 1 for UL
        % Read throughput and goodput bytes transmitted for this UE in the
        % current TTI for logging
        [UESlotMetrics(ueIdx, 1), UESlotMetrics(ueIdx, 2)] = getTTIBytes(UEs{ueIdx});
        UESlotMetrics(ueIdx, 3) = getBufferStatus(UEs{ueIdx}); % Read pending buffer (in bytes) on UE
    end
    % Update scheduling logs based on the current slot run of UEs and gNB.
    % Logs are updated in each slot, RB grid visualizations are updated
    % every frame, and metrics plots are updated every metricsStepSize
    % slots
    logScheduling(simSchedulingLogger, symbolNum + 1, resourceAssignmentsUL, UESlotMetrics, uplinkChannelQuality, HARQProcessStatus, 1);
    
    % Visualization
    % 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 UL scheduling 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 maximum achievable data rate value for UL throughput is shown with a dashed line in throughput and goodput plots. 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 ULTimeStepLogs, 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 allocated 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.

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. The last row contains the cumulative RLC statistics of the entire simulation.

  • 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.

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

  • RNTI: Radio network temporary identifier of a UE.

  • LCID: Logical channel identifier.

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

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

  • ReTxDataPDU: Number of data PDUs retransmitted by RLC to MAC layer.

  • ReTxDataBytes: Number of data bytes retransmitted by RLC to MAC layer.

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

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

  • TxPacketsDropped: Number of RLC SDUs dropped by RLC due to Tx buffer overflow.

  • TxBytesDropped: Number of bytes dropped by RLC due to Tx buffer overflow.

  • TimerPollRetransmitTimedOut: Number of times the poll retransmit timer expired.

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

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

  • RxDataPDUDropped: Number of received data PDUs from MAC which are dropped by RLC layer.

  • RxDataBytesDropped: Number of received data bytes from MAC which are dropped by RLC layer.

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

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

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

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

  • TimerReassemblyTimedOut: Number of times the reassembly timer expired.

  • TimerStatusProhibitTimedOut: Number of times the status prohibit timer expired.

You can run the script NRPostSimVisualization to get a post simulation visualization of logs. In the post simulation script, you are provided with 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 save them in MAT-files
simulationLogs = cell(1, 1);
simulationLogs{1} = struct('ULTimeStepLogs',[], 'SchedulingAssignmentLogs',[] ,'RLCLogs',[]);
[~, simulationLogs{1}.ULTimeStepLogs] = getSchedulingLogs(simSchedulingLogger); % UL time step scheduling logs
simulationLogs{1}.SchedulingAssignmentLogs = getGrantLogs(simSchedulingLogger); % Scheduling assignments log
simulationLogs{1}.RLCLogs = getRLCLogs(simRLCLogger); % RLC statistics logs
save(simParameters.SimulationLogFile, 'simulationLogs'); % Save simulation logs in a MAT-file
save(simParameters.ParametersLogFile, 'simParameters'); % Save simulation parameters in a MAT-file

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