SpeedTestLite Extension V1
SpeedTestLite is a non-visible extension to measure Download Speed, Upload Speed, and Ping (plus instant/average throughput, jitter, packet loss) directly from your Kodular/AI2 app.
It is Java 7–compatible and uses no external libraries — just import the AIX and go.
Highlights
- Multi-threaded download test with live progress (instant & average Mbps)
- Multi-threaded upload test (you provide the upload endpoint)
- Ping test (uses
/system/bin/ping
when available; falls back toInetAddress.isReachable
) - Progress & final metrics in JSON
- Adjustable HTTP timeouts
- Helper to read local IP
Installation
- Import
SpeedTestLite.aix
into your project. - Drag the SpeedTestLite (non-visible) component onto your screen.
- Ensure the app has INTERNET permission (enabled by default).
Properties
Property | Type | Description |
---|---|---|
ConnectTimeoutMs |
Number | HTTP connect timeout in ms (default 8000). |
ReadTimeoutMs |
Number | HTTP read timeout in ms (default 8000). |
LocalIp() |
Text | Best-effort local IP address of the device. |
Functions (Blocks)
Function | Parameters | What it does |
---|---|---|
StartDownloadTest(url, durationSec, threads, bufferKB) |
Text , Number , Number , Number |
Starts a download test against url . Use a large/static file on a fast server. |
StartUploadTest(url, durationSec, threads, payloadKB) |
Text , Number , Number , Number |
Starts an upload test (binary POST) to your endpoint. |
StartPingTest(host, count, intervalMs, timeoutMs) |
Text , Number , Number , Number |
Sends pings and measures RTT, jitter, loss. |
Cancel() |
— | Cancels any running test. |
Suggested ranges
durationSec
≥ 10 for stable readingsthreads
download: 1–8; upload: 1–4bufferKB
64–256 (download)payloadKB
128–1024 (upload)
Events
Event | Parameters | Notes |
---|---|---|
OnStatus(message) |
Text |
Informational logs. |
OnError(message) |
Text |
Startup/runtime errors. |
OnDownloadProgress(bytesTotal, instMbps, avgMbps, elapsedMs) |
Number , Number , Number , Number |
Fires ~every 500 ms. |
OnDownloadComplete(jsonMetrics) |
Text (JSON) |
Final download metrics. |
OnUploadProgress(bytesTotal, instMbps, avgMbps, elapsedMs) |
Number , Number , Number , Number |
Fires ~every 500 ms. |
OnUploadComplete(jsonMetrics) |
Text (JSON) |
Final upload metrics. |
OnPingProgress(seq, rttMs) |
Number , Number |
Per-reply RTT. |
OnPingComplete(jsonMetrics) |
Text (JSON) |
Summary: min/avg/max/jitter/loss. |
Example final payloads
Download
{
"type":"download",
"url":"http://example.com/100MB.bin",
"threads":4,
"durationSec":12,
"bytesTotal":123456789,
"avgMbps":54.32,
"elapsedMs":12045
}
Upload
{
"type":"upload",
"url":"https://your-server.com/upload-test",
"threads":2,
"durationSec":12,
"bytesTotal":73400320,
"avgMbps":39.75,
"elapsedMs":12036,
"payloadBytesPerRequest":262144
}
Ping
{
"type":"ping",
"host":"1.1.1.1",
"count":20,
"sent":20,
"received":20,
"lossPercent":0.0,
"minMs":9.34,
"avgMs":14.72,
"maxMs":28.11,
"jitterMs":3.25
}
Quick Start (Blocks)
A) Download Speed
-
(Optional) set:
ConnectTimeoutMs = 8000
ReadTimeoutMs = 8000
-
Call:
call SpeedTestLite.StartDownloadTest(
url = "http://example.com/100MB.bin",
durationSec = 12,
threads = 4,
bufferKB = 128
)
-
Handle:
OnDownloadProgress(bytesTotal, instMbps, avgMbps, elapsedMs)
OnDownloadComplete(jsonMetrics)
Use a large, static file on a fast server you control or trust. Replace the sample URL accordingly.
B) Upload Speed
Requires an endpoint you control that accepts binary
POST
and closes the response quickly.
call SpeedTestLite.StartUploadTest(
url = "https://your-server.com/upload-test",
durationSec = 12,
threads = 2,
payloadKB = 256
)
Handle:
OnUploadProgress(...)
OnUploadComplete(jsonMetrics)
Minimal upload endpoint (Node/Express)
const express = require('express');
const app = express();
app.post('/upload-test', (req, res) => {
let bytes = 0;
req.on('data', c => bytes += c.length);
req.on('end', () => res.status(200).send('OK ' + bytes));
});
app.listen(8081);
C) Ping
call SpeedTestLite.StartPingTest(
host = "1.1.1.1",
count = 20,
intervalMs = 250,
timeoutMs = 1000
)
Handle:
OnPingProgress(seq, rttMs)
OnPingComplete(jsonMetrics)
D) Cancel
call SpeedTestLite.Cancel()
Recommended Parameters
- Download:
durationSec
10–20,threads
4–8,bufferKB
64–256 - Upload:
durationSec
10–20,threads
1–4,payloadKB
128–512 - Ping:
count
≥ 20,intervalMs
200–500,timeoutMs
800–1500
Accuracy Tips
- Close other network-heavy apps while testing.
- Repeat tests and take median/average.
- Choose servers geographically close for lower latency/jitter.
- Show both instant and average Mbps in your UI.
Troubleshooting
- OnError: “URL is empty” → provide a valid URL.
- Download stalls/slow → increase
threads
, verifydurationSec
, use a better file/host. - Upload doesn’t move → your endpoint must accept the body and finish the response.
- Ping shows 100% loss → target drops ICMP; try another host. Java fallback may be less precise on some networks.
- Inconsistent results → mobile/Wi-Fi conditions vary; increase duration and retry.
Limitations
- Upload testing depends on your server endpoint.
- No chunked transfer; standard
Content-Length
writes. - On some ROMs,
/system/bin/ping
may be unavailable → fallback is less precise. - Built for light diagnostics (not an official carrier benchmark).
Download
com.rasitech.speedtest.aix (29.0 KB)
License
Sample extension & docs: Apache-2.0. Use/modify with reasonable attribution.
FAQ
Q: Auto-select fastest server?
A: Not built-in. You can probe a list of URLs (latency + short throughput burst) and pick the best.
Q: Can I draw charts?
A: Yes. Feed instMbps
/avgMbps
from progress events into your chart component or canvas.
Q: Run download + upload + ping at once?
A: Possible, but results will interfere. For accuracy, run one test at a time.
Need a ready-made Blocks layout for a speed meter UI (gauges/bars) or a results screen template? Say the word and I’ll drop a plug-and-play snippet.