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

pyperf2-0.4.8-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyperf2-0.4.8-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for pyperf2-0.4.8-py3-none-any.whl
Algorithm Hash digest
SHA256 fb84745ac335abc698a659ca93a2bb81374ae1f47c21d22ec4a138683af7846e
MD5 f2e01adaf57106871a56ecb81c4b8e6e
BLAKE2b-256 658c30fc1e81929c53ef27bdf5b50a80cc174a15c0ea57427552256db8ceb106

See more details on using hashes here.

Supported by

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