Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 06-10-2015, 03:34 AM   #1
LQ Newbie
Registered: May 2015
Posts: 9

Rep: Reputation: Disabled
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?

Last edited by ali_it; 06-10-2015 at 03:58 AM.
Old 06-10-2015, 03:00 PM   #2
LQ Newbie
Registered: May 2015
Posts: 9

Original Poster
Rep: Reputation: Disabled
# 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"


cluster header ns2, ns2

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create cluster using NS2 ton5cob Linux - Wireless Networking 0 06-27-2014 04:44 AM
what are the un utilized fields of ns2 packet header rose24 Linux - Networking 0 02-26-2014 11:44 AM
How to create a cluster in ns2.33 Nad14 Linux - Software 0 12-29-2013 07:44 PM
error receiving header from <hostname> 11111. while creating cluster. sudheer.khanduri Linux - Server 1 11-13-2013 10:02 AM > Forums > Linux Forums > Linux - Software

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration