## 3 Security Level
### Dynamic Selection of Cluster Heads
The greater the number of WSN nodes close to it (nominated trusted node), the greater the chance of it becoming a CH node. Moreover, the average distances between the candidate node (CH) and the adjacent node will be taken into account, as shown in Equation (10) [17]. \[\sigma(N)=\frac{\sum_{j=1,\ j\
eq n}^{\alpha}d_{n\rightarrow j}}{a}\] (10) On the other hand, we also need to set the threshold (\(d_{Th}\)) value on the distance between CH nodes and the host nodes. Since increased distance and weak signal lead to increased unwanted power consumption. Thus, we will determine this value (\(d_{Th}\)) based on Equation (11) [17]. \[d_{Th}=\left(\sqrt{\frac{\beta_{fsm}}{\beta_{trm}}}\right)\] (11) In addition, we need to know the average distances between the candidate node (Trusted node) and the existing CH nodes to keep the RPL working to transfer data to the AP. Equation (12) will represent this process. \[\partial(Tn)=\frac{\sum_{j=1,\ j\
eq n}^{m}d_{n\rightarrow j}}{m}\] (12) where \(\partial(Tn)\) is the average distance, \(m\) is the total number of CHs operating at that time and \(Tn\) is the candidate node. In this work, GPS will be used in real application to determine distances between nodes [19], but Cartesian coordinates (X, Y) will now be implemented for each node. Finally, the residual energy level (\(P_{r}\)) will enter into the equation for choosing the best CH node. The node with higher \(P_{r}\) value is nominated to be the CH. However, based on the average set of interaction factors that we proposed, the weight of each candidate node from the trusted nodes will be determined to be the CH. Equation (13) illustrates the average weights of these factors. \[\omega=\frac{a+2\times P_{r}+\sigma/10}{d_{Th}\times\vartheta} \tag{13}\]  
We find that the values of the coefficient of multiplication between the interactive factors are not convergent, thus we take an approach by increasing the effect of the residual energy and decreasing the effect of distance by dividing \(\sigma\) by 10. However, based on Equation (13), the selection of the optimal node (CH) depends on that it mediates the largest number of nodes, is close to the other CH nodes and has high residual energy. Furthermore, do not forget that it has absolute confidence (full trust). Since the proposal depends on the scenario of the moving nodes, it is possible for nodes to move away from their associated node (CH). Thus, when the threshold value (\(Th\)) passes between it and its (CH), the WSN node either searches for the nearest CH or forms a new cluster based on its adjacent nodes. This process is carried out in the same way as reference [26]. However, keep in mind that the new CH has a trust feature. Figure 5 explains the mechanism of the CH node creation and rotation between mobile nodes. The algorithm begins by tracking the distance between the WSN node and its CH, as the nodes of this type of network move at a slow speed. Assuming that the nodes are moving at a speed of about 5 m/s and the distance between the node and its CH is checked once every second (s) [41]. Figure 5: Trust-CH rotation process. Once the distance between a node and its CH reaches the assumed limit (\(d_{Th}\)), the node searches for any adjacent CH nodes. If a node can find a variety of neighboring CH nodes, it will link to the nearest one and start the correspondence process between the node, the CH node and the target-CH node to handoff to the target-CH node. The _Join_Request_ and _Release_Request_ messages are used for these purposes. Next, the table (ns) of the CH parent nodes is modified, which is owned by each CH individually and called (ns). This table (ns) has all IDs of the associated nodes. The identifier is deleted from the CH parent node and added to the table of the target-CH node. If the node is a CH and it has moved far enough from the host nodes (children) and the distance (\(d\)) is closed to the \(d_{Th}\), CH will also detach from its host nodes and return to the \"normal node\" in search of a link to the nearest CH.