tquic
tquic copied to clipboard
feat: support datagram extension
Add QUIC Datagram Extension (RFC 9221) Support
Summary
This PR implements the QUIC Datagram Extension as specified in RFC 9221, enabling unreliable, unordered datagram transmission over QUIC connections.
This feature allows applications to send and receive datagrams without the overhead of stream-based reliable delivery.
Features
- Complete RFC 9221 Compliance: Full implementation of the QUIC Datagram Extension specification
- Configurable Support: Enable/disable datagram support with configurable maximum frame sizes
- Buffer Management: Separate send and receive buffers with configurable sizes (default: 1 MB each)
- Flow Control: Automatic buffer overflow protection with optional drop-on-full behavior
- MTU Awareness: Smart payload size calculation considering frame overhead and current MTU
- Peer Capability Negotiation: Automatic detection and negotiation of peer datagram support
Implementation Details
Core Components
| Component | Description |
|---|---|
DatagramConfig |
Configuration structure for datagram support settings |
DatagramState |
State management for datagram sending and receiving |
Frame::Datagram |
Added variant to the frame system |
| Connection Integration | Seamless integration with existing QUIC connection logic |
Key APIs
| API | Purpose |
|---|---|
Config::set_datagram_enabled() |
Enable datagram support with optional max frame size |
Config::set_datagram_send_buffer_size() |
Configure send buffer size |
Config::set_datagram_recv_buffer_size() |
Configure receive buffer size |
Connection::datagram_send() |
Send a datagram with optional drop-on-full behavior |
Connection::datagram_recv() |
Receive the next available datagram |
Connection::datagram_max_size() |
Get maximum datagram payload size |
Connection::datagram_send_buffer_space() |
Check available send buffer space |
Connection::datagram_recv_buffer_space() |
Check available receive buffer space |
Transport Parameter Integration
- Automatically negotiates
max_datagram_frame_sizetransport parameter - Respects peer’s datagram capabilities during connection establishment
- Properly handles cases where peer doesn’t support datagrams
resolve #222
Codecov Report
:x: Patch coverage is 69.77492% with 94 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 94.47%. Comparing base (b62863a) to head (f03d6cd).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/connection/datagram.rs | 77.00% | 46 Missing :warning: |
| src/connection/connection.rs | 34.69% | 32 Missing :warning: |
| src/lib.rs | 9.09% | 10 Missing :warning: |
| src/frame.rs | 84.61% | 6 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #492 +/- ##
===========================================
- Coverage 94.72% 94.47% -0.26%
===========================================
Files 50 51 +1
Lines 30282 30591 +309
===========================================
+ Hits 28685 28901 +216
- Misses 1597 1690 +93
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.