thiezn / iperf3-python

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

Reverse Mode not working #25

Closed stefanrodrigues closed 6 years ago

stefanrodrigues commented 6 years ago

When reverse mode is set, IPERF3 does not work correctly and there are errors in returning.

CODE:

import iperf3 client = iperf3.Client() client.server_hostname = '192.168.1.1' client.port = 5201 client.protocol = 'udp' client.duration = 10 client.num_streams = 10 client.reverse = True

RUN!

result = client.run()

print('BW {:0.3f}'.format(result.Mbps)) print('LOST {:0.3f}%'.format(result.lost_percent)) print('JITTER {:0.3f}'.format(result.jitter_ms))

RETURN WITH REVERSE MODE:

Traceback (most recent call last): File "teste.py", line 54, in result = client.run() File "/usr/local/lib/python2.7/dist-packages/iperf3/iperf3.py", line 512, in run return TestResult(data) File "/usr/local/lib/python2.7/dist-packages/iperf3/iperf3.py", line 659, in init self.json = json.loads(result) File "/usr/lib/python2.7/json/init.py", line 338, in loads return _default_decoder.decode(s) File "/usr/lib/python2.7/json/decoder.py", line 366, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode raise ValueError("No JSON object could be decoded") ValueError: No JSON object could be decoded

SERVER RETURN WITH IPERF3-PYTHON: [SUM] 0.00-10.08 sec 537 MBytes 447 Mbits/sec 1.442 ms 5087/5193 (98%)

SERVER RETURN WITHOUT IPERF3-PYTHON ( iperf3 -c 192.168.1.1 -p 5201 -P 10 -t 10 -u -R): [SUM] 0.00-10.01 sec 12.5 MBytes 10.5 Mbits/sec 3.296 ms 0/1599 (0%)

The BW are diferent! The interfaces are Fast-Ethernet (100Mbps).

thiezn commented 6 years ago

Hi @stefanrodrigues, I did a quick test on my own machine against iperf v3.1.6 and was not able to reproduce the issue. I suspect this has to do with the iperf3 version you are using on the system but not able to test earlier versions myself at the moment.

Could you check the iperf version you are working against? If this indeed breaks on certain versions i'll add a note to the documentation.

$ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import iperf3
>>> client = iperf3.Client()
>>> client.server_hostname = "127.0.0.1"
>>> client.port = 5201
>>> client.protocol = 'udp'
>>> client.duration = 10
>>> client.num_streams = 10
>>> client.reverse = True
>>> result = client.run()
warning: Warning:  UDP block size 65507 exceeds TCP MSS 21845, may result in fragmentation / drops
>>> result
{
        "start":        {
                "connected":    [{
                                "socket":       8,
                                "local_host":   "127.0.0.1",
                                "local_port":   53768,
                                "remote_host":  "127.0.0.1",
                                "remote_port":  5201
thiezn commented 6 years ago

@stefanrodrigues You can open a new issue if you are still experiencing the issue. Please include the iperf3 library version and any other relevant information around your setup so we can troubleshoot further.