2 * echo_client.c - vpp built-in echo client code
4 * Copyright (c) 2017 by Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include <vnet/vnet.h>
19 #include <vlibapi/api.h>
20 #include <vlibmemory/api.h>
21 #include <vnet/session-apps/echo_client.h>
23 echo_client_main_t echo_client_main;
25 #define ECHO_CLIENT_DBG (0)
28 signal_evt_to_cli_i (int *code)
30 echo_client_main_t *ecm = &echo_client_main;
31 ASSERT (vlib_get_thread_index () == 0);
32 vlib_process_signal_event (ecm->vlib_main, ecm->cli_node_index, *code, 0);
36 signal_evt_to_cli (int code)
38 if (vlib_get_thread_index () != 0)
39 vl_api_rpc_call_main_thread (signal_evt_to_cli_i, (u8 *) & code,
42 signal_evt_to_cli_i (&code);
46 send_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
48 u8 *test_data = ecm->connect_test_data;
49 int test_buf_len, test_buf_offset, rv;
52 test_buf_len = vec_len (test_data);
53 ASSERT (test_buf_len > 0);
54 test_buf_offset = s->bytes_sent % test_buf_len;
55 bytes_this_chunk = clib_min (test_buf_len - test_buf_offset,
62 svm_fifo_t *f = s->data.tx_fifo;
63 rv = clib_min (svm_fifo_max_enqueue (f), bytes_this_chunk);
64 svm_fifo_enqueue_nocopy (f, rv);
65 if (svm_fifo_set_event (f))
67 session_fifo_event_t evt;
69 evt.event_type = FIFO_EVENT_APP_TX;
70 svm_queue_add (s->data.vpp_evt_q, (u8 *) & evt, 0);
74 rv = app_send_stream (&s->data, test_data + test_buf_offset,
81 session_dgram_hdr_t hdr;
82 svm_fifo_t *f = s->data.tx_fifo;
83 app_session_transport_t *at = &s->data.transport;
84 u32 max_enqueue = svm_fifo_max_enqueue (f);
86 if (max_enqueue <= sizeof (session_dgram_hdr_t))
89 max_enqueue -= sizeof (session_dgram_hdr_t);
90 rv = clib_min (max_enqueue, bytes_this_chunk);
94 clib_memcpy (&hdr.rmt_ip, &at->rmt_ip, sizeof (ip46_address_t));
95 hdr.is_ip4 = at->is_ip4;
96 hdr.rmt_port = at->rmt_port;
97 clib_memcpy (&hdr.lcl_ip, &at->lcl_ip, sizeof (ip46_address_t));
98 hdr.lcl_port = at->lcl_port;
99 svm_fifo_enqueue_nowait (f, sizeof (hdr), (u8 *) & hdr);
100 svm_fifo_enqueue_nocopy (f, rv);
101 if (svm_fifo_set_event (f))
103 session_fifo_event_t evt;
105 evt.event_type = FIFO_EVENT_APP_TX;
106 svm_queue_add (s->data.vpp_evt_q, (u8 *) & evt, 0);
110 rv = app_send_dgram (&s->data, test_data + test_buf_offset,
111 bytes_this_chunk, 0);
114 /* If we managed to enqueue data... */
117 /* Account for it... */
118 s->bytes_to_send -= rv;
124 ELOG_TYPE_DECLARE (e) =
126 .format = "tx-enq: xfer %d bytes, sent %u remain %u",
127 .format_args = "i4i4i4",
134 ed = ELOG_DATA (&vlib_global_main.elog_main, e);
136 ed->data[1] = s->bytes_sent;
137 ed->data[2] = s->bytes_to_send;
143 receive_data_chunk (echo_client_main_t * ecm, eclient_session_t * s)
145 svm_fifo_t *rx_fifo = s->data.rx_fifo;
146 u32 thread_index = vlib_get_thread_index ();
152 n_read = app_recv_stream (&s->data, ecm->rx_buf[thread_index],
153 vec_len (ecm->rx_buf[thread_index]));
155 n_read = app_recv_dgram (&s->data, ecm->rx_buf[thread_index],
156 vec_len (ecm->rx_buf[thread_index]));
160 n_read = svm_fifo_max_dequeue (rx_fifo);
161 svm_fifo_dequeue_drop (rx_fifo, n_read);
169 ELOG_TYPE_DECLARE (e) =
171 .format = "rx-deq: %d bytes",
179 ed = ELOG_DATA (&vlib_global_main.elog_main, e);
180 ed->data[0] = n_read;
185 for (i = 0; i < n_read; i++)
187 if (ecm->rx_buf[thread_index][i]
188 != ((s->bytes_received + i) & 0xff))
190 clib_warning ("read %d error at byte %lld, 0x%x not 0x%x",
191 n_read, s->bytes_received + i,
192 ecm->rx_buf[thread_index][i],
193 ((s->bytes_received + i) & 0xff));
194 ecm->test_failed = 1;
198 ASSERT (n_read <= s->bytes_to_receive);
199 s->bytes_to_receive -= n_read;
200 s->bytes_received += n_read;
205 echo_client_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
206 vlib_frame_t * frame)
208 echo_client_main_t *ecm = &echo_client_main;
209 int my_thread_index = vlib_get_thread_index ();
210 eclient_session_t *sp;
213 u32 *connection_indices;
214 u32 *connections_this_batch;
215 u32 nconnections_this_batch;
217 connection_indices = ecm->connection_index_by_thread[my_thread_index];
218 connections_this_batch =
219 ecm->connections_this_batch_by_thread[my_thread_index];
221 if ((ecm->run_test == 0) ||
222 ((vec_len (connection_indices) == 0)
223 && vec_len (connections_this_batch) == 0))
226 /* Grab another pile of connections */
227 if (PREDICT_FALSE (vec_len (connections_this_batch) == 0))
229 nconnections_this_batch =
230 clib_min (ecm->connections_per_batch, vec_len (connection_indices));
232 ASSERT (nconnections_this_batch > 0);
233 vec_validate (connections_this_batch, nconnections_this_batch - 1);
234 clib_memcpy (connections_this_batch,
235 connection_indices + vec_len (connection_indices)
236 - nconnections_this_batch,
237 nconnections_this_batch * sizeof (u32));
238 _vec_len (connection_indices) -= nconnections_this_batch;
241 if (PREDICT_FALSE (ecm->prev_conns != ecm->connections_per_batch
242 && ecm->prev_conns == vec_len (connections_this_batch)))
245 ecm->prev_conns = vec_len (connections_this_batch);
246 if (ecm->repeats == 500000)
248 clib_warning ("stuck clients");
253 ecm->prev_conns = vec_len (connections_this_batch);
257 for (i = 0; i < vec_len (connections_this_batch); i++)
261 sp = pool_elt_at_index (ecm->sessions, connections_this_batch[i]);
263 if (sp->bytes_to_send > 0)
265 send_data_chunk (ecm, sp);
268 if (sp->bytes_to_receive > 0)
272 if (PREDICT_FALSE (delete_session == 1))
276 __sync_fetch_and_add (&ecm->tx_total, sp->bytes_sent);
277 __sync_fetch_and_add (&ecm->rx_total, sp->bytes_received);
278 s = session_get_from_handle_if_valid (sp->vpp_session_handle);
282 vnet_disconnect_args_t _a, *a = &_a;
283 a->handle = session_handle (s);
284 a->app_index = ecm->app_index;
285 vnet_disconnect_session (a);
287 vec_delete (connections_this_batch, 1, i);
289 __sync_fetch_and_add (&ecm->ready_connections, -1);
293 clib_warning ("session AWOL?");
294 vec_delete (connections_this_batch, 1, i);
297 /* Kick the debug CLI process */
298 if (ecm->ready_connections == 0)
300 signal_evt_to_cli (2);
305 ecm->connection_index_by_thread[my_thread_index] = connection_indices;
306 ecm->connections_this_batch_by_thread[my_thread_index] =
307 connections_this_batch;
312 VLIB_REGISTER_NODE (echo_clients_node) =
314 .function = echo_client_node_fn,
315 .name = "echo-clients",
316 .type = VLIB_NODE_TYPE_INPUT,
317 .state = VLIB_NODE_STATE_DISABLED,
322 create_api_loopback (echo_client_main_t * ecm)
324 api_main_t *am = &api_main;
325 vl_shmem_hdr_t *shmem_hdr;
327 shmem_hdr = am->shmem_hdr;
328 ecm->vl_input_queue = shmem_hdr->vl_input_queue;
329 ecm->my_client_index = vl_api_memclnt_create_internal ("echo_client",
330 ecm->vl_input_queue);
335 echo_clients_init (vlib_main_t * vm)
337 echo_client_main_t *ecm = &echo_client_main;
338 vlib_thread_main_t *vtm = vlib_get_thread_main ();
342 if (create_api_loopback (ecm))
345 num_threads = 1 /* main thread */ + vtm->n_threads;
347 /* Init test data. Big buffer */
348 vec_validate (ecm->connect_test_data, 4 * 1024 * 1024 - 1);
349 for (i = 0; i < vec_len (ecm->connect_test_data); i++)
350 ecm->connect_test_data[i] = i & 0xff;
352 vec_validate (ecm->rx_buf, num_threads - 1);
353 for (i = 0; i < num_threads; i++)
354 vec_validate (ecm->rx_buf[i], vec_len (ecm->connect_test_data) - 1);
358 vec_validate (ecm->connection_index_by_thread, vtm->n_vlib_mains);
359 vec_validate (ecm->connections_this_batch_by_thread, vtm->n_vlib_mains);
360 vec_validate (ecm->vpp_event_queue, vtm->n_vlib_mains);
366 echo_clients_session_connected_callback (u32 app_index, u32 api_context,
367 stream_session_t * s, u8 is_fail)
369 echo_client_main_t *ecm = &echo_client_main;
370 eclient_session_t *session;
372 u8 thread_index = vlib_get_thread_index ();
376 clib_warning ("connection %d failed!", api_context);
377 signal_evt_to_cli (-1);
381 ASSERT (s->thread_index == thread_index);
383 if (!ecm->vpp_event_queue[thread_index])
384 ecm->vpp_event_queue[thread_index] =
385 session_manager_get_vpp_event_queue (thread_index);
390 clib_spinlock_lock_if_init (&ecm->sessions_lock);
391 pool_get (ecm->sessions, session);
392 clib_spinlock_unlock_if_init (&ecm->sessions_lock);
394 memset (session, 0, sizeof (*session));
395 session_index = session - ecm->sessions;
396 session->bytes_to_send = ecm->bytes_to_send;
397 session->bytes_to_receive = ecm->no_return ? 0ULL : ecm->bytes_to_send;
398 session->data.rx_fifo = s->server_rx_fifo;
399 session->data.rx_fifo->client_session_index = session_index;
400 session->data.tx_fifo = s->server_tx_fifo;
401 session->data.tx_fifo->client_session_index = session_index;
402 session->data.vpp_evt_q = ecm->vpp_event_queue[thread_index];
403 session->vpp_session_handle = session_handle (s);
407 transport_connection_t *tc;
408 tc = session_get_transport (s);
409 clib_memcpy (&session->data.transport, tc,
410 sizeof (session->data.transport));
411 session->data.is_dgram = 1;
414 vec_add1 (ecm->connection_index_by_thread[thread_index], session_index);
415 __sync_fetch_and_add (&ecm->ready_connections, 1);
416 if (ecm->ready_connections == ecm->expected_connections)
419 /* Signal the CLI process that the action is starting... */
420 signal_evt_to_cli (1);
427 echo_clients_session_reset_callback (stream_session_t * s)
429 if (s->session_state == SESSION_STATE_READY)
430 clib_warning ("Reset active connection %U", format_stream_session, s, 2);
431 stream_session_cleanup (s);
436 echo_clients_session_create_callback (stream_session_t * s)
442 echo_clients_session_disconnect_callback (stream_session_t * s)
444 echo_client_main_t *ecm = &echo_client_main;
445 vnet_disconnect_args_t _a, *a = &_a;
446 a->handle = session_handle (s);
447 a->app_index = ecm->app_index;
448 vnet_disconnect_session (a);
453 echo_clients_rx_callback (stream_session_t * s)
455 echo_client_main_t *ecm = &echo_client_main;
456 eclient_session_t *sp;
458 sp = pool_elt_at_index (ecm->sessions,
459 s->server_rx_fifo->client_session_index);
460 receive_data_chunk (ecm, sp);
462 if (svm_fifo_max_dequeue (s->server_rx_fifo))
464 session_fifo_event_t evt;
466 if (svm_fifo_set_event (s->server_rx_fifo))
468 evt.fifo = s->server_rx_fifo;
469 evt.event_type = FIFO_EVENT_BUILTIN_RX;
470 q = session_manager_get_vpp_event_queue (s->thread_index);
471 if (PREDICT_FALSE (q->cursize == q->maxsize))
472 clib_warning ("out of event queue space");
473 else if (svm_queue_add (q, (u8 *) & evt, 0))
474 clib_warning ("failed to enqueue self-tap");
481 echo_client_add_segment_callback (u32 client_index, const ssvm_private_t * sp)
483 /* New heaps may be added */
488 static session_cb_vft_t echo_clients = {
489 .session_reset_callback = echo_clients_session_reset_callback,
490 .session_connected_callback = echo_clients_session_connected_callback,
491 .session_accept_callback = echo_clients_session_create_callback,
492 .session_disconnect_callback = echo_clients_session_disconnect_callback,
493 .builtin_app_rx_callback = echo_clients_rx_callback,
494 .add_segment_callback = echo_client_add_segment_callback
498 static clib_error_t *
499 echo_clients_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
501 u32 prealloc_fifos, segment_size = 256 << 20;
502 echo_client_main_t *ecm = &echo_client_main;
503 vnet_app_attach_args_t _a, *a = &_a;
505 clib_error_t *error = 0;
507 memset (a, 0, sizeof (*a));
508 memset (options, 0, sizeof (options));
510 a->api_client_index = ecm->my_client_index;
511 a->session_cb_vft = &echo_clients;
513 prealloc_fifos = ecm->prealloc_fifos ? ecm->expected_connections : 1;
515 if (ecm->private_segment_size)
516 segment_size = ecm->private_segment_size;
518 options[APP_OPTIONS_ACCEPT_COOKIE] = 0x12345678;
519 options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
520 options[APP_OPTIONS_ADD_SEGMENT_SIZE] = segment_size;
521 options[APP_OPTIONS_RX_FIFO_SIZE] = ecm->fifo_size;
522 options[APP_OPTIONS_TX_FIFO_SIZE] = ecm->fifo_size;
523 options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT] = ecm->private_segment_count;
524 options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] = prealloc_fifos;
525 options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
526 options[APP_OPTIONS_TLS_ENGINE] = ecm->tls_engine;
529 options[APP_OPTIONS_FLAGS] |= appns_flags;
530 options[APP_OPTIONS_NAMESPACE_SECRET] = appns_secret;
532 a->options = options;
533 a->namespace_id = appns_id;
535 if ((error = vnet_application_attach (a)))
538 ecm->app_index = a->app_index;
543 echo_clients_detach ()
545 echo_client_main_t *ecm = &echo_client_main;
546 vnet_app_detach_args_t _da, *da = &_da;
549 da->app_index = ecm->app_index;
550 rv = vnet_application_detach (da);
551 ecm->test_client_attached = 0;
557 echo_client_thread_fn (void *arg)
562 /** Start a transmit thread */
564 echo_clients_start_tx_pthread (echo_client_main_t * ecm)
566 if (ecm->client_thread_handle == 0)
568 int rv = pthread_create (&ecm->client_thread_handle,
570 echo_client_thread_fn, 0);
573 ecm->client_thread_handle = 0;
581 echo_clients_connect (vlib_main_t * vm, u32 n_clients)
583 echo_client_main_t *ecm = &echo_client_main;
584 vnet_connect_args_t _a, *a = &_a;
585 clib_error_t *error = 0;
588 memset (a, 0, sizeof (*a));
589 for (i = 0; i < n_clients; i++)
591 a->uri = (char *) ecm->connect_uri;
593 a->app_index = ecm->app_index;
595 if ((error = vnet_connect_uri (a)))
598 /* Crude pacing for call setups */
600 vlib_process_suspend (vm, 10e-6);
601 ASSERT (i + 1 >= ecm->ready_connections);
602 while (i + 1 - ecm->ready_connections > 1000)
604 vlib_process_suspend (vm, 100e-6);
610 #define ec_cli_output(_fmt, _args...) \
611 if (!ecm->no_output) \
612 vlib_cli_output(vm, _fmt, ##_args)
614 static clib_error_t *
615 echo_clients_command_fn (vlib_main_t * vm,
616 unformat_input_t * input, vlib_cli_command_t * cmd)
618 echo_client_main_t *ecm = &echo_client_main;
619 vlib_thread_main_t *thread_main = vlib_get_thread_main ();
620 u64 tmp, total_bytes, appns_flags = 0, appns_secret = 0;
621 f64 test_timeout = 20.0, syn_timeout = 20.0, delta;
622 char *default_uri = "tcp://6.0.1.1/1234";
623 uword *event_data = 0, event_type;
624 f64 time_before_connects;
626 int preallocate_sessions = 0;
628 clib_error_t *error = 0;
632 ecm->bytes_to_send = 8192;
634 ecm->fifo_size = 64 << 10;
635 ecm->connections_per_batch = 1000;
636 ecm->private_segment_count = 0;
637 ecm->private_segment_size = 0;
640 ecm->test_failed = 0;
642 ecm->tls_engine = TLS_ENGINE_OPENSSL;
645 if (thread_main->n_vlib_mains > 1)
646 clib_spinlock_init (&ecm->sessions_lock);
647 vec_free (ecm->connect_uri);
649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
651 if (unformat (input, "uri %s", &ecm->connect_uri))
653 else if (unformat (input, "nclients %d", &n_clients))
655 else if (unformat (input, "mbytes %lld", &tmp))
656 ecm->bytes_to_send = tmp << 20;
657 else if (unformat (input, "gbytes %lld", &tmp))
658 ecm->bytes_to_send = tmp << 30;
659 else if (unformat (input, "bytes %lld", &ecm->bytes_to_send))
661 else if (unformat (input, "test-timeout %f", &test_timeout))
663 else if (unformat (input, "syn-timeout %f", &syn_timeout))
665 else if (unformat (input, "no-return"))
667 else if (unformat (input, "fifo-size %d", &ecm->fifo_size))
668 ecm->fifo_size <<= 10;
669 else if (unformat (input, "private-segment-count %d",
670 &ecm->private_segment_count))
672 else if (unformat (input, "private-segment-size %U",
673 unformat_memory_size, &tmp))
675 if (tmp >= 0x100000000ULL)
676 return clib_error_return
677 (0, "private segment size %lld (%llu) too large", tmp, tmp);
678 ecm->private_segment_size = tmp;
680 else if (unformat (input, "preallocate-fifos"))
681 ecm->prealloc_fifos = 1;
682 else if (unformat (input, "preallocate-sessions"))
683 preallocate_sessions = 1;
685 if (unformat (input, "client-batch %d", &ecm->connections_per_batch))
687 else if (unformat (input, "appns %_%v%_", &appns_id))
689 else if (unformat (input, "all-scope"))
690 appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
691 | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
692 else if (unformat (input, "local-scope"))
693 appns_flags = APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
694 else if (unformat (input, "global-scope"))
695 appns_flags = APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
696 else if (unformat (input, "secret %lu", &appns_secret))
698 else if (unformat (input, "no-output"))
700 else if (unformat (input, "test-bytes"))
702 else if (unformat (input, "tls-engine %d", &ecm->tls_engine))
705 return clib_error_return (0, "failed: unknown input `%U'",
706 format_unformat_error, input);
709 /* Store cli process node index for signalling */
710 ecm->cli_node_index =
711 vlib_get_current_process (vm)->node_runtime.node_index;
713 if (ecm->is_init == 0)
715 if (echo_clients_init (vm))
716 return clib_error_return (0, "failed init");
720 ecm->ready_connections = 0;
721 ecm->expected_connections = n_clients;
725 if (!ecm->connect_uri)
727 clib_warning ("No uri provided. Using default: %s", default_uri);
728 ecm->connect_uri = format (0, "%s%c", default_uri, 0);
731 if (ecm->connect_uri[0] == 'u' && ecm->connect_uri[3] != 'c')
734 #if ECHO_CLIENT_PTHREAD
735 echo_clients_start_tx_pthread ();
738 vlib_worker_thread_barrier_sync (vm);
739 vnet_session_enable_disable (vm, 1 /* turn on session and transports */ );
740 vlib_worker_thread_barrier_release (vm);
742 if (ecm->test_client_attached == 0)
744 if ((error = echo_clients_attach (appns_id, appns_flags, appns_secret)))
747 clib_error_report (error);
752 ecm->test_client_attached = 1;
754 /* Turn on the builtin client input nodes */
755 for (i = 0; i < thread_main->n_vlib_mains; i++)
756 vlib_node_set_state (vlib_mains[i], echo_clients_node.index,
757 VLIB_NODE_STATE_POLLING);
759 if (preallocate_sessions)
760 pool_init_fixed (ecm->sessions, 1.1 * n_clients);
762 /* Fire off connect requests */
763 time_before_connects = vlib_time_now (vm);
764 if ((error = echo_clients_connect (vm, n_clients)))
767 /* Park until the sessions come up, or ten seconds elapse... */
768 vlib_process_wait_for_event_or_clock (vm, syn_timeout);
769 event_type = vlib_process_get_events (vm, &event_data);
773 ec_cli_output ("Timeout with only %d sessions active...",
774 ecm->ready_connections);
775 error = clib_error_return (0, "failed: syn timeout with %d sessions",
776 ecm->ready_connections);
780 delta = vlib_time_now (vm) - time_before_connects;
782 ec_cli_output ("%d three-way handshakes in %.2f seconds %.2f/s",
783 n_clients, delta, ((f64) n_clients) / delta);
785 ecm->test_start_time = vlib_time_now (ecm->vlib_main);
786 ec_cli_output ("Test started at %.6f", ecm->test_start_time);
790 ec_cli_output ("unexpected event(1): %d", event_type);
791 error = clib_error_return (0, "failed: unexpected event(1): %d",
796 /* Now wait for the sessions to finish... */
797 vlib_process_wait_for_event_or_clock (vm, test_timeout);
798 event_type = vlib_process_get_events (vm, &event_data);
802 ec_cli_output ("Timeout with %d sessions still active...",
803 ecm->ready_connections);
804 error = clib_error_return (0, "failed: timeout with %d sessions",
805 ecm->ready_connections);
809 ecm->test_end_time = vlib_time_now (vm);
810 ec_cli_output ("Test finished at %.6f", ecm->test_end_time);
814 ec_cli_output ("unexpected event(2): %d", event_type);
815 error = clib_error_return (0, "failed: unexpected event(2): %d",
820 delta = ecm->test_end_time - ecm->test_start_time;
823 total_bytes = (ecm->no_return ? ecm->tx_total : ecm->rx_total);
824 transfer_type = ecm->no_return ? "half-duplex" : "full-duplex";
825 ec_cli_output ("%lld bytes (%lld mbytes, %lld gbytes) in %.2f seconds",
826 total_bytes, total_bytes / (1ULL << 20),
827 total_bytes / (1ULL << 30), delta);
828 ec_cli_output ("%.2f bytes/second %s", ((f64) total_bytes) / (delta),
830 ec_cli_output ("%.4f gbit/second %s",
831 (((f64) total_bytes * 8.0) / delta / 1e9),
836 ec_cli_output ("zero delta-t?");
837 error = clib_error_return (0, "failed: zero delta-t");
841 if (ecm->test_bytes && ecm->test_failed)
842 error = clib_error_return (0, "failed: test bytes");
846 for (i = 0; i < vec_len (ecm->connection_index_by_thread); i++)
848 vec_reset_length (ecm->connection_index_by_thread[i]);
849 vec_reset_length (ecm->connections_this_batch_by_thread[i]);
852 pool_free (ecm->sessions);
854 /* Detach the application, so we can use different fifo sizes next time */
855 if (ecm->test_client_attached)
857 if (echo_clients_detach ())
859 error = clib_error_return (0, "failed: app detach");
860 ec_cli_output ("WARNING: app detach failed...");
864 ec_cli_output ("test failed");
865 vec_free (ecm->connect_uri);
870 VLIB_CLI_COMMAND (echo_clients_command, static) =
872 .path = "test echo clients",
873 .short_help = "test echo clients [nclients %d][[m|g]bytes <bytes>]"
874 "[test-timeout <time>][syn-timeout <time>][no-return][fifo-size <size>]"
875 "[private-segment-count <count>][private-segment-size <bytes>[m|g]]"
876 "[preallocate-fifos][preallocate-sessions][client-batch <batch-size>]"
877 "[uri <tcp://ip/port>][test-bytes][no-output]",
878 .function = echo_clients_command_fn,
884 echo_clients_main_init (vlib_main_t * vm)
886 echo_client_main_t *ecm = &echo_client_main;
891 VLIB_INIT_FUNCTION (echo_clients_main_init);
894 * fd.io coding-style-patch-verification: ON
897 * eval: (c-set-style "gnu")