## 5 System Simulation
### Simulation Results
Similar results and analysis are seen that as the hop cost decreases, the routing paths are longer and more dynamic. It is clear that as the hop cost increases the paths are more symmetrical and balanced. Table 3 shows the load on the BS neighbors in this specific period and assures our conclusion that as the cost of the hop increases the routing paths are more balanced and less dynamic every period. It should be noted that longer and unbalanced paths have the advantage of depleting the whole network together, which could be useful in some types of irregular networks. This comes at the expense of increasing the overall network communication energy consumption and longer paths, which by itself could pose the risk of higher packet dropping rate. Similar results are found in smaller topologies such as 5 \(\times\) 5 and larger topologies such as the 15 \(\times\)15 grid. Figure 6: Routing paths with hop cost equals zero. As for the 31 \(\times\)31 topology, it contains 961 nodes and thus requires more than one byte to account for the node IDs. So, we doubled the message size and simulated the network again. The protocol proved to be correct even for such large networks, giving a balanced and shortest path routing for all nodes in the network. Following we discuss the detection and isolation of bad misbehaving nodes for which we assigned several bad nodes as discussed in the simulation setup. First, node 12 was set to be a partially non-cooperative node dropping one out of every three packets forwarded through it. In the sixth pass, that is the first activity period after the BS distributed the DL and UL information to all the nodes, node 12 is put on UL probation and its UL node 11 is put on DL probation. Then the BS changes the link between the two nodes to detect which node is misbehaving and set node 3 as an UL of node 12. In the following activity report period, pass 12, the BS found a difference in the counters of node 3 and node 12. Thus in giving node 12 another UL probation, with the maximum allowed probation set to 1, node 12 is set as a bad node, and thus isolated from the network for the next three periods, since its dtrust value is 0.67 and its banNum is still 1, so as per the banning system, the banRem is set to three activity periods and the banNum is incremented to 2. Thus, as described earlier, when the BS detects a difference in what nodes are claiming to have sent/forwarded through/for each other, it gives them another chance and changes the link between them; since this may be due to a noisy link, lying node, or uncooperative node. As seen in this example, even a node 12 partially dropping packets can be detected by the BS, if it persists on its bad actions. Note that the decreasing the probation limit increases the decision to ban a node at the expense of false positives. On the other way, increasing the probation limit gives the misbehaving node more time to exploit the network and drop its neighbors' packet. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Hop Cost** & **Node 32** & **Node 40** & **Node 42** & **Node 50** \\ \hline
1 & 12 & 26 & 25 & 13 \\
0.5 & 6 & 29 & 0 & 41 \\
0.25 & 1 & 0 & 30 & 45 \\
0 & 0 & 50 & 26 & 0 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Load on the BS neighbors with respect to hop cost. Figure 7: (**a**) Routing paths with hop cost equals 0.5; (**b**) routing paths with hop cost equals 0.25. Then node 7 is an outsider attacker node not belonging to the system and node 23 is a partially malicious node sending one bad packet every three packets. The results showed that node 7 is isolated from the system as it does not have the required key to sign its packets, and thus all of its packets are dropped by its neighbors 6, 8, and 16. As for node 23, the BS detects each malicious packet and set it as a bad node and then isolated for 2 periods, since its dtrust value is 0.75 (sending only one bad packet out of four in the first period). Definitely, in subsequent periods, node 23 is isolated more and more for every additional malicious packet sent.