Skip to content

Commit

Permalink
TCP socket send buffer limit (#646)
Browse files Browse the repository at this point in the history
* Refs #20119: Add non_blocking_send to TCPTransportDescriptor

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

* Refs #20119: non_blocking_send moved to properties

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

* Refs #20119: Apply suggestions

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>

---------

Signed-off-by: Jesus Perez <jesusperez@eprosima.com>
  • Loading branch information
jepemi committed Feb 6, 2024
1 parent 039b600 commit b74412f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 3 deletions.
11 changes: 11 additions & 0 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions code/XMLTester.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3592,6 +3592,21 @@
</participant>
<!--><-->

<!-->XML-TCP-NON-BLOCKING-SEND<-->
<participant profile_name="participant_xml_conf_tcp_non_blocking_send">
<rtps>
<propertiesPolicy>
<properties>
<property>
<name>fastdds.tcp_transport.non_blocking_send</name>
<value>true</value>
</property>
</properties>
</propertiesPolicy>
</rtps>
</participant>
<!--><-->

<!-->XML_TYPELOOKUP_SERVICE_ENABLING<-->
<participant profile_name="participant_typelookup_service_enabled">
<rtps>
Expand Down
44 changes: 44 additions & 0 deletions docs/fastdds/property_policies/non_consolidated_qos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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: <!--><-->
1 change: 1 addition & 0 deletions docs/fastdds/rtps_layer/rtps_layer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
3 changes: 0 additions & 3 deletions docs/fastdds/transport/tcp/tcp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,3 @@ A TCP version of helloworld example can be found in the
`HelloWorldExampleTCP folder <https://github.com/eProsima/Fast-DDS/tree/master/examples/cpp/dds/HelloWorldExampleTCP>`_.
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*.



0 comments on commit b74412f

Please sign in to comment.