Conversation
Implements draft-cardwell-iccrg-bbr-congestion-control-03 alongside the existing NewReno and Cubic, selectable via ConnectionConfig.congestion_control. Architecture follows picoquic's bbr.c structure: three-stage onAckBatch pipeline (model → state → control), seven-state machine with four event-driven ProbeBW sub-states (Down → Cruise → Refill → Up), max-BW + min-RTT filters with separate ProbeRTT stamp, lower bounds (bw_lo, inflight_lo) reset at REFILL, BBRLossThresh-gated inflight_hi reduction, ECN EWMA alpha, ACK aggregation extra_acked, recovery state with packet conservation. Supporting changes: - congestion.CongestionControl tagged union over NewReno/Cubic/Bbr with inline-else dispatch; AckContext extended with prior_bytes_in_flight, newly_acked_bytes, newly_lost_bytes, largest_acked_pn so BBR has the inputs it needs without per-packet tracking. - delivery_rate.RateSampler (RFC 9002 §B / draft-cheng) with per-packet snapshot fields on SentPacket, gated by PacketHandler.rate_sampling_enabled so non-BBR connections pay zero per-send/per-ack overhead. - Pacer.setPacingRate(bps) for BBR's model-driven pacing alongside the existing setBandwidth(cwnd, rtt) used by NewReno/Cubic; cc.updatePacer dispatches the right path. - Migration resets preserve cc_algorithm so the user-chosen CC survives address rebinding. Test coverage: 551/551 pass. New tests cover BBRLossThresh both directions, ProbeRTT actually firing (separate min-stamp fix), all 4 ProbeBW sub-state transitions, inflight_hi growth in Up, ECN EWMA threshold crossing, persistent congestion preserves model, PTO recovery exit lifts inflight_hi, send_quantum scaling, CRUISE headroom, bdp uses bounded bw, path-change reset. Performance: bench-codec identical to main (within sub-ns noise); loopback HTTP/3 bench median 20,995 rps vs main 21,010 rps (-0.07%, within 5-10% run-to-run loopback variance). Default remains Cubic. See SPEC/9002_BBR.md for architecture details and outstanding caveats (qlog instrumentation, interop --cc CLI flag).
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.
Summary
Implements a faithful BBRv3 (
draft-cardwell-iccrg-bbr-congestion-control-03) alongside the existing NewReno and Cubic, selectable viaConnectionConfig.congestion_control = .bbr. Default remains Cubic — BBR is opt-in, with zero per-packet overhead when not selected.Architecture follows picoquic's
bbr.cstructure: three-stageonAckBatchpipeline, seven-state machine with four event-driven ProbeBW sub-states, full lower-bound dynamics, BBRLossThresh-gatedinflight_hi, ECN EWMA, ACK aggregation, recovery state.What's in here
Core:
src/quic/bbr.zig(~1080 lines):Bbrstruct, state machine, model estimators, pacing/cwnd computation.src/quic/delivery_rate.zig(~210 lines):RateSamplerper RFC 9002 §B / draft-cheng-iccrg-delivery-rate-estimation.src/quic/congestion.zig:Algorithmenum +CongestionControltagged union overNewReno/Cubic/Bbrwithinline elsedispatch;AckContextextended withprior_bytes_in_flight,newly_acked_bytes,newly_lost_bytes,largest_acked_pn;Pacer.setPacingRate(bps).src/quic/ack_handler.zig: per-packet snapshot fields onSentPacket;PacketHandler.rate_sampler+rate_sampling_enabledflag.src/quic/connection.zig: union dispatch;cc_algorithmfield preserved across migration; rate-sampling enabled only when.bbr.Docs:
SPEC/9002_BBR.md: architecture, state machine, caveats.SPEC/STATUS.md: row added to RFC 9002 table.State machine
Performance
bb61b7e)Within run-to-run loopback variance (5–10%).
bench-codecidentical within sub-ns noise. Per-packet rate-sampler overhead is gated behindrate_sampling_enabledso non-BBR connections pay nothing.Caveats (documented in SPEC/9002_BBR.md)
BBRRaiseInflightHiSlopeuses a per-round approximation rather than the draft's per-ack slope.--cc bbrCLI flag (default Cubic).Test plan
zig build test— 551/551 pass (including 19 new BBR tests + 6 union-dispatch parity tests + 4 sampler tests + 3 connection-level algorithm-selection tests).zig build— all 20+ executables build clean.bench-codec(pure CPU) — identical to main within sub-ns noise.bench(loopback HTTP/3) — median rps within 0.07% of main..bbrselected (deferred — needs--cc bbrflag on interop binaries first).