Share your knowledge at the LQ Wiki.
 LinuxQuestions.org [SOLVED] How do i select a cluster header with NS2?
 User Name Remember Me? Password
 Linux - Software This forum is for Software issues. Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

 06-10-2015, 03:34 AM #1 ali_it LQ Newbie   Registered: May 2015 Posts: 9 Rep: How do i select a cluster header with NS2? Hi Friends i have a sensor field in dimension of 200 * 200 and nodes deployed randomly. i want select nearest node to midpoint of sensor field as a Cluster Header. How do I do this? thanks Last edited by ali_it; 06-10-2015 at 03:58 AM.
 06-10-2015, 03:00 PM #2 ali_it LQ Newbie   Registered: May 2015 Posts: 9 Original Poster Rep: # calculate distance between node (i) and center for {set i 0} {\$i<\$val(nn)} {incr i} { set x_posi [\$n(\$i) set X_] set y_posi [\$n(\$i) set Y_] #puts "\$x_posi , \$y_posi" set x_pos [expr \$x_posi - 100] set y_pos [expr \$y_posi - 100] set v [expr (\$x_pos * \$x_pos) + (\$y_pos * \$y_pos)] set d [expr pow(\$v , 0.5)] set nd(\$i) \$d puts "\$nd(\$i) \n" #puts "distance of n(\$i) from center \$d" #puts "\n" } #calculate minimum distance to center set mind \$nd(0) set j 0 for {set i 0} {\$i < \$val(nn)} {incr i} { if {\$nd(\$i) < \$mind } { set mind \$nd(\$i) set j \$i ;#j is index node that nearest to center } } puts "nearest node to center is \$j with distance \$mind"

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is Off HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post ton5cob Linux - Wireless Networking 0 06-27-2014 04:44 AM rose24 Linux - Networking 0 02-26-2014 11:44 AM Nad14 Linux - Software 0 12-29-2013 07:44 PM sudheer.khanduri Linux - Server 1 11-13-2013 10:02 AM

LinuxQuestions.org

All times are GMT -5. The time now is 04:26 AM.

 Contact Us - Advertising Info - Rules - Privacy - LQ Merchandise - Donations - Contributing Member - LQ Sitemap -