Skip to main content

Modern Python wrapper for iperf3 using cffi (libiperf), with async support.

Project description

iperf3-lib

Modern Python wrapper for iperf3 using cffi against libiperf.

  • Typed configs/results (Pydantic)
  • Sync + Async APIs
  • Feature detection for SCTP / bidirectional / MPTCP (when lib supports it)
  • Ready for uv workflows, ruff/ty/pytest

Quickstart

# create env & install
uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"

You need a system libiperf (install iperf3 via your package manager). To point to a non-standard library path:

export IPERF3_LIB=/usr/local/lib/libiperf.so
from iperf3_lib.config import ClientConfig, Protocol
from iperf3_lib.iperf_client import Client

cfg = ClientConfig(server="127.0.0.1", duration=2, protocol=Protocol.TCP, parallel=2)
res = Client(cfg).run()
print("OK:", res.ok, "Mbps:", f"{res.summary_mbps:.2f}", "err:", res.error)

Notes

  • Full features require a recent libiperf (iperf3 ≥ 3.19.x recommended).
  • Some symbols may not exist on older builds; we detect and degrade gracefully.
  • Integration tests are marked with @pytest.mark.integration.

Running tests

  • Run tests locally with Docker (recommended for Windows):
# build the test image (pick python base and iperf version if needed)
docker build --build-arg PYTHON_BASE=python:3.12-slim --build-arg IPERF3_VERSION=3.20 -t py-iperf3-test .

# run the full test suite inside the container (mounted volume allows editing without rebuilding)
docker run --rm -v "$(pwd):/app" py-iperf3-test bash -c "pytest -vv --cov=src --cov-report=term-missing"
  • Quick single-test run (example):
docker run --rm -v "$(pwd):/app" py-iperf3-test bash -c "pytest -q tests/test_client_integration_configs.py::test_client_various_configs\[udp_rate\] -vv"

Notes about optional features

  • MPTCP and some other features are optional and require the libiperf to be built with kernel/header support. Tests that exercise optional features will be skipped or xfailed depending on whether the built shared object exports the required symbol.

CI

  • This repository includes a GitHub Actions workflow that builds and runs the tests inside the Docker image for a matrix of Python base images and iperf versions (see .github/workflows/ci.yml).

# Changelog

## 0.1.0
- Initial release: cffi (ABI) wrapper of libiperf (client & server),
  Pydantic models, async support, ruff/ty/pytest, CI with uv.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iperf3_lib-0.1.0.tar.gz (47.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iperf3_lib-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file iperf3_lib-0.1.0.tar.gz.

File metadata

  • Download URL: iperf3_lib-0.1.0.tar.gz
  • Upload date:
  • Size: 47.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iperf3_lib-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d427b354e4dac0aff81768aeb693ae37663864cdcc7e802eb35c919322809cc8
MD5 7879261477de76aa4d8021bb3b0e1987
BLAKE2b-256 bc94dde389067716b2b63e0a4b67ac0bd5cfc8015df25b5fb1c150755d5b266b

See more details on using hashes here.

Provenance

The following attestation bundles were made for iperf3_lib-0.1.0.tar.gz:

Publisher: release.yml on dariuszpanas/iperf3-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iperf3_lib-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iperf3_lib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for iperf3_lib-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40e62336a4dcdac9af46a1b3da6fb3d1ebb278c34a2b66f8f03c239aae145438
MD5 a0ec675d24acfcfe63ba26578b0d44e8
BLAKE2b-256 b7b01d7ea23e0446d017b854203fe5f007ee4276b3001d190bb3ce10b1a98610

See more details on using hashes here.

Provenance

The following attestation bundles were made for iperf3_lib-0.1.0-py3-none-any.whl:

Publisher: release.yml on dariuszpanas/iperf3-lib

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page