LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
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.

Notices


Reply
  Search this Thread
Old 06-10-2015, 04:34 AM   #1
ali_it
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?
thanks

Last edited by ali_it; 06-10-2015 at 04:58 AM.
 
Old 06-10-2015, 04:00 PM   #2
ali_it
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"
 
  


Reply

Tags
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 05:44 AM
what are the un utilized fields of ns2 packet header rose24 Linux - Networking 0 02-26-2014 12:44 PM
How to create a cluster in ns2.33 Nad14 Linux - Software 0 12-29-2013 08:44 PM
error receiving header from <hostname> 11111. while creating cluster. sudheer.khanduri Linux - Server 1 11-13-2013 11:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:24 AM.

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