Random access is how a 5G device gets the gNB's attention, and its uplink timing, before it has any dedicated resources. In the classic 4-step RACH procedure the device sends a preamble on the PRACH (Msg1), the gNB answers with a random access response (Msg2), the device sends its identity on PUSCH (Msg3), and the gNB settles any collision (Msg4). Release 16 added a 2-step version that folds the four messages into MsgA and MsgB.
The procedure lives in TS 38.321 (MAC), with the physical-layer side in TS 38.211 and TS 38.213.
When a device runs random access
TS 38.300 lists the triggers. The ones you'll see most:
- Initial access from RRC_IDLE, and resuming from RRC_INACTIVE.
- RRC re-establishment after a radio link failure.
- Handover, when the target cell needs the device's timing.
- Uplink or downlink data arriving while the device has lost uplink sync.
- Uplink data with no PUCCH resource for a scheduling request, or after SR failure.
- Beam failure recovery, and on-demand requests for other system information.
The 4-step procedure, message by message
Before Msg1 the device has read SIB1, whose RACH-ConfigCommon gives it everything it needs: the PRACH configuration index, the root sequence, the target received power, the response window, and how SSBs map to RACH occasions. It picks an SSB whose RSRP is above rsrp-ThresholdSSB, which is how the gNB will learn which beam the device is on.
- Msg1: preamble on PRACH. The device picks one of the 64 preambles in a RACH occasion mapped to its chosen SSB and sends it. Transmit power is the configured target plus any ramping, plus the pathloss the device estimates from the SSB (ss-PBCH-BlockPower in SIB1 minus the SS-RSRP it measures).
- Msg2: random access response (RAR). The gNB sends a DCI 1_0 whose CRC is scrambled with the RA-RNTI, scheduling a PDSCH that carries the RAR. It must arrive inside ra-ResponseWindow, which is at most 10 ms in licensed spectrum. Each RAR is tagged with the preamble ID it answers and carries a 12-bit timing advance command, an uplink grant for Msg3, and a temporary C-RNTI (TC-RNTI). The gNB can add a backoff indicator to slow everyone down when it's overloaded.
- Msg3: the device's identity, on PUSCH. For initial access this is RRCSetupRequest, with a 39-bit identity (part of the 5G-S-TMSI, or a random value if the device has none) and the establishment cause. A device that's already connected sends a C-RNTI MAC CE instead. Retransmissions of Msg3 are scheduled with DCI 0_0 on the TC-RNTI. The device starts ra-ContentionResolutionTimer (8 to 64 ms).
- Msg4: contention resolution. The gNB echoes the first 48 bits of the Msg3 message in a UE Contention Resolution Identity MAC CE, usually together with RRCSetup, addressed to the TC-RNTI. If the echo matches what the device sent, it has won: it acknowledges on PUCCH and its TC-RNTI becomes its C-RNTI. If it doesn't match, another device with the same preamble won, and this one starts again.
How RA-RNTI is calculated
The RA-RNTI isn't assigned; both sides compute it from the RACH occasion the preamble used (TS 38.321):
RA-RNTI = 1 + s_id + 14 × t_id + 14 × 80 × f_id + 14 × 80 × 8 × ul_carrier_id
Here s_id is the first OFDM symbol of the occasion (0–13), t_id the first slot in the frame (0–79), f_id the frequency index (0–7), and ul_carrier_id is 0 for the normal uplink and 1 for a supplementary uplink. Every device that used the same occasion shares the RA-RNTI, and the preamble ID in each RAR tells them apart. Two devices that picked the same preamble in the same occasion can't be told apart until Msg4, which is why the contention resolution step exists.
Contention-based vs contention-free
| Contention-based (CBRA) | Contention-free (CFRA) |
|---|
| Preamble | Picked at random from the shared pool | Dedicated, assigned by the gNB (ra-PreambleIndex) |
| Collisions | Possible | No |
| Messages | Msg1 to Msg4 | Msg1 and Msg2; in most cases done once the RAR arrives |
| Typical use | Initial access, re-establishment, SR failure | Handover, PDCCH order, beam failure recovery |
For handover the dedicated preamble arrives in the RRCReconfiguration with reconfigurationWithSync (rach-ConfigDedicated). A PDCCH order is a DCI 1_0 on the device's C-RNTI that tells a connected device to run random access, usually because it has lost uplink timing. CFRA is faster and can't collide, but it needs the network to set aside preambles, so the pool for everyone else gets smaller.
2-step RACH: MsgA and MsgB
Release 16 added 2-step random access for latency and signaling savings. MsgA is the preamble and a PUSCH payload sent together, the payload carrying what Msg3 would have carried. MsgB comes back on PDSCH, addressed by the MSGB-RNTI (the RA-RNTI formula plus a fixed offset of 14 × 80 × 8 × 2).
MsgB takes one of two forms. A successRAR carries the contention resolution identity, the C-RNTI and a timing advance, and the device is done. A fallbackRAR carries a grant, and the device sends its Msg3 as in the 4-step procedure. After msgA-TransMax failed attempts, the device switches to 4-step.
A device picks 2-step only when the cell offers it and its RSRP is above msgA-RSRP-Threshold. That makes sense: the MsgA payload goes out before the device has a timing advance, so it works best close to the cell. It's an optional device capability and a network configuration choice; 4-step is the baseline every device supports.
NR preambles are Zadoff–Chu sequences, and the cell derives its 64 preambles by cyclically shifting one or more root sequences.
- Long preambles use an 839-length sequence, formats 0–3, at 1.25 kHz (formats 0–2) or 5 kHz (format 3) subcarrier spacing. FR1 only. They resemble LTE preambles and suit large cells; restricted sets are available for high-speed trains.
- Short preambles use a 139-length sequence, formats A1–A3, B1–B4, C0 and C2, at 15 or 30 kHz in FR1 and 60 or 120 kHz in FR2. They fit inside a slot and repeat well across beams. Release 16 added longer 571 and 1151 sequences for unlicensed spectrum.
The prach-ConfigurationIndex (0–255) picks the format and the frames, slots and symbols that carry RACH occasions, from tables in TS 38.211. The zeroCorrelationZoneConfig sets the cyclic shift: a larger shift supports a larger cell radius but gives fewer preambles per root, so a cell needs more roots. When two nearby cells reuse the same root sequences on the same occasions, each can detect the other's preambles.
Why random access fails
Work through it in order. Each step that fails leaves a different footprint.
No RAR received. Either Msg1 wasn't detected or Msg2 didn't make it back. Common causes are weak uplink coverage, a preamble target power set too low, high uplink interference, or a wrong ss-PBCH-BlockPower in SIB1, which makes every device misjudge its pathloss. The device ramps power by powerRampingStep (0, 2, 4 or 6 dB) on each retry. The ramp doesn't step up when it switches to a different SSB, so a device hopping between beams can keep retrying at low power. At preambleTransMax, MAC reports a random access problem to RRC: in connected mode that's a radio link failure, and during handover it ends as a T304 expiry.
RAR received, Msg3 lost. Msg3 goes out before the gNB has any channel feedback from the device, so its MCS is a fixed guess. It fails on uplink power (check msg3-DeltaPreamble and the nominal PUSCH power) or on a wrong timing advance. A cyclic shift too small for the real cell size, or users far beyond the planned radius because the cell overshoots, gives the gNB a wrong timing estimate, and Msg3 then arrives misaligned.
Msg3 sent, no Msg4. The contention resolution timer runs out. Causes include collisions in a busy cell, Msg4 PDSCH failures at the cell edge, or, in a split gNB, a slow path between DU and CU: the CU builds RRCSetup, so F1 delay adds straight to the Msg4 time.
Ghost preambles. Preambles detected that nobody sent, from root-sequence reuse or interference. They waste RARs and inflate the attempt count.
Most vendors count each step separately: preambles detected, RARs sent, Msg3 received, contention resolved. The ratio between each pair tells you which step is broken before you open a single trace.
Where you'll meet this
Accessibility KPIs. The RRC setup attempt counter starts when RRCSetupRequest arrives, and that's Msg3. A device that never gets past Msg1 or Msg2 is never counted, so a RACH problem can hide behind a healthy RRC setup success rate. Our
RRC connection failure guide picks up where random access ends.
Handover failures. CFRA on the target cell is the last step of a handover. Many T304 expiries are random access failures on the target, covered in the
5G handover procedure.
Drive tests and UE logs. You'll see the chosen SSB, the preamble index, each attempt's power, whether the RAR arrived, and the timing advance it carried. Turn that timing advance into a distance with the
TA to distance calculator to check whether the device is where the cell plan says it should be.
Beam problems. Because SSBs map to RACH occasions, random access is also the first beam decision. If devices keep choosing a poor SSB, look at rsrp-ThresholdSSB and the SSB beam layout;
5G beamforming covers how those beams are built.
Interviews. Expect "What's in the RAR?", "What's the difference between RA-RNTI, TC-RNTI and C-RNTI?", and "Why does CFRA skip Msg3 and Msg4?" Each one is answered above.