Skip to content

fix(qmux): backport TCP byte counters to 0.5 - #436

Closed
kixelated wants to merge 1 commit into
qmux-v0.5.xfrom
fix/qmux-byte-counters-0.5
Closed

kixelated wants to merge 1 commit into
qmux-v0.5.xfrom
fix/qmux-byte-counters-0.5

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

Backport #435 to qmux-v0.5.x so QMux 0.5 sessions can expose the same TCP payload counters as the current line.

Approach

Extend the existing TcpStats TCP_INFO reader with sent/received payload bytes and forward them through SocketStats and Session::stats(). Check the kernel's returned struct length; unsupported platforms and older kernels keep both counters unavailable.

Sent bytes include retransmissions plus TLS, WebSocket, and QMux framing, excluding TCP/IP headers. Received bytes count TCP-delivered payload, excluding duplicate retransmissions. These follow the kernel's TCP_INFO fields and transmit accounting.

Impact

  • Add SocketStats::bytes_sent() and bytes_received(), both defaulting to None for existing implementations.
  • Sessions with attached TcpStats report these counters on supported Linux kernels.
  • Wire format unchanged; package versions unchanged.

Alternatives

Counting application writes would miss framing and retransmissions. Reuse the kernel counters already adjacent to the RTT and delivery-rate measurements.

Validation

Clean head 3ff96e8e691cf553aa17c388d33d975538fc3b5a:

  • just fix, just check, and just test passed in the pinned Nix shell.
  • Native/WASM feature checks, documentation tests, 158 TypeScript tests, and both JS/Rust interop directions passed.
  • A real loopback WebSocket regression failed before this change and now checks cumulative bytes in both directions without sleeps.
  • Kernel layout and truncated/zero-counter regressions passed.

The inherited LIBCLANG_PATH selected a library from another devshell; validation used the source shell's own library paths.

Follow-ups

This targets qmux-v0.5.x; #435 carries the main-line change. Version bumps, publication, and consumer adoption remain separate.

(written by GPT-6)

Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated

Copy link
Copy Markdown
Collaborator Author

Source backport complete at 3ff96e8e691cf553aa17c388d33d975538fc3b5a.

  • just fix, just check, and just test passed on the clean committed head in the pinned Nix shell.
  • Real loopback WebSocket counters, old-kernel length/zero guards, native/WASM checks, 158 TypeScript tests, and both JS/Rust interop directions passed.
  • Main-line source change: feat(qmux): expose TCP byte counters in session stats #435. No package version, publication, or consumer pin change.

The MoQ quest still needs source merge/publication and its transport mapping before adoption. Its untouched claim was released.

(written by GPT-6)

@kixelated

Copy link
Copy Markdown
Collaborator Author

Closing: QMux development has moved to moq-dev/moq. web-transport's copy only takes finished bug fixes until it is frozen (see moq's qmux-rs-retire). This draft is stale, and later merges like #437 and #451 likely overlap with it. Any remaining issue belongs in moq-dev/moq's qmux.

(Written by Claude Opus 5.5 with high)

@kixelated kixelated closed this Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant