Skip to main content

Crate linkprobe_core

Crate linkprobe_core 

Source
Expand description

Protocol-agnostic network link measurement for Rust.

linkprobe-core provides shared types, server discovery, measurement backends, and OpenMetrics formatting. The linkprobe CLI crate adds argument parsing, MQTT publish, and an HTTP scrape endpoint on top of this library.

Use this crate when you want to embed link measurement in an agent, dashboard, or test harness. Use the CLI when you want a ready-made probe with JSON, Prometheus, and MQTT exporters.

§Backends

All engines implement MeasurementEngine and run synchronously (blocking HTTP or a subprocess). Pick the backend that matches your endpoint:

BackendTypeRequiresTypical fields
LibreSpeedLibreSpeedEngineOutbound HTTPSlatency, jitter, download, upload
iperf3Iperf3Engineiperf3 on PATHlatency, jitter, download, upload; UDP adds packet loss

Optional fields on Measurement mean the backend did not report that metric for the run (for example TCP iperf3 has no packet loss).

§Example

use linkprobe_core::backends::LibreSpeedEngine;
use linkprobe_core::{MeasurementEngine, Server};

let server = Server::librespeed("https://example-librespeed/");
let engine = LibreSpeedEngine::new()?;
let measurement = engine.measure(&server)?;

if let Some(ms) = measurement.latency_ms {
    println!("latency: {ms:.1} ms");
}

Discovery helpers such as fetch_librespeed_servers and rank_by_latency need a network connection. See FAILOVER_EXTRA for list rotation behavior used by the CLI.

Re-exports§

pub use export::format_openmetrics;
pub use export::format_openmetrics_failed;

Modules§

backends
export

Structs§

Measurement
Result of one link measurement against a server.
RunResult
Outcome of one completed probe, suitable for JSON serialization or OpenMetrics export.
Server
Target server for a link measurement.
Throughput
Throughput in bits per second.

Enums§

Error
Failure from discovery, measurement, or export helpers.

Constants§

DEFAULT_IPERF3_SERVERS_URL
DEFAULT_LIBRESPEED_SERVERS_URL
FAILOVER_EXTRA
How many additional list servers the CLI may try after the preferred host fails (auto-pick and --server-id only; explicit --server URLs do not rotate).

Traits§

MeasurementEngine
Runs latency, download, upload, and optional packet-loss measurement against a Server.

Functions§

failover_candidates
Build a probe order: preferred first, then up to extra other servers by ping rank.
fetch_iperf3_servers
Download and parse an iperf3 server list from list_url.
fetch_librespeed_servers
Download and parse a LibreSpeed server list from list_url.
parse_iperf3_servers
Parse an iperf3 public server list JSON document into Server values.
parse_librespeed_servers
Parse a LibreSpeed server list JSON document into Server values.
pick_lowest_latency
Return the server with the lowest ping latency, or an error if none responded.
rank_by_latency
Ping servers and return those that responded, sorted by ascending latency (ms).
server_by_id
Look up a server by numeric list id (string match on Server::id).
servers_list_url
Pick the default iperf3 list URL when the CLI still has the LibreSpeed default configured.