Using UDP for discovery and TCP for user data

RTI Connext DDS allows you to use different transports for communication between endpoints in your application (e.g., shared memory, UDP, TCP, etc.). You can take advantage of this flexibility and use different transports for discovery data and user data in the same application. 

This article shows how to use the UDPv4 transport for discovery and the TCPv4 transport for user data. This can be useful for use cases that require discovery to occur with minimum latency (UDP) and the exchange of user-data to occur with a protocol that enables flow control (TCP). There is a similar example like this for UDP and Shared Memory here .

This example illustrates how you can do this by just changing your QoS configuration via XML.

Step 1: Add the TCP transport library to your environment library path

Configure the Path so the system knows where to find the TCP library, libnddstransporttcp . This file is typically located under <NDDSHOME>/lib/<arch>/ .

You can do this by setting  the PATH/LD_LIBRARY_PATH/DYLD_LIBRARY_PATH  environment variable, depending on the platform Windows/Linux/Mac .

Step 2: Enable the UDPv4 transport for discovery

We explicitly enable the UDPv4 transport and set it to be used for discovery by adding the following snippet to the <participant_qos>  tag.

	
		
			UDPv4
		
		
			
				udpv4
			
		
	

Note that the name for UDP transport is “udpv4” in lowercase.

Step 3: Enable the TCPv4 transport

This example configures TCP in a LAN setting. To use it over WAN, just change the last part of the classid to WAN. Also note that we have set an alias to this transport, so it is easy to reference it in DataReaders and DataWriters.

	
		
			
				
					dds.transport.load_plugins
					dds.transport.TCPv4.tcp1
				
				
					dds.transport.TCPv4.tcp1.library
					nddstransporttcp
				
				
					dds.transport.TCPv4.tcp1.create_function
					NDDS_Transport_TCPv4_create
				
				
					dds.transport.TCPv4.tcp1.parent.classid
					NDDS_TRANSPORT_CLASSID_TCPV4_LAN
				
				
					dds.transport.TCPv4.tcp1.aliases
					DDS_TCPv4
				
			
		
	

Step 4: Bind the Publisher / Subscriber to a port

The following snippet in the <participant_qos>  tag will bind the participant to a specific port:

	
		
			
				
					dds.transport.TCPv4.tcp1.server_bind_port
					7401
				
			
		
	

Step 5: Select the TCP transport for DataReaders / DataWriters

Now we are ready to channel user data over TCP for a specific DataReader / DataWriter. You can add this snippet to select the previously aliased TCPv4 transport - DDS_TCPv4, in a DataReader / DataWriter QoS.

	
		
			
				DDS_TCPv4
			
		
	

With these settings, your user-data communication will happen over TCP once discovery is completed over UDP. You can find a sample XML QoS profile and a Wireshark capture that demonstrates this attached to this article. More details about the TCP transport can be found in the RTI Connext DDS Core Libraries User's Manual.