3. Transport protocol configuration

3.1. UDP settings

The XML basically mimics the UDP attribute C++ source code:

 1<?xml version="1.0" encoding="utf-8"?>
 2<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" >
 3  
 4  <servers>
 5    <server name="server" profile_name="UDP server" />
 6  </servers>
 7  
 8  <profiles>
 9    
10    <participant profile_name="UDP server">
11      <rtps>
12        <prefix>
13          4D.49.47.55.45.4c.5f.42.41.52.52.4f
14        </prefix>
15        <builtin>
16            <discovery_config>
17                <discoveryProtocol>SERVER</discoveryProtocol>
18                <leaseDuration>
19                    <sec>DURATION_INFINITY</sec>
20                </leaseDuration>
21            </discovery_config>
22            <metatrafficUnicastLocatorList>
23            <locator>
24                <udpv4>
25                <!-- UDP address placeholder -->
26                <address>192.168.1.113</address>
27                <port>64863</port>
28                </udpv4>
29            </locator>
30            </metatrafficUnicastLocatorList>
31        </builtin>        
32      </rtps>
33    </participant>
34    
35  </profiles>
36  
37</DS>
  • Server prefix is specified.

  • Discovery kind set to SERVER.

  • Metatraffic locators set to the UDP listening port.

Note

leaseDuration is set to INFINITY in order to mimic the HelloWorldExample participants but can be whatever value without affecting the discovery operation.

3.2. TCP settings

The XML basically mimics the TCP attribute C++ source code:

 1<?xml version="1.0" encoding="utf-8"?>
 2<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" >
 3  <servers>
 4    <server name="server" profile_name="TCP server" />
 5  </servers>
 6  
 7  <profiles>
 8      <transport_descriptors>
 9          <transport_descriptor>
10              <transport_id>TCPv4_SERVER</transport_id>
11              <type>TCPv4</type>
12              <listening_ports>
13                  <port>64863</port>
14              </listening_ports>
15          </transport_descriptor>
16      </transport_descriptors>
17
18    <participant profile_name="TCP server">
19      <rtps>
20        <prefix>4D.49.47.55.45.4c.5f.42.41.52.52.4f</prefix>
21        <userTransports>
22              <transport_id>TCPv4_SERVER</transport_id>
23        </userTransports>
24        <useBuiltinTransports>false</useBuiltinTransports>
25        <builtin>
26            <discovery_config>
27                <discoveryProtocol>SERVER</discoveryProtocol>
28                <leaseDuration>
29                    <sec>DURATION_INFINITY</sec>
30                </leaseDuration>
31            </discovery_config>
32            <metatrafficUnicastLocatorList>
33            <locator>
34                <tcpv4>
35                    <!-- if no address is provided the server would export all its public interfaces as address -->
36                    <!-- this is a logical port, the physical one is specify as listening port above -->
37                    <port>65215</port>
38                </tcpv4>
39            </locator>
40            </metatrafficUnicastLocatorList>
41        </builtin>
42      </rtps>
43    </participant>
44  </profiles>
45</DS>
  • A TCP transport descriptor is created specifying the physical listening port as 9843.

  • The above transport descriptor is added to the participant user transports.

  • Builtin transport is disabled to avoid UDP operation. This wouldn’t disturb TCP communication in any way and is specified merely to prove that the actual discovery traffic is not going through UDP.

  • Server prefix is specified

  • Discovery kind set to SERVER.

  • Metatraffic locators set to the logical listening port. The real TCP locator is provided in the transport this one is merely a port number that is linked with this particular server.

Note

leaseDuration is set to INFINITY in order to mimic the HelloWorldExample participants but can be whatever value without affecting the discovery operation.

3.3. UDP and TCP simultaneously

The XML config generates a server able to listen simultaneously on TCP or UDP ports. It mixes concepts from previous UDP and TCP config files:

 1<?xml version="1.0" encoding="utf-8"?>
 2<DS xmlns="http://www.eprosima.com/XMLSchemas/discovery-server" >
 3  
 4  <servers>
 5    <server name="tcp-udp server" profile_name="TCP-UDP server" />
 6  </servers>
 7  
 8  <profiles>
 9        <transport_descriptors>
10            <transport_descriptor>
11                <transport_id>TCPv4_SERVER</transport_id>
12                <type>TCPv4</type>
13                <listening_ports>
14                    <port>64863</port>
15                </listening_ports>
16            </transport_descriptor>
17        </transport_descriptors>
18
19        <participant profile_name="TCP-UDP server">
20            <rtps>
21            <prefix>
22                4D.49.47.55.45.4c.5f.42.41.52.52.4f
23            </prefix>
24            <userTransports>
25                    <transport_id>TCPv4_SERVER</transport_id>
26            </userTransports>
27            <useBuiltinTransports>true</useBuiltinTransports>
28            <builtin>
29                <discovery_config>
30                    <discoveryProtocol>SERVER</discoveryProtocol>
31                    <leaseDuration>
32                        <sec>DURATION_INFINITY</sec>
33                    </leaseDuration>
34                </discovery_config>
35                <metatrafficUnicastLocatorList>
36                    <locator>
37                        <tcpv4>
38                            <!-- Placeholder for server address -->
39                            <address>192.168.1.113</address>
40                            <!-- This is a logical port, the physical one was specified as listening port -->
41                            <port>65215</port>
42                        </tcpv4>
43                    </locator>
44                    <locator>
45                        <udpv4>
46                            <!-- Placeholder for server address -->
47                            <address>192.168.1.113</address>
48                            <port>64863</port>
49                        </udpv4>
50                    </locator>
51                </metatrafficUnicastLocatorList>
52            </builtin>
53            </rtps>
54        </participant>
55    
56  </profiles>
57  
58</DS>
  • A TCP transport descriptor is created specifying the physical listening port as 9843.

  • The above transport descriptor is added to the participant user transports.

  • Builtin transport is not disabled in order to allow UDP traffic.

  • Server prefix is specified

  • Discovery kind set to SERVER.

  • Metatraffic locators set to the logical TCP listening port and UDP actual IP address and listening port.

Using this last config XML file to generate a server allows, not only that participants with the same transport (either UDP or TCP) discover each other, but that all participants (disregarding selected transport) discover each other. A publisher in a TCP participant can match a subscriber in a TCP one (cannot exchange data due to the configuration of the HelloWorldExample Clients; only one transport is selected).