16.3.4 Choosing a Domain ID and Creating Multiple DDS Domains

A domain ID identifies the DDS domain in which the DomainParticipant is communicating. DomainParticipants with the same domain ID are on the same communication “channel” (or “databus”). DomainParticipants with different domain IDs are completely isolated from each other.

The domain ID is a purely arbitrary value; you can use any integer 0 or higher, provided it does not violate the guidelines for the DDS_RtpsWellKnownPorts_t structure (44.10.2 Ports Used for Discovery). Domain IDs are typically between 0 and 232. Please see the API Reference HTML documentation for the DDS_RtpsWellKnownPorts_t structure and in particular, DDS_INTEROPERABLE_RTPS_WELL_KNOWN_PORTS.

Note: On Windows, you should avoid using ports 49152 through 65535 for inbound traffic. Connext’s ephemeral ports (see Chapter 23 Ports Used for Discovery) may be within that range (see https://msdn.microsoft.com/en-us/library/windows/desktop/ms737550(v=vs.85).aspx). With the default RtpsWellKnownPorts settings, port 49152 corresponds to domain ID 167, so using domain IDs 168 through 232 on Windows introduces the risk of a port collision and failure to create the DomainParticipant when using multicast discovery. You may see this error:

RTIOsapiSocket_bindWithIP:OS bind() failure, error 0X271D: An attempt was made to access a socket in a way forbidden by its access permissions.

Most distributed systems can use a single DDS domain for all of its applications. Thus a single domain ID is sufficient. Some systems may need to logically partition nodes to prevent them from communicating with each other directly, and thus will need to use multiple DDS domains. However, even in systems that only use a single DDS domain, during the testing and development phases, one may want to assign different users/testers different domain IDs for running their applications so that their tests do not interfere with each other.

To run multiple applications on the same node with the same domain ID, Connext uses a participant ID to distinguish between the different DomainParticipants in the different applications. The participant ID is simply an integer value that must be unique across all DomainParticipants created on the same node that use the same domain ID. The participant_idis part of the 44.10 WIRE_PROTOCOL QosPolicy (DDS Extension).

Although usually those DomainParticipants have been created in different applications, the same application can also create multiple DomainParticipants with the same domain ID. For optimal results, the participant_id should be assigned sequentially to the different DomainParticipants, starting from the default value of 0.

Once you have a DomainParticipant, you can retrieve its domain ID with the get_domain_id() operation.

The domain ID and participant ID are mapped to port numbers that are used by transports for discovery traffic. For information on how port numbers are calculated, see Chapter 23 Ports Used for Discovery. How DomainParticipants discover each other is discussed in Chapter 22 Discovery Overview.