# A Trusted Routing Scheme Using Blockchain and Reinforcement Learning for Wireless Sensor Networks
## 4 Experimental Analysis and Evaluation
### Testing Setting  
We built a PoA consortium blockchain and simulated 32 virtual servers to update blockchain transactions on the chain. All the routing information required by the reinforcement learning model can be obtained from the public blockchain transactions. The consortium blockchain was built based on Geth 1.8.19 which can provide reliable Ethereum transaction services. We chose the BP routing algorithm as the benchmark of performance comparisons [10]. To simulate real packet arrival rates, we simulated 32 terminals in the 16 \(\times\) 16 matrix, randomly transmitting packets to the target point according to the Poisson distribution with \(\lambda\) packets/slot. We also simulated 16 \(\times\) 16 routing nodes to receive and deliver real packets in one packet/slot at most based on the routing policy generated by the local reinforcement learning model. The data was finally recorded in the experiment, including average packet delay, transaction delay, energy consumption, etc. The detail configurations of the devices are shown below in Table 1.  
To test the effectiveness, we set delay performance experiments in the routing environment with malicious nodes. In order to establish the comparative experiments, we compared our RLBC algorithm with the traditional BP algorithm, the trust-based backpressure (TB-BP) algorithm [18], the state-of-the-art reinforcement learning-based algorithm named QL-BP [34], and our original blockchain-based algorithm. There were 25% and 50% malicious nodes in the 16 \(\times\) 16 routing nodes to interfere with the normal routing scheduling, that the malicious nodes will try to forge false queue length information and use the vulnerability of BP algorithm to cheat more packets (see in Figure 1) or act as a black hole node and not transmit any packet. Specifically, we assigned three kinds of malicious nodes and they appear with the same probability:  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Parameter Name** & **Server Node** & **Terminal Node** & **Routing Node** \\ \hline CPU & 2.6 GHz & 1.2 GHz & 580 MHz \\ RAM & 16 GB & 1 GB & 32 MB \\ Storage & 1 TB & 16 GB & 256 MB \\ Network & 1000 Mb & 100 Mb & 100 Mb \\ OS & Ubuntu Server 16.04 & Raspbian 4.14 & OpenWRT 15.05 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Specifications of devices.  
1. A malicious node releases a fake low (10% of the true amount) queue length information, but it transmits packets to other routing nodes.
2. A malicious node releases the true queue length information, but it doesn't transmit any packet to other routing nodes.
3. A malicious node releases a fake low queue length information and it doesn't transmit any packet to other routing nodes.  
To evaluate the effectiveness of our system, we tested the average latency, average energy consumption and throughput of the blockchain token transactions in comparative experiments. We implemented and compared the traditional blockchain system based on PoW consensus mechanism to show the advantages of our system based on PoA consensus mechanism [38].