# Enhancing the Reliability of Cellular Internet of Things through Agreement
## 4 An Example of CIOTAP Executed the Proposed Protocol  
In an MEC-based MECIoT, through a combination of a large number of CIoT PUs with different functions, it is possible to collect sensor data required by various application services, then a wide range of application services can be provided. For example, the MECIoT used in this study can be used in an environmental monitoring system to prevent debris flow hazards. In MECIoT, the sensing data of different CIoT PUs within the coverage of the BS in the _Access-tier_ is sent to the corresponding MEC cloud in the _MEC-tier_, and this data is processed by the MEC PU in the specific MEC cloud. The MEC PUs in each MEC cloud collect the relevant monitoring information of different BS coverage areas, and then analyzes and judges the data collected in each MEC cloud. Finally, the status of the different coverage areas of the BS is sent to the disaster prevention center in _Cloud-tier_. Figure 7 is an example of a rock flow disaster monitoring system constructed by MECIoT. In CIoTAP, within the coverage of a specific BS in the _Access-tier_, the CIoT PU obtains the sensing data of the application service and sends it to the MEC cloud of the corresponding _MEC-tier_. For example, within the coverage of a specific \(BS_{1}\), there are six CIoT PUs that obtain sensing data of 1, 0, 1, 1, 1, and 0, respectively. Figure 8 is an example of the coverage area of a specific \(BS_{1}\). An example of the specific PUs in the MEC cloud \(E_{1}\) performing CIoTAP is shown in Figure 9. Each MEC PU in the MEC cloud \(E_{1}\) receives the sensing data transmitted from the CIoT PUs within the coverage of the specific \(BS_{1}\). When the MEC PU receives the sensing data sent by the six CIoT PUs, these data will be calculated by the MEC PU with majority value (_majority_ (1,0,1,1,1,0) = 1). Next, the function _Agree_ ( ) is executed, and this majority value (1) is used as the initial value (\(v_{i}\)) of the MEC PU in the MEC cloud \(E_{1}\). Then, the required times of executing _Data Collection Stage_ (\(\sigma=\lfloor(n_{Mj}-1)/3\rfloor+1\)) is calculated, and the function _Agree_ (\(\sigma\), \(v_{i}\), \(n_{Mj}\)) is executed. The initial value of each MEC PU in the MEC cloud \(E_{1}\) of the _MEC-tier_ is shown in Figure 9a. Figure 8: An example of the coverage of a specific \(BS_{1}\). Figure 7: An example of a rock flow disaster monitoring system built by MECIoT. In this example, there are six MEC PUs in the MEC cloud \(E_{1}\), and it is assumed that the MEC PU \(e_{14}\) is a faulty PU. Figure 9a is the initial value of each MEC PU in the MEC cloud \(E_{1}\). In order to obtain the agreement value, two times of data exchanges are required when executing _Agree_ ( ) (\(\sigma=\lfloor(n_{M1}-1)/3\rfloor+1=\lfloor(6-1)/3\rfloor+1=2\), where \(n_{M1}\) is the number of PUs in MEC cloud \(E_{1}\)). An example of the Cloud PUs in the _Cloud-tier_ performing CIoTAP is shown in Figure 10. At the first round of the _Data Collection Stage_, each MEC PU of MEC cloud \(E_{1}\) sends the initial value to all other PUs of MEC cloud \(E_{1}\), and stores the \(n_{M1}\) (=6) data received from other MEC PUs at the root of each corresponding _dc-tree_, as shown in Figure 9b. In the second time, each MEC PU sends the data in the root of the corresponding _dc-tree_ to other MEC PUs in the MEC cloud \(E_{1}\), and stores the received value in the level 2 of the \(n_{M1}\) (=6) corresponding _dc-tree_. Figure 9c shows the process of MEC PU \(e_{12}\) in the _Data Collection Stage_, and Figure 9d shows the process of \(e_{16}\) in the _Data Collection Stage_. Figure 9: An example of the specific PUs in the MEC cloud \(E_{1}\) performing CIoTAP. **(a)** The initial value of each MEC PU in MEC cloud \(E_{1}\) of _MEC-tier_. **(b)** The _dc-tree_ of each MEC PU in MEC cloud \(E_{1}\) at the first round of _Data Collection Stage_. **(c)** The final _dc-tree_ of \(e_{12}\) by _Data Collection Stage_. **(d)** The final _dc-tree_ of \(e_{16}\) by _Data Collection Stage_.