Skip to main content

Abstraction layer for iperf2 linux binary

Project description

Pyperf2 is an abstraction layer to simplify programatic use of the iperf2 binary for linux. It was written to have a simple interface for network test setups. It is mostly used for unicast/multicast network convergence tests so the defaults are tcp 1000pps per instance to have packetloss == 1ms/second. Nevertheless all options are configurable.

Why iperf2 and not iperf3

The reason is simple, iperf3 does not support multicast streams as of now. I need multicast testing capability, so I chose iperf2.

Features

Pyperf2 has following features:
  • create and manage iperf2 server instances

  • create and manage iperf2 client instances

  • get results of client and server instances by parsing output to python datastructures.

  • register callbacks for packetloss and intermediate results.

  • linux namespace support (requires ip command of iproute2 package)

Installation

Install pyperf2 by running:

pip3 install pyperf2

Examples

Create a unicast udp 1000pps setup and test for 10 seconds

from pyperf2 import Server, Client
from time import sleep
from pprint import pformat


def on_data_callback(message, **kwargs):
    print(f"got message {pformat(message)} \n\n kwargs are {pformat(kwargs)}")
    print("----------------------------------------------------------------------")


receiver = Server()
sender = Client()

receiver.set_options(protocol="udp", server_ip="127.0.0.1", test_duration=12)
receiver.register_on_data_callback(
    on_data_callback, some_custom_parameter="some_custom_value"
)
receiver.start()


sender.set_options(protocol="udp", server_ip="127.0.0.1", test_duration=10)
sender.start()

while sender.status != "stopped":
    print(f"status sender: {sender.status}\nstatus receiver: {receiver.status}\n")
    print("do something usefull in the main thread -> sleeping for 1 second\n")
    sleep(1)

Supported Parameters

To see all supported parameters for the set_options function, review the constructor of the IPerfInstance object.

Contribute

Roadmap

Selected Roadmap items:
  • add class documentation

For documentation please refer to https://pyperf2.readthedocs.io/en/latest/

License

This project is licensed under the Apache License Version 2.0

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pyperf2-0.4.9-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file pyperf2-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: pyperf2-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for pyperf2-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6b8aaf75bcf54c039070e8f78d78572a0866c7faa88c7aa9b0d5e4b3c0aa1e38
MD5 cdfd953b8417618b4e9099aa31fba9be
BLAKE2b-256 2d40dd5bee56b149fe76d030b06dccfbc35da382a9e9feb886b6dc75f2697110

See more details on using hashes here.

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