feat(udp): optional per-endpoint ZSTD compression - #78
Open
MatejFranceskin wants to merge 1 commit into
Open
MatejFranceskin wants to merge 1 commit into
MatejFranceskin wants to merge 1 commit into
Conversation
MatejFranceskin
force-pushed
the
feat/zstd-compressed-endpoints
branch
from
July 28, 2026 05:34
64485ab to
e77ac8d
Compare
MatejFranceskin
force-pushed
the
feat/zstd-compressed-endpoints
branch
2 times, most recently
from
July 28, 2026 05:46
36540aa to
ed75cbf
Compare
Add two per-UDP-endpoint options, ZstdCompression (bool) and ZstdDictionary (path), to compress an endpoint's traffic and save bandwidth on a constrained link. - Each outgoing datagram (a coalesced batch of framed MAVLink messages) is compressed into one standalone ZSTD frame at level 3, optionally with a trained dictionary. - Time-critical message ids (HEARTBEAT, SYSTEM_TIME, PING, MISSION_CURRENT, COMMAND_LONG, COMMAND_ACK, TIMESYNC, CURRENT_EVENT_SEQUENCE, REQUEST_EVENT), and any datagram that does not shrink, are sent uncompressed. - The receiver auto-detects the 4-byte ZSTD magic per datagram and decompresses, passing plain MAVLink through unchanged (no negotiation; mixed streams decode). libzstd is an optional dependency (meson feature 'zstd', auto): when present the feature is built, otherwise it is compiled out cleanly and an endpoint that requests ZstdCompression fails at startup with a clear message. Compression sits only at the UDP syscall layer (compress before sendto in flush_pending_msgs, decompress after recvfrom in _read_msg); the shared MAVLink framer/CRC path and UART/TCP endpoints are untouched. UDP datagram atomicity means one datagram == one frame. RX_BUF_MAX_SIZE is raised to 8 KiB so a decompressed coalesced batch fits. The dictionary is provided per deployment (via the ZstdDictionary path); no dictionary is bundled. tools/train-zstd-dict.sh trains one from captured MAVLink traffic, and the README has a "ZSTD Compression" section. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
MatejFranceskin
force-pushed
the
feat/zstd-compressed-endpoints
branch
from
July 28, 2026 06:00
ed75cbf to
0f6f9d3
Compare
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.
Jira: SW-2443
Adds optional per-UDP-endpoint ZSTD compression, controlled by two new endpoint options:
It lets an endpoint compress its traffic to save bandwidth on a constrained link (e.g. a telemetry radio).
Behavior
ZstdCompressionand, if used, use the sameZstdDictionary.Design
Compression sits only at the UDP syscall layer (compress before
sendtoinflush_pending_msgs, decompress afterrecvfromin_read_msg); the shared MAVLink framer/CRC path and UART/TCP endpoints are untouched. UDP datagram atomicity means one datagram == one frame.RX_BUF_MAX_SIZEis raised to 8 KiB so a decompressed coalesced batch fits. The ZSTD library types are kept out of headers (opaquevoid*inZstdCodec).Includes
tools/train-zstd-dict.shto train a dictionary from captured MAVLink traffic, a default dictionary installed to<datadir>/mavlink-router/, and a README "ZSTD Compression" section.Testing