Increase UDP socket receive buffer to prevent large message loss#402
Open
alvgaona wants to merge 1 commit intoAtostek:masterfrom
Open
Increase UDP socket receive buffer to prevent large message loss#402alvgaona wants to merge 1 commit intoAtostek:masterfrom
alvgaona wants to merge 1 commit intoAtostek:masterfrom
Conversation
4252ddd to
317e0dd
Compare
RustDDS used OS-default UDP receive buffers (~786 KB on macOS, ~208 KB on Linux), which caused silent packet loss when receiving large fragmented DDS messages (e.g., 1080p images at ~6 MB). The buffer overflowed during fragment bursts, and with BestEffort QoS, lost fragments are never retransmitted. Set SO_RCVBUF to 8 MB by default (configurable via DomainParticipantBuilder::socket_receive_buffer_size). On Linux, users may need to raise net.core.rmem_max for larger payloads. This matches the approach used by CycloneDDS and FastDDS.
Contributor
Author
|
@jhelovuo more enhancements. Let me know what you think. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RustDDS silently drops large DDS messages (e.g.,
sensor_msgs/Imageat ~1200p or above) because the OS-default UDP receive buffer is too small to absorb fragment bursts. When a publisher (e.g., CycloneDDS) sends a large message, it gets fragmented into thousands of small UDP packets (~1 KB each). These arrive in a burst that overflows the default receive buffer (~786 KB on macOS, ~208 KB on Linux). With BestEffort QoS — standard for image topics — lost fragments are never retransmitted, so the message is silently lost.Fix
Set
SO_RCVBUFto 8 MB on all UDP listener sockets. The buffer size is configurable viaDomainParticipantBuilder::socket_receive_buffer_size().On macOS, the per-socket buffer is capped at
kern.ipc.maxsockbuf(8 MB by default), which limits reliable reception to ~8 MB payloads. On Linux, users can raisenet.core.rmem_maxfor larger payloads (e.g., 4K uncompressed images).Testing
Tested with a ROS 2 camera node publishing
sensor_msgs/Imageover CycloneDDS: