Skip to content

Commit 91d96b8

Browse files
authored
New max_message_size property to limit output datagrams size (#770)
* Refs #20849: Add max_message_size property policy docs Signed-off-by: elianalf <[email protected]> * Refs 20849: Apply suggestions Signed-off-by: elianalf <[email protected]> * Refs #20849: Apply suggestions Signed-off-by: elianalf <[email protected]> --------- Signed-off-by: elianalf <[email protected]>
1 parent 416952f commit 91d96b8

File tree

3 files changed

+142
-5
lines changed

3 files changed

+142
-5
lines changed

code/DDSCodeTester.cpp

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,28 @@ void dds_domain_examples()
903903
"unicast");
904904
//!--
905905
}
906+
907+
{
908+
// MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT
909+
DomainParticipantQos pqos;
910+
911+
// Set maximum number of bytes of the datagram to be sent
912+
pqos.properties().properties().emplace_back(
913+
"fastdds.max_message_size",
914+
"1200");
915+
//!--
916+
}
917+
918+
{
919+
// MAX_MESSAGE_SIZE_PROPERTY_WRITER
920+
DataWriterQos wqos;
921+
922+
// Set maximum number of bytes of the datagram to be sent
923+
wqos.properties().properties().emplace_back(
924+
"fastdds.max_message_size",
925+
"1200");
926+
//!--
927+
}
906928
}
907929

908930
//DOMAINPARTICIPANTLISTENER-DISCOVERY-CALLBACKS
@@ -4986,10 +5008,10 @@ void dynamictypes_examples()
49865008
sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_type(
49875009
type_descriptor)->build());
49885010
*/
4989-
5011+
49905012
// Add the sequence member to the struct
49915013
struct_builder->add_member(sequence_member_descriptor);
4992-
5014+
49935015
sequence_member_descriptor = traits<MemberDescriptor>::make_shared();
49945016
sequence_member_descriptor->name("short_sequence");
49955017
sequence_member_descriptor->type(DynamicTypeBuilderFactory::get_instance()->create_sequence_type(
@@ -5027,7 +5049,7 @@ void dynamictypes_examples()
50275049
int16_t out_simple_value;
50285050
sequence_data->set_int16_value(2, in_simple_value);
50295051
sequence_data->get_int16_value(out_simple_value, 2);
5030-
5052+
50315053
data->return_loaned_value(sequence_data);
50325054
//!--
50335055
}
@@ -5080,7 +5102,7 @@ void dynamictypes_examples()
50805102
int32_t out_simple_value;
50815103
array_data->set_int32_value(2, in_simple_value);
50825104
array_data->get_int32_value(out_simple_value, 2);
5083-
5105+
50845106
data->return_loaned_value(array_data);
50855107
//!--
50865108
}
@@ -5351,7 +5373,7 @@ void dynamictypes_examples()
53515373
// Get the loan for the bitset member
53525374
DynamicData::_ref_type bitset_data = data->loan_value(data->get_member_id_by_name("my_bitset"));
53535375

5354-
// Set and retrieve bitfield values
5376+
// Set and retrieve bitfield values
53555377
int16_t in_value {2};
53565378
int16_t out_value;
53575379
bitset_data->set_int16_value(bitset_data->get_member_id_by_name("d"), in_value);

code/XMLTester.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3232,6 +3232,42 @@
32323232
-->
32333233
<!--><-->
32343234

3235+
<!-->MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT<-->
3236+
<!--
3237+
<?xml version="1.0" encoding="UTF-8" ?>
3238+
-->
3239+
<participant profile_name="max_message_size_participant_xml_profile">
3240+
<rtps>
3241+
<propertiesPolicy>
3242+
<properties>
3243+
<!-- Set the maximum size in bytes for all RTPS datagrams sent by the participant -->
3244+
<property>
3245+
<name>fastdds.max_message_size</name>
3246+
<value>1200</value>
3247+
</property>
3248+
</properties>
3249+
</propertiesPolicy>
3250+
</rtps>
3251+
</participant>
3252+
<!--><-->
3253+
3254+
<!-->MAX_MESSAGE_SIZE_PROPERTY_WRITER<-->
3255+
<!--
3256+
<?xml version="1.0" encoding="UTF-8" ?>
3257+
-->
3258+
<data_writer profile_name="max_msg_size_datawriter_xml_profile">
3259+
<propertiesPolicy>
3260+
<properties>
3261+
<!-- Set the maximum size in bytes for all RTPS datagrams sent by the writer -->
3262+
<property>
3263+
<name>fastdds.max_message_size</name>
3264+
<value>1200</value>
3265+
</property>
3266+
</properties>
3267+
</propertiesPolicy>
3268+
</data_writer>
3269+
<!--><-->
3270+
32353271
<!-->FASTDDS_STATISTICS_MODULE<-->
32363272
<participant profile_name="statistics_domainparticipant_conf_xml_profile">
32373273
<rtps>

docs/fastdds/property_policies/non_consolidated_qos.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,82 @@ The behavior regarding this can be configured using the property ``fastdds.shm.e
351351
:language: xml
352352
:start-after: <!-->XML-SHM-ENFORCE-META-TRAFFIC
353353
:end-before: <!--><-->
354+
355+
.. _property_max_message_size:
356+
357+
Maximum Message Size
358+
^^^^^^^^^^^^^^^^^^^^
359+
360+
One common requirement is the differentiation between the maximum size of received and sent datagrams.
361+
This capability is especially important in scenarios where a system might need to handle large incoming
362+
data sizes but should restrict the size of the data it sends to prevent overwhelming network resources
363+
or complying with network traffic policies.
364+
The primary attribute for controlling datagram size is `maxMessageSize`, which sets the upper limit
365+
for both the size of datagrams that can be received and those that can be sent.
366+
Property ``fastdds.max_message_size`` allows restricting the size of outgoing datagrams without
367+
changing the size of incoming ones.
368+
This property allows for the specific configuration of the maximum number of bytes for datagrams that
369+
are sent.
370+
By configuring this property to a value lower than the smallest `maxMessageSize` across all transports,
371+
applications can achieve a lower sending limit while maintaining the ability to receive larger datagrams.
372+
373+
.. list-table::
374+
:header-rows: 1
375+
:align: left
376+
377+
* - PropertyPolicyQos name
378+
- PropertyPolicyQos value
379+
- Default value
380+
* - ``"fastdds.max_message_size"``
381+
- ``uint32_t``
382+
- ``"4294967295"``
383+
384+
.. note::
385+
An invalid value of ``fastdds.max_message_size`` would log an error,
386+
and the default value will be used.
387+
388+
.. _setting_max_message_size_participant:
389+
390+
Setting ``fastdds.max_message_size`` At Participant Level
391+
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
392+
393+
.. tabs::
394+
395+
.. tab:: C++
396+
397+
.. literalinclude:: /../code/DDSCodeTester.cpp
398+
:language: c++
399+
:start-after: // MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT
400+
:end-before: //!--
401+
:dedent: 6
402+
403+
.. tab:: XML
404+
405+
.. literalinclude:: /../code/XMLTester.xml
406+
:language: xml
407+
:start-after: <!-->MAX_MESSAGE_SIZE_PROPERTY_PARTICIPANT<-->
408+
:end-before: <!--><-->
409+
:lines: 2,4-16
410+
411+
.. _setting_max_message_size_writer:
412+
413+
Setting ``fastdds.max_message_size`` At Writer Level
414+
""""""""""""""""""""""""""""""""""""""""""""""""""""
415+
416+
.. tabs::
417+
418+
.. tab:: C++
419+
420+
.. literalinclude:: /../code/DDSCodeTester.cpp
421+
:language: c++
422+
:start-after: // MAX_MESSAGE_SIZE_PROPERTY_WRITER
423+
:end-before: //!--
424+
:dedent: 6
425+
426+
.. tab:: XML
427+
428+
.. literalinclude:: /../code/XMLTester.xml
429+
:language: xml
430+
:start-after: <!-->MAX_MESSAGE_SIZE_PROPERTY_WRITER<-->
431+
:end-before: <!--><-->
432+
:lines: 2,4-14

0 commit comments

Comments
 (0)