iperf icon indicating copy to clipboard operation
iperf copied to clipboard

UDP link capacity reported as 0 in JSON output

Open esqt opened this issue 7 years ago • 4 comments

Context

  • Version of iperf3: iperf 3.5 (cJSON 1.5.2)

  • Hardware: VirtualBox VM

  • Operating system (and distribution, if any): Ubuntu 18.04

Bug Report

The JSON output reports total bytes received to 0 and total bitrate to 0. The default output reports the total bitrate and bytes received correctly.

  • Expected Behavior The total bytes received should be the sum of the periodic bytes received reports. The total bitrate should be the total bytes received divided by the duration of the connection.

  • Actual Behavior Client command:

iperf3 -c 192.168.0.4 -u 

Server default output (this is what is expected):

iperf3 -s
> -----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.2.3, port 53252
[  6] local 192.168.0.4 port 5201 connected to 192.168.2.3 port 53906
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  6]   0.00-1.00   sec  55.1 KBytes   452 Kbits/sec  6.478 ms  0/39 (0%)  
[  6]   1.00-2.00   sec   127 KBytes  1.04 Mbits/sec  1.330 ms  0/90 (0%)  
[  6]   2.00-3.00   sec   129 KBytes  1.05 Mbits/sec  2.535 ms  0/91 (0%)  
[  6]   3.00-4.00   sec   127 KBytes  1.04 Mbits/sec  1.406 ms  0/90 (0%)  
[  6]   4.00-5.00   sec   127 KBytes  1.04 Mbits/sec  2.266 ms  0/90 (0%)  
[  6]   5.00-6.00   sec   129 KBytes  1.05 Mbits/sec  1.951 ms  0/91 (0%)  
[  6]   6.00-7.00   sec   129 KBytes  1.05 Mbits/sec  1.593 ms  0/91 (0%)  
[  6]   7.00-8.00   sec   129 KBytes  1.05 Mbits/sec  1.427 ms  0/91 (0%)  
[  6]   8.00-9.00   sec   127 KBytes  1.04 Mbits/sec  1.381 ms  0/90 (0%)  
[  6]   9.00-10.00  sec   127 KBytes  1.04 Mbits/sec  1.212 ms  0/90 (0%)  
[  6]  10.00-10.58  sec  73.5 KBytes  1.03 Mbits/sec  1.859 ms  0/52 (0%)  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Jitter    Lost/Total Datagrams
[  6]   0.00-10.58  sec  1.25 MBytes   991 Kbits/sec  1.859 ms  0/905 (0%)  receiver

Server JSON output (this is NOT what is expected):

iperf3 -s -J
{
	"start":	{
		"connected":	[{
				"socket":	6,
				"local_host":	"192.168.0.4",
				"local_port":	5201,
				"remote_host":	"192.168.2.3",
				"remote_port":	50720
			}],
		"version":	"iperf 3.5",
		"system_info":	"Linux labo-VirtualBox 4.13.0-45-generic #50~16.04.1-Ubuntu SMP Wed May 30 11:18:27 UTC 2018 x86_64",
		"timestamp":	{
			"time":	"Fri, 15 Jun 2018 13:49:02 GMT",
			"timesecs":	1529070542
		},
		"accepted_connection":	{
			"host":	"192.168.2.3",
			"port":	53250
		},
		"cookie":	"wal54elil5zyamwx2kjwfbiv2ye4inht4aef",
		"sock_bufsize":	0,
		"sndbuf_actual":	212992,
		"rcvbuf_actual":	212992,
		"test_start":	{
			"protocol":	"UDP",
			"num_streams":	1,
			"blksize":	1448,
			"omit":	0,
			"duration":	10,
			"bytes":	0,
			"blocks":	0,
			"reverse":	0,
			"tos":	0
		}
	},
	"intervals":	[{
			"streams":	[{
					"socket":	6,
					"start":	0,
					"end":	1.0005419254302979,
					"seconds":	1.0005419254302979,
					"bytes":	56472,
					"bits_per_second":	451531.30370394728,
					"jitter_ms":	5.4631684203400441,
					"lost_packets":	0,
					"packets":	39,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	0,
				"end":	1.0005419254302979,
				"seconds":	1.0005419254302979,
				"bytes":	56472,
				"bits_per_second":	451531.30370394728,
				"jitter_ms":	5.4631684203400441,
				"lost_packets":	0,
				"packets":	39,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	1.0005419254302979,
					"end":	2.0001649856567383,
					"seconds":	0.99962306022644043,
					"bytes":	131768,
					"bits_per_second":	1054541.4986337041,
					"jitter_ms":	1.6919598513460861,
					"lost_packets":	0,
					"packets":	91,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	1.0005419254302979,
				"end":	2.0001649856567383,
				"seconds":	0.99962306022644043,
				"bytes":	131768,
				"bits_per_second":	1054541.4986337041,
				"jitter_ms":	1.6919598513460861,
				"lost_packets":	0,
				"packets":	91,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	2.0001649856567383,
					"end":	3.000032901763916,
					"seconds":	0.99986791610717773,
					"bytes":	130320,
					"bits_per_second":	1042697.7235743667,
					"jitter_ms":	1.5736765527118337,
					"lost_packets":	0,
					"packets":	90,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	2.0001649856567383,
				"end":	3.000032901763916,
				"seconds":	0.99986791610717773,
				"bytes":	130320,
				"bits_per_second":	1042697.7235743667,
				"jitter_ms":	1.5736765527118337,
				"lost_packets":	0,
				"packets":	90,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	3.000032901763916,
					"end":	4.0004148483276367,
					"seconds":	1.0003819465637207,
					"bytes":	130320,
					"bits_per_second":	1042161.9498244241,
					"jitter_ms":	1.5316822491530364,
					"lost_packets":	0,
					"packets":	90,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	3.000032901763916,
				"end":	4.0004148483276367,
				"seconds":	1.0003819465637207,
				"bytes":	130320,
				"bits_per_second":	1042161.9498244241,
				"jitter_ms":	1.5316822491530364,
				"lost_packets":	0,
				"packets":	90,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	4.0004148483276367,
					"end":	5.0005488395690918,
					"seconds":	1.0001339912414551,
					"bytes":	130320,
					"bits_per_second":	1042420.3248065611,
					"jitter_ms":	1.80109779831896,
					"lost_packets":	0,
					"packets":	90,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	4.0004148483276367,
				"end":	5.0005488395690918,
				"seconds":	1.0001339912414551,
				"bytes":	130320,
				"bits_per_second":	1042420.3248065611,
				"jitter_ms":	1.80109779831896,
				"lost_packets":	0,
				"packets":	90,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	5.0005488395690918,
					"end":	6.000154972076416,
					"seconds":	0.99960613250732422,
					"bytes":	131768,
					"bits_per_second":	1054559.3566496815,
					"jitter_ms":	1.683127610266788,
					"lost_packets":	0,
					"packets":	91,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	5.0005488395690918,
				"end":	6.000154972076416,
				"seconds":	0.99960613250732422,
				"bytes":	131768,
				"bits_per_second":	1054559.3566496815,
				"jitter_ms":	1.683127610266788,
				"lost_packets":	0,
				"packets":	91,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	6.000154972076416,
					"end":	7.0003039836883545,
					"seconds":	1.0001490116119385,
					"bytes":	131768,
					"bits_per_second":	1053986.9437065562,
					"jitter_ms":	1.6203054576171958,
					"lost_packets":	0,
					"packets":	91,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	6.000154972076416,
				"end":	7.0003039836883545,
				"seconds":	1.0001490116119385,
				"bytes":	131768,
				"bits_per_second":	1053986.9437065562,
				"jitter_ms":	1.6203054576171958,
				"lost_packets":	0,
				"packets":	91,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	7.0003039836883545,
					"end":	8.000424861907959,
					"seconds":	1.0001208782196045,
					"bytes":	130320,
					"bits_per_second":	1042433.9924349393,
					"jitter_ms":	1.3385075006647031,
					"lost_packets":	0,
					"packets":	90,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	7.0003039836883545,
				"end":	8.000424861907959,
				"seconds":	1.0001208782196045,
				"bytes":	130320,
				"bits_per_second":	1042433.9924349393,
				"jitter_ms":	1.3385075006647031,
				"lost_packets":	0,
				"packets":	90,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	8.000424861907959,
					"end":	9.0005559921264648,
					"seconds":	1.0001311302185059,
					"bytes":	131768,
					"bits_per_second":	1054005.7879907144,
					"jitter_ms":	2.6760332096776791,
					"lost_packets":	0,
					"packets":	91,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	8.000424861907959,
				"end":	9.0005559921264648,
				"seconds":	1.0001311302185059,
				"bytes":	131768,
				"bits_per_second":	1054005.7879907144,
				"jitter_ms":	2.6760332096776791,
				"lost_packets":	0,
				"packets":	91,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	9.0005559921264648,
					"end":	10.000185012817383,
					"seconds":	0.999629020690918,
					"bytes":	131768,
					"bits_per_second":	1054535.2107438846,
					"jitter_ms":	1.4132002938937065,
					"lost_packets":	0,
					"packets":	91,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	9.0005559921264648,
				"end":	10.000185012817383,
				"seconds":	0.999629020690918,
				"bytes":	131768,
				"bits_per_second":	1054535.2107438846,
				"jitter_ms":	1.4132002938937065,
				"lost_packets":	0,
				"packets":	91,
				"lost_percent":	0,
				"omitted":	false
			}
		}, {
			"streams":	[{
					"socket":	6,
					"start":	10.000185012817383,
					"end":	10.580043792724609,
					"seconds":	0.57985877990722656,
					"bytes":	73848,
					"bits_per_second":	1018841.1738708542,
					"jitter_ms":	1.5506041746410271,
					"lost_packets":	0,
					"packets":	51,
					"lost_percent":	0,
					"omitted":	false
				}],
			"sum":	{
				"start":	10.000185012817383,
				"end":	10.580043792724609,
				"seconds":	0.57985877990722656,
				"bytes":	73848,
				"bits_per_second":	1018841.1738708542,
				"jitter_ms":	1.5506041746410271,
				"lost_packets":	0,
				"packets":	51,
				"lost_percent":	0,
				"omitted":	false
			}
		}],
	"end":	{
		"streams":	[{
				"udp":	{
					"socket":	6,
					"start":	0,
					"end":	10.580043792724609,
					"seconds":	10.580043792724609,
					"bytes":	0,
					"bits_per_second":	0,
					"jitter_ms":	1.5506041746410271,
					"lost_packets":	0,
					"packets":	905,
					"lost_percent":	0,
					"out_of_order":	0
				}
			}],
		"sum":	{
			"start":	0,
			"end":	10.580043792724609,
			"seconds":	10.580043792724609,
			"bytes":	0,
			"bits_per_second":	0,
			"jitter_ms":	1.5506041746410271,
			"lost_packets":	0,
			"packets":	905,
			"lost_percent":	0
		},
		"cpu_utilization_percent":	{
			"host_total":	0.043347153484469859,
			"host_user":	0.0433497330579931,
			"host_system":	0,
			"remote_total":	0,
			"remote_user":	0,
			"remote_system":	0
		}
	}
}

Note that the total bytes received is 0 in the final report whereas it is reported as 130 kB (so around 1 Mb, as expected) in the periodic reports.

  • Steps to Reproduce Send UDP data from the client. Output in JSON with the server.

  • Possible Solution Set the number of bytes received equal to the sum of the number of bytes received in the periodic reports. Set the bitrate equal to the number of bytes received divided by the connection duration.

esqt avatar Jun 15 '18 15:06 esqt

The problem here is in iperf_print_results(). When we print the JSON, it basically assumes (incorrectly) that it's running on the sender side. In a normal (non --reverse) test, the sender is the client, so the receiver/server is printing the wrong statistics. It's zero bytes because the server doesn't have any of the client statistics at the time this report is generated. Basically we need to add some conditional logic to this line to make it handle both sender and receiver:

cJSON_AddItemToObject(test->json_end, "sum", iperf_json_printf("start: %f  end: %f  seconds: %f  bytes: %d  bits_per_second: %f  jitter_ms: %f  lost_packets: %d  packets: %d  lost_percent: %f", (double) start_time, (double) receiver_time, (double) receiver_time, (int64_t) total_sent, bandwidth * 8, (double) avg_jitter * 1000.0, (int64_t) lost_packets, (int64_t) total_packets, (double) lost_percent));

bmah888 avatar Jun 21 '18 22:06 bmah888

Anybody know when this will be fixed or if there is a workaround to this issue?

timoho98 avatar Sep 24 '19 17:09 timoho98

This bug still exists in version 3.11 of iperf3. Is there any idea when this will be fixed for the server side "sum"? It seems that "sum_received" works but not "sum".

JoeAPL avatar Jun 20 '22 16:06 JoeAPL

... It seems that "sum_received" works but not "sum".

Submitted PR #1358 with a proposed fix for this problem.

davidBar-On avatar Jun 30 '22 14:06 davidBar-On