Python script for parsing Trace files and showing node movement

344 views
Skip to first unread message

Simon Hook

unread,
Mar 6, 2014, 8:48:21 AM3/6/14
to castalia-...@googlegroups.com
Hey Guys,

I wrote a little python script to visualize the movement of nodes in the network. This can be used to check if your MobilityManager works as intended and if you set everything up correctly in the omnetpp.ini file. It's VERY basic and probably prone to a lot of erros, so proceed at your own risk ;)
I used python 2.7 and the latest version of pygame. Put the script in your castalia folder and run it with:
python visualize_castalia.py Simulations/radioTest
to show the movements of the radioTest simulation. Make sure you have actually run the simulation before, or else the script can't find the Castalia-Trace.txt file. Hitting Escape will stop the Simulation. 

I'm not sure if I'll put more work into this, because it could already be enough for my purpose and it's not really the focus of my work. Gotta check what my advisor says to it. If you extend it, please share the modifications so other people can also use them.

I also found this comment in the group here and Rachids tool looks way better than my script, so keep an eye out for that! Anyway, here's a screenshot and here is the script.

Best wishes

Simon

Simon Hook

unread,
Mar 6, 2014, 8:56:12 AM3/6/14
to castalia-...@googlegroups.com
I forgot to mention that, make you sure to uncomment
SN.node[*].MobilityManager.collectTraceInfo = true
in the omnetpp.ini file before running the simulation, or there won't be any data about the movement to parse!

José Miguel Catela

unread,
Mar 6, 2014, 9:17:15 AM3/6/14
to castalia-...@googlegroups.com
Hi Simon,

Thank you very much for the script, it works like a charm. If nothing else, it will be very useful to debug my configurations and check if the mobility is as expected.

If you decide to put more work into it, I have some ideas for you: identify the node numbers, color them randomly, draw the grid, show the simulation time, ....

Best regards


--
You received this message because you are subscribed to the Google Groups "Castalia Simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castalia-simula...@googlegroups.com.
To post to this group, send email to castalia-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/castalia-simulator/b6829be1-169f-4db2-a3f0-6cd7191fe49b%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
José Miguel Catela

José Miguel Catela

unread,
Mar 6, 2014, 9:18:29 AM3/6/14
to castalia-...@googlegroups.com
Also: don't forget to erase the Castalia-Trace.txt after each simulation. Do you have any idea how the script behaves for multiple runs?


2014-03-06 13:56 GMT+00:00 Simon Hook <hook....@googlemail.com>:

--
You received this message because you are subscribed to the Google Groups "Castalia Simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castalia-simula...@googlegroups.com.
To post to this group, send email to castalia-...@googlegroups.com.



--
José Miguel Catela

Simon Hook

unread,
Mar 6, 2014, 10:13:45 AM3/6/14
to castalia-...@googlegroups.com
Glad you like it! And thanks for the suggestions. I also have some in mind, like pausing/speed control, text field which shows the previous and current line of the trace file, showing messages being sent/received.. But well, unless my advisor wants me to I probably won't put much effort into it.

Deleting the trace file is very important, thanks for mentioning that. Right now the script adds a new node if it parses a line with "initial position" in it, so having multiple runs in one file should show the first run correct, then add all the nodes from the second run and then move the nodes from the first run, while those from later runs just stay in place.
 

On Thursday, March 6, 2014 3:18:29 PM UTC+1, José Catela wrote:
Also: don't forget to erase the Castalia-Trace.txt after each simulation. Do you have any idea how the script behaves for multiple runs?


2014-03-06 13:56 GMT+00:00 Simon Hook <hook....@googlemail.com>:
I forgot to mention that, make you sure to uncomment
SN.node[*].MobilityManager.collectTraceInfo = true
in the omnetpp.ini file before running the simulation, or there won't be any data about the movement to parse!


On Thursday, March 6, 2014 2:48:21 PM UTC+1, Simon Hook wrote:
Hey Guys,

I wrote a little python script to visualize the movement of nodes in the network. This can be used to check if your MobilityManager works as intended and if you set everything up correctly in the omnetpp.ini file. It's VERY basic and probably prone to a lot of erros, so proceed at your own risk ;)
I used python 2.7 and the latest version of pygame. Put the script in your castalia folder and run it with:
python visualize_castalia.py Simulations/radioTest
to show the movements of the radioTest simulation. Make sure you have actually run the simulation before, or else the script can't find the Castalia-Trace.txt file. Hitting Escape will stop the Simulation. 

I'm not sure if I'll put more work into this, because it could already be enough for my purpose and it's not really the focus of my work. Gotta check what my advisor says to it. If you extend it, please share the modifications so other people can also use them.

I also found this comment in the group here and Rachids tool looks way better than my script, so keep an eye out for that! Anyway, here's a screenshot and here is the script.

Best wishes

Simon

--
José Miguel Catela

José Miguel Catela

unread,
Mar 6, 2014, 10:23:05 AM3/6/14
to castalia-...@googlegroups.com
I don't have great experience with python but I can try to give you a hand in that. I believe much of the users of this list can profit from it.

Would you mind uploading it to some version control system (i.e. github) together with a to-do list so it can be improved by whoever wants to do it?


--
You received this message because you are subscribed to the Google Groups "Castalia Simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castalia-simula...@googlegroups.com.
To post to this group, send email to castalia-...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
José Miguel Catela
Message has been deleted

Simon Hook

unread,
Mar 6, 2014, 11:56:46 AM3/6/14
to castalia-...@googlegroups.com
Okay, I made a github repro here. The readme file has a description and a todo list in it. 

José Miguel Catela

unread,
Mar 6, 2014, 12:11:25 PM3/6/14
to castalia-...@googlegroups.com
Excellent! I'll refresh my python knowledge and start contributing to it.

Thank you once again.


2014-03-06 16:56 GMT+00:00 Simon Hook <hook....@googlemail.com>:
Okay, I made a github repro here. The readme file has a description and a todo list in it. 

--
You received this message because you are subscribed to the Google Groups "Castalia Simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castalia-simula...@googlegroups.com.
To post to this group, send email to castalia-...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
José Miguel Catela

Simon Hook

unread,
Mar 6, 2014, 2:06:51 PM3/6/14
to castalia-...@googlegroups.com
Your are very welcome. I just added another bug to the issues in github. Maybe I'll do some cleaning up, documentation and bugfixing on the weekend, so it's easier to understand.

If you got any questions about the code, feel free to shoot me a msg/mail!

On Thursday, March 6, 2014 6:11:25 PM UTC+1, José Catela wrote:
Excellent! I'll refresh my python knowledge and start contributing to it.

Thank you once again.
2014-03-06 16:56 GMT+00:00 Simon Hook <hook....@googlemail.com>:
Okay, I made a github repro here. The readme file has a description and a todo list in it. 

--
You received this message because you are subscribed to the Google Groups "Castalia Simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to castalia-simulator+unsub...@googlegroups.com.

To post to this group, send email to castalia-...@googlegroups.com.



--
José Miguel Catela

Thanassis Boulis

unread,
Mar 6, 2014, 8:27:31 PM3/6/14
to Castalia Simulator
Thank you Simon for your useful contribution and thanks Jose for your offer to help develop it further.
It would be good to consolidate efforts and have a tool that's past the prototype phase. I will happily include that tool into the main castalia distribution (keeping the copyright and license to the ones you desire of course). I'll try to contact Rachids to gauge what their plans are.

Bennani Taj

unread,
Feb 10, 2015, 8:19:38 PM2/10/15
to castalia-...@googlegroups.com


Hi i tried this script and i got this error

from: can't read /var/mail/pygame.locals
./visualize_castalia.py: line 28: syntax error near unexpected token `fpsClock'
./visualize_castalia.py: line 28: `fpsClock = pygame.time.Clock()'
Best regards
Reply all
Reply to author
Forward
0 new messages