thiezn / iperf3-python

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

Unable to run Iperf with parallel streams for more than 20 seconds #20

Closed mahalakshmi27 closed 6 years ago

mahalakshmi27 commented 7 years ago

Running Iperf with 5 parallel streams(TCP) does not work while running the same code with a single connection works fine.

CODE SNIPPET:

class IperfClient(object):
    def __init__(self):
         self.run()

    def run(self):
         print('1')
         client = iperf3.Client()
         client.server_hostname = 0.0.0.0
         client.duration = 60
         client.num_streams = 5
         print('2')
         response = client.run()
         print('3')

class IperfAgent(object):
    def startAgent(self):
        protocol = 'tcp'
        p1 = Process(target=IperfClient).start()

OUTPUT:

1

2

It does not reach "print('3')" line. I pressed Ctrl+C after waiting for several minutes and only this was printed:

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/multiprocessing/popen_fork.py", line 31, in poll
pid, sts = os.waitpid(self.pid, flag)

KeyboardInterrupt

thiezn commented 7 years ago

Hi @mahalakshmi27, I tried to reproduce the issue but could not on my own machine. I did notice you set the server_hostname to 0.0.0.0 instead of a string "0.0.0.0" which won't work. Here's a quick test I did myself:

$ cat temptest.py

!/usr/bin/env python3

import iperf3

print('1')
client = iperf3.Client()
client.server_hostname = "127.0.0.1"
client.duration = 2
client.num_streams = 5
client.json_output = True
print('2')
response = client.run()
print(response.sent_Mbps)
print('3')

Output:

1
2
19713.14
3

Without seeing your full code I'm not sure if this is your actual problem. It looks like you are trying to run this in a separate Process, perhaps launching multiple sessions at the same time?

VasiliyRusin commented 5 years ago

I can confirm this problem. It's really exist.

def start_test(hostname, port, duration=1):
    print("start_test")
    client = iperf3.Client()
    client.duration = duration
    client.reverse = True
    client.num_streams = 16
    client.server_hostname = hostname
    client.port = port
    client.verbose = True
    return client.run()

There is my code. If I call function as start_test("iperf.perm.rtsd.ru", "5256"). Everything is ok. But code stuck if I call start_test("iperf.perm.rtsd.ru", "5256", 20) iperf version:

iperf 3.1.3 Linux vasiliyrusin 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 Optional features available: CPU affinity setting, IPv6 flow label, TCP congestion algorithm setting, sendfile / zerocopy, socket pacing