5G NR PRACH 检测与虚警测试
R2026b此示例实现 TS 38.141-1 中定义的物理随机接入信道 (PRACH) 漏检和虚警一致性测试。您可以测量在存在前导码信号的情况下正确检测 PRACH 前导码的概率,也可以关闭 PRACH 传输,以测量虚警概率。
简介
PRACH 是用户设备 (UE) 用于发起与 gNodeB 的同步的上行链路传输。TS 38.141-1 第 8.4.1.5 节规定,在一组 PRACH 配置和传播条件对应的特定 SNR 值下,PRACH 的检测概率需要大于或等于 99%。检测错误的情况有以下几种:
检测到错误的前导码
未检测到前导码
检测到正确的前导码,但定时估计错误
TS 38.141-1 指出,当最强路径的定时偏移估计误差小于表 8.4.1.1-1 中给出的时间误差容限时,即认为检测正确。对于信道传播条件 TDLC300-100 和 PRACH 前导码格式 0,该时间误差容限为 2.55 微秒。
此示例中配置了一个 PRACH 波形,并使该波形通过了相应信道。此示例在接收机端执行 PRACH 检测并计算 PRACH 检测概率。此示例采用 TS 38.141-1 表 8.4.1.5-1 和表 A.6-1 中定义的参数。具体为:正常模式(即无限制集合)、2 个接收天线、TDLC300-100 信道、正常循环前缀、突发格式 0、SNR -6.0 dB。如果将 PRACH 配置更改为使用表 A.6-1 中所列的其他 PRACH 前导码格式之一,则需要根据 TS 38.141-1 表 8.4.1.1-1 以及表 8.4.1.5-1 至 8.4.1.5-3,分别更新时间误差容限和 SNR 的值。
仿真配置
此示例考虑了多个 SNR 下的 10 个 PRACH 时隙。应使用较大的 numPRACHSlots 值,以生成有意义的结果。可以将 SNRdB 设置为值数组或标量。有关此示例使用的 SNR 定义的说明,请参阅SNR Definition Used in Link Simulations。TS 38.141-1 中的表 8.4.1.5-1 指定了在发射机与接收机之间建模的频率偏移 foffset。timeErrorTolerance 变量指定了时间误差容限,如 TS 38.141-1 表 8.4.1.1-1 所定义。可以将检测阈值设置为 [0,1] 范围内的某个值,也可以将其留空,以便使用 nrPRACHDetect 函数中的默认值。要对虚警测试进行仿真,请改为将 prachEnabled 设置为 false,以禁用 PRACH 传输。
numPRACHSlots = 10; % Number of PRACH slots to simulate at each SNR SNRdB = [-21, -16, -11, -6, -1]; % SNR range in dB foffset = 400.0; % Frequency offset in Hz timeErrorTolerance = 2.55; % Time error tolerance in microseconds threshold = []; % Detection threshold prachEnabled = true; % Enable PRACH transmission. To simulate false alarm test, disable PRACH transmission.
载波配置
使用 nrCarrierConfig 配置对象 carrier 来指定载波设置。此示例所用载波的子载波间隔为 15 kHz,带宽为 5 MHz。即根据 TS 38.104 表 5.3.2-1,该载波跨越 25 个资源块。
carrier = nrCarrierConfig;
carrier.SubcarrierSpacing = 15;
carrier.NSizeGrid = 25;
% Compute the OFDM-related information
ofdmInfo = nrOFDMInfo(carrier);
PRACH 配置
TS 38.141-1 表 A.6-1 指定了用于 PRACH 检测一致性测试的 PRACH 配置。
根据 TS 38.141-1 中的表 A.6-1 和第 8.4.1.4.2 节,使用 nrPRACHConfig 配置对象 prach 设置 PRACH 配置。
% Set PRACH configuration prach = nrPRACHConfig; prach.FrequencyRange = 'FR1'; % Frequency range prach.DuplexMode = 'FDD'; % Frequency Division Duplexing (FDD) prach.ConfigurationIndex = 27; % Configuration index for format 0 prach.SubcarrierSpacing = 1.25; % Subcarrier spacing prach.SequenceIndex = 22; % Logical sequence index prach.PreambleIndex = 32; % Preamble index prach.RestrictedSet = 'UnrestrictedSet'; % Normal mode prach.FrequencyStart = 0; % Frequency location % Define the value of ZeroCorrelationZone using the NCS table stored in % the nrPRACHConfig object switch prach.Format case {'0','1','2'} ncsTable = nrPRACHConfig.Tables.NCSFormat012; ncsTableCol = (string(ncsTable.Properties.VariableNames) == prach.RestrictedSet); case '3' ncsTable = nrPRACHConfig.Tables.NCSFormat3; ncsTableCol = (string(ncsTable.Properties.VariableNames) == prach.RestrictedSet); otherwise ncsTable = nrPRACHConfig.Tables.NCSFormatABC; ncsTableCol = contains(string(ncsTable.Properties.VariableNames), num2str(prach.LRA)); end NCS = 13; zeroCorrelationZone = ncsTable.ZeroCorrelationZone(ncsTable{:,ncsTableCol}==NCS); prach.ZeroCorrelationZone = zeroCorrelationZone; % Cyclic shift index
传播信道配置
使用 nrTDLChannel 对象来配置抽头延迟线 (TDL) 传播信道模型 channel,如 TS 38.141-1 表 8.4.1.1-1 所述。
channel = nrTDLChannel; channel.DelayProfile = "TDLC300"; % Delay profile channel.MaximumDopplerShift = 100.0; % Maximum Doppler shift in Hz channel.SampleRate = ofdmInfo.SampleRate; % Input signal sample rate in Hz channel.MIMOCorrelation = "Low"; % MIMO correlation channel.TransmissionDirection = "Uplink"; % Uplink transmission channel.NumReceiveAntennas = 2; % Number of receive antennas channel.NormalizePathGains = true; % Normalize delay profile power channel.Seed = 42; % Channel seed. Change this for different channel realizations channel.NormalizeChannelOutputs = true; % Normalize for receive antennas % Get the channel characteristic information channelInfo = info(channel);
SNR 值循环
使用循环对向量 SNRdB 给出的 SNR 点集运行仿真。此处配置的 SNR 向量是一系列 SNR 点,其中包括 -6.0 dB 点,前导码格式 0 需要在该 SNR 点下满足 PRACH 检测率 (99%) 测试要求,如 TS 38.141-1 表 8.4.1.5-1 所述。
hNRPRACHWaveformGenerator 生成的输出信号会归一化为与 5G Toolbox™ 中上行链路数据传输相同的发射功率。因此,必须对添加到 PRACH 的噪声执行相同的归一化。在 OFDM 解调之前添加的噪声会通过 IFFT 放大,放大因子等于 IFFT 长度的平方根 (
)。为了确保在解调后对所添加噪声的功率进行归一化,从而达到所需的 SNR,需将所需噪声功率除以
。此外,由于噪声的实部和虚部是分别生成后再合并为复加性高斯白噪声的,因此噪声振幅需按
进行缩放,使生成的噪声功率为 1。
在每个 SNR 测试点,按照以下步骤逐时隙计算检测概率:
PRACH 传输:使用
hNRPRACHWaveformGenerator生成 PRACH 波形。按照 TS 38.141-1 图 8.4.1.4.2-2 定义的定时偏移发送 PRACH 前导码。将定时偏移基准值设置为 PRACH 生成所用循环移位数的 50%。此偏移量按 0.1 微秒的步长值对每个前导码递增,直至达到测试范围末尾(对于 PRACH 前导码格式 0 为 0.9 微秒)。之后重复此模式。含噪信道建模:使波形通过 TDL 信道,并加入加性高斯白噪声。在波形末尾添加额外的采样点,以涵盖信道建模预期的延迟范围(实现延迟与信道时延扩展的组合)。随后删除此实现延迟,以确保前导码检测器不会将其解释为实际的定时偏移。
应用频率偏移:按照规范的定义,对接收的波形应用频率偏移。
PRACH 检测:使用
nrPRACHDetect函数对所有小区前导码索引 (0:63) 执行 PRACH 检测。根据简介部分讨论的约束,使用nrPRACHDetect返回的检测到的 PRACH 索引和偏移量,确定检测成功的位置。
% Initialize variables storing detection probability at each SNR pDetection = zeros(size(SNRdB)); % Store the configuration parameters needed to generate the PRACH waveform waveconfig.NumSubframes = prach.SubframesPerPRACHSlot; waveconfig.Windowing = []; waveconfig.Carriers = carrier; waveconfig.PRACH.Config = prach; waveconfig.PRACH.Enable = prachEnabled; % The temporary variables 'prach_init', 'waveconfig_init', 'ofdmInfo_init', % and 'channelInfo_init' are used to create the temporary variables % 'prach', 'waveconfig', 'ofdmInfo', and 'channelInfo' within the SNR loop % to create independent instances in case of parallel simulation prach_init = prach; waveconfig_init = waveconfig; ofdmInfo_init = ofdmInfo; channelInfo_init = channelInfo; for snrIdx = 1:numel(SNRdB) % comment out for parallel computing % parfor snrIdx = 1:numel(SNRdB) % uncomment for parallel computing % To reduce the total simulation time, you can execute this loop in % parallel by using the Parallel Computing Toolbox. Comment out the 'for' % statement and uncomment the 'parfor' statement. If the Parallel Computing % Toolbox(TM) is not installed, 'parfor' defaults to normal 'for' statement % Display progress in the command window timeNow = char(datetime('now','Format','HH:mm:ss')); fprintf([timeNow ': Simulating SNR = %+5.1f dB...'], SNRdB(snrIdx)); % Set the random number generator settings to default values rng('default'); % Initialize variables for this SNR point, required for initialization % of variables when using the Parallel Computing Toolbox prach = prach_init; waveconfig = waveconfig_init; ofdmInfo = ofdmInfo_init; channelInfo = channelInfo_init; % Reset the channel so that each SNR point will experience the same % channel realization reset(channel); % Normalize noise power to account for the sampling rate, which is a % function of the IFFT size used in OFDM modulation. The SNR is defined % per carrier resource element for each receive antenna. SNR = 10^(SNRdB(snrIdx)/10); N0 = 1/sqrt(2.0*channel.NumReceiveAntennas*double(ofdmInfo.Nfft)*SNR); % Detected preamble count detectedCount = 0; % Loop for each PRACH slot numActivePRACHSlots = 0; for nSlot = 0:numPRACHSlots-1 % Generate PRACH waveform for the current slot prach.NPRACHSlot = nSlot; waveconfig.PRACH.Config.NPRACHSlot = nSlot; [waveform,~,winfo] = hNRPRACHWaveformGenerator(waveconfig); % Set PRACH timing offset in microseconds as per TS 38.141-1 Figure % 8.4.1.4.2-2 and Figure 8.4.1.4.2-3 if prach.LRA==839 % Long preamble, values as in Figure 8.4.1.4.2-2 baseOffset = ((winfo.WaveformResources.PRACH.Resources.PRACHSymbolsInfo.NumCyclicShifts/2)/prach.LRA)/prach.SubcarrierSpacing*1e3; % (microseconds) timingOffset = baseOffset + mod(nSlot,10)/10; % (microseconds) else % Short preamble, values as in Figure 8.4.1.4.2-3 baseOffset = 0; % (microseconds) timingOffset = baseOffset + mod(nSlot,9)/10; % (microseconds) end sampleDelay = fix(timingOffset / 1e6 * ofdmInfo.SampleRate); % Generate transmit waveform txwave = [zeros(sampleDelay,1); waveform]; % Pass data through channel model. Append zeros at the end of the % transmitted waveform to flush channel content. These zeros take % into account any delay introduced in the channel. This is a mix % of multipath delay and implementation delay. This value may % change depending on the sampling rate, delay profile and delay % spread rxwave = channel([txwave; zeros(channelInfo.MaximumChannelDelay, size(txwave,2))]); % Add noise noise = N0*complex(randn(size(rxwave)), randn(size(rxwave))); rxwave = rxwave + noise; % Skip this slot if the PRACH is inactive. % Skip the detection of this slot after advancing the channel to % make sure that the channel is always synchronized with the % current slot. % If the PRACH is inactive in this slot, the receiver should not % expect any PRACH transmission and thus should not even try to % detect a PRACH. Skipping the detection of an inactive slot is % particularly important when performing a conformance test. If the % PRACH is inactive, the reference waveform computed internally in % the |nrPRACHDetect| function is empty. This leads to an empty % correlation and thus to an empty detected preamble. This empty % preamble leads to an incorrect value of the detection % probability. if isempty(winfo.WaveformResources.PRACH.Resources.PRACHSymbols) continue; end numActivePRACHSlots = numActivePRACHSlots + 1; % Remove the implementation delay of the channel filter rxwave = rxwave((channelInfo.ChannelFilterDelay + 1):end, :); % Apply frequency offset t = ((0:size(rxwave, 1)-1)/channel.SampleRate).'; rxwave = rxwave .* repmat(exp(1i*2*pi*foffset*t), 1, size(rxwave, 2)); % PRACH detection for all cell preamble indices [detected, offsets] = nrPRACHDetect(carrier, prach, rxwave, 'DetectionThreshold', threshold); % Test for preamble detection if (isscalar(detected)) if ~prachEnabled % For the false alarm test, any preamble detected is wrong detectedCount = detectedCount + 1; else % Test for correct preamble detection if (detected==prach.PreambleIndex) % Calculate timing estimation error trueOffset = timingOffset/1e6; % (s) measuredOffset = offsets(1)/channel.SampleRate; timingerror = abs(measuredOffset-trueOffset); % Test for acceptable timing error if (timingerror<=timeErrorTolerance/1e6) detectedCount = detectedCount + 1; % Detected preamble end end end end end % of nSlot loop % Compute final detection probability for this SNR pDetection(snrIdx) = detectedCount/numActivePRACHSlots; % Display the detection probability for this SNR fprintf('Detection probability: %d%%\n', pDetection(snrIdx)*100); end % of SNR loop
04:13:58: Simulating SNR = -21.0 dB...Detection probability: 0% 04:13:59: Simulating SNR = -16.0 dB...Detection probability: 40% 04:13:59: Simulating SNR = -11.0 dB...Detection probability: 80% 04:13:59: Simulating SNR = -6.0 dB...Detection probability: 100% 04:13:59: Simulating SNR = -1.0 dB...Detection probability: 100%
结果
在 SNR 循环结束时,此示例将绘制计算得出的各 SNR 值下检测概率对目标概率的图。
% Sort the results in increasing values of SNR [SNRdB_sorted,idx] = sort(SNRdB); pDetection_sorted = pDetection(idx); % Plot detection probability figure('Name','Detection Probability'); plot(SNRdB_sorted,pDetection_sorted,'b-o','LineWidth',2,'MarkerSize',7); title(['Detection Probability for ', num2str(numPRACHSlots) ' PRACH Slot(s)'] ); xlabel('SNR (dB)'); ylabel('Detection Probability'); grid on; hold on; % Plot target probability if prachEnabled % For a missed detection test, detection probability should be >= 99% pTarget = 99; else % For a false alarm test, detection probability should be < 0.1% pTarget = 0.1; %#ok<UNRCH> end plot(-6.0,pTarget/100,'rx','LineWidth',2,'MarkerSize',7); legend('Simulation Result', ['Target ' num2str(pTarget) '% Probability'],'Location','best'); minP = 0; if(~isnan(min(pDetection_sorted))) minP = min([pDetection_sorted(:); pTarget]); end axis([SNRdB_sorted(1)-0.1 SNRdB_sorted(end)+0.1 minP-0.05 1.05])

参考资料
3GPP TS 38.141-1."NR; Base Station (BS) conformance testing.Part 1:Conducted conformance testing."3rd Generation Partnership Project; Technical Specification Group Radio Access Network.
3GPP TS 38.104."NR; Base Station (BS) radio transmission and reception."3rd Generation Partnership Project; Technical Specification Group Radio Access Network.