Skip to main content
. 2022 Jan 9;22(2):478. doi: 10.3390/s22020478
Algorithm 1 Proposed Algorithm
1. Initialize:
2. N = total nodes
3. Dead = 0 //the number of dead nodes.
4. Begin
5. for i = 1:N
6.    if S(i)·E>0   //If node is alive
7.     Cluster formation
8.     Record the ID of node
9.     if The sensor nodes need to forward the data
10.        The sensor nodes forward the data
11.     else
12.        Calculate the sleep threshold T(Si)
13.        if T(Si)T(Si)
14.         The sensor node remains idle listen
15.        else
16.         The sensor node will enter the sleep state from idle listening
17.        end if
18.     end if
19.    else
20.     Dead = Dead +1
21.     if DeadN
22.        End of simulation
23.     end if
24.    end if
25. end for