tquic
tquic copied to clipboard
issue 469: Implement Packet Loss Simulation for TQUIC Tools
This PR implements comprehensive packet loss simulation capabilities for TQUIC tools, enabling testing of network resilience and protocol behavior under adverse conditions.
closed #469
Features Implemented
Packet Header Parsing
- Added packet header parsing interface to extract packet sequence numbers and types
- Utilizes
PacketHeader::from_bytes()for robust packet analysis - Supports all QUIC packet types:
Initial, ZeroRTT, Handshake, OneRTT, Retry, VersionNegotiation
Packet Loss Simulation
- Random Loss: Configurable loss rate (0.0 to 1.0) with uniform distribution
- Specific Packet Numbers: Target exact packet sequence numbers for testing
- Packet Type Filtering: Drop specific packet types (e.g., handshake packets only)
- Directional Control: Separate control for incoming vs outgoing packet loss
Command Line Interface
Added new parameters to both tquic_client and tquic_server:
--packet-loss-rate <RATE> # Random loss rate (0.0-1.0)
--packet-loss-numbers <NUMBERS> # Comma-separated packet numbers
--packet-loss-types <TYPES> # Packet types to drop
--packet-loss-incoming # Apply to incoming packets
--packet-loss-outgoing # Apply to outgoing packets
Implementation Details
Core Components:
tools/src/packet_loss.rs: Main simulation logic and configurationtools/src/common.rs: Integration with QuicSocket for packet interception- Updated client/server binaries with CLI parameter support
Integration Points:
- Receive Path: Intercepts packets in recv_from() before processing
- Send Path: Intercepts packets in send_to() before transmission
- Error Handling: Uses WouldBlock to simulate dropped packets gracefully
Usage Examples
# Server with 10% random packet loss
./tquic_server --packet-loss-rate 0.1 --packet-loss-outgoing
# Client dropping handshake packets
./tquic_client --packet-loss-types handshake --packet-loss-outgoing --connect-to 127.0.0.1:8443 https://example.org
# Combined testing with specific packet numbers
./tquic_client --packet-loss-numbers 1,5,10 --packet-loss-incoming --connect-to 127.0.0.1:8443 https://example.org
Test
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 94.72%. Comparing base (b62863a) to head (7325353).
Additional details and impacted files
@@ Coverage Diff @@
## develop #477 +/- ##
========================================
Coverage 94.72% 94.72%
========================================
Files 50 50
Lines 30282 30282
========================================
Hits 28685 28685
Misses 1597 1597
: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.