thiezn / iperf3-python

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

"bandwidth" attribute #21

Closed Dron-Z closed 5 years ago

Dron-Z commented 7 years ago

I'm using iperf3 for testing VoIP quality, and would like to use iperf-lib, but can't set bandwidth in udp mode, script tests at the maximum speed that it can send. for example:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import iperf3

client = iperf3.Client()
client.protocol = 'udp'
client.bandwidth = 1
client.duration = 5
client.server_hostname = '127.0.0.1'
client.port = 6969

result = client.run()

print('')
print('Test completed:')
print('  started at         {0}'.format(result.time))
print('  bytes transmitted  {0}'.format(result.bytes))
print('  jitter (ms)        {0}'.format(result.jitter_ms))
print('  avg cpu load       {0}%\n'.format(result.local_cpu_total))
print('  Megabits per second  (Mbps)  {0}'.format(result.Mbps))

where out are:


Test completed:
  started at         Sun, 25 Jun 2017 04:26:54 GMT
  bytes transmitted  21561039487
  jitter (ms)        0.00436181
  avg cpu load       87.6748%

  Megabits per second  (Mbps)  32899.4750977

In CLI version iperf work is fine

Debian GNU/Linux 8.8 (jessie) Python 2.7.9

b12mihai commented 5 years ago

I am having the exact same issue with exact same behavior described here. Bandwidth setting is just not taken into account regardless of value I set. Not sure though it's an actual issue in iperf3 API instead of this python lib.

Potential workaround is to temporarly set QoS rule for Tx Shaping.

Did somebody take a look into this?

ChristofKaufmann commented 5 years ago

So for me it kind of works. I am using iperf3 3.6. And you? However the value is in bits per second. Using client.bandwidth = 200000 gives me 208 Kbits/sec. There is one difference to the CLI: When not using this parameter the default value of the library is used, which is 0, which means unlimited bandwidth. The CLI sets the value to 1024*1024, if the user did not set a value. iperf3-python should also do that.

thiezn commented 5 years ago

Hi @ChristofKaufmann

My intention is to follow the libiperf3 library as closely as possible which is why the default value of the library is used. If the libiperf3 defaults get updated, iperf3-python should follow automatically.

@Dron-Z can you confirm this is working for you, taking into account the bandwidth parameter is in bits/second?

ChristofKaufmann commented 5 years ago

@thiezn That's reasonable, but from the user perspective it would be nice to have quick access to the default settings as if using the CLI. Because now it is easy to make mistakes, when not aware of the source code of the CLI.

Dron-Z commented 5 years ago

Hi @ChristofKaufmann

My intention is to follow the libiperf3 library as closely as possible which is why the default value of the library is used. If the libiperf3 defaults get updated, iperf3-python should follow automatically.

@Dron-Z can you confirm this is working for you, taking into account the bandwidth parameter is in bits/second?

Yes, it's works. I'm don't know why I'm didn't check this format before ) Thnx