Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sum speed over rate-limited speed #692

Closed
FuzzyStatic opened this issue Jan 24, 2018 · 13 comments
Closed

Sum speed over rate-limited speed #692

FuzzyStatic opened this issue Jan 24, 2018 · 13 comments
Assignees
Labels
Milestone

Comments

@FuzzyStatic
Copy link
Contributor

FuzzyStatic commented Jan 24, 2018

Context

  • Version of iperf3: 3.2

  • Hardware: Between a Linux server and a Linux client

  • Operating system (and distribution, if any): Debian-based Linux

Bug Report

  • Expected Behavior

@aledesma78 was the original discoverer of this issue.

We have a device rate-limited for 3750kbps. We expected to see the final speed result to be at or below 3.75Mbits/sec

  • Actual Behavior

We see a final speed result above the rate-limited speed, but no non-omitted intervals reach that speed.

  • Steps to Reproduce

Rate-limited a device and run a downstream speed test.

CLIENT OUTPUT

iperf3_2 -c 10.254.223.197 -R -P 2 -O2 -t5 -C cubic
Connecting to host 10.254.223.197, port 5201
Reverse mode, remote host 10.254.223.197 is sending
[  5] local 10.0.0.103 port 48668 connected to 10.254.223.197 port 5201
[  7] local 10.0.0.103 port 48669 connected to 10.254.223.197 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec   250 KBytes  2.05 Mbits/sec                  (omitted)
[  7]   0.00-1.00   sec   246 KBytes  2.02 Mbits/sec                  (omitted)
[SUM]   0.00-1.00   sec   496 KBytes  4.07 Mbits/sec                  (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   250 KBytes  2.05 Mbits/sec                  (omitted)
[  7]   1.00-2.00   sec   185 KBytes  1.52 Mbits/sec                  (omitted)
[SUM]   1.00-2.00   sec   436 KBytes  3.57 Mbits/sec                  (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-1.00   sec   195 KBytes  1.60 Mbits/sec
[  7]   0.00-1.00   sec   242 KBytes  1.98 Mbits/sec
[SUM]   0.00-1.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   212 KBytes  1.74 Mbits/sec
[  7]   1.00-2.00   sec   225 KBytes  1.84 Mbits/sec
[SUM]   1.00-2.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   2.00-3.00   sec   232 KBytes  1.90 Mbits/sec
[  7]   2.00-3.00   sec   204 KBytes  1.67 Mbits/sec
[SUM]   2.00-3.00   sec   436 KBytes  3.57 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   3.00-4.00   sec   266 KBytes  2.18 Mbits/sec
[  7]   3.00-4.00   sec   171 KBytes  1.40 Mbits/sec
[SUM]   3.00-4.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   4.00-5.00   sec   164 KBytes  1.34 Mbits/sec
[  7]   4.00-5.00   sec   272 KBytes  2.22 Mbits/sec
[SUM]   4.00-5.00   sec   436 KBytes  3.57 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.02   sec  1.36 MBytes  2.28 Mbits/sec    0             sender
[  5]   0.00-5.00   sec  1.17 MBytes  1.96 Mbits/sec                  receiver
[  7]   0.00-5.02   sec  1.51 MBytes  2.53 Mbits/sec    0             sender
[  7]   0.00-5.00   sec  1.34 MBytes  2.24 Mbits/sec                  receiver
[SUM]   0.00-5.02   sec  2.88 MBytes  4.81 Mbits/sec    0             sender
[SUM]   0.00-5.00   sec  2.51 MBytes  4.20 Mbits/sec                  receiver

SERVER OUTPUT

Accepted connection from 10.254.223.201, port 48667
[  5] local 10.254.223.197 port 5201 connected to 10.254.223.201 port 48668
[  8] local 10.254.223.197 port 5201 connected to 10.254.223.201 port 48669
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   518 KBytes  4.24 Mbits/sec    0   83.4 KBytes       (omitted)
[  8]   0.00-1.00   sec   520 KBytes  4.26 Mbits/sec    0   83.4 KBytes       (omitted)
[SUM]   0.00-1.00   sec  1.01 MBytes  8.50 Mbits/sec    0             (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   407 KBytes  3.34 Mbits/sec    0   96.2 KBytes       (omitted)
[  8]   1.00-2.00   sec   263 KBytes  2.16 Mbits/sec    0   90.5 KBytes       (omitted)
[SUM]   1.00-2.00   sec   670 KBytes  5.49 Mbits/sec    0             (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-1.00   sec   153 KBytes  1.25 Mbits/sec    0    105 KBytes
[  8]   0.00-1.00   sec   297 KBytes  2.43 Mbits/sec    0    102 KBytes
[SUM]   0.00-1.00   sec   450 KBytes  3.68 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   334 KBytes  2.73 Mbits/sec    0    115 KBytes
[  8]   1.00-2.00   sec   161 KBytes  1.32 Mbits/sec    0    112 KBytes
[SUM]   1.00-2.00   sec   495 KBytes  4.05 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   2.00-3.00   sec   187 KBytes  1.53 Mbits/sec    0    126 KBytes
[  8]   2.00-3.00   sec   356 KBytes  2.92 Mbits/sec    0    124 KBytes
[SUM]   2.00-3.00   sec   543 KBytes  4.45 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   3.00-4.00   sec   444 KBytes  3.64 Mbits/sec    0    163 KBytes
[  8]   3.00-4.00   sec   206 KBytes  1.69 Mbits/sec    0    146 KBytes
[SUM]   3.00-4.00   sec   650 KBytes  5.33 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   4.00-5.00   sec   280 KBytes  2.29 Mbits/sec    0    197 KBytes
[  8]   4.00-5.00   sec   529 KBytes  4.33 Mbits/sec    0    202 KBytes
[SUM]   4.00-5.00   sec   809 KBytes  6.63 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.02   sec  1.36 MBytes  2.28 Mbits/sec    0             sender
[  8]   0.00-5.02   sec  1.51 MBytes  2.53 Mbits/sec    0             sender
[SUM]   0.00-5.02   sec  2.88 MBytes  4.81 Mbits/sec    0             sender

As you can see, the client's final sum reports 4.20Mbits/sec, over the rate-limit of the client. It should not be possible to achieve speeds higher than the rate-limit.

There is a noticeable delay after the final interval of the test. Is iperf3 still counting the final incoming packets after the last interval and adding them to the over total, which is then divided only by the time of the intervals? This would explain the sum being over the average of the interval speeds.

We did a wireshark capture of the incoming packets on the server side, and we noticed a lot of TCP errors (shown below). The errors were a bunch of duplicate ACKs, presumably from the burst of traffic that the cubic algorithm does while it ramps-up.

iperf3 packets with cubic

Since congestion can lead to a delay in packets, we tried the Vegas TCP congestion algorithm, to see if that made a difference.

CLIENT OUTPUT

iperf3_2 -c 10.254.223.197 -R -P 2 -O2 -t5 -C vegas
Connecting to host 10.254.223.197, port 5201
Reverse mode, remote host 10.254.223.197 is sending
[  5] local 10.0.0.103 port 48680 connected to 10.254.223.197 port 5201
[  7] local 10.0.0.103 port 48681 connected to 10.254.223.197 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec   238 KBytes  1.95 Mbits/sec                  (omitted)
[  7]   0.00-1.00   sec   259 KBytes  2.12 Mbits/sec                  (omitted)
[SUM]   0.00-1.00   sec   496 KBytes  4.07 Mbits/sec                  (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   325 KBytes  2.66 Mbits/sec                  (omitted)
[  7]   1.00-2.00   sec   112 KBytes   915 Kbits/sec                  (omitted)
[SUM]   1.00-2.00   sec   437 KBytes  3.58 Mbits/sec                  (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-1.00   sec   208 KBytes  1.70 Mbits/sec
[  7]   0.00-1.00   sec   229 KBytes  1.88 Mbits/sec
[SUM]   0.00-1.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   178 KBytes  1.46 Mbits/sec
[  7]   1.00-2.00   sec   257 KBytes  2.11 Mbits/sec
[SUM]   1.00-2.00   sec   436 KBytes  3.57 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   2.00-3.00   sec   182 KBytes  1.49 Mbits/sec
[  7]   2.00-3.00   sec   255 KBytes  2.09 Mbits/sec
[SUM]   2.00-3.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   3.00-4.00   sec   175 KBytes  1.44 Mbits/sec
[  7]   3.00-4.00   sec   262 KBytes  2.14 Mbits/sec
[SUM]   3.00-4.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   4.00-5.00   sec   181 KBytes  1.48 Mbits/sec
[  7]   4.00-5.00   sec   256 KBytes  2.10 Mbits/sec
[SUM]   4.00-5.00   sec   437 KBytes  3.58 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.02   sec   911 KBytes  1.49 Mbits/sec    0             sender
[  5]   0.00-5.00   sec   925 KBytes  1.52 Mbits/sec                  receiver
[  7]   0.00-5.02   sec  1.24 MBytes  2.08 Mbits/sec    0             sender
[  7]   0.00-5.00   sec  1.35 MBytes  2.27 Mbits/sec                  receiver
[SUM]   0.00-5.02   sec  2.13 MBytes  3.56 Mbits/sec    0             sender
[SUM]   0.00-5.00   sec  2.26 MBytes  3.79 Mbits/sec                  receiver

SERVER OUTPUT

Accepted connection from 10.254.223.201, port 48679
[  5] local 10.254.223.197 port 5201 connected to 10.254.223.201 port 48680
[  8] local 10.254.223.197 port 5201 connected to 10.254.223.201 port 48681
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   379 KBytes  3.10 Mbits/sec    0   35.4 KBytes       (omitted)
[  8]   0.00-1.00   sec   455 KBytes  3.73 Mbits/sec    0   17.0 KBytes       (omitted)
[SUM]   0.00-1.00   sec   834 KBytes  6.83 Mbits/sec    0             (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   325 KBytes  2.66 Mbits/sec    0   17.0 KBytes       (omitted)
[  8]   1.00-2.00   sec  70.7 KBytes   579 Kbits/sec    0   7.07 KBytes       (omitted)
[SUM]   1.00-2.00   sec   396 KBytes  3.24 Mbits/sec    0             (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-1.00   sec   195 KBytes  1.60 Mbits/sec    0   8.48 KBytes
[  8]   0.00-1.00   sec   212 KBytes  1.74 Mbits/sec    0   9.90 KBytes
[SUM]   0.00-1.00   sec   407 KBytes  3.34 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec   195 KBytes  1.60 Mbits/sec    0   7.07 KBytes
[  8]   1.00-2.00   sec   283 KBytes  2.32 Mbits/sec    0   9.90 KBytes
[SUM]   1.00-2.00   sec   478 KBytes  3.92 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   2.00-3.00   sec   195 KBytes  1.60 Mbits/sec    0   7.07 KBytes
[  8]   2.00-3.00   sec   283 KBytes  2.32 Mbits/sec    0   9.90 KBytes
[SUM]   2.00-3.00   sec   478 KBytes  3.92 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   3.00-4.00   sec   195 KBytes  1.60 Mbits/sec    0   7.07 KBytes
[  8]   3.00-4.00   sec   212 KBytes  1.74 Mbits/sec    0   9.90 KBytes
[SUM]   3.00-4.00   sec   407 KBytes  3.34 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   4.00-5.00   sec   130 KBytes  1.07 Mbits/sec    0   7.07 KBytes
[  8]   4.00-5.00   sec   283 KBytes  2.32 Mbits/sec    0   9.90 KBytes
[SUM]   4.00-5.00   sec   413 KBytes  3.38 Mbits/sec    0
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.02   sec   911 KBytes  1.49 Mbits/sec    0             sender
[  8]   0.00-5.02   sec  1.24 MBytes  2.08 Mbits/sec    0             sender
[SUM]   0.00-5.02   sec  2.13 MBytes  3.56 Mbits/sec    0             sender

Viola! The sum is below the rate-limited speed. But there were still times when I ran iperf3 with the Vegas algorithm that I would see a sum of 3.78Mbits/sec (only slightly over rate-limited speed).

We did a wireshark capture again (shown below). This time, no TCP errors.

iperf3 packets with vegas

  • Possible Solution

N/A

Enhancement Request

  • Current behavior

Sum speed seems to include more bytes than the individual interval speeds, leading to inaccurate sum speeds that are higher than they should be.

  • Desired behavior

Sum speeds should include the average of the byte counts over all the intervals, any excess should be included as an additional data set.

@FuzzyStatic
Copy link
Contributor Author

FuzzyStatic commented Jan 26, 2018

I created a script to do the math for the interval counts and compare it to the sum.

./iperf3 -c 10.254.223.197 -P 2 -R -J -t 5 -O 2 
{
	"start":	{
		"connected":	[{
				"socket":	5,
				"local_host":	"10.0.0.103",
				"local_port":	42061,
				"remote_host":	"10.254.223.197",
				"remote_port":	5201
			}, {
				"socket":	7,
				"local_host":	"10.0.0.103",
				"local_port":	42062,
				"remote_host":	"10.254.223.197",
				"remote_port":	5201
			}],
		"version":	"iperf 3.3",
		"system_info":	"Linux alarm 3.14.79-28-ARCH #1 SMP PREEMPT Tue Nov 28 20:47:59 MST 2017 aarch64",
		"timestamp":	{
			"time":	"Mon, 15 Jan 2018 23:15:14 GMT",
			"timesecs":	1516058114
		},
		"connecting_to":	{
			"host":	"10.254.223.197",
			"port":	5201
		},
		"cookie":	"p53abfwnpdgxdb4i4ben3aby5q6p3tr72mzd",
		"tcp_mss_default":	1448,
		"sock_bufsize":	0,
		"sndbuf_actual":	16384,
		"rcvbuf_actual":	87380,
		"sock_bufsize":	0,
		"sndbuf_actual":	16384,
		"rcvbuf_actual":	87380,
		"test_start":	{
			"protocol":	"TCP",
			"num_streams":	2,
			"blksize":	131072,
			"omit":	2,
			"duration":	5,
			"bytes":	0,
			"blocks":	0,
			"reverse":	1,
			"tos":	545460846592
		}
	},
	"intervals":	[{
			"streams":	[{
					"socket":	5,
					"start":	0,
					"end":	1.0000720024108887,
					"seconds":	1.0000720024108887,
					"bytes":	263536,
					"bits_per_second":	2108136.2091104626,
					"omitted":	true
				}, {
					"socket":	7,
					"start":	0,
					"end":	1.0000808238983154,
					"seconds":	1.0000808238983154,
					"bytes":	244712,
					"bits_per_second":	1957537.784165184,
					"omitted":	true
				}],
			"sum":	{
				"start":	0,
				"end":	1.0000720024108887,
				"seconds":	1.0000720024108887,
				"bytes":	508248,
				"bits_per_second":	4065691.2604273204,
				"omitted":	true
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	1.0000720024108887,
					"end":	2.0000720024108887,
					"seconds":	1,
					"bytes":	254848,
					"bits_per_second":	2038784,
					"omitted":	true
				}, {
					"socket":	7,
					"start":	1.0000808238983154,
					"end":	2.0000829696655273,
					"seconds":	1.0000021457672119,
					"bytes":	192584,
					"bits_per_second":	1540668.6940836317,
					"omitted":	true
				}],
			"sum":	{
				"start":	1.0000720024108887,
				"end":	2.0000720024108887,
				"seconds":	1,
				"bytes":	447432,
				"bits_per_second":	3579456,
				"omitted":	true
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	9.3936920166015625e-05,
					"end":	0.99996590614318848,
					"seconds":	1.0000598430633545,
					"bytes":	205616,
					"bits_per_second":	1644829.5683599333,
					"omitted":	false
				}, {
					"socket":	7,
					"start":	8.296966552734375e-05,
					"end":	0.99997401237487793,
					"seconds":	1.0000569820404053,
					"bytes":	241816,
					"bits_per_second":	1934417.7729283024,
					"omitted":	false
				}],
			"sum":	{
				"start":	9.3936920166015625e-05,
				"end":	0.99996590614318848,
				"seconds":	1.0000598430633545,
				"bytes":	447432,
				"bits_per_second":	3579241.80720577,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	0.99996590614318848,
					"end":	1.9999659061431885,
					"seconds":	1,
					"bytes":	231680,
					"bits_per_second":	1853440,
					"omitted":	false
				}, {
					"socket":	7,
					"start":	0.99997401237487793,
					"end":	1.9999749660491943,
					"seconds":	1.0000009536743164,
					"bytes":	215752,
					"bits_per_second":	1726014.3539444408,
					"omitted":	false
				}],
			"sum":	{
				"start":	0.99996590614318848,
				"end":	1.9999659061431885,
				"seconds":	1,
				"bytes":	447432,
				"bits_per_second":	3579456,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	1.9999659061431885,
					"end":	2.9999370574951172,
					"seconds":	0.99997115135192871,
					"bytes":	237472,
					"bits_per_second":	1899830.8075503621,
					"omitted":	false
				}, {
					"socket":	7,
					"start":	1.9999749660491943,
					"end":	2.9999480247497559,
					"seconds":	0.99997305870056152,
					"bytes":	209960,
					"bits_per_second":	1679725.253981042,
					"omitted":	false
				}],
			"sum":	{
				"start":	1.9999659061431885,
				"end":	2.9999370574951172,
				"seconds":	0.99997115135192871,
				"bytes":	447432,
				"bits_per_second":	3579559.2654454992,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	2.9999370574951172,
					"end":	3.9999649524688721,
					"seconds":	1.0000278949737549,
					"bytes":	275120,
					"bits_per_second":	2200898.6059911489,
					"omitted":	false
				}, {
					"socket":	7,
					"start":	2.9999480247497559,
					"end":	3.9999740123748779,
					"seconds":	1.0000259876251221,
					"bytes":	170864,
					"bits_per_second":	1366876.4781264982,
					"omitted":	false
				}],
			"sum":	{
				"start":	2.9999370574951172,
				"end":	3.9999649524688721,
				"seconds":	1.0000278949737549,
				"bytes":	445984,
				"bits_per_second":	3567772.4770803885,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	5,
					"start":	3.9999649524688721,
					"end":	4.9999239444732666,
					"seconds":	0.99995899200439453,
					"bytes":	176656,
					"bits_per_second":	1413305.9568444674,
					"omitted":	false
				}, {
					"socket":	7,
					"start":	3.9999740123748779,
					"end":	4.9999361038208008,
					"seconds":	0.99996209144592285,
					"bytes":	270776,
					"bits_per_second":	2166290.1209261958,
					"omitted":	false
				}],
			"sum":	{
				"start":	3.9999649524688721,
				"end":	4.9999239444732666,
				"seconds":	0.99995899200439453,
				"bytes":	447432,
				"bits_per_second":	3579602.7923355773,
				"omitted":	false
			}
		}],
	"end":	{
		"streams":	[{
				"sender":	{
					"socket":	5,
					"start":	0,
					"end":	5.0177791118621826,
					"seconds":	5.0177791118621826,
					"bytes":	1662304,
					"bits_per_second":	2650262.5371774738,
					"retransmits":	0,
					"max_snd_cwnd":	0,
					"max_rtt":	0,
					"min_rtt":	0,
					"mean_rtt":	0
				},
				"receiver":	{
					"socket":	5,
					"start":	0,
					"end":	4.9999239444732666,
					"seconds":	4.9999239444732666,
					"bytes":	1388688,
					"bits_per_second":	2221934.5980812446
				}
			}, {
				"sender":	{
					"socket":	7,
					"start":	0,
					"end":	5.0177791118621826,
					"seconds":	5.0177791118621826,
					"bytes":	1601488,
					"bits_per_second":	2553301.7126465905,
					"retransmits":	0,
					"max_snd_cwnd":	0,
					"max_rtt":	0,
					"min_rtt":	0,
					"mean_rtt":	0
				},
				"receiver":	{
					"socket":	7,
					"start":	0,
					"end":	4.9999239444732666,
					"seconds":	4.9999239444732666,
					"bytes":	1240240,
					"bits_per_second":	1984414.1851332216
				}
			}],
		"sum_sent":	{
			"start":	0,
			"end":	5.0177791118621826,
			"seconds":	5.0177791118621826,
			"bytes":	3263792,
			"bits_per_second":	5203564.2498240648,
			"retransmits":	0
		},
		"sum_received":	{
			"start":	0,
			"end":	4.9999239444732666,
			"seconds":	4.9999239444732666,
			"bytes":	2628928,
			"bits_per_second":	4206348.7832144666
		},
		"cpu_utilization_percent":	{
			"host_total":	1.4895097996990692,
			"host_user":	0.27786769885254531,
			"host_system":	1.2504046448364539,
			"remote_total":	0.077469205119125223,
			"remote_user":	0.033212949675937929,
			"remote_system":	0.044283932901250572
		},
		"sender_tcp_congestion":	"cubic",
		"receiver_tcp_congestion":	"cubic"
	}
}

Intvl (non-omitted) start time: 0.000094
Intvl (non-omitted) end time: 4.999924
Intvl (non-omitted) total bytes: 2235712
Intvl (non-omitted) data rate (bits/s): 3577260.821464
Sum total bytes: 2628928
Sum data rate (bits/s): 4206348.783214
Diff (Sum total bytes - Intvl (non-omitted) total bytes): 393216

If we just calculate the non-omitted intervals, we can see the data rate is more in line with what we see per interval at 3.58Mbits/sec and the total byte count and interval byte count has a byte disparity of almost 400KB

@bmah888
Copy link
Contributor

bmah888 commented Jan 26, 2018

Thanks for the descriptive bug report and analysis and I apologize for not acknowledging this issue sooner. Clearly something odd is happening with our accounting. I wonder if we're somehow including the omitted bytes in the sum total or some other thing to inflate the sum?

@FuzzyStatic
Copy link
Contributor Author

We think iperf3 is still counting bytes left over in the buffers even after iperf3 has finished measuring intervals.

@bmah888
Copy link
Contributor

bmah888 commented Jan 26, 2018

I'm not convinced that counting those bytes at the end is a bug (they were validly sent by the sender during the test duration, and remember the stopping conditions of the test apply at the sender side, not the receiver). However if we do count them, we need to also account for the time over which those bytes were received so the rate computation is correct.

@FuzzyStatic
Copy link
Contributor Author

I agree. It's advantageous to keep account of all the bytes that are received and I don't see that as the bug, but rather iperf3 is not accounting for that time when those last bytes come in. Can there be another interval added to the JSON that accounts for that time and have it marked as an extra interval?

@bmah888
Copy link
Contributor

bmah888 commented Jan 29, 2018

Can there be another interval added to the JSON that accounts for that time and have it marked as an extra interval?

I thought that's what we did, which is why I'm a little confused. I need to try to reproduce this bug locally and then dive into the source code. Does this happen consistently? Also does it only happen with multiple, parallel streams or do you see it with single-stream as well?

@FuzzyStatic
Copy link
Contributor Author

It happens consistently when using the cubic algorithm and it doesn't matter whether it is a single-stream or more.

It is only because we are testing lower speeds that we were able to find this issue. The extra bytes are not as noticeable on the overall SUM at higher speeds.

@bmah888
Copy link
Contributor

bmah888 commented Jan 29, 2018

OK. Good (?!?) news: I've been able to reproduce this problem with a couple of VMs on my laptop with a link artificially constrained by tc(8) to 256Kbps. However I've only seen this so far with multiple parallel TCP streams. I don't know at this point how significant that is, just an observation.

Server is CentOS 7, client is CentOS 6, both running iperf3 compiled from the tip of master code:

bmah-centos6:iperf% src/iperf3 --client 192.168.56.104 --parallel 2 --reverse -O2 -t 5 -C cubic -fk
Connecting to host 192.168.56.104, port 5201
Reverse mode, remote host 192.168.56.104 is sending
[  5] local 192.168.56.101 port 52906 connected to 192.168.56.104 port 5201
[  7] local 192.168.56.101 port 52908 connected to 192.168.56.104 port 5201
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  21.2 KBytes   173 Kbits/sec                  (omitted)
[  7]   0.00-1.00   sec  14.1 KBytes   116 Kbits/sec                  (omitted)
[SUM]   0.00-1.00   sec  35.4 KBytes   289 Kbits/sec                  (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec  17.0 KBytes   139 Kbits/sec                  (omitted)
[  7]   1.00-2.00   sec  9.90 KBytes  81.1 Kbits/sec                  (omitted)
[SUM]   1.00-2.00   sec  26.9 KBytes   220 Kbits/sec                  (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-1.00   sec  14.1 KBytes   116 Kbits/sec                  
[  7]   0.00-1.00   sec  14.1 KBytes   116 Kbits/sec                  
[SUM]   0.00-1.00   sec  28.3 KBytes   232 Kbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec  14.1 KBytes   116 Kbits/sec                  
[  7]   1.00-2.00   sec  17.0 KBytes   139 Kbits/sec                  
[SUM]   1.00-2.00   sec  31.1 KBytes   255 Kbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   2.00-3.00   sec  14.1 KBytes   116 Kbits/sec                  
[  7]   2.00-3.00   sec  14.1 KBytes   116 Kbits/sec                  
[SUM]   2.00-3.00   sec  28.3 KBytes   232 Kbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   3.00-4.00   sec  15.6 KBytes   127 Kbits/sec                  
[  7]   3.00-4.00   sec  15.6 KBytes   127 Kbits/sec                  
[SUM]   3.00-4.00   sec  31.1 KBytes   255 Kbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   4.00-5.00   sec  14.1 KBytes   116 Kbits/sec                  
[  7]   4.00-5.00   sec  14.1 KBytes   116 Kbits/sec                  
[SUM]   4.00-5.00   sec  28.3 KBytes   232 Kbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.02   sec  79.2 KBytes   129 Kbits/sec    0             sender
[  5]   0.00-5.00   sec  72.1 KBytes   118 Kbits/sec                  receiver
[  7]   0.00-5.02   sec   110 KBytes   180 Kbits/sec    0             sender
[  7]   0.00-5.00   sec  74.9 KBytes   123 Kbits/sec                  receiver
[SUM]   0.00-5.02   sec   189 KBytes   309 Kbits/sec    0             sender
[SUM]   0.00-5.00   sec   147 KBytes   241 Kbits/sec                  receiver

iperf Done.

It shouldn't be possible for the sender to push out 309Kbps. So I need to figure out what's going on with this.

@bmah888
Copy link
Contributor

bmah888 commented Jan 30, 2018

OK after playing around with this for awhile I came up with a few things. TL;DR: iperf3 is operating correctly but there are a few subtleties in interpreting the output that can be misleading.

  • The measurements at each interval are taken at the application layer (i.e. within iperf3 itself). This is an important fact that people (including me) forget sometimes. Between the application and the wire are the kernel's socket buffers, the entire TCP/IP protocol stack (including flow control and congestion control), and interface buffers.

  • The anomalous readings (with the abnormally high bitrate) were taken from the sending side, in particular before the rate-limiting effects of TCP's flow control and congestion control.

  • The tests done to investigate this (including those that I ran) were all fairly short, only a few seconds.

What I think is happening here is that the sending process is able to send a large burst of data (up to the limits of the socket buffers and without regard to TCP's congestion control algorithm). At some point, the congestion control algorithms and/or packet loss force it to stop. Note that the last part of each burst is already sent as far as iperf3 is concerned (so it's counted in the interval statistics as being "sent"), but it's sitting in the socket buffers on the application side, waiting for retransmission. So it's possible for an interval to record an amount of data sent that's actually more than is possible to send over the wire, because the data hasn't actually left the sending host yet.

This effect is especially visible because the short test duration (5 seconds) makes it possible to observe over a short time interval rates that aren't indicative of the longer-term rate. You don't really see this on the client (receiver) side, but the server (sender) logs show it. Here's a sender log for a recent test that I did. Note the bursty nature of traffic coming from the sender. This is visible too in the server-side output in your original bug report, although it's a little less visible (maybe because you had a larger bottleneck bandwidth?). But it shows fluctuations in the amount of data sent in each interval, both above and below the bottleneck bandwidth.

-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.56.101, port 53362
[  5] local 192.168.56.104 port 5201 connected to 192.168.56.101 port 53364
[  8] local 192.168.56.104 port 5201 connected to 192.168.56.101 port 53366
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec   130 KBytes  1.06 Mbits/sec    0   28.3 KBytes       (omitted)
[  8]   0.00-1.00   sec  77.8 KBytes   636 Kbits/sec    0   14.1 KBytes       (omitted)
[SUM]   0.00-1.00   sec   208 KBytes  1.70 Mbits/sec    0             (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec  60.8 KBytes   498 Kbits/sec    0   28.3 KBytes       (omitted)
[  8]   1.00-2.00   sec  49.5 KBytes   405 Kbits/sec    0   19.8 KBytes       (omitted)
[SUM]   1.00-2.00   sec   110 KBytes   903 Kbits/sec    0             (omitted)
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   0.00-1.00   sec  0.00 Bytes  0.00 bits/sec    0   28.3 KBytes       
[  8]   0.00-1.00   sec  0.00 Bytes  0.00 bits/sec    0   19.8 KBytes       
[SUM]   0.00-1.00   sec  0.00 Bytes  0.00 bits/sec    0             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   1.00-2.00   sec  0.00 Bytes  0.00 bits/sec    0   28.3 KBytes       
[  8]   1.00-2.00   sec  0.00 Bytes  0.00 bits/sec    0   19.8 KBytes       
[SUM]   1.00-2.00   sec  0.00 Bytes  0.00 bits/sec    0             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   2.00-3.00   sec  0.00 Bytes  0.00 bits/sec    0   28.3 KBytes       
[  8]   2.00-3.00   sec  48.1 KBytes   394 Kbits/sec    0   19.8 KBytes       
[SUM]   2.00-3.00   sec  48.1 KBytes   394 Kbits/sec    0             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   3.00-4.00   sec  79.2 KBytes   649 Kbits/sec    0   28.3 KBytes       
[  8]   3.00-4.00   sec  0.00 Bytes  0.00 bits/sec    0   22.6 KBytes       
[SUM]   3.00-4.00   sec  79.2 KBytes   649 Kbits/sec    0             
- - - - - - - - - - - - - - - - - - - - - - - - -
[  5]   4.00-5.00   sec  0.00 Bytes  0.00 bits/sec    0   28.3 KBytes       
[  8]   4.00-5.00   sec  62.2 KBytes   509 Kbits/sec    0   22.6 KBytes       
[SUM]   4.00-5.00   sec  62.2 KBytes   509 Kbits/sec    0             
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-5.02   sec  79.2 KBytes   129 Kbits/sec    0             sender
[  8]   0.00-5.02   sec   110 KBytes   180 Kbits/sec    0             sender
[SUM]   0.00-5.02   sec   189 KBytes   309 Kbits/sec    0             sender

Note that when I ran similar tests, but longer (say 10-30 seconds), we still see the fluctuations in data sent at the application layer per interval, but the long-term average (correctly) approaches the bottleneck bandwidth. Here's the end of a 30-second test, showing the sending and receiving bitrates roughly equal and about what we'd expect to see on a 256Kbps rate-limited link:

- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-30.02  sec   410 KBytes   112 Kbits/sec    0             sender
[  5]   0.00-30.00  sec   450 KBytes   123 Kbits/sec                  receiver
[  7]   0.00-30.02  sec   484 KBytes   132 Kbits/sec    0             sender
[  7]   0.00-30.00  sec   448 KBytes   122 Kbits/sec                  receiver
[SUM]   0.00-30.02  sec   894 KBytes   244 Kbits/sec    0             sender
[SUM]   0.00-30.00  sec   898 KBytes   245 Kbits/sec                  receiver

iperf Done.

So from what I can tell iperf3 is working correctly, but using longer tests might be needed to produce more meaningful results. (Other ways to get rid of this effect might be to use smaller sending sizes, reducing the socket buffer sizes, or using per-socket based fair queueing, although I didn't test any of those.)

@bmah888 bmah888 self-assigned this Jan 30, 2018
@FuzzyStatic
Copy link
Contributor Author

FuzzyStatic commented Jan 30, 2018

When the sender has a bit-rate over the rate limit it makes sense that congestion is involved, but I am more concerned with seeing that happen on the receiver end. If you look at my first client output, the receiver SUM has a bit-rate over the rate limit

[SUM]   0.00-5.00   sec  2.51 MBytes  4.20 Mbits/sec                  receiver

Why would the receiver claim to have received a rate higher than possible (in the above case it is limited to 3.75Mbits/sec)?

I'd like to note that when I ran my tests, I would notice a delay in the sum results in the last interval. I usually do not see a delay in the sum results, so it makes me wonder if the receiver is still counting bytes left over in the buffer even after the last interval measurement.

@bmah888
Copy link
Contributor

bmah888 commented Jan 30, 2018

Acknowledged. Let me dig into this some more. The problem on the receiver end is not one that I'm seeing (maybe I was looking at the wrong part of the problem, but anywho...). I might need to figure out something else to try to reproduce that side.

@bmah888
Copy link
Contributor

bmah888 commented Feb 13, 2018

I spent most of a day last week trying to reproduce this bug, because the measurement accuracy (unlike some optional features) is something that's very important to us. But I haven't been able to recreate it. If somebody (anybody) can help me to see this problem first-hand and poke at it, preferably by using a couple of VMs and some limiting mechanism like tc, that'd be greatly appreciated.

@FuzzyStatic
Copy link
Contributor Author

@bmah888 I sent you an e-mail that may be helpful

@bmah888 bmah888 added bug and removed question labels Feb 22, 2018
bmah888 added a commit that referenced this issue Feb 22, 2018
This prevents is from reporting an incorrect number of bytes
received at the end of the test, which doesn't match up with the
sum of the data received during the test intervals.
Log late receives if debugging mode enabled.

Fixes #692.

More follow-up commits coming to fix UDP and SCTP tests.
bmah888 added a commit that referenced this issue Feb 22, 2018
Compile-tested only at this time, run-time testing is pending.

Follow-up to #692.
@bmah888 bmah888 added this to the 3.5 milestone Feb 22, 2018
palmerc pushed a commit to palmerc/iperf that referenced this issue Jul 8, 2018
Don't count data for tests received after the end of a test.
This prevents is from reporting an incorrect number of bytes
received at the end of the test, which doesn't match up with the
sum of the data received during the test intervals.
Log late receives if debugging mode enabled.

Fixes esnet#692.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants