The DDSI specification gained something called a “domain tag” not so very long ago, and that’s basically an extension of the domain id: it is an octet sequence that must match for participants to communicate with each other but it doesn’t affect the port numbers.
If you run all systems on domain id 0 but with a different domain tags for each system, the participant discovery messages will go everywhere, but those from different systems will be ignored. That means no discovery of the readers/writers, and that in turn means any data that happens to arrive is also dropped because the writer is unknown.
You can also combine them of course.
Minor remark: 232 is the maximum domain ID based on the default port numbering scheme in the DDSI specification.
Correct, for example, Cyclone DDS is happy to let you use any domain id in [0,2**32-2] as long as the port mapping yields valid port numbers. At the same time the domain tag was introduced, the domain id was also added to the discovery data. That means it is now safe to set have different domains use the same port number. In its most extreme form, you can just set the “domain gain” to 0 and make all domains use the default port.
In other words, domain id and tag prevent cross-communication, different port numbers and different multicast addresses reduce unnecessary network traffic.
I know some of these can’t be set via ROS 2, but there’s no reason some of this can’t be added to it once there is consensus on the interface. Until then, at least with Cyclone DDS, you can set it using the CYCLONEDDS_URI environment variable, e.g.,
<Tag>Jantje zag eens pruimen hangen, O! als eieren zo groot</>
It might be interesting to experiment with this a bit.
(And yes, it’d probably be better to make a proper configuration file rather than using abbreviated XML in an environment variable … )