Skip to content

Replace LibreSpeed with a built-in M-Lab engine (0.2.0) - #2

Merged
mrgenty merged 9 commits into
mainfrom
feature/mlab-engine
Nov 27, 2026
Merged

mrgenty merged 9 commits into
mainfrom
feature/mlab-engine

Conversation

@mrgenty

@mrgenty mrgenty commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Summary

Replaces the bundled LibreSpeed CLI with a built-in C# client for Measurement Lab (M-Lab), so NetSpeed measures fast connections (1–10 Gbps) better and ships without third-party executables. Version 0.2.0.

Engine (NetSpeed.Core, new, platform-independent, AOT/trim compatible)

  • ISpeedEngine with IProgress<SpeedProgress> and cancellation; engine-neutral SpeedResult.
  • Locate API v2 discovery with access tokens; candidates ranked by TCP-handshake RTT.
  • MSAK throughput1 with 4 parallel streams, automatic fallback to ndt7 when MSAK has no capacity or every server refuses.
  • 10 s download and 10 s upload. The headline value excludes the first 2 s (ramp-up) and the idle close-handshake tail; the full-phase average is reported too.
  • Upload throughput from server-side counters, as the ndt7 spec recommends.
  • Idle latency and jitter via TCP handshakes; latency under load during both phases; bufferbloat grade.
  • JSON via source generation only; HttpClient and ClientWebSocket, no external processes.

Extension UI

  • First-run consent notice: M-Lab publishes results, including the public IP, as open data. Consent is stored locally and can be withdrawn.
  • Live Mbps, Cancel, result with latency, jitter and bufferbloat, and Copy result (IP left out).
  • Local limit of 40 tests per 24 hours (M-Lab AUP for interactive users); clear error messages.

Removed

  • LibreSpeed CLI, its LGPL notice, scripts/Prepare-LibreSpeed.ps1 and the CI download steps.

Docs and CI

  • New PRIVACY.md (the M-Lab AUP requires a published privacy policy for third-party clients); README, SECURITY, THIRD_PARTY_NOTICES, CHANGELOG and PROJECT_INFO updated.
  • New cross-platform test project; the debug workflow runs it on Linux before the Windows MSIX builds, and the release workflow runs it before packaging.

Verification

  • 63 unit tests pass on Windows. They include a loopback fake WebSocket server that exercises the real download and upload code.
  • Debug x64 build and Release MSIX publish succeed for x64 and ARM64; trim warnings come only from Microsoft SDK and WinRT assemblies.
  • One real end-to-end run against M-Lab (MSAK, 4 streams, Milan): about 1.7 Gbps down, about 450 Mbps up, 13 ms idle latency, 24 s total. That run revealed the idle-tail issue fixed in the last commit, which has not been re-run live.

Not yet verified

  • Installing the extension and using it inside Command Palette.
  • Tests on Linux: this PR's CI is the first run there.
  • Legal review of PRIVACY.md.

Platform-independent library: ISpeedEngine and neutral SpeedResult,
Locate v2 client, MSAK throughput1 (multi-stream) and ndt7 over
ClientWebSocket, steady-state throughput tracking, TCP-handshake
latency/jitter, local consent and daily fair-use limit.
JSON via source generation; AOT/trim compatible.
Covers throughput math, latency stats, Locate parsing, measurement
parsing, query building, consent store and a loopback WebSocket
fake server exercising download/upload phases.
- New page flow: first-run M-Lab data-policy consent (stored locally),
  live Mbps during download/upload, cancel, result with latency,
  jitter, loaded latency/bufferbloat and a Copy result command.
- Local fair-use limit of 40 tests per 24 hours (M-Lab AUP).
- Remove the bundled LibreSpeed CLI, its parser and Prepare script.
- Reference NetSpeed.Core; add Core and tests to the solution.
- Version 0.2.0.
Debug workflow gains a Linux unit-test job that gates the Windows
MSIX builds; the release workflow runs the tests before packaging.
Add PRIVACY.md (required by the M-Lab AUP for third-party clients),
rewrite README engine and limits sections, update SECURITY.md,
THIRD_PARTY_NOTICES.md, CHANGELOG.md and PROJECT_INFO.txt.
A real MSAK run showed ~1 s with no data at the end of each phase
(server finished, waiting for close), which pulled the headline
download value from ~1720 to 1535 Mbps. Both the steady-state and
average figures now end at the first sample that reached the final
byte count.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T17:47:03.205924Z 02a0272 PR opened
🔒 Security Review ✅ Completed 2026-11-27T17:43:29.486911Z 02a0272 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 02a027281d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread NetSpeed.Core/Mlab/PhaseRunner.cs Resolved
Comment thread NetSpeed.Core/Mlab/PhaseRunner.cs Resolved
- Each stream starts reading (or uploading) as soon as its own
  WebSocket handshake completes, instead of waiting for every
  stream to connect. The phase clock starts at the first connection
  and each upload stream sends for the full duration from its own
  start. A slow or failing stream no longer delays or distorts the
  others (msak-server starts its timed test at upgrade).
- A phase that connected but closed before any payload is now a
  ServerUnavailableException, so the engine tries the next server or
  falls back to ndt7 instead of reporting 0 Mbps.
- Loopback tests for both cases.
Client bytes queued into a socket the server immediately closed were
counted as transferred, making the empty-phase check flaky for
uploads.
- Developer name g_ in the UI, manifest display name, LICENSE and
  PRIVACY.md. Package identity and publisher CN are unchanged: they
  must match the signing certificate and existing installs.
- Remove SECURITY.md, THIRD_PARTY_NOTICES.md, PROJECT_INFO.txt and
  scripts/Install-Package.ps1; condense README.
- CHANGELOG: 0.2.0 dated 2026-11-27.
@mrgenty
mrgenty merged commit 9a4c3f8 into main Nov 27, 2026
3 checks passed
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