**4.1 Sensor nodes deployment**

For example, 100 sensor nodes are randomly deployed over a 100 m<sup>2</sup> area of interest. The SB is positioned at the coordinates (50 m, 200 m). Initially, there is no CH, so the nodes are all normal type. The **Table 2** shows simulation setting.


**Table 2.**

*The simulation settings.*

### **4.2 Simulation results**

In this simulation our experimental model is established with 100 nodes randomly spread over a square surface of 100 m<sup>2</sup> and a base station situated in (50,200) coordinate: **Figure 6** illustrates the simulation phase with k = 7.

After the simulation we compare the performance of the two protocols LEACH and LEACH improvement with K-means by certain metrics.

#### **Figure 6.**

*The phase of clustering with (k = 7).*

#### *4.2.1 Residual energy*

**Figure 7** below represents the residual energy relative to the number of rounds for the two LEACH and K-LEACH protocols. Both protocols showed a gradual decrease in energy and the difference between the two protocols is acceptable. However, K-LEACH show good improvement in lifespan with the same measures.

#### *4.2.2 Lifetime comparison*

**Figure 8** shows the number of dead nodes in both protocols. In LEACH, there was a very rapid decrease in the number of dead nodes depending on the number of rounds The first dead node in round Number: 97 and the tenth dead node in round 120 and all nodes died Round 441. This is what causes a very short lifespan in LEACH. On the other hand in K-LEACH has a longer lifespan, with a slow decrease in the number of dead nodes according to the round or The first dead node in round Number: 235 and the tenth dead node in round 337 and all nodes died Round 689.

#### *4.2.3 Comparison of CH numbers*

**184 Figure 9** shows the number of CHs in both protocols. We find that in LEACH has a high number of CHs which implies high energy consumption on the other hand

**185**

**Figure 9.**

*Number of CHs nodes versus round.*

**Figure 7.**

**Figure 8.**

*K-Means Efficient Energy Routing Protocol for Maximizing Vitality of WSNs*

*DOI: http://dx.doi.org/10.5772/intechopen.96567*

*Residual energy versus rounds (LEACH and K-LEACH).*

*Number of dead nodes "first, tenth, last" versus rounds.*

*K-Means Efficient Energy Routing Protocol for Maximizing Vitality of WSNs DOI: http://dx.doi.org/10.5772/intechopen.96567*

**Figure 7.** *Residual energy versus rounds (LEACH and K-LEACH).*

**Figure 8.**

*Computational Optimization Techniques and Applications*

domly spread over a square surface of 100 m<sup>2</sup>

coordinate: **Figure 6** illustrates the simulation phase with k = 7.

and LEACH improvement with K-means by certain metrics.

In this simulation our experimental model is established with 100 nodes ran-

**Parameter Value** The size of the network. 10 m \* 10 m La localisation de la station de la base. (50,200) The number of nodes 100 N The initial energy of the nodes 0.12 J Le nombre de cluster à créer avec K-means 5

After the simulation we compare the performance of the two protocols LEACH

**Figure 7** below represents the residual energy relative to the number of rounds for the two LEACH and K-LEACH protocols. Both protocols showed a gradual decrease in energy and the difference between the two protocols is acceptable. However, K-LEACH show good improvement in lifespan with the same measures.

**Figure 8** shows the number of dead nodes in both protocols. In LEACH, there was a very rapid decrease in the number of dead nodes depending on the number of rounds The first dead node in round Number: 97 and the tenth dead node in round 120 and all nodes died Round 441. This is what causes a very short lifespan in LEACH. On the other hand in K-LEACH has a longer lifespan, with a slow decrease in the number of dead nodes according to the round or The first dead node in round Number: 235 and the tenth dead node in round 337 and all nodes died Round 689.

**Figure 9** shows the number of CHs in both protocols. We find that in LEACH has a high number of CHs which implies high energy consumption on the other hand

and a base station situated in (50,200)

**4.2 Simulation results**

*The simulation settings.*

**Table 2.**

*4.2.1 Residual energy*

*The phase of clustering with (k = 7).*

**Figure 6.**

*4.2.2 Lifetime comparison*

*4.2.3 Comparison of CH numbers*

**184**

*Number of dead nodes "first, tenth, last" versus rounds.*

**Figure 9.** *Number of CHs nodes versus round.*

in K-LEACH a fixed number of CH k-10 will die slowly. K-LEACH ensures a good distribution of CH on the network. LEACH presents a huge variation in the number of CH per round this leads to poor network coverage, and affects the overall lifespan of the network.

After comparing the performance of the two LEACH and K-LEACH protocols, we noticed that the our adaptation K-LEACH has several advantages such as: The decrease in energy consumption; A longer lifespan during the simulation with a good distribution of CH thanks to the k-means method.
