Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 387129 - [PATCH] net-misc/iperf-2.0.5: --bandwidth broken for low values
Summary: [PATCH] net-misc/iperf-2.0.5: --bandwidth broken for low values
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Netmon project
URL: https://sourceforge.net/tracker/?func...
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2011-10-14 14:14 UTC by Israel G. Lugo
Modified: 2012-10-06 13:38 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
fix compat/delay.cpp:delay_loop() for delays of 1s and greater (iperf-fix-bandwidth-limit.patch,757 bytes, text/plain)
2011-10-14 14:14 UTC, Israel G. Lugo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Israel G. Lugo 2011-10-14 14:14:45 UTC
Created attachment 289793 [details]
fix compat/delay.cpp:delay_loop() for delays of 1s and greater

Trying to send UDP packets at low bandwidth  will fail horribly and flood.

An example, requesting a bandwidth of 1000 bits/s, sending 10 packets of 125 bytes, which should mean 1 packet per second, this is what I get:

$ time iperf -u -c 10.0.0.254 -b1000 -l125 -n1250
------------------------------------------------------------
Client connecting to 10.0.0.254, UDP port 5001
Sending 125 byte datagrams
nanosleep failed: Invalid argument
UDP buffer size:  120 KByte (default)
------------------------------------------------------------
nanosleep failed: Invalid argument
[  3] local 10.0.0.18 port 50674 connected with 10.0.0.254 port 5001
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
nanosleep failed: Invalid argument
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 0.0 sec  1.22 KBytes   119 Mbits/sec
[  3] Sent 10 datagrams
[  3] Server Report:
[  3]  0.0-3814.5 sec  1.22 KBytes  2.62 bits/sec   0.000 ms    0/    9 (0%)
[  3]  0.0-3814.5 sec  1 datagrams received out-of-order

real    0m0.021s
user    0m0.003s
sys     0m0.000s

The problem is the function which is called to do the sleeping between packet sends. It's compat/delay.cpp:delay_loop() and it doesn't deal with usec>=1000000 (1 second) properly. It uses POSIX nanosleep(), which requires that the tv_nsec argument be lower than 1000 million, that is, that the seconds value be used appropriately and not just set to zero. As is, delay_loop will fail for usec > 999999. It doesn't sleep at all, causing a very high packet send rate.

Steps to reproduce:
1. Set up an UDP iperf server on a remote machine: iperf -u -s -U
2. Send UDP packets at a low rate, e.g. for 10 packets (to limit amount of errors):
   iperf -u -c $server_ip -b1000 -l125 -n1250
3. See a bunch of errors and the actual rate is much higher.

I am attaching a patch that fixes this and restores expected behavior:
$ time ./src/iperf -u -c 10.0.0.254 -b1000 -l125 -n1250
------------------------------------------------------------
Client connecting to 10.0.0.254, UDP port 5001
Sending 125 byte datagrams
UDP buffer size:  120 KByte (default)
------------------------------------------------------------
[  3] local 10.0.0.18 port 35078 connected with 10.0.0.254 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  1.22 KBytes  1000 bits/sec
[  3] Sent 10 datagrams
[  3] Server Report:
[  3]  0.0-4130.0 sec  1.22 KBytes  2.42 bits/sec   0.006 ms    0/   10 (0%)

real    0m10.027s
user    0m0.000s
sys     0m0.010s

Patch is made against upstream SVN trunk (r81), but it also applies perfectly against release 2.0.5. Upstream's last commit was a year ago, and they have stated in their site that they don't plan on updating 2.0x unless absolutely necessary, so IMHO it would be good to merge this patch into Portage.

Changelog entry:

2011-10-14 Israel G. Lugo <israel.lugo@lugosys.com>

* Fix delay_loop() for delays of 1s and greater. Was causing breakage when a
low bandwidth limit was specified.
Comment 1 Sergey Popov gentoo-dev 2012-10-06 13:38:49 UTC
+  06 Oct 2012; Sergey Popov <pinkbyte@gentoo.org> +iperf-2.0.5-r1.ebuild,
+  +files/iperf-fix-bandwidth-limit.patch:
+  Revision bump, add fix for bug #387129, bump to EAPI 4