Skip to content

feat(qmux): expose TCP byte counters in session stats - #435

Closed
kixelated wants to merge 1 commit into
mainfrom
fix/qmux-byte-counters
Closed

kixelated wants to merge 1 commit into
mainfrom
fix/qmux-byte-counters

Conversation

@kixelated

@kixelated kixelated commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

QMux session statistics omit byte counters even when the underlying TCP socket tracks them.

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 5a9c69221e1b2a0296d0cc8a6d254ad4c51f02f7:

  • 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

The matching qmux-v0.5.x backport is #436, with the same full check/test gates passed. 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 counter implementation is complete and just fix/check/test passed on the recorded clean head. Kept this PR in draft for review. The matching 0.5 source backport is validating separately; publication and consumer adoption remain separate actions.

(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