Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[20849] New max_message_size property to limit output datagrams size (backport #770) #775

Merged
merged 1 commit into from
May 24, 2024
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
22 changes: 22 additions & 0 deletions code/DDSCodeTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,28 @@ void dds_domain_examples()
"fastdds.tcp_transport.non_blocking_send",
"true");
//!--
}

{
// MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT
DomainParticipantQos pqos;

// Set maximum number of bytes of the datagram to be sent
pqos.properties().properties().emplace_back(
"fastdds.max_message_size",
"1200");
//!--
}

{
// MAX_MESSAGE_SIZE_PROPERTY_WRITER
DataWriterQos wqos;

// Set maximum number of bytes of the datagram to be sent
wqos.properties().properties().emplace_back(
"fastdds.max_message_size",
"1200");
//!--
}
}

Expand Down
36 changes: 36 additions & 0 deletions code/XMLTester.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3110,6 +3110,42 @@
-->
<!--><-->

<!-->MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT<-->
<!--
<?xml version="1.0" encoding="UTF-8" ?>
-->
<participant profile_name="max_message_size_participant_xml_profile">
<rtps>
<propertiesPolicy>
<properties>
<!-- Set the maximum size in bytes for all RTPS datagrams sent by the participant -->
<property>
<name>fastdds.max_message_size</name>
<value>1200</value>
</property>
</properties>
</propertiesPolicy>
</rtps>
</participant>
<!--><-->

<!-->MAX_MESSAGE_SIZE_PROPERTY_WRITER<-->
<!--
<?xml version="1.0" encoding="UTF-8" ?>
-->
<data_writer profile_name="max_msg_size_datawriter_xml_profile">
<propertiesPolicy>
<properties>
<!-- Set the maximum size in bytes for all RTPS datagrams sent by the writer -->
<property>
<name>fastdds.max_message_size</name>
<value>1200</value>
</property>
</properties>
</propertiesPolicy>
</data_writer>
<!--><-->

<!-->FASTDDS_STATISTICS_MODULE<-->
<participant profile_name="statistics_domainparticipant_conf_xml_profile">
<rtps>
Expand Down
79 changes: 79 additions & 0 deletions docs/fastdds/property_policies/non_consolidated_qos.rst
Original file line number Diff line number Diff line change
Expand Up @@ -395,3 +395,82 @@ packet.
:language: xml
:start-after: <!-->XML-TCP-NON-BLOCKING-SEND
:end-before: <!--><-->

.. _property_max_message_size:

Maximum Message Size
^^^^^^^^^^^^^^^^^^^^

One common requirement is the differentiation between the maximum size of received and sent datagrams.
This capability is especially important in scenarios where a system might need to handle large incoming
data sizes but should restrict the size of the data it sends to prevent overwhelming network resources
or complying with network traffic policies.
The primary attribute for controlling datagram size is `maxMessageSize`, which sets the upper limit
for both the size of datagrams that can be received and those that can be sent.
Property ``fastdds.max_message_size`` allows restricting the size of outgoing datagrams without
changing the size of incoming ones.
This property allows for the specific configuration of the maximum number of bytes for datagrams that
are sent.
By configuring this property to a value lower than the smallest `maxMessageSize` across all transports,
applications can achieve a lower sending limit while maintaining the ability to receive larger datagrams.

.. list-table::
:header-rows: 1
:align: left

* - PropertyPolicyQos name
- PropertyPolicyQos value
- Default value
* - ``"fastdds.max_message_size"``
- ``uint32_t``
- ``"4294967295"``

.. note::
An invalid value of ``fastdds.max_message_size`` would log an error,
and the default value will be used.

.. _setting_max_message_size_participant:

Setting ``fastdds.max_message_size`` At Participant Level
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""

.. tabs::

.. tab:: C++

.. literalinclude:: /../code/DDSCodeTester.cpp
:language: c++
:start-after: // MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT
:end-before: //!--
:dedent: 6

.. tab:: XML

.. literalinclude:: /../code/XMLTester.xml
:language: xml
:start-after: <!-->MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT<-->
:end-before: <!--><-->
:lines: 2,4-16

.. _setting_max_message_size_writer:

Setting ``fastdds.max_message_size`` At Writer Level
""""""""""""""""""""""""""""""""""""""""""""""""""""

.. tabs::

.. tab:: C++

.. literalinclude:: /../code/DDSCodeTester.cpp
:language: c++
:start-after: // MAX_MESSAGE_SIZE_PROPERTY_WRITER
:end-before: //!--
:dedent: 6

.. tab:: XML

.. literalinclude:: /../code/XMLTester.xml
:language: xml
:start-after: <!-->MAX_MESSAGE_SIZE_PROPERTY_WRITER<-->
:end-before: <!--><-->
:lines: 2,4-14