From a070c2ab298c5b108883bec5b38f07d70a251716 Mon Sep 17 00:00:00 2001
From: elianalf <62831776+elianalf@users.noreply.github.com>
Date: Fri, 17 May 2024 17:21:30 +0200
Subject: [PATCH] New `max_message_size` property to limit output datagrams
size (#770)
* Refs #20849: Add max_message_size property policy docs
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
* Refs 20849: Apply suggestions
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
* Refs #20849: Apply suggestions
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
---------
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
(cherry picked from commit 91d96b831ccdf47888e5aec86c079ee6071284ed)
# Conflicts:
# code/DDSCodeTester.cpp
---
code/DDSCodeTester.cpp | 22 ++++++
code/XMLTester.xml | 36 +++++++++
.../non_consolidated_qos.rst | 79 +++++++++++++++++++
3 files changed, 137 insertions(+)
diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp
index eaf9d6aea..ffe57f831 100644
--- a/code/DDSCodeTester.cpp
+++ b/code/DDSCodeTester.cpp
@@ -883,6 +883,28 @@ void dds_domain_examples()
"unicast");
//!--
}
+
+ {
+ // 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");
+ //!--
+ }
}
//DOMAINPARTICIPANTLISTENER-DISCOVERY-CALLBACKS
diff --git a/code/XMLTester.xml b/code/XMLTester.xml
index 7af50027e..09f0e91d7 100644
--- a/code/XMLTester.xml
+++ b/code/XMLTester.xml
@@ -3229,6 +3229,42 @@
-->
<-->
+MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT<-->
+
+
+
+
+
+
+
+ fastdds.max_message_size
+ 1200
+
+
+
+
+
+<-->
+
+MAX_MESSAGE_SIZE_PROPERTY_WRITER<-->
+
+
+
+
+
+
+ fastdds.max_message_size
+ 1200
+
+
+
+
+<-->
+
FASTDDS_STATISTICS_MODULE<-->
diff --git a/docs/fastdds/property_policies/non_consolidated_qos.rst b/docs/fastdds/property_policies/non_consolidated_qos.rst
index 7b0e14656..17d91f7bb 100644
--- a/docs/fastdds/property_policies/non_consolidated_qos.rst
+++ b/docs/fastdds/property_policies/non_consolidated_qos.rst
@@ -351,3 +351,82 @@ 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_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