Skip to content

winnie264/myspeed.ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myspeed.ai


Source for myspeed.ai — a C++ HTTPS speed-test server that measures download speed, RTT, and connection quality. Clients get a session UUID, run parallel download tests, and retrieve aggregated speed and a signal-strength metric. Signal strength is derived from an RTT-to-RSSI mapping (using RTT variance and data/rttvartorssi.csv). The CSV holds normalized RTT data collected on a mobile device over 3G, 2G, WiFi, and wired; it is not actual radio/Wi‑Fi RSSI.

Features

  • HTTPS server (OpenSSL) with TLS certificate support
  • Session-based testing: client obtains a UUID, then runs multi-thread download tests
  • Download test: configurable payload sizes (2 MB, 10 MB, or ~140 MB) over up to 12 concurrent connections
  • Metrics: download speed (Kbps), RTT, RTT variance, and a signal-strength value from RTT→RSSI mapping. RTT is read via the Linux socket API getsockopt(2) with TCP_INFO (struct tcp_info: tcpi_rtt / tcpi_min_rtt, tcpi_rttvar).
  • Static file serving: optional www root for a speed-test web UI
  • CORS enabled for browser clients

Requirements

  • C++17 compiler (e.g. g++)
  • OpenSSL (libssl, libcrypto) — development headers and libraries
  • zlib (libz)
  • pthread

On Debian/Ubuntu:

sudo apt install build-essential libssl-dev zlib1g-dev

Project structure

myspeed.ai/
├── src/           # Server source (main.cpp, utility.cpp, etc.)
├── include/       # Headers (OpenSSL, httplib, json, rapidcsv, loguru)
├── lib/           # Optional static libs (e.g. OpenSSL) if not system-installed
├── data/          # Required: rttvartorssi.csv (normalized RTT data from mobile: 3G, 2G, WiFi, wired → RSSI mapping)
├── www/           # Optional: static files for web UI (path set in server.conf)
├── server.conf    # Server config (cert, key, www path)
├── myspeed.service # Optional systemd unit
└── Makefile

Build

make

Binary is produced at bin/netspeedsrv.

To install into bin/ (copy binary, data/, server.conf, myspeed.service):

make install

Configuration

The server reads server.conf from the current working directory at startup. Use a JSON object with:

Key Description
cert Path to TLS certificate (e.g. PEM)
privatekey Path to TLS private key
www Path to directory to serve at / (static files)
ipaddress (Optional) Bind address for HTTPS; empty = 0.0.0.0

Example (use your own paths and keep this file out of version control if it contains deployment paths):

{
  "cert": "/path/to/cert.pem",
  "privatekey": "/path/to/privkey.pem",
  "www": "/path/to/www",
  "ipaddress": ""
}

The server also expects a data/ directory in the current working directory containing rttvartorssi.csv with columns rttvar and rssi. This file is normalized RTT data collected on a mobile device over 3G, 2G, WiFi, and wired. It defines the RTT-to-RSSI mapping: RTT variance is mapped to a signal-strength (RSSI) value returned in results; it is not measured from the device’s radio.

Sample RTT and signal strength reference

Typical RTT ranges and corresponding RSSI-like signal-strength values help interpret results:

Connection type Typical RTT (ms) Typical RSSI (dBm) Quality
Wired (Ethernet) 5–25 -30 to -50 Excellent
Wi‑Fi (strong) 10–40 -40 to -60 Very good
Wi‑Fi (fair) 40–100 -60 to -75 Fair
Wi‑Fi (weak) 100–200 -75 to -85 Poor
4G/3G 30–150 -50 to -80 Variable
2G 150–500+ -80 to -90 Poor

Lower RTT and higher RSSI (closer to 0, e.g. -30) mean better connection quality. Wired links usually show lower RTT variance; wireless shows higher variance and higher RTT, especially when signal is weak.

Running

Start the server with the HTTPS port as the first argument:

./bin/netspeedsrv 443

Or from the project root (so server.conf and data/ are found):

cd /path/to/myspeed.ai
./bin/netspeedsrv 443
  • HTTPS listens on the given port (and optional ipaddress from config).
  • An HTTP server also listens on port 8080 and redirects / to https://localhost:5757 (redirect target is hardcoded; change in source if needed).
  • Logs are written to speedtest.log and speedtestinfo.log in the current working directory.

API overview

Endpoint Method Description
/speeduuid GET Create a session; returns JSON with sessionuuid and initial rtt
/download GET Download test. Query params: uuid, thread (1–12), size (1=2MB, 2=10MB, 3=~140MB)
/getspeedinfo GET Get speed result. Query params: uuid, optional init=1 for initial probe. Returns downloadspeed, rtt, rttmax, rssi

Clients should: (1) GET /speeduuid, (2) run parallel GETs to /download with the same uuid and different thread, (3) GET /getspeedinfo?uuid=... for the aggregated result.

Running as a service (Linux)

Example systemd unit is provided in myspeed.service. Adjust paths and user as needed, then:

sudo cp myspeed.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable myspeed
sudo systemctl start myspeed

Test client

A simple C++ test client lives under test/client/. It uses the httplib client to request a UUID and run a download test. Build and run from that directory according to its Makefile; point it at your server URL (e.g. in source or via config) instead of any hardcoded IP before use.

License

MIT License — see LICENSE. Uses cpp-httplib by Yuji Hirose (MIT).

About

C++ HTTPS speed-test server for myspeed.ai — measures download speed, RTT, and connection quality. Session-based testing with parallel downloads, RTT-to-RSSI signal-strength mapping. OpenSSL/TLS, CORS-ready.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors