Skip to main content

A tiny iperf3-like tool with JSON output (TCP/UDP)

Project description

Minimal iperf3-like network throughput tool with JSON output. Supports TCP and UDP, server and client modes.

Features

  • TCP and UDP tests

  • JSON or human-readable output

  • Optional bandwidth capping (TCP/UDP)

  • UDP packet loss estimation

  • Linux TCP congestion control selection (if available)

Installation

From PyPI (recommended):

python3 -m pip install ipyrf

From source (editable):

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -U pip build
python3 -m pip install -e .

Development

For development, install with test dependencies:

python3 -m pip install -e ".[test]"

Test Utilities (ipyrf.test)

The ipyrf.test module provides test utilities for writing your own tests:

from ipyrf.test import IPyrfBuilder, CheckCriteria, pick_free_port

def test_my_network(testdirectory):
    builder = IPyrfBuilder(testdirectory)
    port = pick_free_port()

    server = builder.build()
    client = builder.build()

    server.run_tcp_server("127.0.0.1", port)
    client.run_tcp_client("127.0.0.1", port, duration=2)

    # Check with custom criteria
    builder.check(
        (server, client),
        timeout=5,
        criteria={"min_bps": 1000000}
    )

Available classes and functions:

  • IPyrfClient: Run and monitor ipyrf instances

  • IPyrfBuilder: Builder pattern for creating test instances

  • CheckCriteria: Configurable criteria for evaluating test results

  • pick_free_port(): Find an available port

  • wait_for_condition(): Helper for waiting on conditions

See examples/using_test_utilities.py for more examples.

Running Tests

The project includes a comprehensive test suite using pytest:

# Run all tests
python -m pytest tests/

# Run only unit tests (fast)
python -m pytest tests/ -m "not integration"

# Run only integration tests
python -m pytest tests/ -m "integration"

# Run with coverage
python -m pytest tests/ --cov=src/ipyrf --cov-report=html

# Use the test runner script
./run_tests.py --type fast --verbose

Test Categories

  • Unit tests: Fast tests that don’t require network access

  • Integration tests: Tests that require network functionality

  • Network tests: Tests that create actual network connections

  • Slow tests: Tests that take longer to run (marked with @pytest.mark.slow)

Continuous Integration

The project uses GitHub Actions for continuous integration, testing against Python 3.8-3.12.

Usage

The package installs a console script named ipyrf.

Quick examples

TCP server:

ipyrf tcp server 0.0.0.0 --port 12345

TCP client:

ipyrf tcp client 127.0.0.1 --port 12345 --time 5
ipyrf tcp client 127.0.0.1 --port 12345 --time 5 --set-mss 1400

UDP server:

ipyrf udp server 0.0.0.0 --port 12345

UDP client (with bandwidth cap and optional payload size):

ipyrf udp client 127.0.0.1 --port 12345 --bandwidth 50M --time 5
ipyrf udp client 127.0.0.1 --port 12345 --bandwidth 50M --time 5 -l 1200

Interactive mode

You can run clients in an interactive mode that lets you adjust the pacing live using your keyboard. Use --interactive and optionally --interval (seconds between stats updates). When interactive is enabled, the same client logic is used underneath with a dynamic pacing controller.

Controls shown in the terminal:

  • : -1 Mbps

  • : +1 Mbps

  • : -10%

  • : +10%

  • 0: reset to initial bandwidth (or unlimited for TCP if none was provided)

  • u: unlimited (disable pacing)

  • q: quit

Examples:

# TCP interactive (unlimited unless you pass --bandwidth)
ipyrf tcp client 127.0.0.1 --port 5201 --interactive

# TCP interactive with initial pacing and custom interval
ipyrf tcp client 127.0.0.1 --port 5201 --bandwidth 200M --set-mss 1400 --interactive --interval 0.5

# UDP interactive (requires initial --bandwidth)
ipyrf udp client 127.0.0.1 --port 5201 --bandwidth 50M -l 1200 --interactive

CLI overview

Top-level structure:

ipyrf [tcp|udp] [server|client] [OPTIONS]

Common options (both protocols, both roles):

  • --port: Port (default 5201)

  • --logfile: Redirect output to a file

  • --json_log: Emit logs in JSON (newline-delimited)

TCP-specific options:

  • tcp server ADDRESS: Start a TCP server on ADDRESS

  • tcp client ADDRESS: Start a TCP client to connect to ADDRESS

  • --congestion-control: Select Linux TCP CC algorithm if available

  • --time: Test duration (seconds), default 10

  • --bandwidth: Target rate (e.g., 50M); used for pacing, optional

  • --set-mss: Set approximate MSS via TCP_MAXSEG

  • --interactive: Enable interactive pacing controls

  • --interval: Stats interval in seconds for interactive mode (default 1.0)

UDP-specific options:

  • udp server ADDRESS: Start a UDP server on ADDRESS

  • udp client ADDRESS: Start a UDP client to ADDRESS

  • --time: Test duration (seconds), default 10

  • --bandwidth: Target rate (required for UDP client; e.g., 50M)

  • -l/--length: UDP payload length (default 1200)

  • --interactive: Enable interactive pacing controls

  • --interval: Stats interval in seconds for interactive mode (default 1.0)

JSON logging

Add --json_log to switch all output to newline-delimited JSON objects. This is useful for machine parsing or dashboards. Example:

ipyrf tcp client 127.0.0.1 --time 5 --json_log | jq

Notes

  • Output is JSON (newline-delimited for update events) when --json_log is given; otherwise, a human-readable summary is printed.

  • UDP mode sends a FIN marker at the end and the server exits after FIN (or inactivity timeout).

  • On Linux, congestion control selection is exposed if /proc entries are available.

License

MIT. See LICENSE.

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

ipyrf-1.1.0.tar.gz (21.5 kB view details)

Uploaded Source

Built Distribution

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

ipyrf-1.1.0-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file ipyrf-1.1.0.tar.gz.

File metadata

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

File hashes

Hashes for ipyrf-1.1.0.tar.gz
Algorithm Hash digest
SHA256 ff6465b1d090e888100f548a0bfe3d5b8f9c8d4469270579e76f7882d92d14f6
MD5 fb52bf838aab3f6c5663b86e163e193d
BLAKE2b-256 1424c621411e0a480d56b89c6c5aa8555f7cbbe0cb4c610c6a48bdab144bcd08

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipyrf-1.1.0.tar.gz:

Publisher: publish.yml on steinwurf/ipyrf

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

File details

Details for the file ipyrf-1.1.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for ipyrf-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aea56076d2b50857c8941f4caf05288351705d4b2f1ccd3ecf453980d5b2ab55
MD5 b9c6858fea2caed237205894ec9a34b5
BLAKE2b-256 fd0c512e950a3c3eee851930f8cab3a4d6794a1dbb86731641757c228531eda5

See more details on using hashes here.

Provenance

The following attestation bundles were made for ipyrf-1.1.0-py3-none-any.whl:

Publisher: publish.yml on steinwurf/ipyrf

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