# Enhancing the Reliability of Cellular Internet of Things through Agreement
## 3 The Proposed Protocol  
In this study, _agreement_ problem will be discussed in MECIoT, and there is no PU delay in our discussion. Therefore, when the proposed CIoTAP is executed by all PUs, each PU will receive data from other PUs within a predictable time. If the PU cannot receive the data on time, it means that the data must be affected by the failed PU. According to the research of [PERSON] and [PERSON] [11], in order to solve the _agreement_ problem, the allowable number of faulty PUs is determined by the total number of PUs in the system. In the protocol of [PERSON] et al. [23], all normal PUs can reach an agreement, the condition that must be met is \(n>3f\), where \(n\) is the total number of PUs and \(f\) is the total number of allowable faulty PUs in the distributed system. In this research, CIoTAP is proposed to solve the _agreement_ problem that PUs may fail in the MECIoT. Based on the three tiers of MECIoT, the proposed protocol CIoTAP is divided into three parts. According to the three tiers of MECIoT, the execution steps of CIoTAP are shown in Figure 4.  
In order to effectively execute CIoTAP, CIoT PUs in MECIoT are used to sense and obtain sensor data required by the specific CIoT applications. Then, the sensing data is transmitted to the corresponding MEC cloud in the _MEC-tier_. In CIoTAP, the MEC PU first receives the sensing data transmitted from the CIoT PU, and obtains the majority value of the received sensing data. The majority value of the received data is used as the initial value (\(v_{i}\)) of the MEC PU to execute the function _Agree_ ( ). When the agreement value of each MEC cloud is obtained, the value is expressed as the result of a specific service. Finally, the agreement value is transferred to the _Cloud-tier_ by the MEC PU. In CIoTAP, the main job of Cloud PUs in the _Cloud-tier_ is to collect the results of different specific services, and then obtain the request vector of the agreement to provide an integrated service center for various CIoT-related applications. CIoTAP is initiated by the CIoT PUs of _Access-tier_ to get the sensing data of the specific application service. In CIoTAP, the function _Agree_ ( ) will be used. The function _Agree_ ( ) includes two stages, one is the _Data Collection Stage_, and the other is the _Data Resolution Stage_. Function _Agree_ ( ) has three parameters, namely \(\sigma,v_{i}\), and \(n_{A}\), where \(\sigma\) is the times required to perform the _Data Collection Stage_, \(v_{i}\) is the initial value of \(\mathrm{PU}_{i}\), and \(n_{A}\) is the total number of PUs participating in the agreement. In order for all normal PUs to reach an agreement, each PU must collect enough exchanged data from all other PUs. In other words, the data received through the data exchanges will help the normal PU to collect enough exchanged data for the subsequent _Data Resolution Stage_. The \(\lfloor(n-1)/3\rfloor+1\) has been proved by [PERSON] and [PERSON] in 1911 to be a necessary and sufficient number of data exchanges to solve the agreement problem, where \(n\) is the total number of PUs in the distributed network [11]. According to the research results of [PERSON] and [PERSON], \(\lfloor(n-1)/3\rfloor+1\) times of data exchanges are the lower bound to solve the agreement problem. Therefore, when the MEC PU executes function _Agree_ ( ), the times of executing (\(\sigma\)) is \(\lfloor(n_{Mj}-1)/3\rfloor+1\), where \(n_{Mj}\) is the number of MEC PUs in the MEC cloud \(E_{j}\) of the _MEC-tier_, and \(n_{Mj}>3\). Similarly, when a Cloud PU executes the CIoTAP function _Agree_ ( ), the required time \(\sigma\) is \(\lfloor(n_{C}-1)/3\rfloor+1\), where \(n_{C}\) is the number of Cloud PUs in the _Cloud-tier_, and \(n_{C}>3\). The data received during the _Data Collection Stage_ will be stored in a data structure called _data collection tree_ (_dc-tree_), which is similar to the data structure proposed by [PERSON] et al. [25]. During the execution of CIoTAP, every normal PU will maintain such a _dc-tree_.