# Distributed Dynamic Cluster-Head Selection and Clustering for Massive IoT Access in 5G Networks
## 2 Description of Random Access and Data Aggregation  
Figure 1 shows the signaling interaction and data transmission between the device and the base station. The device is in a Radio Resource Control (RRC) idle state before starting the data reporting process. The following three processes are required to complete the data transfer:  
* Establishing an RRC-connected contention-based random access procedure
* Establishing an RRC-connected data transmission
* Releasing an RRC connection  
The active User (UE) 1, 2, and 3 send _data1_, 2, and 3 to the base station respectively at different times. Collisions mainly occur during the random access process. The random access procedure includes four steps MSG1 to MSG4. The device first selects a limited preamble resource to send request access to the base station on the Physical Random Access Channel (PRACH) in MSG1. Collisions occur when two or more devices select the same preamble. The device can transmit multiple times, and the base station settings determine the maximum number of transmissions. Upon receiving the preamble, the base station applies for a Cell Radio Network Temporary ID (C-RNTI) and applies for uplink and downlink resources for scheduling. Then, the base station sends a random access response over the Physical Downlink Shared Channel (PDSCH) for each UE. The response contains the Random Access (RA)-preamble identifier, timing alignment information, initial uplink grant, and temporary C-RNTI. One PDSCH can carry random access responses to multiple UEs. After the UE sends the preamble, it monitors the Physical Downlink Control Channel (PDCCH) and waits for a random access response within a random access response window:  
* If the UE receives a response containing an RA-preamble identifier which is the same as the identifier contained in the transmitted random access preamble, the response is successful, and the RA-preamble identifier is used for uplink transmission. Figure 1: Signaling interaction and data transmission between device and base station. * If the UE does not receive a response within the random access window or fails to verify the response, the response fails. In this case, if the number of random access attempts is smaller than the upper limit, the UE retries random access. Otherwise, random access fails. The UE sends Msg3 using the resources contained in the random access response. The UE transmits uplink scheduled data over the Physical Uplink Shared Channel (PUSCH). The size of the transport block is specified in the random access response. The information in the transport block sent by the UE varies in different random access scenarios: The RRC Connection Request message is sent by the UE over the Common Control Channel (CCCH) and contains the cause of the Radio Resource Control connection setup. This message also contains the Media Access Control (MAC) control element for requesting uplink transmission resources. Other scenarios at least the C-RNTI of the UE are transmitted. After the UE sends Msg3, a contention resolution timer starts. Within the timer length, the base station performs contention resolution at the MAC layer and informs the UE of the resolution through the C-RNTI on the PDCCH or through the UE Contention Resolution Identity on the PDSCH. The UE monitors the PDCCH before the timer expires. The UE considers the contention resolution as successful, notifies upper layers, and stops the timer if both of the following conditions are met: the UE obtains the temporary C-RNTI over the PDCCH, the MAC packet data unit (PDU) is successfully decoded, and the MAC PDU contains information matching the CCCH equipment data unit (SDU) transmitted in Msg3. If the contention resolution is successful, the contention-based random access procedure is complete. If the contention resolution timer expires, the UE considers the contention resolution as failed. Then, the UE performs random access again if the number of random access attempts has not reached its upper limit.