iperf3-lib
iperf3-lib is a typed Python wrapper around the native iperf3 libiperf
library. It uses CFFI's ABI mode and provides synchronous and asynchronous
client APIs, a minimal server wrapper, Pydantic configuration, and typed result
models.
Support
| Component | Supported and tested | Notes |
|---|---|---|
| Python | 3.12, 3.13, 3.14 | Python 3.15 prereleases run in a non-blocking preview job. |
| libiperf | 3.19.1, 3.21 | 3.19.1 is the minimum supported security baseline; 3.21 is the default. |
| Platform | Linux | CI runs on Linux. macOS and FreeBSD are unverified; Windows requires a compatible DLL and is best-effort. |
| Protocol | TCP, UDP, SCTP | SCTP also requires operating-system and libiperf SCTP support. |
The Python package does not bundle libiperf. Install a supported iperf3
release from your operating-system packages or from the
official iperf releases. If the
library is outside the dynamic loader's normal search path, set IPERF3_LIB to
the full shared-library path before using a client or server.
export IPERF3_LIB=/usr/local/lib/libiperf.so
Current limitations
- MPTCP cannot be selected through libiperf's published ABI. Setting
ClientConfig(mptcp=True)raisesUnsupportedFeatureError. - Streaming JSON is not exposed. Setting
json_stream=TrueraisesUnsupportedFeatureError; normal runs still return one complete JSON result. Client.arun()andServer.aserve_once()run blocking libiperf calls in an executor thread. Cancelling the awaiting task does not stop the native call.- Concurrent operations in the same process are not supported. Serialize runs or isolate them in separate processes.
Server.stop()is cooperative: it prevents the next server iteration but cannot interrupt an active blockingiperf_run_server()call.
Install
For an application using uv:
uv add iperf3-lib
With pip:
python -m pip install iperf3-lib
Importing the package does not load the native library immediately. The first
client/server operation will raise IperfLibraryError if a compatible
libiperf cannot be found.
Client example
Start an iperf3 server separately, then run:
from iperf3_lib import Client, ClientConfig, Protocol
config = ClientConfig(
server="127.0.0.1",
duration=2,
parallel=2,
protocol=Protocol.TCP,
)
result = Client(config).run()
if result.ok:
print(f"{result.summary_mbps:.2f} Mbps")
else:
print(f"iperf failed: {result.error}")
For UDP, the wrapper applies libiperf's 1,048,576 bits/s default rate and leaves
block-size selection to libiperf's dynamic path unless a value is supplied.
SCTP defaults to a 65,536-byte block. Set rate or blksize explicitly to
override these values.
The asynchronous API has the same configuration and result behavior:
result = await Client(config).arun()
Server example
from iperf3_lib import Server
server = Server(port=5201, bind_host="127.0.0.1")
server.run_once()
serve_forever() reuses one libiperf test object across sequential runs. See
the cooperative shutdown limitation above before embedding it in a service.
Contributing
Install uv 0.11.31 and synchronize the committed lockfile:
uv sync --frozen --dev
With a supported native libiperf available:
make check
uv run --frozen pytest
The reproducible Linux route builds libiperf and runs the complete suite in Docker:
make docker-test
You can override either compatibility dimension:
make docker-test PYTHON_BASE=python:3.14-slim IPERF3_VERSION=3.19.1
make check never changes source files. Run make format explicitly to apply
formatting and safe lint fixes. See CONTRIBUTING.md for the
full development and review checklist.
Changelog
0.2.0 — 2026-07-22
- Correctly apply and verify TCP, UDP, and SCTP protocol selection.
- Fix server bind-address handling, lazy-load libiperf, and keep JSON output out of the host process's stdout.
- Validate native option limits and reject unsupported MPTCP/streaming-JSON requests explicitly.
- Add Python 3.14 and libiperf 3.21 support, refreshed dependencies, reproducible CI/release tooling, and stronger native integration coverage.
0.1.0
- Initial CFFI ABI wrapper for libiperf clients and servers.
- Typed Pydantic configuration/results and asynchronous convenience methods.
- Docker compatibility testing and PyPI release automation.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iperf3_lib-0.2.0.tar.gz.
File metadata
- Download URL: iperf3_lib-0.2.0.tar.gz
- Upload date:
- Size: 75.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1dfd57a58e2fd926ce3c947cfbb180c88fe3fb8d7f7891c6ed7a2dd6faeb11cc
|
|
| MD5 |
7d637d5ef47936edf566ca194b4a1cce
|
|
| BLAKE2b-256 |
e7493e6c2829a1f1a0d92fee8e1b2d4c16eae68b5d415f83e589bdc546e1db7c
|
Provenance
The following attestation bundles were made for iperf3_lib-0.2.0.tar.gz:
Publisher:
release.yml on dariuszpanas/iperf3-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iperf3_lib-0.2.0.tar.gz -
Subject digest:
1dfd57a58e2fd926ce3c947cfbb180c88fe3fb8d7f7891c6ed7a2dd6faeb11cc - Sigstore transparency entry: 2220949455
- Sigstore integration time:
-
Permalink:
dariuszpanas/iperf3-lib@e41bfb34faecab1c5119fcf3d2d9247235c7a1a2 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dariuszpanas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e41bfb34faecab1c5119fcf3d2d9247235c7a1a2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file iperf3_lib-0.2.0-py3-none-any.whl.
File metadata
- Download URL: iperf3_lib-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9215d1ca0f358178f97ef867768f9c31a8791d107c4d5d27865a231e2ff03eee
|
|
| MD5 |
198acfe31ac659edee36af493ece2fef
|
|
| BLAKE2b-256 |
e05a6d10e98d7c95e12c84125282e173d9a2eea2c797a94bbcb68ed021a5ffed
|
Provenance
The following attestation bundles were made for iperf3_lib-0.2.0-py3-none-any.whl:
Publisher:
release.yml on dariuszpanas/iperf3-lib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iperf3_lib-0.2.0-py3-none-any.whl -
Subject digest:
9215d1ca0f358178f97ef867768f9c31a8791d107c4d5d27865a231e2ff03eee - Sigstore transparency entry: 2220949814
- Sigstore integration time:
-
Permalink:
dariuszpanas/iperf3-lib@e41bfb34faecab1c5119fcf3d2d9247235c7a1a2 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/dariuszpanas
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e41bfb34faecab1c5119fcf3d2d9247235c7a1a2 -
Trigger Event:
push
-
Statement type: