hsa: adjust echo client reporting for udp runs 39/43739/2
authorSemir Sionek <[email protected]>
Tue, 23 Sep 2025 12:13:07 +0000 (12:13 +0000)
committerFlorin Coras <[email protected]>
Tue, 23 Sep 2025 18:48:56 +0000 (18:48 +0000)
Do not print handshake times for UDP, include total dgram
sent/received/loss percentage statistics.

Type: improvement
Change-Id: I67df73d56b2971c8fddd757fceef76c0f208aed4
Signed-off-by: Semir Sionek <[email protected]>
src/plugins/hs_apps/echo_client.c
src/plugins/hs_apps/echo_client.h
test-c/hs-test/echo_test.go

index 7581133..93e7296 100644 (file)
@@ -59,6 +59,14 @@ ec_worker_get (clib_thread_index_t thread_index)
   return vec_elt_at_index (ec_main.wrk, thread_index);
 }
 
+static inline void
+ec_sessions_stop_clean ()
+{
+  ec_main_t *ecm = &ec_main;
+  ecm->test_timeout += 1;
+  ecm->end_test = true;
+}
+
 static inline ec_session_t *
 ec_session_alloc (ec_worker_t *wrk)
 {
@@ -397,10 +405,12 @@ ec_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
          delete_session = 0;
        }
 
-      if (PREDICT_FALSE (delete_session == 1) || ecm->timer_expired)
+      if (PREDICT_FALSE (delete_session == 1) || ecm->end_test)
        {
          clib_atomic_fetch_add (&ecm->tx_total, es->bytes_sent);
          clib_atomic_fetch_add (&ecm->rx_total, es->bytes_received);
+         clib_atomic_fetch_add (&ecm->tx_total_dgrams, es->dgrams_sent);
+         clib_atomic_fetch_add (&ecm->rx_total_dgrams, es->dgrams_received);
          s = session_get_from_handle_if_valid (es->vpp_session_handle);
 
          if (s)
@@ -471,11 +481,13 @@ ec_reset_runtime_config (ec_main_t *ecm)
   ecm->tls_engine = CRYPTO_ENGINE_OPENSSL;
   ecm->no_copy = 0;
   ecm->run_test = EC_STARTING;
-  ecm->timer_expired = false;
+  ecm->end_test = false;
   ecm->ready_connections = 0;
   ecm->connect_conn_index = 0;
   ecm->rx_total = 0;
   ecm->tx_total = 0;
+  ecm->rx_total_dgrams = 0;
+  ecm->tx_total_dgrams = 0;
   ecm->barrier_acq_needed = 0;
   ecm->prealloc_sessions = 0;
   ecm->prealloc_fifos = 0;
@@ -1392,6 +1404,7 @@ ec_print_final_stats (vlib_main_t *vm, f64 total_delta)
 {
   ec_main_t *ecm = &ec_main;
   u64 total_bytes;
+  f64 dgram_loss;
   char *transfer_type;
 
   if (ecm->transport_proto == TRANSPORT_PROTO_TCP ||
@@ -1408,7 +1421,18 @@ ec_print_final_stats (vlib_main_t *vm, f64 total_delta)
       else
        ec_cli ("error measuring roundtrip time");
     }
-
+  if (ecm->transport_proto == TRANSPORT_PROTO_UDP)
+    {
+      ec_cli ("sent total %llu datagrams, received total %llu datagrams",
+             ecm->tx_total_dgrams, ecm->rx_total_dgrams);
+      dgram_loss = (ecm->tx_total_dgrams ?
+                     ((f64) (ecm->tx_total_dgrams - ecm->rx_total_dgrams) /
+                      (f64) ecm->tx_total_dgrams * 100.0) :
+                     0.0);
+      if (ecm->echo_bytes && dgram_loss > 0.0)
+       ec_cli ("lost %llu datagrams (%.2f%%)",
+               ecm->tx_total_dgrams - ecm->rx_total_dgrams, dgram_loss);
+    }
   total_bytes = (ecm->echo_bytes ? ecm->rx_total : ecm->tx_total);
   transfer_type = ecm->echo_bytes ? "full-duplex" : "half-duplex";
   ec_cli ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds", total_bytes,
@@ -1596,10 +1620,13 @@ parse_config:
       goto stop_test;
 
     case EC_CLI_CONNECTS_DONE:
-      delta = vlib_time_now (vm) - ecm->syn_start_time;
-      if (delta != 0.0)
-       ec_cli ("%d three-way handshakes in %.2f seconds %.2f/s",
-               ecm->n_clients, delta, ((f64) ecm->n_clients) / delta);
+      if (ecm->transport_proto == TRANSPORT_PROTO_TCP)
+       {
+         delta = vlib_time_now (vm) - ecm->syn_start_time;
+         if (delta != 0.0)
+           ec_cli ("%d three-way handshakes in %.2f seconds %.2f/s",
+                   ecm->n_clients, delta, ((f64) ecm->n_clients) / delta);
+       }
       break;
 
     case EC_CLI_CONNECTS_FAILED:
@@ -1652,8 +1679,7 @@ parse_config:
            {
              if (ecm->run_time)
                {
-                 ecm->timer_expired = true;
-                 ecm->test_timeout += 1;
+                 ec_sessions_stop_clean ();
                  break;
                }
              ec_print_timeout_stats (vm);
@@ -1661,6 +1687,11 @@ parse_config:
                error =
                  clib_error_return (0, "failed: timeout with %d sessions",
                                     ecm->ready_connections);
+             else if (ecm->echo_bytes)
+               {
+                 ec_sessions_stop_clean ();
+                 break;
+               }
              goto stop_test;
            }
          else
index 63e4863..787ae7e 100644 (file)
@@ -72,8 +72,10 @@ typedef struct
   volatile u32 ready_connections;
   volatile u64 rx_total;
   volatile u64 tx_total;
+  volatile u64 rx_total_dgrams;
+  volatile u64 tx_total_dgrams;
   volatile int run_test; /**< Signal start of test */
-  volatile bool timer_expired; /**< Signal end of timed test */
+  volatile bool end_test; /**< Signal end of test */
 
   f64 syn_start_time;
   f64 test_start_time;
index b9471ff..6e26f87 100644 (file)
@@ -166,6 +166,7 @@ func EchoBuiltinEchobytesTest(s *VethsSuite) {
        o := clientVpp.Vppctl("test echo client echo-bytes verbose uri" +
                " udp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1)
        s.Log(o)
+       s.AssertContains(o, "sent total 6 datagrams, received total 6 datagrams")
        s.AssertNotContains(o, "test echo clients: failed: timeout with 1 sessions")
 }
 
@@ -185,6 +186,7 @@ func EchoBuiltinTestbytesTest(s *VethsSuite) {
                " udp://" + s.Interfaces.Server.Ip4AddressString() + "/" + s.Ports.Port1)
        s.Log(o)
        s.AssertNotContains(o, "failed")
+       s.AssertContains(o, "lost")
        s.AssertContains(o, " bytes out of 32768 sent (32768 target)")
 }