Random Access

Msg2 —
The Random Access Response

After sending Msg1, the UE monitors the PDCCH for a RAR — the gNB's response. The RAR carries the Timing Advance command that synchronises the UE's uplink, a grant for sending Msg3, and a Temporary C-RNTI. This section explains how the UE finds the RAR, what it contains, and what happens if it never arrives.

TS 38.321 §5.1.4 TS 38.213 §8.2 TS 38.212 §6.2

RA-RNTI — finding the RAR on PDCCH

The gNB does not send the RAR directly to the UE — it doesn't know the UE's identity yet. Instead, the RAR is addressed to an RA-RNTI derived from the PRACH occasion parameters. Any UE that transmitted in that occasion will monitor for this RA-RNTI.

The RA-RNTI associated with the PRACH occasion is computed as:

RA-RNTI = 1 + s_id + 14·t_id + 14·80·f_id + 14·80·8·ul_carrier_id

where s_id is the index of the first OFDM symbol of the PRACH occasion, t_id is the index of the first slot of the PRACH occasion in a system frame, f_id is the index of the PRACH occasion in the frequency domain, and ul_carrier_id is the uplink carrier used.
3GPP TS 38.321, Section 5.1.4
RA-RNTI calculation — our PRACH occasionTS 38.321 §5.1.4
// Our PRACH occasion parameters:
s_id         = 0   (first OFDM symbol of PRACH = symbol 0)
t_id         = 0   (first slot of the PRACH subframe = slot 0)
f_id         = 0   (only 1 PRACH occasion in freq, msg1-FDM=1)
ul_carrier_id = 0   (normal uplink carrier)

// Calculation:
RA-RNTI = 1 + 0 + 14×0 + 14×80×0 + 14×80×8×0
        = 1

// UE monitors PDCCH for DCI 1_0 with CRC masked by RA-RNTI = 0x0001
// Within the RAR window: slots 2+1 to 2+10 = slots 3..12
// (Msg1 was in slot 2, ra-ResponseWindow = sl10)

RAR window — when to look

After sending Msg1 in slot 2, the UE opens a RAR window lasting ra-ResponseWindow = sl10 = 10 slots = 5 ms. During this window, the UE monitors the PDCCH (using the initial DL BWP CORESET) for the RA-RNTI. If no RAR is found within the window, the attempt is considered failed.

RAR window — slots 3 to 12 after Msg1 TS 38.321 §5.1.4

RAR contents — MAC subPDU structure

The RAR is carried in a MAC PDU that can contain multiple sub-headers and sub-PDUs — one per preamble detected by the gNB. Each sub-PDU contains one RAR, identifying which preamble it responds to and providing the resources for Msg3.

RAR MAC sub-PDU contents — our UE (preamble index 27)TS 38.321 §6.2.3
// MAC subheader:
RAPID = 27   ← Random Access Preamble IDentifier
// (UE matches RAPID=27 against the preamble index it sent)

// RAR payload (6 bytes = 48 bits):
Timing Advance Command (12 bits) = 31
// TA = 31 → actual advance = 31 × 16 × T_s = 31 × 16 / 30.72MHz ≈ 16.1 μs
// Meaning: UE must start transmitting 16.1 μs earlier than it currently does

UL Grant (27 bits):
  Frequency resource  = RBs 05   ← 6 RBs for Msg3 PUSCH
  Time resource       = row 3      ← slot offset + symbol allocation
  MCS                 = 4          ← QPSK, low rate — conservative
  TPC command         = 0 dB       ← no power adjustment yet

Temporary C-RNTI (16 bits) = 0x3A7F
// Temporary identity used for Msg3 and contention resolution

Timing Advance — what it means physically

The gNB measured that the UE's preamble arrived 16.1 μs late relative to the uplink timing reference. This corresponds to a one-way propagation delay of ~8 μs, meaning the UE is approximately 8 μs × 3×10⁸ m/s = 2.4 km from the gNB.

By advancing its transmit timing by 16.1 μs, the UE compensates for both the uplink and downlink propagation delays, ensuring its signal arrives at the gNB in the correct timing window.

Timing Advance — propagation delay compensation TS 38.213 §4.2

After receiving the RAR

When the UE successfully decodes the RAR and finds its RAPID (=27), it:

1
Apply Timing Advance = 31
UE sets its uplink transmit timing: start transmitting 31 × 16 × T_s = 16.1 μs earlier than the downlink frame timing. All subsequent uplink transmissions use this offset until a new TA command arrives.
2
Store Temporary C-RNTI = 0x3A7F
This temporary identity will be used for Msg3 (sent on PUSCH with TC-RNTI) and will be confirmed or replaced in Msg4. If contention resolution fails, the TC-RNTI is discarded.
3
Prepare Msg3 using the UL grant
The UL grant in the RAR allocates RBs 0–5 for Msg3 PUSCH. The UE assembles an RRCSetupRequest message and schedules it for the granted resources.
Msg2 received — UE now has:
Timing Advance      → TA = 31 → advance TX by 16.1 μs
UE-gNB distance     → approximately 2.4 km
UL grant            → RBs 0–5, MCS 4, for Msg3
Temporary C-RNTI    → 0x3A7F
Next step           → Send Msg3 (RRCSetupRequest) on PUSCH