Skip to content

Reuse the profile's transports with the LOCALHOST discovery range - #985

Open
fujitatomoya wants to merge 1 commit into
rollingfrom
fujitatomoya/localhost-reuse-profile-transports
Open

fujitatomoya wants to merge 1 commit into
rollingfrom
fujitatomoya/localhost-reuse-profile-transports

Conversation

@fujitatomoya

Copy link
Copy Markdown
Collaborator

Description

With ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST, rmw_fastrtps always appended a shared memory transport and a UDPv4 transport with maxInitialPeersRange = 32, without looking at the transports the default XML profile had already put in the participant QoS. The UDPv4 descriptor was created in code after the profile was loaded, so the profile could not change it. The only way to discover more than 32 participants on a host was to register a second UDPv4 transport from the profile.

This change keeps the UDPv4 and shared memory transports that are already in the default participant QoS, and only adds the ones that are missing:

  • A UDPv4 transport from the profile is used as it is, so a maxInitialPeersRange larger than 32 takes effect with a single transport.
  • A maxInitialPeersRange lower than 32 is raised to 32. Fast DDS defaults to 4, and a profile cannot say whether 4 was chosen or left at the default, so without this floor every profile with a plain UDPv4 transport would drop from 32 to 4 participants. The value is changed on a copy, because the descriptor object is shared with the loaded profiles and with other participants in the process.
  • A shared memory transport from the profile is used as it is. It had the same problem: a profile with a SHM transport ended up with two of them, and each one creates its own segment.
  • With no user transports in the profile, the result is the same as before: one SHM transport and one UDPv4 transport with 32.

The README gets a short section on the 32-participant limit and how to raise it.

Fixes #984

Is this user-facing behavior change?

Yes, only with ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST and a default XML profile that has a UDPv4 or SHM transport in userTransports (or uses builtinTransports modes such as LARGE_DATA, which fill userTransports when the XML is parsed).

  • The participant gets one UDPv4 transport and one SHM transport, not two of each.
  • maxInitialPeersRange in the profile can raise the number of participants discovered on a host above 32.

Nothing changes for the other discovery ranges, or without user transports in the profile.

Did you use Generative AI?

Yes, Claude Fable 5.2 (Claude Code). The change, the tests and this description were generated, and verified as described below.

Additional Information

Why the second transport was a problem. In Fast DDS every registered transport expands the initial peers (NetworkFactory::configureInitialPeerLocator) and opens its own output channel (UDPTransportInterface::OpenOutputChannel), so with two UDPv4 transports every unicast datagram is sent twice.

Measurements (Fast DDS 3.6.3, one talker and one listener, UDP datagrams on lo to the RTPS ports of the domain over 30 s, two runs each):

Profile rolling this PR
none 660 / 660 660 / 660
UDPv4 with maxInitialPeersRange 64 (the workaround in #984) 2533 / 2491 1282 / 1300

With the 64-peer profile the talker has one socket fewer (11 to 10), and with a profile that also has a SHM transport the two processes create 2 SHM segments, down from 4.

Reproducer from #984 (20 talker/listener pairs, 40 participants):

Profile Listeners that never received
none listener_16 to listener_19 (same as rolling, the default stays 32)
UDPv4 with maxInitialPeersRange 64 none
SHM + UDPv4 with 64, useBuiltinTransports false none
UDPv4 without maxInitialPeersRange listener_16 to listener_19 (raised from 4 to 32); none with 14 pairs

Tests. test_localhost_transports creates participants on top of a default participant QoS with user transports and checks the transports of the resulting participant. Three of the five tests fail on rolling. colcon test --packages-select rmw_fastrtps_cpp: 558 tests, 0 failures.

Points for review

  • The floor of 32 means a profile cannot lower the range below 32. That keeps today's behavior, where the transport added in code always provided 32.
  • A UDPv4 transport with an interfaceWhiteList is reused like any other. I checked that this is not a behavior change: with a whitelist that only has a non-loopback address, discovery with the LOCALHOST range fails on rolling as well, and with 127.0.0.1 it works on both.
  • A SHM transport is still added when the profile has none, including profiles that leave it out on purpose (useBuiltinTransports false with only UDPv4). That is the existing behavior and is not changed here.
  • The commit has Signed-off-by twice by mistake. It can be dropped in the squash message.

🤖 Generated with Claude Code

With ROS_AUTOMATIC_DISCOVERY_RANGE=LOCALHOST, a shared memory transport
and a UDPv4 transport with maxInitialPeersRange = 32 were always added,
even when the default XML profile already had transports of those kinds.
The UDPv4 descriptor created in code could not be reached from the
profile, so the only way to discover more than 32 participants on a host
was to register a second UDPv4 transport, which sends every unicast
datagram twice.

Keep the UDPv4 and shared memory transports that are already in the
default participant QoS, and only add the missing ones. A UDPv4
transport with a maxInitialPeersRange lower than 32 is raised to 32 on a
copy of the descriptor, as it is shared with the loaded profiles. The
behavior without user transports in the profile does not change.

Fixes #984

Signed-off-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Signed-off-by: Tomoya Fujita <fujita.tomoya@triorb.co.jp>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant