| 1 input: Number of devices, Base Station, |
| Simulation Area , Upper |
| Bound of , Lower Bound of , Cluster |
| Head , Cluster Head Group |
| , Nodes Residual |
| Energy |
| 2 output: Dead Nodes, Node’s latency, Energy consumption, Time complexity, |
| Packets delivery |
| 3 Initialization: parameters, variables |
| 4 Execution:; |
| 5 whiletermination criterion metdo |
| 6 for i=1:SN do |
| 7 nodes |
| 8 get (, ) |
| 9 Deploy (-th node) in (, ) |
| 10 ifnodes deployment = = truethen |
| 11 break; |
| 12 else |
| 13 continue; |
| 14 end |
| 15 end |
| 16 Distance-WSN (Nodes, Rounds)get distance() |
| 17 K-medoids-Clustering (, ), Deploy clusters, get CH |
| 18 IDs (, , CHG)calculate |
| opt-route |
| 19 get next hop CHs//Communication phase |
| 20 whilerounds max roundnodesdeaddo |
| 21 rounds++22 Energy Consumption Model get residual energy |
| 23 fordo |
| 24 get next hop |
| 25 ifnext hop (CH) == BSthen |
| 26 receive M data length |
| 27 //CH receives data from M SeNs |
| 28 transmit N data length; |
| 29 // CH transmits data of N SeNs |
| 30 else |
| 31 ifnext hop (CH) == CH(k)then |
| 32 receive Mdata length |
| 33 transmit N data length |
| 34 end |
| 35 Node(n) transmit CH(k) |
| 36 end |
| 37 ifenergy-th nodethresholdthen |
| 38 declare ith node as a dead node |
| 39 end |
| 40 end |
| 41 end |
| 42 end |