Yeah, i got your idea. However, as i have read a paper related to the distance calculation, the authors could calculate the distance by using NS-2, and store the distance information into a registry in order to be used by the higher layer. But, they used a simple but different mechanism from signal strength or node coordinates. Thus, I'm just wondering whether there is existing implementation of such a mechanism. If you needed that paper, maybe you could check the attached file.
Thanks, Cheav ________________________________ From: Valeriy Ivanov <wizard19891...@gmail.com> To: Cheav Chhing <chhingch...@yahoo.com> Sent: Tuesday, October 30, 2012 10:39 PM Subject: Re: [ns] mobile nodes distance calculation in NS-2 The way to calculate distance for mobile node is the same. All you need is to periodicaly probe the coordinates of all nodes. I don't know exact functions to do this. Also there are some scripts that calculate signal strength of adjacent nodes. They are based on distance calculation. Read this scripts. Or you can just use the highest level of signal. Node with highest level of signal is closest. If you don't research satellite networks, delay is not an issue. So use the highest level of signal in any case. 30.10.2012 17:29 пользователь "Cheav Chhing" <chhingch...@yahoo.com> написал: >Hello, > >Recently, i'm researching on the wireless and mobile networking. I would like >to calculate the distance between two wireless nodes which are moving in their >communication range, so that, in the upper layer, I can select a nearer node >to send data. > >There probably existed such a question in the list (as shown below), but I >think it's for fix nodes, while not what i'm expecting. >set x1 [$node_a set X_] >set y1 [$node_a set Y_] set x2 [$node_b set X_] >set y2 [$node_b set Y_] set distance [expr >"sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))"] > >Therefore, would anyone mind pointing me out the way of calculating such a >distance in NS-2 (by using C++ code or TCL)? > > >Regards, > >Cheav >