Skip to content

Proposal: RTPS Port Configuration

Fred Hornsey edited this page May 14, 2024 · 10 revisions

Problem

Users would like to control the ports used by OpenDDS to make firewall configuration easier.

Analysis

This analysis assumes that multicast is used for SEDP and the transport.

The local port for SPDP can be set using the SpdpLocalAddress configuration value, e.g., SpdpLocalAddress=9876 causes it to use port 9876. Otherwise, the port is determined using the formula PB + DB * domainId + D1 + PG * participantId. More specifically, OpenDDS attempts to open the computed port for increasing values of participantId until an open port is found.

Likewise, the local port for SEDP can be set using the SedpLocalAddress configuration value. Otherwise, the SEDP port is assigned by the OS.

The local port for the transport can be set using the local_address configuration, e.g., local_address=7654 causes it to use port 7654. Otherwise, the port is assigned by the OS.

Setting the ports this way would require that each participant have an [rtps_discovery] section and a rtps_udp [transport] section.

The port for the SPDP multicast address cannot be set explicitly. However, it can be manipulated through the PB, DG, and D0 configuration values. The formula for the port is PB + DG * domainId + D0. The multicast address can be set explicitly using InteropMulticastOverride.

The port for the SEDP multicast address cannot be set explicitly. However, it can be manipulated through the PB, DG, and DX configuration values. The formula for the port is PB + DG * domainId + DX. The multicast address can be set explicitly using InteropMulticastOverride, i.e., the address part for SEDP will be the same as SPDP.

The multicast address and port for a transport can be set using multicast_group_address.

The multicast addresses are configurable through the configuration templating/customization mechanism.

While not entirely deterministic, the local port used for SPDP is predictable and already compatible with the templating mechanism.

Proposal

Since the multicast addresses are configurable and SPDP ports are predictable, the main effort will be making the local SEDP and transport ports configurable.

For the local SEDP port, we propose adding a new configuration variable SedpPortMode=[system|sequential|probe]. SedpLocalAddress would take precedence if set. The modes are as follows:

  • system - Use a system assigned port (default).

  • sequential - Attempt to use SPDP port + 1.

  • probe - Probe for an open port using a formula similar to the one used for SPDP: PB + DG * domainId + DY + PG * participantId where the default value of DY is 11. Assuming default values, this would cause the same behavior as sequential. All of the modes work with the templating mechanism.

For the local transport port, we propose adding a new configuration variable PortMode=[system|probe]. local_address would take precedence if set. The modes are as follows:

  • system - Use a system port (default).
  • probe - Probe for an open port using a formula similar to the one used for SPDP: PB + DG * domainId + DZ + PG * transportId. All of the modes work with the templating mechanism.

Example

This example uses probe to allocate ports in blocks.

[rtps_discovery/mydiscovery]
SedpPortMode=probe
PB=7400
DG=250
PG=3
D1=10
DY=11

[transport_template/myrtps]
transport_type=rtps_udp
PortMode=probe
PB=7400
DG=250
PG=3
DZ=12

Recall that the formulas for local port assignment are

  • SPDP port = PB + DB * domainId + D1 + PG * participantId
  • SEDP port = PB + DB * domainId + DY + PG * participantId
  • DATA port = PB + DB * domainId + DZ + PG * participantId
Domain Participant SPDP port SEDP port DATA port
0 0 7410 7411 7412
0 1 7413 7414 7415
... ... ... ... ...
0 82 7656 7657 7658
1 0 7660 7661 7662
1 1 7663 7664 7665