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

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • 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