Generating ASCII Trace for SUMO mobility trace file

752 views
Skip to first unread message

Urvik Upadhyay

unread,
Mar 12, 2014, 6:23:09 AM3/12/14
to ns-3-...@googlegroups.com
Hello. I'm able to generate log file from sumo mobility trace in ns3. But I also want to generate .tr file after implementing AODV in ns3. How to do that? What addition should I make in my ns2mobilityhelper.cc file?

Konstantinos

unread,
Mar 12, 2014, 6:48:18 AM3/12/14
to ns-3-...@googlegroups.com
You made one question, and in order to help you I had to make more than 5 and still can not help you.

What is your ns2mobiltyhelper.cc file is? 
Is it the ns2-mobility-helper.cc file in /scr/mobility/helper folder (http://www.nsnam.org/doxygen/ns2-mobility-helper_8cc.html)? If yes, then you should not do ANYTHING on that file.

If it is a scenario file in /scratch that you have created, then you have to give more information. Is it a copy of the /src/mobility/examplesns2-mobility-trace.cc (http://www.nsnam.org/doxygen/ns2-mobility-trace_8cc.html)? 

Generally, look at the examples in /examples/wireless or /src/aodv/examples where you can find source code for scenarios using AODV or similar protocols. In those, you only need to change the mobility of the nodes by using the ns2mobilityhelper. 

Urvik Upadhyay

unread,
Mar 12, 2014, 8:21:09 AM3/12/14
to ns-3-...@googlegroups.com
Well first of all sorry if my question was not clear enough and troubles I've caused.
 I'm pretty new to ns3 and I didn't get enough time to learn the basics. I've a final year project on Simulation of AODV,GPSR and GPCR in VANET. I was under the impression that I would eventually get one sample simulation scenario for complete simulation but unfortunately didn't find one.
So I've created a sample scenario in sumo consisting 150 nodes and I generated ns2mobility ns2activity and ns2config files using that traceExporter tool.
 I read a blog which explained how to import this mobility file in ns3 using ns2-mobility-helper.cc file. I made some changes in that file as shown in the blog and I was able to generate log file which is correct one as the values of X,Y and velocity matches my mobility file.
But I'm interested in generating trace file.Because based on that file I can do performance evaluation. For that, I need to include a protocol package, say AODV. But I don't know how to do it in ns3. I read tracing manual but it didn't help a lot. Here is my ns2-mobility-helper.cc file which resides in /scratch.
ns2-mobility-tracex.cc

Konstantinos

unread,
Mar 12, 2014, 12:12:16 PM3/12/14
to ns-3-...@googlegroups.com


On Wednesday, March 12, 2014 12:21:09 PM UTC, Urvik Upadhyay wrote:
Well first of all sorry if my question was not clear enough and troubles I've caused.
 I'm pretty new to ns3 and I didn't get enough time to learn the basics.

You should start with basics, go through the tutorials and examples of the modules you want to simulate. The meaning of tutorial, is to teach you do things.
 
I've a final year project on Simulation of AODV,GPSR and GPCR in VANET. I was under the impression that I would eventually get one sample simulation scenario for complete simulation but unfortunately didn't find one.

Just a heads up here; GPSR has been submitted for review in ns-3 but it is not yet included in ns3, so it may work as expected or not. For GPCR there is no code.
 
So I've created a sample scenario in sumo consisting 150 nodes and I generated ns2mobility ns2activity and ns2config files using that traceExporter tool.
 I read a blog which explained how to import this mobility file in ns3 using ns2-mobility-helper.cc file. I made some changes in that file as shown in the blog and I was able to generate log file which is correct one as the values of X,Y and velocity matches my mobility file.

The file you mention shows how you can use the trace file from the mobility of nodes in NS3. That's only one part of the problem you want to solve. Now you have to (a) build a communication system on those moving nodes, (b) introduce some data traffic and (c) decide the performance metric you want to capture and analyse. These two parts are not included in your script.
 
But I'm interested in generating trace file.Because based on that file I can do performance evaluation. For that, I need to include a protocol package, say AODV. But I don't know how to do it in ns3. I read tracing manual but it didn't help a lot. Here is my ns2-mobility-helper.cc file which resides in /scratch.


There is no need to create ASCII traces from NetDevice if for example you only want to do performance evaluation of packets received at the application. It would produce false results.

See the examples in /examples/wireless and in /src/aodv/examples to understand how you can do the first task (i.e. create a communication system on a set of nodes). These examples assume different mobility models (either static or randomwaypoint) but that is not an issue. You can replace it with the ns2-traces.

Then, almost every tutorial/example has some sort of Application (source/sink). Study them and implement it in your scenario. 

Finally, based on your performance metrics, you can use different traces, either from the netdevice or using other modules such as FlowMonitor/Statistics, to get the indicators you want (received packets, lost packets, timings etc).

Urvik Upadhyay

unread,
Mar 17, 2014, 5:35:47 PM3/17/14
to ns-3-...@googlegroups.com
Dear Konstantinos,
Hello again. I've been working on my basics of ns3. And as per your suggestions, I looked at the examples of wifi and aodv. I got a code from this group and learned from it, Then I copied "wifi-simple-adhoc.cc" file from /wireless and modified it for my scenario and I've attached it here.

Now the problem here is, my scenario contains 150 nodes. So I've changed number of nodes to 150 in 123rd line. Is it technically correct? Should number of nodes in ns3 be same as number of nodes in sumo?(In sumo nodes are vehicles) I assume it must be same but still I just want to make it clear.

Then there's code which sets up wifi channel. And then I added mobility nodes using Ns2MobilityHelper class. Now should there be some value in ns2.Install()? I tried passing 150 or c as parameter but it resulted in error.

Anyways, I declared AodvHelper class as I want to use AODV. But I'm not sure whether it can be implemented just by declaring it. After that there's InternetStackHelper class which is basically used to assign IP to devices & nodes I assume.

But the code after that is something I couldn't understand. Do I've to create sockets for all the source and receive sinks!!! I've 150 nodes and it would be a hell of a job to do that. However I tried to use a loop which can set 1 to 149 nodes as receive sink and 150th as source but it generates error.

Tracing generates individual pcap file for all 150 nodes but it doesn't look useful to me.

So, what additions should I make in this code to complete the simulation.

P.S. The code I've attached runs but I'm not getting what it actually produces. :O

Konstantinos

unread,
Mar 17, 2014, 6:40:21 PM3/17/14
to ns-3-...@googlegroups.com


On Monday, March 17, 2014 9:35:47 PM UTC, Urvik Upadhyay wrote:
Dear Konstantinos,
Hello again. I've been working on my basics of ns3. And as per your suggestions, I looked at the examples of wifi and aodv. I got a code from this group and learned from it, Then I copied "wifi-simple-adhoc.cc" file from /wireless and modified it for my scenario and I've attached it here.


I do not see any attached code.
 
Now the problem here is, my scenario contains 150 nodes. So I've changed number of nodes to 150 in 123rd line. Is it technically correct? Should number of nodes in ns3 be same as number of nodes in sumo?(In sumo nodes are vehicles) I assume it must be same but still I just want to make it clear.


The number of nodes in NS3 should be the same as those in the trace file, if you do not modify the Ns2MobilityHelper. See next answer for detail.
 
Then there's code which sets up wifi channel. And then I added mobility nodes using Ns2MobilityHelper class. Now should there be some value in ns2.Install()? I tried passing 150 or c as parameter but it resulted in error.

No, the Install() does not require any parameter.
From the API you can get that:
void ns3::Ns2MobilityHelper::Install(void )const

Read the ns2 trace file and configure the movement patterns of all nodes contained in the global ns3::NodeList whose nodeId is matches the nodeId of the nodes in the trace file.

 
That means that it looks at the Node_ID from the trace file and the Node_ID from the NodeList. You can have more nodes in NS-3, but for the extra you should use a new mobility model. They will not get their mobility from Ns2MobilityHelper.


Anyways, I declared AodvHelper class as I want to use AODV. But I'm not sure whether it can be implemented just by declaring it. After that there's InternetStackHelper class which is basically used to assign IP to devices & nodes I assume.


There are examples with AODV or OLSR or other Ipv4RoutingProtocols. After 'declaring' it, you have to 'install' it on the nodes. You need to study the tutorial more clearly to understand the InternetStackHelper and the process of creating a network.
 
But the code after that is something I couldn't understand. Do I've to create sockets for all the source and receive sinks!!! I've 150 nodes and it would be a hell of a job to do that. However I tried to use a loop which can set 1 to 149 nodes as receive sink and 150th as source but it generates error.


It depends on your scenario, what you want to simulate. That part is the creation of application traffic. You can do it with Sockets, you can do it with the Applications (OnOff, UdpClient/Server, etc). It is explained even in the first tutorial http://www.nsnam.org/docs/tutorial/html/conceptual-overview.html#applications .

About the sources/sinks and how to do it for large number of nodes, if you study the documentation and the examples you can classes named "Helpers" http://www.nsnam.org/docs/manual/html/helpers.html
These classes can 'help' do things without requiring loops.
 
Tracing generates individual pcap file for all 150 nodes but it doesn't look useful to me.


Perhaps you do not need PCAP or ASCII tracing. Look at other types of output. For example from FlowMonitor or Statistics modules.

Urvik Upadhyay

unread,
Mar 17, 2014, 11:48:54 PM3/17/14
to ns-3-...@googlegroups.com
Extremely sorry I forgot to attach the file. Here it is.



--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/LfjbgCWxNV8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

wifi-simple-adhoc.cc

Housin Eng

unread,
May 11, 2014, 8:42:36 AM5/11/14
to ns-3-...@googlegroups.com
Hello

please, how can i export the generated file ns2activity ns2mobility ns2config to NS2

Islam Zakaria

unread,
Jan 22, 2016, 5:16:55 PM1/22/16
to ns-3-users
Hello

I have the same question and I need the answer.

thanks

Tommaso Pecorella

unread,
Jan 22, 2016, 6:02:57 PM1/22/16
to ns-3-users
Hi,

we all need an answer. What's different for everyone os the question.

For me, most of the time, the question is: why should I spend my time in googling stuff for other people ? What am I trying to demonstrate ? That I'm smarter than them at using a tool ? That's not being smart, it's just being able to find stuff by myself.

I could give you the google link, but I'd rather not. This is a group to help ns-3 users, not to help people at using a search engine, sorry.

If you want to ask something related to ns-3, you'll be welcome. As an example, you could have asked if ns2activity and ns2config are used at all in ns-3, but you didn't (and perhaps that's why the original question didn't get an answer).


T.
Reply all
Reply to author
Forward
0 new messages