Msg3 and Msg4 are used for contention resolution.
The uplink time synchronization are completed in Msg1 and Msg2.
The purpose of Msg3 and Msg4 is to identify the C-RNTI for the subsequent data transmission.
During CBRA, there are chances that multiple UE may use the same PRACH preamble on the same RACH Occasion to send Msg1.
In that case, in Msg2, TC-RNTI may be used by multiple UEs.
So Msg3/4 is sued to avoid the conflict and clearly specify the C-RNTI belong to which UE.
Conflict Resolution is divided into 2 parts depending upon the UE already has C-RNTI or not.
1. If the UE already has C-RNTI, then UE sends a C-RNTI MAC CE on Msg3. Then the PDCCH of Msg4 can be successfully decoded using C-RNTI, and the random access will be considered as successful.
2. If the UE does not have a C-RNTI then UE sends CCCH SDUs (such as RRCSetupRequest, etc.) on Msg3. These CCCH SDUs contain the contention resolution identity, and then the UE uses TC-RNTI to successfully decode the PDCCH of Msg4 and it can also successfully solve the Msg4. Contention Resolution Identity MAC CE, and the identity in the MAC CE is the same as that sent by the UE in Msg3.
UE will determine if it should apply transform precoding for Msg 3 PUSCH or not, based on the RRC parameter called msg3-tp (msg3-transformPrecoding)
UE will determine the subcarrier spacing for Msg3 PUSCH from the RRC parameter called msg3-scs
UE will transmit Msg3 PUSCH to the same serving cell that it has sent PRACH.
After UE sends Msg3, it will start “ra-ContentionResolutionTimer” and will monitor PDCCH till the timer expires. If the timer expires and it did not receive any message, then UE will discard TC-RNTI and thinks conflict has failed.
If PDCCH is successfully decoded, then UE will decode PDSCH carrying the MAC CE, Set C-RNTI = TC-RNTI and consider RACH to be successful.
Once UE successfully decode Msg4 (Contention Resolution), UE sends HARQ ACK for the data(PDSCH carrying Msg4).