This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 5592e3825 netutils: iperf: Fix the transfer bytes and the bandwidth 
overflow
5592e3825 is described below

commit 5592e38253bc74c65f4d105f837d8bc048ac1859
Author: Masayuki Ishikawa <masayuki.ishik...@gmail.com>
AuthorDate: Mon Dec 12 14:30:40 2022 +0900

    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 <masayuki.ishik...@jp.sony.com>
---
 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;

Reply via email to