How to convert real traces to ns-3 mobility format

300 views
Skip to first unread message

RBM-IT

unread,
Nov 18, 2015, 11:06:02 AM11/18/15
to ns-3-users
Hello everyone,

I want to use real mobility traces downloaded from the CRAWDAD website (which has the format: time, X, Y) in my simulation of an ad-hoc network.
I verified that this can be done by using the ns2mobilityhelper. However, i don't know how to generate the .tcl file from that .txt file.

I want to mention that this is an ad-hoc network of people carrying mobile devices (not vehicles). Thus, i wouldn't use SUMO.

Any suggestions?

Regards,

Konstantinos

unread,
Nov 18, 2015, 11:24:58 AM11/18/15
to ns-3-users
Hi,

First of all, the ending of the file (.tcl or .txt) does not play any role. The format that describes the movement of the nodes plays.

What is the granularity of those files in terms of time? e.g. is it every second? less? more?

You could create your own 'mobiliy-helper'/parser from those files by extending waypoint mobility.
In NS-3, each WayPoint is defined as a Time and a Position, which IMHO resembles the format in CRAWDAD. 
You would then have to read the file (simple C++ operation), get each line, create a WayPoint, add that WayPoint to the Mobility of the node.  

Is that clear enough?

You you also use SUMO, as it can be used for pedestrians (e.g. http://sumo.dlr.de/wiki/Simulation/Pedestrians)

Regards,
K.

RBM-IT

unread,
Nov 18, 2015, 12:05:19 PM11/18/15
to ns-3-users


Le mercredi 18 novembre 2015 17:24:58 UTC+1, Konstantinos a écrit :
Hi,

First of all, the ending of the file (.tcl or .txt) does not play any role. The format that describes the movement of the nodes plays.
I mentioned .txt and .tcl just to make the difference between the (X Y writing format) and the (ns-3 format ) 

What is the granularity of those files in terms of time? e.g. is it every second? less? more?
The granularity is about each 10 seconds

You could create your own 'mobiliy-helper'/parser from those files by extending waypoint mobility.
In NS-3, each WayPoint is defined as a Time and a Position, which IMHO resembles the format in CRAWDAD. 
You would then have to read the file (simple C++ operation), get each line, create a WayPoint, add that WayPoint to the Mobility of the node.  

Is that clear enough?

Yes, your suggestion is clear enough. Thank you
However, since i saw a simple way to have ns compatible trace files from SUMO, Bonnmotion, i was wondering if there is a similar way to convert a (t,x,y) file to ns format. I am thinking of doing it manually, by printing the global format ($node..) with python.
 

You you also use SUMO, as it can be used for pedestrians (e.g. http://sumo.dlr.de/wiki/Simulation/Pedestrians)

Regards,
K.

Regards,

Konstantinos

unread,
Nov 18, 2015, 12:14:05 PM11/18/15
to ns-3-users


On Wednesday, November 18, 2015 at 5:05:19 PM UTC, RBM-IT wrote:


Le mercredi 18 novembre 2015 17:24:58 UTC+1, Konstantinos a écrit :
Hi,

First of all, the ending of the file (.tcl or .txt) does not play any role. The format that describes the movement of the nodes plays.
I mentioned .txt and .tcl just to make the difference between the (X Y writing format) and the (ns-3 format ) 

What is the granularity of those files in terms of time? e.g. is it every second? less? more?
The granularity is about each 10 seconds

This granularity will not be good enough for WayPointModel because you do not have the the speed from A to B. It it was <1sec you could use WayPoint without significant loss of accuracy.
 

You could create your own 'mobiliy-helper'/parser from those files by extending waypoint mobility.
In NS-3, each WayPoint is defined as a Time and a Position, which IMHO resembles the format in CRAWDAD. 
You would then have to read the file (simple C++ operation), get each line, create a WayPoint, add that WayPoint to the Mobility of the node.  

Is that clear enough?

Yes, your suggestion is clear enough. Thank you
However, since i saw a simple way to have ns compatible trace files from SUMO, Bonnmotion, i was wondering if there is a similar way to convert a (t,x,y) file to ns format. I am thinking of doing it manually, by printing the global format ($node..) with python.

Yes, that is another option. You can create that parser in python to convert the (t,x,y) to ns-2 format remembering the below format is supported.

  $node set X_ x1
  $node set Y_ y1
  $node set Z_ z1
  $ns at $time $node setdest x2 y2 speed
  $ns at $time $node set X_ x1
  $ns at $time $node set Y_ Y1
  $ns at $time $node set Z_ Z1
 

The last commands (i.e $ns at $time $node set X_ x1) are similar to setting waypoints, however, as mentioned above, the granularity is large, so you would have to calculate the velocity of the node from t0 to t1, as Speed = (position_t1 - position_t0) / (t1 - t0). 

RBM-IT

unread,
Nov 18, 2015, 12:16:56 PM11/18/15
to ns-3-users

Hi Konstantinos,

Exactly, this came to mind also (calculating the speed)

Thank you very much for your recommendations. This makes more comfortable now.

Best Regards

FAS

unread,
Mar 10, 2016, 6:27:55 PM3/10/16
to ns-3-users
Hi, 

I'm looking for the same thing as you (converting <id,time,x,y> into NS-like movement format).

Did you code a script to do that? If so, could you make it available or give us directions on how to implement it?

Thanks in advance!

Regards! 

RBM-IT

unread,
Mar 11, 2016, 4:12:02 AM3/11/16
to ns-3-users
Hi FAS,

I did this with a simple python script (or you can use other programming languages)
You just need to save in a file with ".ns_movements" extension your coordinates in the ns2 mobility format which is:

$node_(0) set X_ 13629.6576521

$node_(0) set Y_ 7090.41723703

$ns_ at 0.0 "$node_(0) setdest x y speed"


As a hint, you must make the two first lines for every new node

Then you compute the speed (simple maths) and you add it with the next coordinates in the third line and so on.


Hope it helps

Reply all
Reply to author
Forward
0 new messages