1: do { ; repeat for all m rounds

2: compute Eres(m) and distance from base

3: if (Eres(m)>Eth&rmod(1/p)≠0) then

4: r ¬random(0,1) and compute T(n)

5: if (r < T(m)) then

6: CH{n}=TRUE; node n be a nominate for CH

7: else

8: CH{m}=FALSE; node s not be a candidate for CH

9: end if

10: end if

11: if (CH{m}=TRUE) then

12: Accept ‘m’ value 0,1,2 with minimum distance d0

13: BM (ADV) ¬broadcast an advertisement message with in the coverage

14: Join(IDi); non-cluster head node i join into the nearby CH

15: CH (j); maximum join message received nominee elected CH of that round

16: Clstr( k) ; form a cluster with TDMA slot to member nodes;

17: end if

18: }