thiezn / iperf3-python

Python wrapper around iperf3
https://iperf3-python.readthedocs.org/
MIT License
110 stars 51 forks source link

client hangs while running #22

Open rpandav opened 7 years ago

rpandav commented 7 years ago

I'm using Python 2.7.12, iperf 3.0.11 on a Ubuntu 16.04.1 x86_64 machine.

I configured the client to run as follows:

>>> import iperf3
>>> client = iperf3.Client()
>>> client.duration = 125
>>> client.bind_address = '127.0.0.1'
>>> client.server_hostname = '127.0.0.1'
>>> client.port = 9923
>>> client.bandwidth = (5096 * 1024)
>>> client.num_streams = 3
>>> client.protocol = "tcp"
>>> client.bulksize = (client.bandwidth * client.duration)/8
>>> client.run()

The bandwidth parameter is configured that way since I need 5096 kbps. The Bulksize parameter is kept as it is to ensure that the total throughput (total bits sent/total duration) matches the bandwidth value of (5096*1024). I've run the same code with smaller throughput and smaller duration values and it works great.

There are two problems: 1) When running this client, the client stalls. It does not terminate on my machine. For lower throughput/duration values, it works like a charm. Whats the problem here? I always have to kill it for this specific test!

2) I've noticed that the traffic is bursty in nature i.e. it attempts to send most of the data within the 1st second itself rather than evenly distributing the data over the entire test duration. Is there a way where I can achieve my expected throughput but have evenly distributed traffic as well?

livestreamx commented 5 years ago

Yes, this problem really exists. I have been tested iperf3 wrapper using multiple combinations of parameters for TCP Client and concluded that issue not related to any parameters of traffic, only one has a weight - this is duration. If I set duration MORE than 99 (seconds) - client won't return any data and hang.

nick0333 commented 4 years ago

Anyone know if there is any fix or workaround on this (other than running in a loop heh)?

I am encountering same issue on rhel7 and Ubuntu 16.04. When i use iperf3 module with python3 it hangs for interval > 130...

When I run iperf3 tool itself command line it works just fine with long test duration.

Thanks, any insight appreciated! :)

(iperf3env) # python3 Python 3.6.8 (default, Jun 11 2019, 15:15:01) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux Type "help", "copyright", "credits" or "license" for more information.

import iperf3 client = iperf3.Client() client.duration = 10 client.server_hostname = '10.0.0.2' client.bandwidth = 50000000 result = client.run() result.sent_Mbps 49.561612938104 del client client = iperf3.Client() client.duration = 131 client.server_hostname = '10.0.0.2' client.bandwidth = 50000000 result = client.run() ^CTraceback (most recent call last): File "", line 1, in File "/home/nick/iperf3env/lib/python3.6/site-packages/iperf3/iperf3.py", line 616, in run error = self.lib.iperf_run_client(self._test) KeyboardInterrupt quit() (iperf3env) #

(iperf3env) # iperf3 -c 10.0.0.2 -b 50000000 -t 180 Connecting to host 10.0.0.2, port 5201 [ 4] local 10.0.0.1 port 38590 connected to 10.0.0.2 port 5201 [ ID] Interval Transfer Bandwidth Retr Cwnd [ 4] 0.00-1.00 sec 5.46 MBytes 45.8 Mbits/sec 29 417 KBytes [ 4] 1.00-2.00 sec 5.88 MBytes 49.3 Mbits/sec 0 427 KBytes [ 4] 2.00-3.00 sec 6.00 MBytes 50.3 Mbits/sec 0 436 KBytes ... [ 4] 177.00-178.00 sec 6.00 MBytes 50.3 Mbits/sec 0 622 KBytes [ 4] 178.00-179.00 sec 5.88 MBytes 49.3 Mbits/sec 0 625 KBytes [ 4] 179.00-180.00 sec 6.00 MBytes 50.3 Mbits/sec 0 625 KBytes


[ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-180.00 sec 1.05 GBytes 50.0 Mbits/sec 82 sender [ 4] 0.00-180.00 sec 1.05 GBytes 50.0 Mbits/sec receiver

iperf Done. (iperf3env) #

shankarcvs commented 2 years ago

i am triying to test bandwidth using iperf3 in python but i am getting error

Traceback (most recent call last): File "C:\Users\Administrator\Desktop\Python310\iperfm.py", line 2, in client = iperf3.Client(r'C:\Users\Administrator\Downloads\iperf-3.1.3-win64\iperf-3.1.3-win64\iperf3.exe') File "C:\Users\Administrator\Desktop\Python310\iperf3-python\iperf3\iperf3.py", line 418, in init super(Client, self).init(role='c', *args, **kwargs) TypeError: IPerf3.init() got multiple values for argument 'role'

shankarcvs commented 2 years ago

how to run this code in windows

import iperf3 client = iperf3.Client(r'C:\Users\Administrator\Downloads\iperf-3.1.3-win64\iperf-3.1.3-win64\iperf3.exe') client.duration = 1 client.server_hostname = '127.0.0.1' client.port = 5201 client.run()