# A Clustering WSN Routing Protocol Based on k-d Tree Algorithm
## 5 Simulation and Results Analysis
### Results and Discussion  
In the results obtained, one of the most stable parameters found in the proposed H-kdtree protocol is related to the formation of CH nodes, as shown in Figure 11. In this section, we analyze the impact of low variability in CH node formation, in relation to the following performance metrics: delay, throughput, and jitter, and their results are interpreted as QoS.  
Regarding CH node formation in each round, we observed that LEACH and LEACH-C reduces the formation of CH nodes as nodes die. On the contrary, H-kdtree increases CH node formation in the network because of the minimum nodes per cluster value: as the number of nodes goes down, H-kdtree tends to maintain its \(k\) value by iterating more times, which tends to comply with the minimum nodes per cluster condition. This behavior can be seen in Figures 11 and 12 after round 80.  
Figure 11: Cluster Head formation behavior.  
Figure 12: Dead nodes.  
Regarding energy levels, we did not find a significant variation or tendency in H-kdtree compared to LEACH and LEACH-C, as shown in Figure 13. The reason is that the energy that LEACH and LEACH-C used in node formation is offset by the energy used in selecting CH nodes in H-kdtree, being that the latter is more stable in terms of variations and allows for a more stable behavior in the data transmission phase. Figure 12 shows node death compared to energy. H-kdtree resulted in a lower number of dead nodes in both scenarios, compared to LEACH and LEACH-C.  
The scenarios allow us to assess QoS features from a hierarchical point of view for LEACH, LEACH-C and H-kdtree, as the protocols share a clustering topology with a two-hop distance to the Sink/BS node.  
Regarding delay, the scenario with random node deployment shows more delay than the deterministic scenario with more density in its central area. H-kdtree maintains a stable number of CH nodes for the maximum possible number of rounds. This simplifies the work of the Sink/BS node, as each node has an identifiable death threshold that, when reached, triggers the transmission of a \"Death\" packet to the Sink/BS node to inform its death. This feature enables H-kdtree to maintain a network topology for the maximum possible number of rounds. This is not possible for LEACH and LEACH-C, per changes in the network topology in each round.  
In the rounds we evaluated in the random scenario, H-kdtree changes the topology of the network five times, and nine times in the deterministic scenario, as shown in Figure 12. LEACH and LEACH-C changed its topology 100 times in both scenarios (in each round, the topology changes).  
CH nodes do not transmit sensory data. CH nodes compile packets from each cluster and retransmit them to the Sink/BS node. For this reason, if the network topology remains constant, delay, jitter, and throughput metrics will not vary, as these three metrics are a function of time. On the other hand, TDMA divides the network nodes into tie slots and ensures no packet loss due to simultaneous transmission.  
In both scenarios, H-kdtree shows the lowest values for Delay and Jitter, due to H-kdtree's low variability of topology, compared to LEACH and LEACH-C. This is shown in Figures 14 and 15.  
The stability of H-kdtree allows data traffic to remain constant, with very low variability in the rounds we evaluated as compared to LEACH and LEACH-C, in both scenarios. The results shown in Figures 14-16 support our recommendation for multimedia applications, due to its stability in delay, jitter, and throughput metrics.  
Figure 13: Average energy.  
Figure 16: Throughput behavior.  
Figure 14: Delay behavior.  
Figure 15: Jitter behavior.