fix: make transport flight-size accounting consistent (plaintext vs encrypted)#4528
fix: make transport flight-size accounting consistent (plaintext vs encrypted)#4528mvanhorn wants to merge 1 commit into
Conversation
|
Now I have everything I need. Let me verify the consistency of the The grep confirmed it: Rule Review: Minor documentation gap; no blocking issuesRules checked: WarningsNone. Info
All other checks passed:
Rule review against |
Summary
Flight-size accounting now adds and releases the same byte count for every packet, so the connection-wide flight-size counter no longer drifts downward over the life of a connection.
Why this matters
on_send/on_send_with_tokenadd the plaintext fragment/packet size to flight size, but all three release paths (ACK viareport_received_receipts->on_ack*, Abandon viaResendAction::Abandon->release_flightsize, anddrop_stream) released the encrypted stored payload length (payload.len(), which includes the AEAD tag and framing overhead). Every release subtracted slightly more than was added, biasing flight size low. It is low-impact under the default FixedRate controller but matters for BBR/LEDBAT, where flight size is load-bearing. Fixes #4402.Changes
packet_sizealongside the encrypted payload in eachpending_receiptsentry, and release that stored plaintext size on all three paths (ACK, Abandon,drop_stream). This makessum(on_send) == sum(release).packet_sizethe caller passed toon_send_with_tokendown throughpacket_sendinginto the tracker, rather than recomputing it from the serialized payload. This handles fragment Overall architecture RFC #1 with embedded metadata, where the actual fragment payload is smaller than the byte count added to flight size, so a recomputed value would under-release.refresh_sent_packetand the insert-or-refresh path) preserves the original plaintext byte count, since flight size is added only on the first send.sent_packet_tracker.rsto describe the new plaintext-on-both-sides convention.Testing
cargo test -p freenet --lib transport::sent_packet_tracker— 61 passed, including a newtest_issue_4402_plaintext_flightsize_releases_balance_all_pathsthat asserts flight size returns to zero after a stream is fully ACKed, fully abandoned, dropped viadrop_stream, and a mixed ACK/drop sequence.cargo test -p freenet --lib transport::peer_connection::tests::packet_sending— 2 passed, including a newpacket_sending_tracks_caller_flight_size_for_metadata_stream_fragmentregression test proving a metadata-bearing fragment releases the caller's flight-size bytes, notpayload.len().cargo check -p freenet --lib— clean.AI was used for assistance.