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
main.c: entry point and CLI handlingnest/speedtest.c: download and upload testsnest/servers.c: closest-server selection and location lookupnest/fetchcoords.c: Geoapify geocoding helpersnest/initservers.c: enriches the raw server list with coordinatesnest/utils.c: shared file and curl buffer helpersspeedtest_server_list.json: raw server listmodified_speedtest_server_list.json: server list with coordinates
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-devWindows (MSYS2 MinGW64) example:
pacman -S --needed mingw-w64-x86_64-gcc mingw-w64-x86_64-curl mingw-w64-x86_64-cjson makemakeIf make is not on PATH in PowerShell, use the MSYS2 shell or run:
mingw32-makeOn Linux, the output binary is:
./speedtestOn Windows, the output binary is:
./speedtest.exe--make-json <file>: generatemodified_speedtest_server_list.jsonfrom a server list JSON file.- default run: when no
--make-jsonis 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.
- Download tests use a
random4000x4000.jpgendpoint 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.