Ask Your Question
0

[ROS2] What does the "discovery multicast port" do?

asked 2019-06-27 23:21:34 -0600

wan_da gravatar image

According to this, RTI Connext in ROS2 uses four ports for UDP transport. Each port has its own purpose: discovery multicast, user multicast, discovery unicast, and user unicast. As far as I could tell, the other DDS implementations use roughly the same ports for the same purposes.

What I want to know is what these mean in the context of ROS2? Like:

  1. What does the discovery multicast port do? My impression from its name is that it serves as a socket for all the ros2_daemon to listen for all the nodes and take in any new nodes.
  2. I have no idea what the user multicast port does, because it doesn't show up when I use lsof -iUDP or ss -uap. Apparently 7401 is the port number reserved for this function but no process is using this port on my machine.
  3. I also do not know what the user unicast and discovery unicast ports do. I used WireShark to examine the UDP/RTPS traffic in my ROS2 communication graph. Apparently sometimes these ports receive packets from ephemeral ports from other nodes, at other times they do not send or receive any packets at all. So I do not understand what purpose these ports serve.
  4. On the use of WireShark, I also do not understand my findings when investigating the traffic going to the discovery multicast port. image description

The large numbers are ephemeral ports from the rest of the nodes in the computational graph, like rqt_gui_py_node, _ros2cli_daemon_0 among other nodes that I created myself. However, they are all sending DATA and INFO_TS to port 7400. I feel that if the discovery multicast node is for discovering new nodes and keeping track of existing ones, they should be sending messages like ACKNACK or HEARTBEAT, according to the legend here.

May I have a simple explanation of what each ports do. or perhaps a link to more documentation? Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-27 23:47:42 -0600

Geoff gravatar image

For the gory details of the ports used by DDS, you can look at section 9.6 of the RTPS specification. RTPS (Real Time Publish Subscribe) is the wire protocol used by DDS.

Discovery traffic is traffic sent between DDS domain participants (in the case of ROS 2, a node) to find each other. It is sent out by one participant when it starts and potentially periodically after that to announce their existence and to find other participants. The ideal way to do this is by doing a UDP multicast, which sends the message to everyone on the same subnet. DDS participants listen on the discovery multicast port for broadcasts by other participants so they know where each other lives. However, because UDP multicast is not always available, unicast is also possible. In unicast the originating host sends the packet directly to the target IP.

User traffic is traffic that is not discovery. In other words, it is the data being sent on your topics, the service calls being made, etc., as well as internal DDS traffic such as looking for topics to connect. It can be sent by multicast because this is quite efficient when sending to multiple destinations (things like switches can handle the packet duplication instead of the originating host having to send out multiple packets itself). Like discovery traffic, it can also be sent via unicast.

All this stuff is happening on UDP, which is why you don't see explicit connections. You will not see these ports sending data because they are for listening on. Which ports are used to send are chosen by the OS, hence you seeing ephemeral ports sending data to them.

On to some specific questions:

I have no idea what the user multicast port does, because it doesn't show up when I use lsof -iUDP or ss -uap. Apparently 7401 is the port number reserved for this function but no process is using this port on my machine.

It won't necessarily be port 7401. As the page you linked to shows, it will be a port number calculated by the formula 7400 + (250 * Domain) + 1. The actual port number may change if your domain ID changes. See what ROS_DOMAIN_ID is set to to get an idea of what it will be.

I feel that if the discovery multicast node is for discovering new nodes and keeping track of existing ones, they should be sending messages like ACKNACK or HEARTBEAT, according to the legend here.

Discovery traffic won't include ACKNACK or HEARTBEAT messages. Those belong to user traffic.

edit flag offensive delete link more

Comments

Thank you.

I understand that the user multicast port is not necessarily 7401, but my domain ID is definitely 0 at the time. I still don't know why it doesn't appear, but I guess it's not really important since most of my nodes communicate via the user unicast port anyway.

However there's still one thing that I'm not clear on. For a topic without subscribers but at least one publisher, will there be a port that is listening for messages in this topic? Because from what I see, the publisher's ephemeral port will send messages to the subscriber's user unicast port, but if I remove the subscriber, then there will be no more traffic observed from the ephemeral port except to the discovery multicast port of 7400 (using Wireshark). So where do the messages go?

wan_da gravatar imagewan_da ( 2019-06-28 03:31:50 -0600 )edit

Just an observation: I guess we could expect these sort of questions with the use / almost standardisation on DDS of ROS 2, but I'm not really sure we should be happy with questions about the inner workings of DDS on ROS Answers.

This is not directed at you @wan_da, nor at @Geoff.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-28 06:29:58 -0600 )edit

Thank you for pointing out the problem of relevance with regard to 'inner-workings-type' questions. I understand that ROS Answers is more for ROS- or ROS2-related questions. I will take note of the relevance of my questions next time.

wan_da gravatar imagewan_da ( 2019-06-28 10:08:22 -0600 )edit

@wan_da: no, that is not what I meant. Your question is completely relevant.

It's just that personally I expect ROS Answers to turn into a DDS debugging/support helpdesk. But we'll see how that turns out.

Please keep posting your questions here.

gvdhoorn gravatar imagegvdhoorn ( 2019-06-28 10:10:37 -0600 )edit

For a topic without subscribers but at least one publisher, will there be a port that is listening for messages in this topic?

No, because there are no subscribers. Note that I am assuming you also have no infrastructure-type subscribers, such as rosbag or any of the RTI-provided DDS introspection tools.

So where do the messages go?

Nowhere. They don't get sent. When you call publish, if there are no subscribers then nothing is done so as to avoid wasting time and resources on sending data that no one is interested in.

Geoff gravatar imageGeoff ( 2019-06-30 18:18:16 -0600 )edit

Thank you to both.

wan_da gravatar imagewan_da ( 2019-06-30 20:17:09 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-06-27 23:21:34 -0600

Seen: 130 times

Last updated: Jun 27