From b74412f56d4a5126062fa38b35c95325be3b2a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20P=C3=A9rez?= <78275223+jepemi@users.noreply.github.com> Date: Tue, 6 Feb 2024 08:54:01 +0100 Subject: [PATCH] TCP socket send buffer limit (#646) * Refs #20119: Add non_blocking_send to TCPTransportDescriptor Signed-off-by: Jesus Perez * Refs #20119: non_blocking_send moved to properties Signed-off-by: Jesus Perez * Refs #20119: Apply suggestions Signed-off-by: Jesus Perez --------- Signed-off-by: Jesus Perez --- code/DDSCodeTester.cpp | 11 +++++ code/XMLTester.xml | 15 +++++++ .../non_consolidated_qos.rst | 44 +++++++++++++++++++ docs/fastdds/rtps_layer/rtps_layer.rst | 1 + docs/fastdds/transport/tcp/tcp.rst | 3 -- 5 files changed, 71 insertions(+), 3 deletions(-) diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index 2071f19a6..deee1204c 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -865,6 +865,17 @@ void dds_domain_examples() "unicast"); //!-- } + + { + //DDS-TCP-NON-BLOCKING-SEND + DomainParticipantQos participant_qos; + + // TCP transport will use non-blocking send + participant_qos.properties().properties().emplace_back( + "fastdds.tcp_transport.non_blocking_send", + "true"); + //!-- + } } //DOMAINPARTICIPANTLISTENER-DISCOVERY-CALLBACKS diff --git a/code/XMLTester.xml b/code/XMLTester.xml index 7222c1b3c..177f965a5 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -3592,6 +3592,21 @@ <--> +XML-TCP-NON-BLOCKING-SEND<--> + + + + + + fastdds.tcp_transport.non_blocking_send + true + + + + + +<--> + XML_TYPELOOKUP_SERVICE_ENABLING<--> diff --git a/docs/fastdds/property_policies/non_consolidated_qos.rst b/docs/fastdds/property_policies/non_consolidated_qos.rst index 7b0e14656..9858014d1 100644 --- a/docs/fastdds/property_policies/non_consolidated_qos.rst +++ b/docs/fastdds/property_policies/non_consolidated_qos.rst @@ -351,3 +351,47 @@ The behavior regarding this can be configured using the property ``fastdds.shm.e :language: xml :start-after: XML-SHM-ENFORCE-META-TRAFFIC :end-before: <--> + +.. _property_policies_tcp_non_blocking_send: + +TCP Non-blocking send +^^^^^^^^^^^^^^^^^^^^^ + +TCP transport will by default configure a :ref:`transport_tcp_tcp` with blocking send calls. +When ``fastdds.tcp_transport.non_blocking_send`` property is set to ``true``, send operations will +return immediately if the send buffer is full, but no error will be returned to the upper layer. +This means that the application will behave as if the packet is sent and lost. + +When set to ``false``, send operations will block until the network buffer has space for the +packet. + +.. list-table:: + :header-rows: 1 + :align: left + + * - PropertyPolicyQos value + - Description + - Default + * - ``"false"`` + - Block on send operations when send buffer is full. + - ✅ + * - ``"true"`` + - Do not block on send operations when send buffer is full. + - + +.. tabs:: + + .. tab:: C++ + + .. literalinclude:: /../code/DDSCodeTester.cpp + :language: c++ + :start-after: //DDS-TCP-NON-BLOCKING-SEND + :end-before: //!-- + :dedent: 8 + + .. tab:: XML + + .. literalinclude:: /../code/XMLTester.xml + :language: xml + :start-after: XML-TCP-NON-BLOCKING-SEND + :end-before: <--> diff --git a/docs/fastdds/rtps_layer/rtps_layer.rst b/docs/fastdds/rtps_layer/rtps_layer.rst index 99b6744d4..6b19aec4c 100644 --- a/docs/fastdds/rtps_layer/rtps_layer.rst +++ b/docs/fastdds/rtps_layer/rtps_layer.rst @@ -184,6 +184,7 @@ function of the :ref:`dds_layer_domainParticipantQos`, XML profiles (see :ref:`R * |TCPTransportDescriptor::calculate_crc-api|, |TCPTransportDescriptor::check_crc-api| and |TCPTransportDescriptor::apply_security-api| are set to false. * |TCPTransportDescriptor::enable_tcp_nodelay-api| is set to true. + * :ref:`property_policies_tcp_non_blocking_send` is set to true. * |TCPTransportDescriptor::keep_alive_thread-api| and |TCPTransportDescriptor::accept_thread-api| use the default configuration. diff --git a/docs/fastdds/transport/tcp/tcp.rst b/docs/fastdds/transport/tcp/tcp.rst index 5baa4fbbd..e4545e60d 100644 --- a/docs/fastdds/transport/tcp/tcp.rst +++ b/docs/fastdds/transport/tcp/tcp.rst @@ -357,6 +357,3 @@ A TCP version of helloworld example can be found in the `HelloWorldExampleTCP folder `_. It shows a publisher and a subscriber that communicate through TCP. The publisher is configured as *TCP server* while the Subscriber is acting as *TCP client*. - - -