Giter Site home page Giter Site logo

speedtest-cli's Introduction

speedtest-cli

[C Version]Command line interface for testing internet bandwidth using speedtest.net

Introduce

This project depends libcurl-devl and libexpat-devl, and can work on MAC and Linux OS.

This project is a C version of sivel/speedtest-cli, But they have some differences. I will expain more about my implement later.

Test

Run on my linux VPS:

[root@host speedtest-cli]# ./speedtest_cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from IT7 Networks (65.49.209.201)...
Selecting best server based on ping...
Bestest server: speedtest.lax.gigenet.com(1.30KM)
Server latency is 2ms
Testing download speed...
Download speed: 732.04Mbps
Testing upload speed.........................
Upload speed: 721.83Mbps

Run on my Mac OS:

~/t/s/speedtest-cli git:master ❯❯❯ ./speedtest_cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from China Telecom jiangsu (114.218.xx.xxx)...
Selecting best server based on ping...
Bestest server: hgh.unpergroup.cn(86.86KM)
Server latency is 120ms
Testing download speed........................
Download speed: 27.34Mbps
Testing upload speed.........
Upload speed: 8.85Mbps

Test Step

Speedtest.net operates entirely over HTTP for maximum compatibility. It tests ping (latency), download speed and upload speed.

Ping

  1. Get server list from speedtest.net
  2. Select 10 closest servers according to their longitude/latitude and your computer location
  3. Sends HTTP requests to the selected server, and measures the time it takes to get a response.

Download Speed

  1. Your computer downloads small binary files from the web server to the client, and we measure that download to estimate the connection speed.
  2. Based on this result, we choose how much data to download for the real test. Our goal is to pick the right amount of data that you can download in 10 seconds, ensuring we get enough for an accurate result but not take too long.
  3. Once we start downloading, we use up to four HTTP threads to saturate your connection and get an accurate measurement.
  4. Calculate speed 5 times per second, and save them into 50 slices
  5. The fastest 10% and slowest 20% of the slices are then discarded.
  6. The remaining slices are averaged together to determine the final result.

Upload Test

  1. A small amount of random data is generated in the client and sent to the web server to estimate the connection speed.
  2. Based on this result, and appropriately sized chunck of randomly generated data is selected for upload.
  3. The upload test is then performed in chunks of uniform size, pushed to the server-side script via POST.
  4. We'll use up to four HTTP threads here as well to saturate the connection.
  5. Chunks are sorted by speed, and The fastest 10% and slowest 20% of the slices are then discarded and determine the result.

speedtest-cli's People

Contributors

divinity76 avatar haibbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

speedtest-cli's Issues

can't run correctly beacause of incorrect CA certificates

./speedtest_cli

Retrieving speedtest.net configuration...
curl_easy_perform() failed: Peer certificate cannot be authenticated with given CA certificates
Retrieving speedtest.net server list...
curl_easy_perform() failed: Peer certificate cannot be authenticated with given CA certificates
Testing from ()...
Selecting best server based on ping...
curl_easy_perform() failed: Couldn't resolve host name 0
curl_easy_perform() failed: Couldn't resolve host name 0
curl_easy_perform() failed: Couldn't resolve host name 0
curl_easy_perform() failed: Couldn't resolve host name 0
curl_easy_perform() failed: Couldn't resolve host name 0
Bestest server: (0.00KM)
curl_easy_perform() failed: Couldn't resolve host name 0

no download and upload results

OS = ubuntu 20.04

Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from PT Telkom Indonesia (110.138.90.92)...
Selecting best server based on ping...
Bestest server: (0.00KM)

Use specific server

Hi, I wish use specific server, but failed to get list, and crash when I try:
user@amber:/speedtest-cli$ ./speedtest_cli -l
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from Confiared S.r.l. (45.225.75.4)...
Selecting best server based on ping...
Bestest server: speed.intercorp.com.bo:8080(212.53KM)
Server latency is 70ms
Testing download speed...............
Download speed: 43.42Mbps
Testing upload speed.................
Upload speed: 24.62Mbps
user@amber:
/speedtest-cli$ ./speedtest_cli -s http://speedtest1.cotas.com.bo:8080/speedtest/upload.php
Server latency is 151ms
Testing download speed...............
Download speed: 23.73Mbps
Segmentation fault (core dumped)

Ability to specify server locale

Longitude and latitude can be a good start for determining a list of test servers but geographical location doesn't always determine the shortest path between two hosts. Route configuration and availability determine most of the shortest path weights.

For instance, I know by running other tests and talking to network techs at various ISPs the most of our local ISPs hit the Internet backbone in Los Angeles. Compared to the distance to San Francisco, Los Angeles is twice the physical distance from my current location (on the southern Oregon coast). However, I consistently get much better ping times and file transfer rates to hosts in Los Angeles than I do in San Francisco.

Using the speedtest-cli (which is a great tool, by the way, and thank you!) I cannot seem to list or test against anything but what the program finds as the physically closest servers. I tried to search for a list of servers and did find some, but the hosts that I have tried are rejected by the program as "unknown". (ERROR: No matched servers: 5031 -- ERROR: No matched servers: 16974 -- etc.)

Is there a way that --list-all could be implemented so that a person could see all available servers worldwide (probably piped to a file for sorting) in order to choose from current hosts? Better yet, the ability to list current hosts by a hard-coded list of regions/states/countries/...?

Thanks for reading this.

Again, thanks for the tool.

Cheers,

-bob

missing a license

ILIKEANAL but you should probably add a license,

if you want people to do whatever they want, even using the code without crediting you, then maybe the CC0 is a good fit

if you want people to give you credit for using your code, but be otherwise free to do whatever they want, i suggest the MIT license

or if you just hate licenses and want to tell people that they're free to do whatever they want, maybe try the WTFPL license

(i have mostly been using the "The Unlicense" myself, but many people smarter than myself says that the CC0 license makes "The Unlicense" obsolete, and CC0 should always be used instead of Unlicense, but idk.)

"Parse client failed"

running the git-master speedtest_cli ( commit 001ad19 ), i get

root@1:/temp/speedtest-cli# ./speedtest_cli
Retrieving speedtest.net configuration...
Parse client failed

.. haven't looked into it, but i guess they changed the XML response somehow and it broke your parsing?

broken? and returns 255

root@x2ratma:/speedtest-cli# git log | head -1
commit bf70b1c93053fe1e4253143e435127fe71d78b45
root@x2ratma:/speedtest-cli# git diff
root@x2ratma:/speedtest-cli# make
gcc main.c -lpthread -lcurl -lexpat -lm -o speedtest_cli
root@x2ratma:/speedtest-cli# ./speedtest_cli
Retrieving speedtest.net configuration...
Retrieving speedtest.net server list...
Testing from DATACITY (45.62.204.210)...
Selecting best server based on ping...
Bestest server: (0.00KM)
root@x2ratma:/speedtest-cli# echo $?
255
root@x2ratma:/speedtest-cli# uname -a
Linux x2ratma 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux
root@x2ratma:/speedtest-cli# cat /etc/*release*
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

main.c:10:10: fatal error: expat.h: No such file or directory

root@1:/temp/speedtest-cli# make
gcc main.c -lcurl -lexpat -lm -o speedtest_cli
main.c:10:10: fatal error: expat.h: No such file or directory
 #include "expat.h"
          ^~~~~~~~~
compilation terminated.
Makefile:2: recipe for target 'speedtest_cli' failed
make: *** [speedtest_cli] Error 1
root@1:/temp/speedtest-cli#

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.