Skip to content
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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Copy link
Contributor

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

Binary file not shown.
141 changes: 141 additions & 0 deletions 5GSPEED_DETAILED_ASSET/5GSPEED_DETAILED_ASSET.py
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)


31 changes: 31 additions & 0 deletions 5GSPEED_DETAILED_ASSET/METADATA/MANIFEST.json
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
}
}
1 change: 1 addition & 0 deletions 5GSPEED_DETAILED_ASSET/METADATA/SIGNATURE.DS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't include the METADATA folder in the PR

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
75d2f596aeb8c4a5b9c8d7e860eb688724197c3fcb758edb07f3190c2d2a2c3b
110 changes: 110 additions & 0 deletions 5GSPEED_DETAILED_ASSET/README.md
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.
Loading