# Blockchain Technology for Secure Communication and Formation Control in Smart Drone Swarms
## 5 Results
### Simulation  
For testing and evaluating the functionalities of the smart contracts, a Python DApp has been developed using the web3 module. Also, for better interaction with the smart contract, a UI has been created. Figure 9 shows the functionalities of the leader. As can be seen on the left-hand side of the figure, the leader first submitted a heartbeat message to the blockchain in order to confirm he was active. In addition, the menu with all the options available to the leader while interacting with the smart contract is shown below. By choosing option 1, the drone registration process in the swarm occurred. On the right-hand side of the figure, the option of submitting data to the blockchain is shown. In this particular case, the leader submitted his location, along with the data \"Hello from leader!\". A mission creation process is also shown below. A dive-and-attack mission by the name of \"Impossible\" was created and submitted successfully to the blockchain. Figure 8: Proposed model. Finally, the last image represents the activation of this particular mission with ID = 0 (the first mission created was ID = 0, the second was ID = 1, and so on). Figure 10 illustrates the functionalities of the followers. As can be seen, the first action was to check whether their leader was active and submit their battery level. It is clear from the first terminal that the leader is alive, and it is definitely not the current drone with ID = 1. One can observe the procedure for reading data from the blockchain in the second terminal. The mission details, declared by the leader, were retrieved by the drone with ID = 1. These details included the mission's name ('Impossible' (string)), the mission's type (dive and attack, integer 1 in the smart contract), the formation that drones must make (V, integer 1 in the smart contract), and the Boolean value (true), indicating that the mission was active. After retrieving the mission's details, the nearest position in the formation could be selected by the drones. First, the available positions were examined through the blockchain (based on Figure 6, terminal 3), and then the best option for each of them was chosen and submitted to the chain (terminal 4). The process was repeated for the other followers. The outcomes of the position selection of the other drones are shown in Figure 11. Position 2 in the V formation was selected by the drone with ID = 1 since it was the one nearest to it. Then, the available locations were examined by the drone with ID = 2, and position 2 was selected. The remaining options were inspected by the drone with ID = 3 through the chain. Only positions 1 and 4 were  
Figure 10: Testing followers’ functionalities in the smart contract: (**1**) Follower’s menu, along with the leader-checking and battery-submission processes. (**2**) Process of retrieving mission details for the followers. (**3**) Checking the available positions through the blockchain. (**4**) Position-selection process in the formation and position submission to the blockchain. Figure 9: Testing leaders’ functionalities in the smart contract: (**a**) On the left, the leader’s menu, along with the drone registration process, can be seen. (**b**) On the right, the data submission, mission creation, and activation processes are shown. available, so position 4 was selected, and so on. For a drone that has already chosen a position, this step cannot be repeated because the blockchain would reverse the transaction. Finally, the program was expected to surpass the predetermined threshold without taking any actions as the leader in order to test the new leader-election procedure. As can be seen in Figure 12, the new leader is the drone with ID = 1, as it was the one with the highest battery life, while the old leader was down. Also, it can be observed that the follower's menu has been replaced by the leader's menu.