-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5GSPEED #88
Open
joncampo-cradlepoint
wants to merge
1
commit into
cradlepoint:master
Choose a base branch
from
joncampo-cradlepoint:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
5GSPEED #88
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
''' | ||
|
||
Description: The 5GSPEED_DETAILED SDK application will uses Ookla Speedtest python library and designed to perform Ookla speedtest from a Cradlepoint Endpoint which will enable comprehensive and end-to-end speedtest result. | ||
|
||
Steps to use: | ||
============= | ||
perform any of the following: | ||
|
||
1. Use NCM API PUT router request to clear the asset ID and to run the SDK speedtest. Wait for 1 min, and run NCM API Get router request to get the result. | ||
|
||
2. Make the asset_id blank in NCM > Devices tab | ||
|
||
3. Go to device console and enter put 5GSPEED 1 | ||
|
||
|
||
Installation: | ||
============= | ||
Go to NCM > Tools page and load the script. Afterwards, load the script in the desired NCM Group where the router belongs | ||
|
||
|
||
Results: | ||
======== | ||
All results will be displayed in asset ID column of the router. | ||
|
||
Sample result: | ||
DL:52.54Mbps - UL:16.55Mbps - Ping:9.715ms - Server:Telstra - ISP:Vocus Communications - TimeGMT:2023-04-11T01:06:43.758382Z - URL:http://www.speedtest.net/result/14595594656.png | ||
|
||
|
||
For any questions, please reach out to developer [email protected] | ||
|
||
DISCLAIMER: | ||
========== | ||
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use. You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment. | ||
|
||
|
||
''' | ||
|
||
from csclient import EventingCSClient | ||
from speedtest import Speedtest | ||
import time | ||
|
||
def asset_id_check(path, asset_id, *args): | ||
if not asset_id: | ||
cp.log('Initiating Speedtest due to asset id empty...') | ||
#cp.put('status/5GSPEED', "1") | ||
speedtest() | ||
return | ||
|
||
#def speedtest(path, value, *args): | ||
def speedtest(): | ||
cp.log('Ongoing Speedtest...') | ||
#cp.put('config/system/asset_id', "Ongoing Speedtest. Please wait 1 minute for the result") | ||
#time.sleep(10) | ||
|
||
#servers = [] | ||
s = Speedtest() | ||
|
||
#Find the best ookla speedtest server based from latency and ping | ||
cp.log("Finding the Best Ookla Speedtest.net Server...") | ||
server = s.get_best_server() | ||
cp.log('Found Best Ookla Speedtest.net Server: {}'.format(server['sponsor'])) | ||
|
||
p = s.results.ping | ||
cp.log('Ping: {}ms'.format(p)) | ||
|
||
#Perform Download ookla download speedtest | ||
cp.log("Performing Ookla Speedtest.net Download Test...") | ||
d = s.download() | ||
cp.log('Ookla Speedtest.net Download: {:.2f} Kb/s'.format(d / 1000)) | ||
|
||
#Perform Upload ookla upload speedtest. Option pre_allocate false prevents memory error | ||
cp.log("Performing Ookla Speedtest.net Upload Test...") | ||
u = s.upload(pre_allocate=False) | ||
cp.log('Ookla Speedtest.net Upload: {:.2f} Kb/s'.format(u / 1000)) | ||
|
||
#Access speedtest result dictionary | ||
res = s.results.dict() | ||
|
||
#share link for ookla test result page | ||
share = s.results.share() | ||
|
||
t = res['timestamp'] | ||
|
||
i = res["client"]["isp"] | ||
|
||
s = server['sponsor'] | ||
|
||
#return res["download"], res["upload"], res["ping"],res['timestamp'],server['sponsor'],res["client"]["isp"], share | ||
|
||
|
||
cp.log('') | ||
cp.log('Test Result') | ||
cp.log('Timestamp GMT: {}'.format(t)) | ||
cp.log('Client ISP: {}'.format(i)) | ||
cp.log('Ookla Speedtest.net Server: {}'.format(s)) | ||
cp.log('Ping: {}ms'.format(p)) | ||
cp.log('Download Speed: {:.2f} Mb/s'.format(d / 1000 / 1000)) | ||
cp.log('Upload Speed: {:.2f} Mb/s'.format(u / 1000 / 1000)) | ||
cp.log('Ookla Speedtest.net URL Result: {}'.format(share)) | ||
|
||
download = '{:.2f}'.format(d / 1000 / 1000) | ||
upload = '{:.2f}'.format(u / 1000 / 1000) | ||
#text = 'DL:{}Mbps UL:{}Mbps - {}'.format(download, upload,share) | ||
text = 'DL:{}Mbps - UL:{}Mbps - Ping:{}ms - Server:{} - ISP:{} - TimeGMT:{} - URL:{}'.format(download, upload, p, s, i, t, share) | ||
cp.put('config/system/asset_id', text) | ||
|
||
cp.log(f'Speedtest Complete! {text}') | ||
return | ||
|
||
|
||
|
||
try: | ||
cp = EventingCSClient('5GSPEEDTEST') | ||
|
||
|
||
cp.log('Starting... To start speedtest: put status/5GSPEED 1 or make asset id blank') | ||
cp.on('put', 'config/system/asset_id', asset_id_check) | ||
cp.on('put', 'status/5GSPEED', speedtest) | ||
asset_id = cp.get('/config/system/asset_id') | ||
#cp.log(asset_id) | ||
|
||
#Performed if asset ID is blank | ||
if asset_id is "" or asset_id is None: | ||
|
||
connected = False | ||
while not connected: | ||
connected = cp.get('status/ecm/state') == 'connected' | ||
time.sleep(1) | ||
|
||
#cp.log('Detected at bootup that the asset id is blank. Starting the 5GSpeedtest in 1 minute to allow device finish its bootup...') | ||
cp.log('Detected at bootup that the asset id is blank.') | ||
#time.sleep(60) | ||
cp.log('Starting Initial 5GSpeedtest with asset id blank...') | ||
#cp.put('status/5GSPEED', '1') | ||
speedtest() | ||
|
||
time.sleep(999999) | ||
except Exception as e: | ||
cp.log(e) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"app": { | ||
"auto_start": true, | ||
"date": "2023-04-11T11:15:01.448246", | ||
"files": { | ||
"5GSPEED_DETAILED_ASSET.py": "25810756c820c1dac38685d41b6c71cd81b89b3551575109449447594f3b1d1d", | ||
"README.md": "5813f2c137692d03895573190561e477c385dbe8a9ad0f01f2010966573299b8", | ||
"_csv.py": "b778711ec11f2d4e9395436fc369710cdacc49fdbfa762e66443a6e24d542bd1", | ||
"csclient.py": "0c6a55c889daf7df554ab1d22e3290cbb45540a081a62b485036d98ef01e681b", | ||
"csv.py": "0f46b397bda6998a4b7083478f22cd02bd6454a3dd1219a5874562eb3784244d", | ||
"package.ini": "54f211020f9081ef1069ea30ce1280701678c9208f7a36cca701171c350a7698", | ||
"speedtest.py": "c9e65ec60ebc450e29a25cee0dfa558c2007922194318cbdb1c9291cffc59cfc", | ||
"start.sh": "a2c8596fbf31ac181633d57e0da44a49dc2280b16e5d5010888a962d7e611a0e", | ||
"timeit.py": "d0884d28561a0dafce6492e8f526ad53b0ad49f38e9f124573c749a4941447f4" | ||
}, | ||
"firmware_major": 7, | ||
"firmware_minor": 2, | ||
"name": "5GSPEED_DETAILED_ASSET", | ||
"notes": "Ookla speedtest from a Cradlepoint Endpoint. To run, make asset id blank", | ||
"reboot": true, | ||
"restart": true, | ||
"uuid": "a8ac42ec-352d-4320-871c-a81f42b2372f", | ||
"vendor": "Cradlepoint", | ||
"version_major": 0, | ||
"version_minor": 2 | ||
}, | ||
"pmf": { | ||
"version_major": 1, | ||
"version_minor": 0 | ||
} | ||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't include the METADATA folder in the PR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
75d2f596aeb8c4a5b9c8d7e860eb688724197c3fcb758edb07f3190c2d2a2c3b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
Application Name | ||
================ | ||
5GSPEED_DETAILED_ASSET | ||
|
||
Application Purpose | ||
=================== | ||
5GSPEED_DETAILED is an improved version of the 5GSPEED SDK. It uses Ookla Speedtest python library and designed to perform Ookla speedtest from a Cradlepoint Endpoint which will enable comprehensive and end-to-end speedtest result. | ||
This python SDK application bring the Ookla speedtest.net functionality that is normally performed by users in the LAN behind the Cradlepoint endpoint. | ||
This will provide uniformity of speedtest between the users and the Cradlepoint endpoint devices. | ||
|
||
For any questions, please reach out to developer [email protected] | ||
|
||
Application Version | ||
=================== | ||
0.1 | ||
|
||
NCOS Devices Supported | ||
====================== | ||
ALL | ||
|
||
|
||
External Requirements | ||
|
||
Once downloaded to PC, folder name needs to be renamed to 5GSPEED_DETAILED and in .tar.gz format. | ||
|
||
Installation: | ||
====================== | ||
|
||
1. Download and unzip file - | ||
|
||
https://github.com/joncampo-cradlepoint/5GSPEED_DETAILED/archive/main.zip | ||
|
||
2. Important! Rename unzipped folder to 5GSPEED_DETAILED | ||
|
||
3.a. For MAC and linux, open console, cd to downloads, then create .tar.gz using terminal command | ||
|
||
tar -czvf 5GSPEED_DETAILED.tar.gz 5GSPEED_DETAILED/* | ||
|
||
b. For Windows, use the python make.py build found in https://customer.cradlepoint.com/s/article/NCOS-SDK-v3 | ||
|
||
--- | ||
NCM Deployment | ||
|
||
4. In NCM, upload 5GSPEED_DETAILED_ASSET.tar.gz to NCM via TOOLS tab | ||
|
||
5. After that, go to Groups > Commands > Manage SDK applications and add the application | ||
|
||
|
||
Usage: | ||
====================== | ||
|
||
1. Speedtest will automatically run if Asset ID in NCM > Devices is blank. It will populate Asset ID with speedtest result and URL. | ||
|
||
2. Use NCM API to run. | ||
Use NCM API PUT router request to clear the asset ID and to run the SDK speedtest. Wait for 1 min, and run NCM API Get router request to get the result. | ||
|
||
|
||
3. You can also run 5GSPEED_DETAILED through cli console | ||
|
||
a. Go to Devices > select Device > Remote Connect > Console | ||
|
||
b. Enter the following command: | ||
|
||
put status/5GSPEED 1 | ||
|
||
c. Run log command to view output: | ||
|
||
log -f | ||
|
||
4. You can also see the result in NCM > Devices > Asset ID column of the device | ||
|
||
|
||
|
||
Expected Output | ||
=============== | ||
Info level log message of ookla speedtest.net results including Timestamp, Client ISP, Ookla Speedtest.net Server, Ping, Download speed, upload speed and the URL link of the test result. | ||
|
||
|
||
Sample output: | ||
|
||
|
||
DL:52.54Mbps - UL:16.55Mbps - Ping:9.715ms - Server:Telstra - ISP:Vocus Communications - TimeGMT:2023-04-11T01:06:43.758382Z - URL:http://www.speedtest.net/result/14595594656.png | ||
|
||
--- | ||
NCM > Devices > Asset ID: | ||
|
||
DL:26.81Mbps UL:9.09Mbps - https://www.speedtest.net/result/10690043282.png | ||
|
||
|
||
|
||
Changelog: | ||
=============== | ||
|
||
version 1.1 | ||
1. Improved bootup blank asset id detection | ||
|
||
2. Notification in asset id that speedtest is running | ||
|
||
3. @speedtest.py module libary: | ||
#11-April-2021 JWC: added to fix the speedtest cli module issue - https://github.com/sivel/speedtest-cli/pull/769 | ||
ignore_servers = list( | ||
#map(int, server_config['ignoreids'].split(',')) | ||
map(int, [server_no for server_no in server_config['ignoreids'].split(',') if server_no]) #11-April-2021 JWC: added to fix the speedtest cli module issue - https://github.com/sivel/speedtest-cli/pull/769 | ||
) | ||
|
||
|
||
DISCLAIMER | ||
=============== | ||
|
||
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use. You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't include this in PR