Amazing technological breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to apply LEACH protocol in NS2?

Description

Low Energy Adaptive Clustering Hierarchy (LEACH) is the hierarchical clustering approach in which network is divided into set of clusters and each cluster is maintained by clusterhead. Clusterhead is selected based on random number and threshold in multiple rounds. In each round clusterhead role is rotated for all sensors in the network.

Sample Code

Filename: leach.tcl

set cper [expr $nclusters.0 / $val(nn)]
set th [expr $ra % [expr round(1.0 / $cper)]]
set th1 [expr $cper * $th]
set threshold [expr $cper / [expr 1 – $th1]]
if { $random($i) < $threshold } {
set ch $i
}


Screenshots

apply LEACH protocol in NS2