6.2. UDP Transport
UDP is a connectionless transport, where the receiving DomainParticipant must open a UDP port listening for incoming messages, and the sending DomainParticipant sends messages to this port.
Warning
This documentation assumes the reader has basic knowledge of UDP/IP concepts, since terms like Time To Live (TTL), socket buffers, and port numbering are not explained in detail. However, it is possible to configure a basic UDP transport on Fast DDS without this knowledge.
6.2.1. UDPTransportDescriptor
eProsima Fast DDS implements UDP transport for both UDPv4 and UDPv6.
Each of these transports is independent from the other, and has its own TransportDescriptorInterface
.
However, all their TransportDescriptorInterface
data members are common.
The following table describes the common data members for both UDPv4 and UDPv6.
Member |
Data type |
Default |
Description |
---|---|---|---|
|
0 |
Size of the sending buffer of the socket (octets). |
|
|
0 |
Size of the receiving buffer of the socket (octets). |
|
|
|
See Netmask filtering. |
|
|
Empty vector |
List of allowed interfaces with |
|
|
Empty vector |
List of blocked interfaces. See Blocklist. |
|
|
Empty vector |
List of allowed interfaces. See Interface Whitelist. |
|
|
1 |
Time to live, in number of hops. |
|
|
0 |
Port number for the outgoing messages. |
|
|
|
Do not block on send operations (*). |
|
Default ThreadSettings for the reception threads. |
|||
|
ThreadSettings for the reception threads on specific ports. |
Note
When non_blocking_send
is set to true, send operations will return immediately if the
buffer is full, but no error will be returned to the upper layer.
This means that the application will behave as if the datagram is sent and lost.
This value is specially useful on high-frequency best-effort writers.
When set to false
, send operations will block until the network buffer has space for the
datagram.
This may hinder performance on high-frequency writers.
6.2.1.1. UDPv4TransportDescriptor
UDPv4TransportDescriptor
has no additional data members from the common ones described in
UDPTransportDescriptor.
Note
The kind
value for a UDPv4TransportDescriptor
is given by the value
LOCATOR_KIND_UDPv4
.
6.2.1.2. UDPv6TransportDescriptor
UDPv6TransportDescriptor
has no additional data members from the common ones described in
UDPTransportDescriptor.
Note
The kind
value for a UDPv6TransportDescriptor
is given by the value
LOCATOR_KIND_UDPv6
.
6.2.2. Enabling UDP Transport
Fast DDS enables a UDPv4 transport by default. Nevertheless, the application can enable other UDP transports if needed. To enable a new UDP transport in a DomainParticipant, first create an instance of UDPv4TransportDescriptor (for UDPv4) or UDPv6TransportDescriptor (for UDPv6), and add it to the user transport list of the DomainParticipant.
The examples below show this procedure in both C++ code and XML file.
DomainParticipantQos qos;
// Create a descriptor for the new transport.
auto udp_transport = std::make_shared<UDPv4TransportDescriptor>();
udp_transport->sendBufferSize = 9216;
udp_transport->receiveBufferSize = 9216;
udp_transport->non_blocking_send = true;
// [OPTIONAL] ThreadSettings configuration
udp_transport->default_reception_threads(eprosima::fastdds::rtps::ThreadSettings{2, 2, 2, 2});
udp_transport->set_thread_config_for_port(12345, eprosima::fastdds::rtps::ThreadSettings{3, 3, 3, 3});
// Link the Transport Layer to the Participant.
qos.transport().user_transports.push_back(udp_transport);
// Avoid using the default transport
qos.transport().use_builtin_transports = false;
<?xml version="1.0" encoding="UTF-8" ?>
<dds>
<profiles xmlns="http://www.eprosima.com">
<transport_descriptors>
<transport_descriptor>
<transport_id>udp_transport</transport_id>
<type>UDPv4</type>
<sendBufferSize>9216</sendBufferSize>
<receiveBufferSize>9216</receiveBufferSize>
<non_blocking_send>true</non_blocking_send>
<default_reception_threads>
<scheduling_policy>2</scheduling_policy>
<priority>2</priority>
<affinity>2</affinity>
<stack_size>2</stack_size>
</default_reception_threads>
<reception_threads>
<reception_thread port="12345">
<scheduling_policy>3</scheduling_policy>
<priority>3</priority>
<affinity>3</affinity>
<stack_size>3</stack_size>
</reception_thread>
</reception_threads>
</transport_descriptor>
</transport_descriptors>
<participant profile_name="UDPParticipant">
<rtps>
<userTransports>
<transport_id>udp_transport</transport_id>
</userTransports>
<useBuiltinTransports>false</useBuiltinTransports>
</rtps>
</participant>
</profiles>
<dds>