Skip to content

RimgaudasJ/SpeedTest

Repository files navigation

SpeedTest

Small C command-line project that:

  • detects the user location
  • finds the closest server from a local server list
  • measures download and upload speed with libcurl
  • can generate a server list enriched with latitude and longitude

Project layout

  • main.c: entry point and CLI handling
  • nest/speedtest.c: download and upload tests
  • nest/servers.c: closest-server selection and location lookup
  • nest/fetchcoords.c: Geoapify geocoding helpers
  • nest/initservers.c: enriches the raw server list with coordinates
  • nest/utils.c: shared file and curl buffer helpers
  • speedtest_server_list.json: raw server list
  • modified_speedtest_server_list.json: server list with coordinates

Dependencies

This project expects:

  • GCC or Clang
  • GNU Make
  • libcurl development package
  • cJSON development package
  • pkg-config (recommended on Linux)

Linux package examples:

  • Debian/Ubuntu:
sudo apt update
sudo apt install -y build-essential pkg-config libcurl4-openssl-dev libcjson-dev
  • Fedora/RHEL:
sudo dnf install -y gcc make pkgconf-pkg-config libcurl-devel cjson-devel
  • Arch Linux:
sudo pacman -S --needed base-devel pkgconf curl cjson
  • Alpine:
sudo apk add build-base pkgconf curl-dev cjson-dev

Windows (MSYS2 MinGW64) example:

pacman -S --needed mingw-w64-x86_64-gcc mingw-w64-x86_64-curl mingw-w64-x86_64-cjson make

Build

make

If make is not on PATH in PowerShell, use the MSYS2 shell or run:

mingw32-make

On Linux, the output binary is:

./speedtest

On Windows, the output binary is:

./speedtest.exe

CLI options

  • --make-json <file>: generate modified_speedtest_server_list.json from a server list JSON file.
  • default run: when no --make-json is given, speedtest runs by default.
  • --server, -s: detect location and print the best server only.
  • --host <host>, -H <host>: target host for manual download-only or upload-only runs.
  • --city <name> and --country <name>: override auto-detected location.
  • --dstreams <count>: force stream count used by throughput tests.
  • --download-only, -d: run only download test.
  • --upload-only, -u: run only upload test.
  • --verbose, -v: print verbose progress output.
  • --help, -h: print usage.

Examples:

./speedtest --make-json speedtest_server_list.json
./speedtest
./speedtest --download-only --host speedtest.example.com
./speedtest --upload-only --host speedtest.example.com
./speedtest --server
./speedtest --city "Vilnius" --country "Lithuania"

Windows users can replace ./speedtest with ./speedtest.exe.

--make-json updates coordinates only when latitude/longitude are missing in input entries. Download and upload actions are always hard-stopped after 15 seconds.

Notes

  • Download tests use a random4000x4000.jpg endpoint under /speedtest/.
  • Upload tests use /speedtest/upload.php.
  • Throughput rounds are time-based (not fixed-size): a short warm-up is run before measured throughput.
  • Auto stream selection still uses ramp-up, but each ramp step is now measured by duration.
  • Full automatic runs print a final summary after all actions complete.
  • Individual actions print their results at the end of the selected action.
  • Not every public speedtest host behaves the same way, so some servers may still reject one of the test endpoints.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors