You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/11 12:52:11 UTC

[incubator-nuttx-apps] branch master updated (324155c -> cc37729)

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

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


    from 324155c  include: update licenses to Apache
     new e8ed125  iperf: improve report precision
     new d2b7d79  iperf_report_task: print the number of bytes transferred
     new b9ad646  iperf: accept -t 0, meaning forever
     new 37bc863  iperf: Make -t0 the default for server mode
     new cc37729  iperf: Make the use of CLOCK_MONOTONIC conditional for now

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 netutils/iperf/iperf.c      | 87 +++++++++++++++++++++++++++++++++++++--------
 netutils/iperf/iperf_main.c | 13 +++++--
 2 files changed, 84 insertions(+), 16 deletions(-)

[incubator-nuttx-apps] 03/05: iperf: accept -t 0, meaning forever

Posted by xi...@apache.org.
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/incubator-nuttx-apps.git

commit b9ad64627d48e3e85cfab2664d67087f9c273995
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 10 13:34:46 2021 +0900

    iperf: accept -t 0, meaning forever
---
 netutils/iperf/iperf.c      | 2 +-
 netutils/iperf/iperf_main.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c
index 2cc4853..58efbcf 100644
--- a/netutils/iperf/iperf.c
+++ b/netutils/iperf/iperf.c
@@ -264,7 +264,7 @@ static void iperf_report_task(void *arg)
              now_len,
              (((double)(now_len - last_len) * 8) /
              ts_diff(&now, &last) / 1e6));
-      if (ts_diff(&now, &start) >= time)
+      if (time != 0 && ts_diff(&now, &start) >= time)
         {
           break;
         }
diff --git a/netutils/iperf/iperf_main.c b/netutils/iperf/iperf_main.c
index 39e8cfc..e31d799 100644
--- a/netutils/iperf/iperf_main.c
+++ b/netutils/iperf/iperf_main.c
@@ -209,7 +209,7 @@ int main(int argc, FAR char *argv[])
   else
     {
       cfg.time = iperf_args.time->ival[0];
-      if (cfg.time <= cfg.interval)
+      if (cfg.time != 0 && cfg.time <= cfg.interval)
         {
           cfg.time = cfg.interval;
         }

[incubator-nuttx-apps] 05/05: iperf: Make the use of CLOCK_MONOTONIC conditional for now

Posted by xi...@apache.org.
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/incubator-nuttx-apps.git

commit cc37729e29a464bcbe3c24650d36d7c867bad80d
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 10 16:49:23 2021 +0900

    iperf: Make the use of CLOCK_MONOTONIC conditional for now
---
 netutils/iperf/Kconfig | 1 -
 netutils/iperf/iperf.c | 9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/netutils/iperf/Kconfig b/netutils/iperf/Kconfig
index 0954ef7..3cebb9c 100644
--- a/netutils/iperf/Kconfig
+++ b/netutils/iperf/Kconfig
@@ -10,7 +10,6 @@ config NETUTILS_IPERF
 	select NETUTILS_NETLIB
 	select LIBC_FLOATINGPOINT
 	select SYSTEM_ARGTABLE3
-	select CLOCK_MONOTONIC
 	---help---
 		Enable the \"iperf example\"
 
diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c
index 58efbcf..6ee511a 100644
--- a/netutils/iperf/iperf.c
+++ b/netutils/iperf/iperf.c
@@ -231,9 +231,14 @@ static void iperf_report_task(void *arg)
   struct timespec start;
   uintmax_t now_len;
   int ret;
+#ifdef CONFIG_CLOCK_MONOTONIC
+  const clockid_t clockid = CLOCK_MONOTONIC;
+#else
+  const clockid_t clockid = CLOCK_REALTIME;
+#endif
 
   now_len = s_iperf_ctrl.total_len;
-  ret = clock_gettime(CLOCK_MONOTONIC, &now);
+  ret = clock_gettime(clockid, &now);
   if (ret != 0)
     {
       fprintf(stderr, "clock_gettime failed\n");
@@ -251,7 +256,7 @@ static void iperf_report_task(void *arg)
       last_len = now_len;
       last = now;
       now_len = s_iperf_ctrl.total_len;
-      ret = clock_gettime(CLOCK_MONOTONIC, &now);
+      ret = clock_gettime(clockid, &now);
       if (ret != 0)
         {
           fprintf(stderr, "clock_gettime failed\n");

[incubator-nuttx-apps] 02/05: iperf_report_task: print the number of bytes transferred

Posted by xi...@apache.org.
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/incubator-nuttx-apps.git

commit d2b7d79f1df12f616ee125b56036bb61aa23026f
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 10 13:28:51 2021 +0900

    iperf_report_task: print the number of bytes transferred
---
 netutils/iperf/iperf.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c
index de22995..2cc4853 100644
--- a/netutils/iperf/iperf.c
+++ b/netutils/iperf/iperf.c
@@ -241,7 +241,7 @@ static void iperf_report_task(void *arg)
     }
 
   start = now;
-  printf("\n%16s %s\n", "Interval", "Bandwidth\n");
+  printf("\n%19s %16s %18s\n", "Interval", "Transfer", "Bandwidth\n");
   while (!s_iperf_ctrl.finish)
     {
       uintmax_t last_len;
@@ -258,9 +258,10 @@ static void iperf_report_task(void *arg)
           exit(EXIT_FAILURE);
         }
 
-      printf("%4.2lf-%4.2lf sec,  %.2f Mbits/sec\n",
+      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));
       if (ts_diff(&now, &start) >= time)
@@ -271,9 +272,10 @@ static void iperf_report_task(void *arg)
 
   if (ts_diff(&now, &start) > 0)
     {
-      printf("%4.2lf-%4.2lf sec,  %.2f Mbits/sec\n",
+      printf("%7.2lf-%7.2lf sec %10ju Bytes %7.2f Mbits/sec\n",
              ts_diff(&start, &start),
              ts_diff(&now, &start),
+             now_len,
              (((double)now_len * 8) /
              ts_diff(&now, &start) / 1e6));
     }

[incubator-nuttx-apps] 04/05: iperf: Make -t0 the default for server mode

Posted by xi...@apache.org.
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/incubator-nuttx-apps.git

commit 37bc863eb75de133866353f2b2c2c483a5b68bb0
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 10 14:11:16 2021 +0900

    iperf: Make -t0 the default for server mode
    
    It matches the original iperf behavior.
    
    Note: -t is a client-only option for the original iperf 2.xx.
    
    Note: You can still choose the previous behavior by
    explictly specifying -t.
---
 netutils/iperf/iperf_main.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/netutils/iperf/iperf_main.c b/netutils/iperf/iperf_main.c
index e31d799..9fa71e1 100644
--- a/netutils/iperf/iperf_main.c
+++ b/netutils/iperf/iperf_main.c
@@ -204,7 +204,16 @@ int main(int argc, FAR char *argv[])
 
   if (iperf_args.time->count == 0)
     {
-      cfg.time = IPERF_DEFAULT_TIME;
+      if (iperf_args.server->count != 0)
+        {
+          /* Note: -t is a client-only option for the original iperf 2. */
+
+          cfg.time = 0;
+        }
+      else
+        {
+          cfg.time = IPERF_DEFAULT_TIME;
+        }
     }
   else
     {

[incubator-nuttx-apps] 01/05: iperf: improve report precision

Posted by xi...@apache.org.
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/incubator-nuttx-apps.git

commit e8ed125fea7f733c2f768c38dcc47183250e30e9
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Jun 10 13:23:14 2021 +0900

    iperf: improve report precision
---
 netutils/iperf/Kconfig |  1 +
 netutils/iperf/iperf.c | 78 +++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 66 insertions(+), 13 deletions(-)

diff --git a/netutils/iperf/Kconfig b/netutils/iperf/Kconfig
index 3cebb9c..0954ef7 100644
--- a/netutils/iperf/Kconfig
+++ b/netutils/iperf/Kconfig
@@ -10,6 +10,7 @@ config NETUTILS_IPERF
 	select NETUTILS_NETLIB
 	select LIBC_FLOATINGPOINT
 	select SYSTEM_ARGTABLE3
+	select CLOCK_MONOTONIC
 	---help---
 		Enable the \"iperf example\"
 
diff --git a/netutils/iperf/iperf.c b/netutils/iperf/iperf.c
index e56a0d2..de22995 100644
--- a/netutils/iperf/iperf.c
+++ b/netutils/iperf/iperf.c
@@ -57,7 +57,7 @@ struct iperf_ctrl_t
 {
   struct iperf_cfg_t cfg;
   bool finish;
-  uint32_t total_len;
+  uintmax_t total_len;
   uint32_t buffer_len;
   uint8_t *buffer;
   uint32_t sockfd;
@@ -190,6 +190,32 @@ static int iperf_show_socket_error_reason(const char *str, int sockfd)
 }
 
 /****************************************************************************
+ * Name: ts_sec
+ *
+ * Description:
+ *    Convert a timespec to a double.
+ *
+ ****************************************************************************/
+
+static double ts_sec(const struct timespec *ts)
+{
+  return (double)ts->tv_sec + (double)ts->tv_nsec / 1e9;
+}
+
+/****************************************************************************
+ * Name: ts_diff
+ *
+ * Description:
+ *   Return the diff of two timespecs in second.
+ *
+ ****************************************************************************/
+
+static double ts_diff(const struct timespec *a, const struct timespec *b)
+{
+  return ts_sec(a) - ts_sec(b);
+}
+
+/****************************************************************************
  * Name: iperf_report_task
  *
  * Description:
@@ -201,29 +227,55 @@ static void iperf_report_task(void *arg)
 {
   uint32_t interval = s_iperf_ctrl.cfg.interval;
   uint32_t time = s_iperf_ctrl.cfg.time;
-  uint32_t last_len = 0;
-  uint32_t cur = 0;
+  struct timespec now;
+  struct timespec start;
+  uintmax_t now_len;
+  int ret;
 
+  now_len = s_iperf_ctrl.total_len;
+  ret = clock_gettime(CLOCK_MONOTONIC, &now);
+  if (ret != 0)
+    {
+      fprintf(stderr, "clock_gettime failed\n");
+      exit(EXIT_FAILURE);
+    }
+
+  start = now;
   printf("\n%16s %s\n", "Interval", "Bandwidth\n");
   while (!s_iperf_ctrl.finish)
     {
+      uintmax_t last_len;
+      struct timespec last;
+
       sleep(interval);
-      printf("%4" PRId32 "-%4" PRId32 " sec,  %.2f Mbits/sec\n",
-             cur, cur + interval,
-             (double)((s_iperf_ctrl.total_len - last_len) * 8) /
-             interval / 1e6);
-      cur += interval;
-      last_len = s_iperf_ctrl.total_len;
-      if (cur >= time)
+      last_len = now_len;
+      last = now;
+      now_len = s_iperf_ctrl.total_len;
+      ret = clock_gettime(CLOCK_MONOTONIC, &now);
+      if (ret != 0)
+        {
+          fprintf(stderr, "clock_gettime failed\n");
+          exit(EXIT_FAILURE);
+        }
+
+      printf("%4.2lf-%4.2lf sec,  %.2f Mbits/sec\n",
+             ts_diff(&last, &start),
+             ts_diff(&now, &start),
+             (((double)(now_len - last_len) * 8) /
+             ts_diff(&now, &last) / 1e6));
+      if (ts_diff(&now, &start) >= time)
         {
           break;
         }
     }
 
-  if (cur != 0)
+  if (ts_diff(&now, &start) > 0)
     {
-      printf("%4d-%4" PRId32 " sec,  %.2f Mbits/sec\n", 0, time,
-            (double)(s_iperf_ctrl.total_len * 8) / cur / 1e6);
+      printf("%4.2lf-%4.2lf sec,  %.2f Mbits/sec\n",
+             ts_diff(&start, &start),
+             ts_diff(&now, &start),
+             (((double)now_len * 8) /
+             ts_diff(&now, &start) / 1e6));
     }
 
   s_iperf_ctrl.finish = true;