SpeedTestLite Extension V1

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.



:sparkles: 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 to InetAddress.isReachable)
  • Progress & final metrics in JSON
  • Adjustable HTTP timeouts
  • Helper to read local IP

:puzzle_piece: Installation

  1. Import SpeedTestLite.aix into your project.
  2. Drag the SpeedTestLite (non-visible) component onto your screen.
  3. Ensure the app has INTERNET permission (enabled by default).

:wrench: 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.

:test_tube: 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 readings
  • threads download: 1–8; upload: 1–4
  • bufferKB 64–256 (download)
  • payloadKB 128–1024 (upload)

:satellite_antenna: 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
}

:rocket: Quick Start (Blocks)

A) Download Speed

  1. (Optional) set:

    • ConnectTimeoutMs = 8000
    • ReadTimeoutMs = 8000
  2. Call:

call SpeedTestLite.StartDownloadTest(
  url = "http://example.com/100MB.bin",
  durationSec = 12,
  threads = 4,
  bufferKB = 128
)
  1. 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()

:control_knobs: 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

:straight_ruler: 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.

:lady_beetle: Troubleshooting

  • OnError: “URL is empty” → provide a valid URL.
  • Download stalls/slow → increase threads, verify durationSec, 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.

:warning: 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)


:page_facing_up: License

Sample extension & docs: Apache-2.0. Use/modify with reasonable attribution.


:person_raising_hand: 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.

3 Likes

Thank you for your contribution, it’s a nice extension. Please add screenshots and aia file. This will serve as an example.

1 Like

post some blocks and aia thanks