From 5592e38253bc74c65f4d105f837d8bc048ac1859 Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Mon, 12 Dec 2022 14:30:40 +0900 Subject: [PATCH] netutils: iperf: Fix the transfer bytes and the bandwidth overflow Summary: - I noticed that the iperf shows incorrect transfer bytes in each period. - Also, the bandwidth overflows sometimes. - This commit fixes these issues. Impact: - None Testing: - Tested with qemu-armv8a:netnsh_smp on QEMU-7.1 Signed-off-by: Masayuki Ishikawa --- netutils/iperf/iperf.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c index aea1b024e..ccddcc212 100644 --- a/netutils/iperf/iperf.c +++ b/netutils/iperf/iperf.c @@ -267,9 +267,10 @@ static void iperf_report_task(FAR void *arg) printf("%7.2lf-%7.2lf sec %10ju Bytes %7.2f Mbits/sec\n", ts_diff(&last, &start), ts_diff(&now, &start), - now_len, - (((double)(now_len - last_len) * 8) / - ts_diff(&now, &last) / 1e6)); + now_len -last_len, + (double)((now_len - last_len) * 8 / 1000000) / + (double)ts_diff(&now, &last) + ); if (time != 0 && ts_diff(&now, &start) >= time) { break; @@ -282,8 +283,9 @@ static void iperf_report_task(FAR void *arg) ts_diff(&start, &start), ts_diff(&now, &start), now_len, - (((double)now_len * 8) / - ts_diff(&now, &start) / 1e6)); + (double)(now_len * 8 / 1000000) / + (double)ts_diff(&now, &start) + ); } ctrl->finish = true;