# Decentralizing Private Blockchain-IoT Network with OLSR
## 4 Decentralization of IoT Blockchain System
### Decentralizing Underlying Blockchain Network  
In this paper, we investigate the decentralization of the underlying network in a blockchain-IoT application. In our approach, we aim to build a blockchain system close to the actual applications, in which sensors normally sense the environment and push to the blockchain. For that purpose, we emulate an environment monitoring application with the particulate matter (PM) sensor that can report the PM data. The skeleton of the whole system is IoT devices, which can run blockchain and the OLSR protocol. In our previous work, we confirmed that the popular IoT device RPi4 is powerful enough to operate Proof of Work (PoW) or mining task [38]. On the other hand, RPi4 supports Linux-based operating systems, which can host the OLSR implementation code. Furthermore, RPi4's Wi-Fi implementation also well supports the ad hoc mode. Therefore, RPi4 was selected as the hardware to build our system. Each RPi4 node works in a wireless ad hoc mode with OLSR protocol and participates in the Ethereum blockchain's operation. We also leverage the smart contract technology to record the PM data into the blockchain automatically. In our investigation, we consider the blockchain communication between a sender and a receiver. A sender is a node with the sensor that disseminates its collected PM data with transactions, which then are mined into blocks. The data are stored on the blockchain through transaction execution. Our written smart contract can monitor the logged data and perform a processing task. More specifically, it emits events once the PM data exceed an alerting value. The receiver receives the transactions, produces blocks with the PoW algorithm, and listens to the smart contract events. The blockchain decentralizes the application in the system, which delivers and processes data without a centralized authority. The functionalities of the underlying network are distributed by the ad hoc mode and OLSR protocol at every node. The system is evaluated with the following metrics when transactions are streaming from the sender to the receiver. **Recovery time**: A blockchain connection over multiple hops in an OLSR ad hoc network depends on the MPRs, which form the backbone. When a sender propagates transactions to the receiver, the data packets are forwarded by the MPR nodes. If a middle forwarding MPR node fails, the transactions will be accumulated in the sender's _TxPool_. Moreover, the receiver temporarily loses the synchronization with the sender. After a failure happens in OLSR, the nodes first need to realize the failure and MPR in the transmission path by the expiration of the latest HELLO message. If the \(T_{validity}\) is greater than \(T_{hold}\), the HELLO messages expire after waiting for \(T_{validity}\). The link of a failed node is marked as LOST_LINK. Otherwise, if the \(T_{validity}\) is smaller than the \(T_{hold}\) (i.e., three times of \(T_{hello}\)), the HELLO messages expire after \(T_{hold}\). Second, the nodes select a new candidate for MPR from the one-hop neighbor set and disseminate the selection result to the targeted node in the next following HELLO message. Upon receiving the message, the new node starts forwarding packets and notifies them to perform as an MPR (in a HELLO message). When the route is successfully rebuilt, the overlying blockchain connection is consequently resumed after the processing at the transport and application layers (denoted as \(T_{blockchain}\)). In Ethereum blockchain, by default, the client Geth will drop peers without responses after  
Figure 1: Blockchain-IoT system over an infrastructure network and an ad hoc network. the inactive period of 30 s ([[https://github.com/ethereum/go-ethereum/blob/master/p2/perver.go](https://github.com/ethereum/go-ethereum/blob/master/p2/perver.go)]([https://github.com/ethereum/go-ethereum/blob/master/p2/perver.go](https://github.com/ethereum/go-ethereum/blob/master/p2/perver.go)) (accessed on 25 June 2021)). We build a simple equation to capture the recovery time in Equation (1).