Robotics StackExchange | Archived questions

Not able to see tcp packet related with specific ros node in Wireshark.

I am trying to capture packet that is published by ros node in wireshark. As an example, when I do rostopic info /mytopic, output is

Type: geometry_msgs/Twist

Publishers:

So, in the wireshark, when I use filter tcp.port == 60176 , I should see tcp packets related with messages being published on /mytopic, but nothing appears in the wireshark after applying that filter. Does anyone have any idea, what I am doing wrong?

Edit: Just to clarify, a robot model is continuously publishing its position and velocity information over some topic. So I should be able to see related packets in the wireshark, but I don't know how to do that! Thanks.

Asked by cybodroid on 2016-03-20 04:28:59 UTC

Comments

ROS is using TCP (http://wiki.ros.org/ROS/Technical%20Overview) so a package can only appear if you have both subscriber and publisher. So if you run "rostopic echo /mytopic" in another terminal, the package should be shown in wireshark.

Asked by DavidN on 2016-03-20 05:22:38 UTC

I guess the same concept would apply for ROS services

Asked by DavidN on 2016-03-20 05:23:06 UTC

@DavidN, nope. It didn't work. I tried doing rostopic echo /mytopic in one terminal and in another terminal I checked for port number by executing rostopic info /mytopic and then I applied the filter to the wireshark. Still I can't see anything.

Asked by cybodroid on 2016-03-20 06:03:53 UTC

I'm assuming this is on a Linux machine, and I'm also assuming you are using only a single machine.

That means that all ROS traffic will go through the tcp loopback device (lo on Linux), so you'll have to make sure you're capturing on that (and not, fi, eth0).

Asked by gvdhoorn on 2016-03-20 06:12:47 UTC

Yes, your assumptions are correct. I am using Ubuntu 14.04 and everything is on single machine. Nevertheless, I am capturing on lo and not on any other interface. Actually I also tried capturing on all the interfaces. But this doesn't work.

Asked by cybodroid on 2016-03-20 06:38:55 UTC

I may try running ROS node on different machine and then try to capture next day. But you see, if my robot is publishing position and velocity information continuously then I should see flood of ros tcp messages in wireshark which is not happening.

Asked by cybodroid on 2016-03-20 06:40:22 UTC

Ok. This is getting more and more interesting (at least for me). After digging and trying for hours, this is what I found:

  1. A ROS node once being started will use 2 ports. Proof: start any node and run the command ss -lp | grep node_name, you will see 2 ports being opened by this node

(cont)

Asked by DavidN on 2016-03-20 11:09:18 UTC

(cont.) 2. When you publish the topic /my_topic, a new node is launched (named rostopic_xxxx) and this node will open 2 ports. In order to see the package from wireshark, you need to try to filter each of the port to see if the package is there.

Asked by DavidN on 2016-03-20 11:14:11 UTC

Btw, not ROS-related, but if you want to know more about the difference of port vs socket, check this out http://stackoverflow.com/questions/152457/what-is-the-difference-between-a-port-and-a-socket

Asked by DavidN on 2016-03-20 11:17:57 UTC

Irrespective of the filter, wireshark doesn't show any packet related with messages being published over topics. I think @ahendrix has written an answer below that it worth looking. Thanks.

Asked by cybodroid on 2016-03-20 16:38:17 UTC

@rahul, there was a mistake in the command in my previous comment. The correct command is ss -t -a -p | grep ros. I have uploaded my screenshot for your preference. Wireshark is showing the packages as expected. http://tinypic.com/r/wldbux/9

Asked by DavidN on 2016-03-20 21:48:48 UTC

Answers

For background on how ROS sets up topics, watch: https://vimeo.com/67806888 and read the slides

The port number listed is the XMLRPC endpoint of the node; not the port number used for the actual topic connection. So you should expect to see some activity on that port during initial topic setup (IE when the subscriber is negotiating the transport), but you won't see topic data sent over that port.

I'm not aware of a way to retrieve the TCP port for a topic directly, but you should be able to find it by either inspecting the topic negotiation packets, or by using the XMLRPC client to contact the node and request the topic information.

There are a few more wrinkles to be aware of if you really want to go down this path:

  • TCP is not broadcast; it is point-to-point. If there are no subscribers to a topic, you will not see any transmitted data. Conversely, if there are multiple subscribers connected, you will see one packet transmitted to each subscriber.
  • roscpp appears to use the same TCP listening port for all topics, which means that if you capture all of the data on this port, you'll see contents of all of the topics that node is publishing, which also have at least subscriber.

Asked by ahendrix on 2016-03-20 16:16:20 UTC

Comments

Thanks for your valuable input. So if I subscribe to the the topic being published, I am in a way creating a point to point connection, right? Then in that case, I should see some tcp packets in the wireshark !! But it doesn't show. Tell me where I am wrong!

Asked by cybodroid on 2016-03-20 17:18:57 UTC

The topic data is carried over a different TCP port than the one listed in rosnode info or rostopic info.

Asked by ahendrix on 2016-03-20 17:24:03 UTC

Hi. Now this time I was running the ROSMASTER on different machine and I ros echoed topics on another machine. In that machine I can see the TCP packets but as pointed out by you, they are on different port. The port that is displayed in rosnode info command is in HTTP/XML packet not TCP packet.

Asked by cybodroid on 2016-03-20 18:32:48 UTC

How will I know that on which port TCP packet comes? Or is it just random?

Asked by cybodroid on 2016-03-20 18:33:07 UTC

I'm not aware of a way to retrieve the TCP port for a topic directly, but you should be able to find it by either inspecting the topic negotiation packets, or by using the XMLRPC client to contact the node and request the topic information.

Asked by ahendrix on 2016-03-20 20:32:15 UTC