eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
877 stars 360 forks source link

Why an RTPS packet could contain multiple fragments in cyclonedds #1938

Open tangc1986 opened 8 months ago

tangc1986 commented 8 months ago

When I configure a smaller value for FragmentSize, one rtps packet contained multiple fragments.

What are the advantages of one packet with multiple segments than one packet with one segment?

Is it enough for the FragmentSize value to be automatically configured to the minimum value of MaxRexmitMessageSize and MaxMessageSize?

eboasson commented 8 months ago

Hi @tangc1986, my apologies for only responding now ...

It usually pays off to avoid IP fragmentation on retransmits, and the unit of retransmissions is a fragment. That means choosing FragmentSize so that a single fragment fits in on IP packet is generally a good idea.

The overhead of DDSI fragmentation is generally higher than that of IP fragmentation (bigger protocol headers, crossing system call boundaries, perhaps also that the IP stack has been highly optimised by a lot of smart people over many years), and so you want to minimise the performance impact in the absence of retransmits. The means you want larger fragments ...

Fortunately, the protocol allows putting multiple fragments in a single DATA_FRAG submessage: that way you can have the best of both worlds.

I don't think there's anything to be gained by setting it much smaller than the MTU. But I am happy to learn otherwise 😀