eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
799 stars 349 forks source link

[Question] Network communication: configuring multicast settings #1991

Closed a-sid closed 2 months ago

a-sid commented 2 months ago

Hi!

I've met a configuration (?) issue and don't know how to resolve it correctly. I have a publisher on a remote host (host_1) which publishes a topic. On another host (host_2), two subscriber processes are running (same binary started twice). Surprisingly, only a single subscriber receives messages from a publisher. After it is terminated, another one starts to receive messages. It looks like a multicast configuration issue but I don't know what's going wrong here.

I'm using CycloneDDS via ROS2 interfaces. My CYCLONEDDS_URI for all running processes is the following:

<CycloneDDS><Domain><Compatibility><ManySocketsMode>none</ManySocketsMode></Compatibility><General><AllowMulticast>true</AllowMulticast><NetworkInterfaceAddress>my_network_interface</NetworkInterfaceAddress></General></Domain></CycloneDDS>

So, multicast is enabled explicitly. Interface settings are correct - otherwise, the communication won't start at all. However, tcpdump shows that only a minor amount of packages on the chosen interface are actually multicast. Most packets are

host_2.hwstand-shekel.rtps-discovery > host_1.rtps-discovery

and back. Multicast packets

host_1.rtps-discovery > 239.255.0.1.rtps-discovery

are met rarely in the output, approximately every 8 seconds. These are service discovery packets, I guess.

So, is there something wrong with my configuration that I am missing?

Thanks for any help in advance!

a-sid commented 2 months ago

Self-answering this after some investigation. The fix for me was to use modern NetworkInterface setting and to configure multicast settings for the interface inside it:

<CycloneDDS><Domain><Compatibility><ManySocketsMode>none</ManySocketsMode></Compatibility><General><Interfaces><NetworkInterface name="my_interface" multicast="true" prefer_multicast="true"/></Interfaces></General></Domain></CycloneDDS>

While the setting itself is well-documented, it would be good to make an explicit recommendation not to use NetworkInterfaceAddress since it is still met across the Internet.