There may be cases where you need to know what ports the DDSi networking service uses. For example if you are using a firewall you will need to open these ports so communication can take place.
This article explains how you can work out these values.
In order for the participants in a domain to discover each other they need to exchange traffic between build-in end points. The specification defines what ports are used.
What ports does the DDSi networking service use?
In order for the participants in a domain to discover each other they need to exchange traffic between build-in end points. The DDSi networking service follows the OMG DDS interoperability Wire Protocol specification which defines which ports it should use.
In the default configuration the DDSi networking service uses the following ports:
- 2 multicast ports – these are common to all applications on the same domain. All Participants must announce and listen on this multicast address.
- 2 unicast ports – which are different for each participant
There are two ports for both, one for discovery and one for sending data. Multicast is used for the discovery of remote participants and to send a same message to a set of discovered participants. Unicast is used when a message is intended for 1 participant only.
There is also the option to configure the DDSI service to use a per-domain participant port instead of 2 unicast ports. This means you don’t have multiple port addresses for the unicast ports. It is turned off by default.
This is useful if you want to limit the number of ports the DDSi service is using. It also may be needed for compatibility with other DDS implementations.
How do you work out what port numbers the DDSI service will use?
The values for the ports are worked out using a formula which depends on the DDS domain ID and the number of participants that are already running on the same operating system instance.
The OMG DDS Interoperability Wire Protocol Specification (DDS-RTPS) defines a number of constants that to use in the formula. These values are:
- DG = DomainId Gain
- PG = ParticipantId Gain
- PB = Port Base number
- d0, d1, d2, d3 = additional offsets
These have the following default values:
- PB =7400
- DG = 250
- PG = 2
- d0 = 0
- d1 = 10
- d2 = 1
- d3 = 11
UDP port numbers are limited to 64K so these defaults will allow the use of 230 domains with up to 120 Participants per node per domain.
To calculate the values for the multicast ports
The values for the multicast ports are calculated as follows:
- DiscoveryMulticastPort = PB + DG * domainID + d0
- UserMulticastPort = PB + DG * domainID + d1
If you are using the default domainID of 0 and the default values for these ports then these values are:
- DiscoveryMulticastPort = 7400 + 250 * 0 + 0 = 7400
- UserMulticastPort = 7401+ 250 *0 + 1 = 7401
If you use domainID of 1 then the values are:
- DiscoveryMulticastPort = 7400 + 250 * 1 + 0 = 7650
- UserMulticastPort = 7401+ 250 *0 + 1 = 7651
To calculate the values for the unicast ports
By default the DDDSi service will allocate two unicast ports.
The values for the unicast ports are calculated using the following formula:
- DiscoveryUnicastPort = PB + DG * domainId + d1 + PG * participantId
- UserUnicastPort = PB + DG * domainId + d3 + PG * participantId
The values for domainId and participantID are used to prevent port conflicts among participants on the same node. Each participant on the same node and in the same domain must use a unique participant id. In the case of multicast, all Participants in the same domain share the same port number, so the participantID identifier is not used in the port number expression.
The value for the participantID is derived from the configuration. For this example we will assume it is set to the default value which is auto. The participantID is an integer which will start at 0 and get incremented each time. The first participant will have id 0, the next id 1 and so on.
If you are using the default domainID of 0 the default values for these ports would be:
- DiscoveryUnicastPort = 7400 + 250 * 0 + 2 * 0 =7410
- UserUnicastPort = 7400 + 250 * 0 + 11 * 0 = 7411
More information on changing the configuration for the ParticipantIndex value is given in the section below.
If you want to configure the DSSI service to use one unicast port per participant then you need to set the configuration property /OpenSplice/DDSI2Service/Compatibility/ManySocketsMode to true. In this case the DiscoveryMulticastPort is used for discovery and data communication will occur on the unicast ports.
The examples given show the default values for the ports. You can change this values in the OpenSpice configuration file.
Read more: OpenSplice configuration
DDSI service port configuration
The examples above use the default values for the constants that OMG use to define the values for working out the ports that the DDSI service uses. You can change each of these elements in the OpenSplice configuration file.
How do I change the domain id?
By default the domain id is set to 0. You may want to change this value if you want to run several DDS domains simultaneously. You can change this value in the following section of the xml file:
<Domain>
<Id>0</Id>
</Domain>
The value of Id is an integer. It is recommended to use values in the range 0 – 230 for maximum interoperability and to allow the DSSi service to derive values for the network communication endpoints.
Read more: Overview of DDS
Changing the domain id with the OpenSplice configuration tool
It is always advisable to use the OpenSplice configuration tool to modify the xml configuration as it will check the file for errors.
Start the OpenSplice configuration tool using the command osplconf in a console window which has been set up to run OpenSplice or using the launcher.
Choose File > Open from the menu and browse to choose the xml file you are using.
Go to the Domain tab and choose Domain.
In the right hand pane you will see the Id. You can click in value section to change the value.
Save the file.
How do I change the participant index
You can find the ParticipantIndex in the following section of the xml configuration file:
<DDSI2Service name=”ddsi2″>
<Discovery>
<ParticipantIndex>auto</ParticipantIndex>
</Discovery>
</DDSI2Service>
This is PI in the formula above.
The values are:
- auto
- none
The default value is auto.
When Participant index is auto a value is set automatically. It will probe UDP port numbers starting at number 0 going up by one each time until it finds a pair of available port numbers or hits the limit which is controlled by the MaxAutoParticipantIndex configuration value discussed below.
When the participant index is none then the kernel will allocate the port. Multicast discovery will work but unicast discovery is no longer possible.
Changing the Participant Index with the OpenSplice configuration tool
To change the participant index with the OpenSplice configuration tool start the configuration tool using opslconf from the command line or using the launcher.
Go to the DDSiService tag.
Right click DDSiService at the top and choose Add > Discovery
Discovery will appear in the list.
Right click Discovery and choose Add > ParticipantIndex. This will appear in the right hand pane and you can change the value by clicking in the value box.
Save the xml file using File > Save
MaxAutoParticipantIndex
When the ParticipantIndex is “auto” the MaxAutoParticipantIndex sets the maximum DDSI participant index that the DDSI2 service can select. By default value is 9.
You will find the MaxAutoParticipantIndex in the following section of the xml file:
<DDSI2Service name=”ddsi2″>
<Discovery>
<ParticipantIndex>auto</ParticipantIndex>
<MaxAutoParticipantIndex>9</MaxAutoParticipantIndex>
</Discovery>
</DDSI2Service>
It is not advisable to set this to a large value as it could cause the port numbers (calculated by the formula) to wrap around resulting in lots of discovery traffic.
To change the MaxAutoPartcipantIndex with the OpenSplice configuration tool
To change the participant index with the OpenSplice configuration tool start the configuration tool using opslconf from the command line or using the launcher.
Go to the DDSiService tag.
Right click DDSiService at the top and choose Add > Discovery
Discovery will appear in the list.
Right click Discovery and choose Add > MaxAutoParticipantIndex. This will appear in the right hand pane and you can change the value by clicking in the value box.
Save the xml file using File > Save
How do I change the default port values?
You will find the port configuration for the DDSi Service in the /OpenSplice/DDSI2Service/Discovery/Ports/ section of the OpenSplice configuration xml file. The default xml file does not contain these values as it uses the defaults.
Which configuration settings control the DDSI ports?
You can change the following settings in the /OpenSplice/DDSI2Service/Discovery/Ports/ section to modify the ports.
Base
This element specifies the base port number PB in the formulas to calculate ports above. This is an integer and takes values from 1 – 65535. By default the value is 7400.
DomainGain
The element specifies the domain gain which relates domain ids to sets of port numbers. It is DG in the formula to calculate ports above. It is an integer and the default value is 250.
ParticipantGain
This element specifies the participant gain which is PG in the formula to calculate ports above. It is an integer and the default value is 2
MulticastDataOffset
This element specifies the port number for multicast meta traffic and is d2 in the formula to calculate ports. It is an integer and the default value is 1.
MulticastMetaOffset
This element specifies the port number for multicast meta traffic and is d0 in the formula to calculate ports. It is an integer and the default value is 0.
UnicastDataOffset
This element specifies the port number for unicast meta traffic and is d3 in the formula to calculate ports. It is an integer and its default value is 11.
UnicastMetaOffset
This element specifies the port number for unicast meta traffic and is d1 in the formula to calculate ports. It is an integer and its default value is 10.
How to change the ports using the OpenSplice configuration tool
To add these values it is best to use the OpenSplice configuration tool. This will check the file for errors.
Read more: OpenSplice configuration tool
Start the OpenSplice configuration tool from a console window set up with OpenSplice configuration using the command: osplconf
Choose File > Open and browse to the xml file you are using.
Go to the DDSI2Service tab.
Right click on DDSI2Service and choose Add >Discovery. Discovery should appear at the bottom.
Right click on Discovery and choose Add >Ports. Ports will appear under Discovery.
Right click ports and you should be able to choose the ports you want to add. Choose one or more from Base, DomainGain, MulticastDataOffset, MulticastMetaOffset, ParticipantGane, UnicastDataOffset and UnicastMetaOffset. These should appear in the right hand pane and you can click to modify the value. You can find more details on each of these values below.
The xml file should now contain a section that looks like this:
<DDSI2Service name=”ddsi2″>
<Discovery>
<MaxAutoParticipantIndex>9</MaxAutoParticipantIndex>
<Ports>
<Base>7400</Base>
<DomainGain>250</DomainGain>
<MulticastDataOffset>1</MulticastDataOffset>
<MulticastMetaOffset>0</MulticastMetaOffset>
<ParticipantGain>2</ParticipantGain>
<UnicastDataOffset>11</UnicastDataOffset>
<UnicastMetaOffset>10</UnicastMetaOffset>
</Ports>
</Discovery>
</DDSI2Service>
Configuration settings
Base
This element specifies the base port number PB in the formulas to calculate ports above. This is an integer and takes values from 1 – 65535. By default the value is 7400.
DomainGain
The element specifies the domain gain which relates domain ids to sets of port numbers. This is DG in the formula to calculate ports above. It is an integer and the default value is 250.
ParticipantGain
This element specifies the participant gain which is PG in the formula to calculate ports above. It is an integer and the default value is 2
MulticastDataOffset
This element specifies the port number for multicast meta traffic and is d2 in the formula to calculate ports. It is an integer and the default value is 1.
MulticastMetaOffset
This element specifies the port number for multicast meta traffic and is d0 in the formula to calculate ports. It is an integer and the default value is 0.
UnicastDataOffset
This element specifies the port number for unicast meta traffic and is d3 in the formula to calculate ports. It is an integer and its default value is 11.
UnicastMetaOffset
This element specifies the port number for unicast meta traffic and is d1 in the formula to calculate ports. It is an integer and its default value is 10.
ManySocketsMode
Some DDSi implementations assume that each domain participant advertises a unique port number as part of the discovery protocol. If you enable the ManySocketsMode it allows each participant to get its own unicast port and OpenSplice will interoperate with these other DDSi services. The DDSI service will take care of discovery using the multicast port.
This value is disabled by default and all participants in the same domain will share the same socket.
You can set ManySocketsMode to true in the following section of the xml file:
<DDSI2Service name=”ddsi2″>
<Compatibility>
<ManySocketsMode>true</ManySocketsMode>
</Compatibility>
</DDSI2Service>
Setting ManySocketsMode with the OpenSplice configuration tool
Start the OpenSplice configuration tool from a console window set up with OpenSplice configuration using the command: osplconf
Choose File > Open and browse to the xml file you are using.
Go to the DDSI2Service tab.
Right click on Compatabiliy which is under DDSi service and choose Add >ManySocketsMode
It will appear in the right hand pane. Click value and change this to true.
Save the file using File > Save
Configuring DDSI for a firewall
To configure DDSi so you have known ports you open for a firewall you need to set ManySocketsMode to false and ParticipantIndex to auto. This will give you two multicast ports and two unicast ports which you can calculate using the formula above.