# cloudflarepycli
Python CLI and python class for retrieving user's realtime performance statistics.
## Purpose
Retrieve near-term performance data about the service provided to a user by an ISP. The data includes up and download speeds, latency, and jitter. The CLI makes it possible to pipe the data to other processes for possible uploading, analysis etc. and/or to build a GUI for displaying current and past data. The cloudflareclass.py module is useful for varying the types of test that are done. I will use both in future projects to expand the functionality.
## Install
pip install cloudflarepycli \
Windows users must also: pip install wres
## CLI usage
Type 'cfspeedtest' in the environment where you installed the package. Note that this is a shell command, not a Python command.
### Options
-h, --help show help message and exit
--debug log network io
--json write json to sysout instead of formatted results
--version show program's version number and exit
## Cloudflareclass Documentation
The Cloudflare Connection Testing Class is a Python module that facilitates testing the speed and latency of your internet connection to Cloudflare's servers. It utilizes the `requests` library to perform various tests and provides insights into download and upload speeds, latency, and other connection metrics.
### Features
- Measures download and upload speeds to Cloudflare's servers.
- Calculates latency and jitter for connection stability assessment.
- Provides information about your IP address, ISP, test location, and more.
- Easy-to-use class interface to conduct various connection tests.
### Function arguments
```python
cloudflare(thedict=None,debug=False,print=True,downtests=None,uptests=None,latencyreps=20)
```
- `thedict`: dictionary to store results in
- if not passed in, created here
- if passed in, used and update - allows keeping partial results from previous runs
- each result has a key and the entry is a dict with "time" and "value" items
- `debug`: if True, turns on io logging for debugging
- `printit`: if True, results are printed as well as added to the dictionary
- `downtests`: tuple of download tests to be performed
- if None, four download tests are performed consecutively: 100kB, 1MB, 10MB, and 25MB
- format is ((size, reps, label)......)
- size: size of block to download
- reps: number of times to repeat test
- label: text label for test - also becomes key in the dict
- `uptests`: tuple of upload tests to be performed
- if None, three upload tests are performed consecutively: 100kB, 1MB, and 10MB
- format is ((size, reps, label)......)
- size: size of block to upload
- reps: number of times to repeat test
- label: text label for test - also becomes key in the dict
- `latencyreps`: number of repetitions for latency test
#### Usage
The `cloudflare` class provides methods to perform various connection tests and retrieve relevant information. Here's a brief overview of its main methods:
- `runalltests()`: Runs a full suite of tests, including latency, jitter, download, and upload tests. Returns a dictionary with test results.
- `getfulldata()`: Retrieves information about your IP address, ISP, test location, and more.
- `download(numbytes, iterations)`: Runs download tests for the specified number of bytes and iterations. Returns timing results.
- `upload(numbytes, iterations)`: Runs upload tests for the specified number of bytes and iterations. Returns timing results.
Refer to the `cloudflareclass.py`` file for detailed documentation on each method and its parameters.
### Stand-alone usage
#### Getting Started
1. Install the required dependencies:
```bash
pip install requests numpy
```
2. Download the cloudflareclass.py file and include it in your project.
3. Import the cloudflare class in your Python script:
```python
from cloudflareclass import cloudflare
```
4. Create an instance of the cloudflare class and run tests:
```python
cf = cloudflare()
results = cf.runalltests()
print(results)
```
#### Example
```python
from cloudflareclass import cloudflare
cf = cloudflare()
results = cf.runalltests()
print(results)
```
## Source repository
https://github.com/tevslin/cloudflarepycli
## How it works
Tests for latency are done by requesting one byte packets from Cloudflare, measuring the elapsed time to get a response, and subtracting the server processing time taken from the header in the returned message. Jitter is computed as the mean of the absolute difference between the arrival of consecutive requests.
The cloudflareclass.py module makes Python requests to various subaddresses of [speed.cloudflare.com](https://speed.cloudflare.com). Their API is not documented, as far as I know, and so that is a vulnerability for this code.
Mirroring the performance of the Cloudflare webpage, the CLI does multiple uploads and downloads with different block sizes and the 90th percentile of all these tests is used for calculating up and download times. Results are similar to those obtained from the webpage. Tests can be varied using the cloudflareclass module.
Unlike Ookla's speedtest CLI, Cloudflare does not require downloading a licensed exe. Cloudflare uses test sites from its own network of caching and hosting centers. This is useful because much of the content users would be retrieving is actually coming from these centers. On the other hand, coverage may be thin in some parts of the world.
## Privacy
No identifying information is sent to any website other than the IP address which servers can see in an HTTP request. Cloudflare can probably deduce something from the tests it runs. No results are sent anywhere. Because this an application and not running in a browser, there are no cookies.
Full source is available in this package.
## Background
Billions of federal dollars are being disbursed to improve broadband availability and quality, especially in rural areas. Tools are needed to assure that ISPs deliver the quality they promise. This software is a pro bono contribution to getting those tools written.
## Disclaimers
No claims of any sort are made for this software. It has been tested on Windows 10 and 11, MacOS, and Raspberry Pi OS and should work on other Linux versions but not tested. Use and/or redistribute solely at your own risk. No commitment is made to maintain this software. As noted above, changes made by Cloudflare might break the functionality.
I have no affiliation with Cloudflare, any hosting service, or any ISP (except as a customer).
Raw data
{
"_id": null,
"home_page": "https://github.com/tevslin/cloudflarepycli",
"name": "cloudflare-speedtest",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "speedtest, cloudflare, latency, jitter",
"author": "\"Tom Evslin\"",
"author_email": "tevslin@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/de/07/bdf0dd3d38bc55ad412c4952bacc2fb59af0c04fe2ab9cb0bc8fdce4bc0c/cloudflare_speedtest-1.8.2.tar.gz",
"platform": null,
"description": "# cloudflarepycli\n\nPython CLI and python class for retrieving user's realtime performance statistics.\n\n## Purpose\n\nRetrieve near-term performance data about the service provided to a user by an ISP. The data includes up and download speeds, latency, and jitter. The CLI makes it possible to pipe the data to other processes for possible uploading, analysis etc. and/or to build a GUI for displaying current and past data. The cloudflareclass.py module is useful for varying the types of test that are done. I will use both in future projects to expand the functionality.\n\n## Install\n\npip install cloudflarepycli \\\nWindows users must also: pip install wres\n\n## CLI usage\n\nType 'cfspeedtest' in the environment where you installed the package. Note that this is a shell command, not a Python command.\n\n### Options\n\n -h, --help show help message and exit\n \n --debug log network io\n \n --json write json to sysout instead of formatted results\n \n --version show program's version number and exit\n \n## Cloudflareclass Documentation\n\nThe Cloudflare Connection Testing Class is a Python module that facilitates testing the speed and latency of your internet connection to Cloudflare's servers. It utilizes the `requests` library to perform various tests and provides insights into download and upload speeds, latency, and other connection metrics.\n\n### Features\n\n- Measures download and upload speeds to Cloudflare's servers.\n- Calculates latency and jitter for connection stability assessment.\n- Provides information about your IP address, ISP, test location, and more.\n- Easy-to-use class interface to conduct various connection tests.\n\n### Function arguments\n\n ```python\n cloudflare(thedict=None,debug=False,print=True,downtests=None,uptests=None,latencyreps=20)\n ```\n\n\n- `thedict`: dictionary to store results in\n - if not passed in, created here\n - if passed in, used and update - allows keeping partial results from previous runs\n - each result has a key and the entry is a dict with \"time\" and \"value\" items\n- `debug`: if True, turns on io logging for debugging\n- `printit`: if True, results are printed as well as added to the dictionary\n- `downtests`: tuple of download tests to be performed\n - if None, four download tests are performed consecutively: 100kB, 1MB, 10MB, and 25MB\n - format is ((size, reps, label)......)\n - size: size of block to download\n - reps: number of times to repeat test\n - label: text label for test - also becomes key in the dict\n- `uptests`: tuple of upload tests to be performed\n - if None, three upload tests are performed consecutively: 100kB, 1MB, and 10MB\n - format is ((size, reps, label)......)\n - size: size of block to upload\n - reps: number of times to repeat test\n - label: text label for test - also becomes key in the dict\n- `latencyreps`: number of repetitions for latency test\n\n#### Usage\n\nThe `cloudflare` class provides methods to perform various connection tests and retrieve relevant information. Here's a brief overview of its main methods:\n\n- `runalltests()`: Runs a full suite of tests, including latency, jitter, download, and upload tests. Returns a dictionary with test results.\n- `getfulldata()`: Retrieves information about your IP address, ISP, test location, and more.\n- `download(numbytes, iterations)`: Runs download tests for the specified number of bytes and iterations. Returns timing results.\n- `upload(numbytes, iterations)`: Runs upload tests for the specified number of bytes and iterations. Returns timing results.\n\nRefer to the `cloudflareclass.py`` file for detailed documentation on each method and its parameters.\n\n### Stand-alone usage\n#### Getting Started\n\n1. Install the required dependencies:\n ```bash\n pip install requests numpy\n ```\n2. Download the cloudflareclass.py file and include it in your project.\n3. Import the cloudflare class in your Python script:\n ```python\n from cloudflareclass import cloudflare\n ```\n4. Create an instance of the cloudflare class and run tests:\n ```python\n cf = cloudflare()\n results = cf.runalltests()\n print(results)\n ```\n\n#### Example\n\n```python\nfrom cloudflareclass import cloudflare\n\ncf = cloudflare()\nresults = cf.runalltests()\nprint(results)\n```\n\n## Source repository\n\nhttps://github.com/tevslin/cloudflarepycli\n\n## How it works\n\nTests for latency are done by requesting one byte packets from Cloudflare, measuring the elapsed time to get a response, and subtracting the server processing time taken from the header in the returned message. Jitter is computed as the mean of the absolute difference between the arrival of consecutive requests.\n\nThe cloudflareclass.py module makes Python requests to various subaddresses of [speed.cloudflare.com](https://speed.cloudflare.com). Their API is not documented, as far as I know, and so that is a vulnerability for this code.\n\nMirroring the performance of the Cloudflare webpage, the CLI does multiple uploads and downloads with different block sizes and the 90th percentile of all these tests is used for calculating up and download times. Results are similar to those obtained from the webpage. Tests can be varied using the cloudflareclass module.\n\nUnlike Ookla's speedtest CLI, Cloudflare does not require downloading a licensed exe. Cloudflare uses test sites from its own network of caching and hosting centers. This is useful because much of the content users would be retrieving is actually coming from these centers. On the other hand, coverage may be thin in some parts of the world.\n\n## Privacy\n\nNo identifying information is sent to any website other than the IP address which servers can see in an HTTP request. Cloudflare can probably deduce something from the tests it runs. No results are sent anywhere. Because this an application and not running in a browser, there are no cookies.\n\nFull source is available in this package.\n\n## Background\n\nBillions of federal dollars are being disbursed to improve broadband availability and quality, especially in rural areas. Tools are needed to assure that ISPs deliver the quality they promise. This software is a pro bono contribution to getting those tools written. \n\n## Disclaimers\n\nNo claims of any sort are made for this software. It has been tested on Windows 10 and 11, MacOS, and Raspberry Pi OS and should work on other Linux versions but not tested. Use and/or redistribute solely at your own risk. No commitment is made to maintain this software. As noted above, changes made by Cloudflare might break the functionality.\n\nI have no affiliation with Cloudflare, any hosting service, or any ISP (except as a customer).\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "\"Python CLI and python class for retrieving user's realtime performance statistics\"",
"version": "1.8.2",
"project_urls": {
"Bug Tracker": "https://github.com/tevslin/cloudflarepycli/issues",
"Homepage": "https://github.com/tevslin/cloudflarepycli"
},
"split_keywords": [
"speedtest",
" cloudflare",
" latency",
" jitter"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "74f49d28b3622a4d814fc8455acd3cb08395e0c3df0eb0cb90bf9f43e2af5770",
"md5": "0a8d142a4ffa1ef34b5b32a88fa9668d",
"sha256": "65de88f083ee4034c6991c2999eee47d61cc952aca0f36310661cf0031feeba5"
},
"downloads": -1,
"filename": "cloudflare_speedtest-1.8.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0a8d142a4ffa1ef34b5b32a88fa9668d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8397,
"upload_time": "2024-06-18T23:01:37",
"upload_time_iso_8601": "2024-06-18T23:01:37.937801Z",
"url": "https://files.pythonhosted.org/packages/74/f4/9d28b3622a4d814fc8455acd3cb08395e0c3df0eb0cb90bf9f43e2af5770/cloudflare_speedtest-1.8.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "de07bdf0dd3d38bc55ad412c4952bacc2fb59af0c04fe2ab9cb0bc8fdce4bc0c",
"md5": "93b3c93ca014cc27208bc6fd1258754d",
"sha256": "f3a2dc2074c77577a7d7e87cd09fe3ce64c04b7dbd2cd3fa7298478a737d31ce"
},
"downloads": -1,
"filename": "cloudflare_speedtest-1.8.2.tar.gz",
"has_sig": false,
"md5_digest": "93b3c93ca014cc27208bc6fd1258754d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 7452,
"upload_time": "2024-06-18T23:01:42",
"upload_time_iso_8601": "2024-06-18T23:01:42.625225Z",
"url": "https://files.pythonhosted.org/packages/de/07/bdf0dd3d38bc55ad412c4952bacc2fb59af0c04fe2ab9cb0bc8fdce4bc0c/cloudflare_speedtest-1.8.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-18 23:01:42",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "tevslin",
"github_project": "cloudflarepycli",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "cloudflare-speedtest"
}