Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6521,6 +6521,23 @@ void dds_transport_examples ()
//!--
}

{
//CONF-TCP-KEEP-ALIVE
DomainParticipantQos qos;

// Create a descriptor for the new transport.
auto tcp_transport = std::make_shared<TCPv4TransportDescriptor>();

// Configure keep alive options
tcp_transport->keep_alive_frequency_ms = 5000; // Send a keep-alive message every 5 seconds when connection is idle
tcp_transport->keep_alive_timeout_ms = 2000; // Consider connection lost if no response is received within 2 seconds
tcp_transport->keep_alive_thread = eprosima::fastdds::rtps::ThreadSettings{-1, 0, 0, -1}; // Configure thread settings

// Link the Transport Layer to the Participant.
qos.transport().user_transports.push_back(tcp_transport);
//!--
}

{
//TRANSPORT-DESCRIPTORS
DomainParticipantQos qos;
Expand Down
15 changes: 15 additions & 0 deletions code/XMLTester.xml
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,21 @@
</participant>
<!--><-->

<!-->CONF-TCP-KEEP-ALIVE<-->
<!--
<?xml version="1.0" encoding="UTF-8" ?>
<profiles xmlns="http://www.eprosima.com">
-->
<transport_descriptors>
<transport_descriptor>
<transport_id>keep_alive_transport</transport_id>
<type>TCPv4</type>
<keep_alive_frequency_ms>5000</keep_alive_frequency_ms>
<keep_alive_timeout_ms>25000</keep_alive_timeout_ms>
</transport_descriptor>
</transport_descriptors>
<!--><-->

<!-->CONF-DISABLE-MULTICAST<-->
<!--
<?xml version="1.0" encoding="UTF-8" ?>
Expand Down
8 changes: 4 additions & 4 deletions docs/fastdds/transport/tcp/tcp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ The following table describes the common data members for both TCPv4 and TCPv6.
- List of ports to listen as *server*. If a port is set to 0, an available port will be automatically assigned.
* - |TCPTransportDescriptor::keep_alive_frequency_ms-api|
- ``uint32_t``
- 5000
- Frequency of RTCP keep alive requests (in ms).
- 0
- |Pro| Frequency of RTCP keep alive requests (in ms).
* - |TCPTransportDescriptor::keep_alive_timeout_ms-api|
- ``uint32_t``
- 15000
- Time since sending the last keep alive request to consider a connection as broken (in ms).
- 0
- |Pro| Time since sending the last keep alive request to consider a connection as broken (in ms).
* - |TCPTransportDescriptor::max_logical_port-api|
- ``uint16_t``
- 100
Expand Down
46 changes: 46 additions & 0 deletions docs/fastdds/use_cases/ip_mobility/ip_mobility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,49 @@ Please refer to :ref:`dds_layer_domainParticipantQos` for more information about
(please refer to :ref:`remotelocatorsallocationattributes`).
It is recommended to use the highest number of local addresses found on all the systems belonging to the same
domain.

.. _tcp-keep-alive:

TCP Keep Alive |Pro|
--------------------

Fast DDS Pro additionally provides a TCP keep-alive mechanism to detect stalled TCP connections and recover
from link failures more reliably.
When enabled, the TCP transport periodically sends keep-alive requests on established TCP channels, and monitors
activity to determine whether a connection is still responsive.
Keep alive requests are sent only when no incoming data has been received for a specified interval.

If the configured timeout is reached without observing activity after a keep-alive request, the channel is
considered broken and is closed, allowing Fast DDS to reconnect and restore communication.

Note that this feature operates at the application level, independently of any TCP keep-alive settings at the OS level.
This allows for more fine-grained control over connection monitoring and recovery within Fast DDS.
It also ensures consistent behavior across different operating systems and increases portability.

Keep alive is disabled by default and can be configured through the following parameters in
|TCPTransportDescriptor-api|:

.. tab-set::

.. tab-item:: XML
:sync: xml

.. literalinclude:: /../code/XMLTester.xml
:language: xml
:start-after: <!-->CONF-TCP-KEEP-ALIVE<-->
:end-before: <!--><-->
:lines: 2-3, 6-
:append: </profiles>

.. tab-item:: C++
:sync: cpp

.. literalinclude:: ../../../../code/DDSCodeTester.cpp
:language: c++
:dedent: 8
:start-after: //CONF-TCP-KEEP-ALIVE
:end-before: //!

.. note::

This feature is intended for TCP transports and only applies to connected TCP channels.
6 changes: 6 additions & 0 deletions docs/fastdds/use_cases/use_cases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ with distributed systems:
If the network interfaces are expected to change while the application is running, *Fast DDS Pro* provides an
automatic way of re-scanning the available interfaces and including them.

+ :ref:`TCP Keep Alive <tcp-keep-alive>` |Pro|.
In the same line as :ref:`IP mobility <ip-mobility>`, TCP Keep Alive feature allows to automatically detect
broken TCP connections by sending periodic keep-alive messages at application level when the connection is idle.
This feature is essential in TCP scenarios with dynamic IP changes or unstable network conditions,
ensuring that stale connections are identified and re-established promptly.

+ :ref:`use-case-tcp`.
Describes how to configure *Fast DDS* to use the ``LARGE_DATA`` builtin transports mode.
This mode enables efficient utilization of TCP transport without the need for constant reconfiguration
Expand Down
8 changes: 4 additions & 4 deletions docs/fastdds/xml_configuration/transports.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ A more detailed explanation of each of these elements can be found in :ref:`comm
- ``string``
-
* - ``<keep_alive_frequency_ms>``
- Frequency in milliseconds for sending :ref:`RTCP <rtcpdefinition>` keep-alive requests (TCP only).
- |Pro| Frequency in milliseconds for sending :ref:`RTCP <rtcpdefinition>` keep-alive requests (TCP only).
- ``uint32_t``
- ``50000``
- ``0``
* - ``<keep_alive_timeout_ms>``
- Time in milliseconds since the last keep-alive request was sent to consider a connection as broken (TCP only).
- |Pro| Time in milliseconds since the last keep-alive request was sent to consider a connection as broken (TCP only).
- ``uint32_t``
- ``10000``
- ``0``
* - ``<max_logical_port>``
- The maximum number of logical ports to try during :ref:`RTCP <rtcpdefinition>` negotiations (TCP only).
- ``uint16_t``
Expand Down
Loading