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 calculate distance between the nodes in NS2?

  • Distance between nodes in Wireless network is calculated using the following formula:

    Node0-x coordinates and y coordinates
    set xx(0) 230,set yy(0) 250
    Node1-x coordinates and y coordinates
    set xx(1) 230,set yy(1) 250
    Distance between 2 nodes =
    set dx [expr $xx(0) – $xx(1)]
    set dy [expr $yy(0) – $yy(1)]
    set dx2 [expr $dx * $dx]
    set dy2 [expr $dy * $dy]
    set h2 [expr $dx2 + $dy2]
    set h(0-1) [expr pow($h2, 0.5)]
    where,
    h(0-1) → represents the distance between node0 and node1