# HPoC: A Lightweight Blockchain Consensus Design for the IoT
## 6 Comparative Experiment and Simulation Results  
This section simulates a smart-home scenario consisting of heterogeneous computing device nodes and implements an HPoC consensus-based blockchain. Nodes are classified into five classes and their storage and computational capacities decrease from Class 1 to Class 5 in order. The storage capacity is simulated by the size of the digital cache table, while the computational capacity is simulated by the random waiting time to begin calculating the random number (from 100 ms to 500 ms). The number of nodes is divided into groups of 15 the ratio of the number of nodes in one group from Class 1 to Class 5 = 1:2:3:4:5. A total of one to five groups of experimental statistics are conducted and the total number of nodes gradually increases from 15 to 75. In addition, this section implements a comparison experiment of the PoW consensus process to show HPoC's superiority in terms of stability of consensus process-time consumption. The data for the experiments are averages obtained from the data of twenty consensus rounds. All programs are developed based on open-source technologies, such as go language, TDengine, and ETCD. The experiment setup information of hardware and software is shown in Table 1.  
The difficulty bits in the HPoC consensus reflect the size of the digital cache table kept by the Class 1 nodes (the nodes with the largest storage capacity) and the number stored in the cache table varies from 0 to the 225. Class 2 nodes have a 24-bit cache table, Class 3 has a 23-bit cache table, and so on. When the difficulty bits are set to 25, the time to complete a consensus round in the network is between 45 and 70 s, as illustrated in Figure 7(a). The number of nodes has no effect on the consensus time consumption, which fluctuates as the number of nodes increases (showing that the consensus time consumption is mostly determined by the random number rather than by the number of nodes); its typical duration is about 60 s. When the difficulty bits are set to 24, the average consensus time consumption drops to 30 s, and when the difficulty bits are set to 23, the average consensus time consumption drops to roughly 15 s. This shows that the network-wide consensus consumption time is halved for each decrease in difficulty bits, and all four difficulty bits show the scalability advantage of the HPoC consensus, with the number of nodes having no effect on the network consensus consumption time when the number of nodes is increased from 15 to 75. For three difficulty bits, we compared the coefficient of variation of time consumption via HPoC and PoW in Figure 7(b). Because HPoC is built as a lightweight consensus protocol, its difficulty bits must tend to be selected as smaller in the process of practical application in order to meet the goal of reducing time and power consumption; we chose not to directly compare the two consensus time consumptions with the same difficulty bits. Furthermore, the coefficient of variation can be used to determine the degree of dispersion of a group of values, or the extent of the deviation from the average. When the difficulty bits remain the same, the coefficient of variation of HPoC stays around 0.5, whereas the coefficient of variation of PoW stays around 1 or even up to 1.5. This means that the PoW consensus has a low level of stability, and obtaining consensus can take anywhere from a few seconds to a hundred seconds. \begin{table}
\begin{tabular}{c c} \hline
**Experiment Setup** & **Description** \\ \hline CPU & Phytium, FT-2000+/64 \\ RAM & 128 GB \\ HDD & 4 TB \\ System & KylinOS \\ \hline \end{tabular}
\end{table} 
Table 1: Experiment set up of hardware and software. Figure 8: Simulation results (**a**) average time consumption of HPoC with four difficulty bits; (**b**) comparison of coefficient of variation of time consumption between HPoC and FoW with three difficulty bits.