2 * nsim.c - skeleton vpp engine plug-in
4 * Copyright (c) <current-year> <your-organization>
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.
20 * @brief Network Delay Simulator
22 /*? %%clicmd:group_label Network Delay Simulator %% ?*/
24 #include <vnet/vnet.h>
25 #include <vnet/plugin/plugin.h>
26 #include <nsim/nsim.h>
28 #include <vlibapi/api.h>
29 #include <vlibmemory/api.h>
30 #include <vpp/app/version.h>
32 /* define message IDs */
33 #include <nsim/nsim.api_enum.h>
34 #include <nsim/nsim.api_types.h>
36 #define REPLY_MSG_ID_BASE nsm->msg_id_base
37 #include <vlibapi/api_helper_macros.h>
39 nsim_main_t nsim_main;
41 /* Action functions shared between message handlers and debug CLI */
44 nsim_cross_connect_enable_disable (nsim_main_t * nsm, u32 sw_if_index0,
45 u32 sw_if_index1, int enable_disable)
47 vnet_sw_interface_t *sw;
48 vnet_hw_interface_t *hw;
51 if (nsm->is_configured == 0)
52 return VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
55 if (pool_is_free_index (nsm->vnet_main->interface_main.sw_interfaces,
57 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
59 if (pool_is_free_index (nsm->vnet_main->interface_main.sw_interfaces,
61 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
63 /* Not a physical port? */
64 sw = vnet_get_sw_interface (nsm->vnet_main, sw_if_index0);
65 if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
66 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
68 sw = vnet_get_sw_interface (nsm->vnet_main, sw_if_index1);
69 if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
70 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
72 /* Add graph arcs for the input / wheel scraper node */
73 hw = vnet_get_hw_interface (nsm->vnet_main, sw_if_index0);
74 nsm->output_next_index0 =
75 vlib_node_add_next (nsm->vlib_main,
76 nsim_input_node.index, hw->output_node_index);
78 hw = vnet_get_hw_interface (nsm->vnet_main, sw_if_index1);
79 nsm->output_next_index1 =
80 vlib_node_add_next (nsm->vlib_main,
81 nsim_input_node.index, hw->output_node_index);
83 nsm->sw_if_index0 = sw_if_index0;
84 nsm->sw_if_index1 = sw_if_index1;
86 vnet_feature_enable_disable ("device-input", "nsim",
87 sw_if_index0, enable_disable, 0, 0);
88 vnet_feature_enable_disable ("device-input", "nsim",
89 sw_if_index1, enable_disable, 0, 0);
95 nsim_output_feature_enable_disable (nsim_main_t * nsm, u32 sw_if_index,
98 vnet_sw_interface_t *sw;
99 vnet_hw_interface_t *hw;
102 if (nsm->is_configured == 0)
103 return VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE;
106 if (pool_is_free_index (nsm->vnet_main->interface_main.sw_interfaces,
108 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
110 /* Not a physical port? */
111 sw = vnet_get_sw_interface (nsm->vnet_main, sw_if_index);
112 if (sw->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
113 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
115 /* Add a graph arc for the input / wheel scraper node */
116 hw = vnet_get_hw_interface (nsm->vnet_main, sw_if_index);
117 vec_validate_init_empty (nsm->output_next_index_by_sw_if_index, sw_if_index,
119 /* Note: use the tx node, this pkt has already visited the output node... */
120 nsm->output_next_index_by_sw_if_index[sw_if_index] =
121 vlib_node_add_next (nsm->vlib_main, nsim_input_node.index,
124 vnet_feature_enable_disable ("interface-output", "nsim-output-feature",
125 sw_if_index, enable_disable, 0, 0);
129 static nsim_wheel_t *
130 nsim_wheel_alloc (nsim_main_t *nsm)
132 u32 pagesize = getpagesize ();
135 nsm->mmap_size = sizeof (nsim_wheel_t) +
136 nsm->wheel_slots_per_wrk * sizeof (nsim_wheel_entry_t);
138 nsm->mmap_size += pagesize - 1;
139 nsm->mmap_size &= ~(pagesize - 1);
141 wp = clib_mem_vm_alloc (nsm->mmap_size);
143 wp->wheel_size = nsm->wheel_slots_per_wrk;
147 wp->entries = (void *) (wp + 1);
153 nsim_configure (nsim_main_t *nsm, f64 bandwidth, f64 delay, u32 packet_size,
154 f64 drop_fraction, f64 reorder_fraction)
156 u64 total_buffer_size_in_bytes, per_worker_buffer_size, wheel_slots_per_wrk;
157 int i, num_workers = vlib_num_workers ();
158 vlib_main_t *vm = nsm->vlib_main;
160 if (bandwidth == 0.0)
161 return VNET_API_ERROR_INVALID_VALUE;
164 return VNET_API_ERROR_INVALID_VALUE_2;
166 if (packet_size < 64 || packet_size > 9000)
167 return VNET_API_ERROR_INVALID_VALUE_3;
169 if (reorder_fraction > 0.0 && delay == 0.0)
170 return VNET_API_ERROR_INVALID_VALUE_4;
172 /* Toss the old wheel(s)... */
173 if (nsm->is_configured)
175 for (i = 0; i < vec_len (nsm->wheel_by_thread); i++)
177 clib_mem_vm_free (nsm->wheel_by_thread[i], nsm->mmap_size);
178 nsm->wheel_by_thread[i] = 0;
183 nsm->drop_fraction = drop_fraction;
184 nsm->reorder_fraction = reorder_fraction;
186 /* delay in seconds, bandwidth in bits/sec */
187 total_buffer_size_in_bytes = ((delay * bandwidth) / 8.0) + 0.5;
190 * Work out how much buffering each worker needs, assuming decent
194 per_worker_buffer_size = total_buffer_size_in_bytes / num_workers;
196 per_worker_buffer_size = total_buffer_size_in_bytes;
198 wheel_slots_per_wrk = per_worker_buffer_size / packet_size;
199 wheel_slots_per_wrk++;
201 /* Save these for the show command */
202 nsm->bandwidth = bandwidth;
203 nsm->packet_size = packet_size;
204 nsm->wheel_slots_per_wrk = wheel_slots_per_wrk;
206 vec_validate (nsm->wheel_by_thread, num_workers);
208 /* Initialize the output scheduler wheels */
209 i = (!nsm->poll_main_thread && num_workers) ? 1 : 0;
210 for (; i < num_workers + 1; i++)
211 nsm->wheel_by_thread[i] = nsim_wheel_alloc (nsm);
213 vlib_worker_thread_barrier_sync (vm);
215 /* turn on the ring scrapers */
216 i = (!nsm->poll_main_thread && num_workers) ? 1 : 0;
217 for (; i < num_workers + 1; i++)
219 vlib_main_t *this_vm = vlib_get_main_by_index (i);
221 vlib_node_set_state (this_vm, nsim_input_node.index,
222 VLIB_NODE_STATE_POLLING);
225 vlib_worker_thread_barrier_release (vm);
227 nsm->is_configured = 1;
232 * enable or disable the cross-connect
234 static clib_error_t *
235 nsim_cross_connect_enable_disable_command_fn (vlib_main_t * vm,
236 unformat_input_t * input,
237 vlib_cli_command_t * cmd)
239 nsim_main_t *nsm = &nsim_main;
240 unformat_input_t _line_input, *line_input = &_line_input;
241 u32 sw_if_index0 = ~0;
242 u32 sw_if_index1 = ~0;
243 int enable_disable = 1;
247 /* Get a line of input. */
248 if (!unformat_user (input, unformat_line_input, line_input))
251 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
253 if (unformat (line_input, "disable"))
255 else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
256 nsm->vnet_main, &tmp))
258 if (sw_if_index0 == ~0)
267 unformat_free (line_input);
269 if (sw_if_index0 == ~0 || sw_if_index1 == ~0)
270 return clib_error_return (0, "Please specify two interfaces...");
272 rv = nsim_cross_connect_enable_disable (nsm, sw_if_index0,
273 sw_if_index1, enable_disable);
280 case VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE:
281 return clib_error_return (0, "Not configured, please 'set nsim' first");
283 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
284 return clib_error_return
285 (0, "Invalid interface, only works on physical ports");
288 case VNET_API_ERROR_UNIMPLEMENTED:
289 return clib_error_return (0,
290 "Device driver doesn't support redirection");
294 return clib_error_return (0, "nsim_enable_disable returned %d", rv);
299 static clib_error_t *
300 nsim_config (vlib_main_t * vm, unformat_input_t * input)
302 nsim_main_t *nsm = &nsim_main;
304 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
306 if (unformat (input, "poll-main-thread"))
308 nsm->poll_main_thread = 1;
312 return clib_error_return (0, "unknown input '%U'",
313 format_unformat_error, input);
319 VLIB_CONFIG_FUNCTION (nsim_config, "nsim");
322 * Enable or disable network simulation cross-connect on two interfaces
323 * The network simulator must have already been configured, see
324 * the "nsim_configure" command.
326 * Place the interfaces into a bridge group, to ensure that
327 * interfaces are in promiscuous mode.
330 * To enable or disable network simulation cross-connect
332 * nsim cross-connect enable-disable TenGigabitEthernet2/0/0 TenGigabitEthernet2/0
333 * nsim cross-connect enable-disable TenGigabitEthernet2/0/0 TenGigabitEthernet2/0 disable
335 * @cliexcmd{nsim enable-disable <intfc> <intfc> [disable]}
337 VLIB_CLI_COMMAND (nsim_enable_disable_command, static) =
339 .path = "nsim cross-connect enable-disable",
341 "nsim cross-connect enable-disable <interface-name-1> "
342 "<interface-name-2> [disable]",
343 .function = nsim_cross_connect_enable_disable_command_fn,
346 /* API message handler */
347 static void vl_api_nsim_cross_connect_enable_disable_t_handler
348 (vl_api_nsim_cross_connect_enable_disable_t * mp)
350 vl_api_nsim_cross_connect_enable_disable_reply_t *rmp;
351 nsim_main_t *nsm = &nsim_main;
353 u32 sw_if_index0, sw_if_index1;
355 sw_if_index0 = clib_net_to_host_u32 (mp->sw_if_index0);
356 sw_if_index1 = clib_net_to_host_u32 (mp->sw_if_index1);
358 if (!vnet_sw_if_index_is_api_valid (sw_if_index0))
360 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
361 goto bad_sw_if_index;
363 if (!vnet_sw_if_index_is_api_valid (sw_if_index1))
365 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
366 goto bad_sw_if_index;
369 rv = nsim_cross_connect_enable_disable (nsm, sw_if_index0, sw_if_index1,
370 (int) (mp->enable_disable));
372 BAD_SW_IF_INDEX_LABEL;
373 REPLY_MACRO (VL_API_NSIM_CROSS_CONNECT_ENABLE_DISABLE_REPLY);
376 /* API message handler */
377 static void vl_api_nsim_output_feature_enable_disable_t_handler
378 (vl_api_nsim_output_feature_enable_disable_t * mp)
380 vl_api_nsim_output_feature_enable_disable_reply_t *rmp;
381 nsim_main_t *nsm = &nsim_main;
383 VALIDATE_SW_IF_INDEX (mp);
385 rv = nsim_output_feature_enable_disable (nsm, ntohl (mp->sw_if_index),
386 (int) (mp->enable_disable));
388 BAD_SW_IF_INDEX_LABEL;
389 REPLY_MACRO (VL_API_NSIM_OUTPUT_FEATURE_ENABLE_DISABLE_REPLY);
392 /* API message handler */
394 vl_api_nsim_configure_t_handler (vl_api_nsim_configure_t * mp)
396 vl_api_nsim_configure_reply_t *rmp;
397 nsim_main_t *nsm = &nsim_main;
398 f64 delay, bandwidth, packet_size, drop_fraction = 0.0, reorder_rate = 0.0;
399 u32 packets_per_drop;
402 delay = ((f64) (ntohl (mp->delay_in_usec))) * 1e-6;
403 bandwidth = (f64) (clib_net_to_host_u64 (mp->bandwidth_in_bits_per_second));
404 packet_size = (f64) (ntohl (mp->average_packet_size));
406 packets_per_drop = ntohl (mp->packets_per_drop);
407 if (packets_per_drop > 0)
408 drop_fraction = 1.0 / (f64) (packets_per_drop);
410 rv = nsim_configure (nsm, bandwidth, delay, packet_size, drop_fraction,
413 REPLY_MACRO (VL_API_NSIM_CONFIGURE_REPLY);
417 vl_api_nsim_configure2_t_handler (vl_api_nsim_configure2_t * mp)
419 vl_api_nsim_configure_reply_t *rmp;
420 nsim_main_t *nsm = &nsim_main;
421 f64 delay, bandwidth, packet_size, drop_fraction = 0.0, reorder_rate = 0.0;
422 u32 packets_per_drop, packets_per_reorder;
425 delay = ((f64) (ntohl (mp->delay_in_usec))) * 1e-6;
426 bandwidth = (f64) (clib_net_to_host_u64 (mp->bandwidth_in_bits_per_second));
427 packet_size = (f64) (ntohl (mp->average_packet_size));
429 packets_per_drop = ntohl (mp->packets_per_drop);
430 if (packets_per_drop > 0)
431 drop_fraction = 1.0 / (f64) (packets_per_drop);
433 packets_per_reorder = ntohl (mp->packets_per_reorder);
434 if (packets_per_reorder > 0)
435 reorder_rate = 1.0 / (f64) packets_per_reorder;
437 rv = nsim_configure (nsm, bandwidth, delay, packet_size, drop_fraction,
440 REPLY_MACRO (VL_API_NSIM_CONFIGURE2_REPLY);
445 * enable or disable the output_feature
447 static clib_error_t *
448 nsim_output_feature_enable_disable_command_fn (vlib_main_t * vm,
449 unformat_input_t * input,
450 vlib_cli_command_t * cmd)
452 nsim_main_t *nsm = &nsim_main;
453 unformat_input_t _line_input, *line_input = &_line_input;
454 u32 sw_if_index = ~0;
455 int enable_disable = 1;
458 /* Get a line of input. */
459 if (!unformat_user (input, unformat_line_input, line_input))
462 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
464 if (unformat (line_input, "disable"))
466 else if (unformat (line_input, "%U", unformat_vnet_sw_interface,
467 nsm->vnet_main, &sw_if_index))
471 clib_error_t *error = clib_error_return (0, "unknown input `%U'",
472 format_unformat_error,
474 unformat_free (line_input);
479 unformat_free (line_input);
481 if (sw_if_index == ~0)
482 return clib_error_return (0, "Please specify one interface...");
484 rv = nsim_output_feature_enable_disable (nsm, sw_if_index, enable_disable);
491 case VNET_API_ERROR_CANNOT_ENABLE_DISABLE_FEATURE:
492 return clib_error_return (0, "Not configured, please 'set nsim' first");
494 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
495 return clib_error_return
496 (0, "Invalid interface, only works on physical ports");
499 case VNET_API_ERROR_UNIMPLEMENTED:
500 return clib_error_return (0,
501 "Device driver doesn't support redirection");
505 return clib_error_return
506 (0, "nsim_output_feature_enable_disable returned %d", rv);
512 * Enable or disable network simulation output feature on an interface
513 * The network simulator must have already been configured, see
514 * the "nsim_configure" command.
517 * To enable or disable network simulation output feature
519 * nsim output-feature enable-disable TenGigabitEthernet2/0/0
520 * nsim output-feature enable-disable TenGigabitEthernet2/0/0 disable
522 * @cliexcmd{nsim output-feature enable-disable <intfc> [disable]}
524 VLIB_CLI_COMMAND (nsim_output_feature_enable_disable_command, static) =
526 .path = "nsim output-feature enable-disable",
528 "nsim output-feature enable-disable <interface-name> [disable]",
529 .function = nsim_output_feature_enable_disable_command_fn,
532 #include <nsim/nsim.api.c>
533 static clib_error_t *
534 nsim_init (vlib_main_t * vm)
536 nsim_main_t *nsm = &nsim_main;
539 nsm->vnet_main = vnet_get_main ();
541 /* Ask for a correctly-sized block of API message decode slots */
542 nsm->msg_id_base = setup_message_id_table ();
543 nsm->arc_index = nsm->vnet_main->interface_main.output_feature_arc_index;
547 VLIB_INIT_FUNCTION (nsim_init);
549 VNET_FEATURE_INIT (nsim, static) =
551 .arc_name = "device-input",
553 .runs_before = VNET_FEATURES ("ethernet-input"),
556 VNET_FEATURE_INIT (nsim_feature, static) = {
557 .arc_name = "interface-output",
558 .node_name = "nsim-output-feature",
559 .runs_before = VNET_FEATURES ("interface-output-arc-end"),
562 VLIB_PLUGIN_REGISTER () =
564 .version = VPP_BUILD_VER,
565 .description = "Network Delay Simulator",
569 unformat_delay (unformat_input_t * input, va_list * args)
571 f64 *result = va_arg (*args, f64 *);
574 if (unformat (input, "%f us", &tmp))
575 *result = tmp * 1e-6;
576 else if (unformat (input, "%f ms", &tmp))
577 *result = tmp * 1e-3;
578 else if (unformat (input, "%f sec", &tmp))
587 unformat_bandwidth (unformat_input_t * input, va_list * args)
589 f64 *result = va_arg (*args, f64 *);
592 if (unformat (input, "%f gbit", &tmp))
594 else if (unformat (input, "%f gbyte", &tmp))
596 else if (unformat (input, "%f gbps", &tmp))
598 else if (unformat (input, "%f mbps", &tmp))
600 else if (unformat (input, "%f kbps", &tmp))
602 else if (unformat (input, "%f bps", &tmp))
610 format_delay (u8 *s, va_list *args)
612 f64 delay = va_arg (*args, f64);
615 s = format (s, "%.1f us", delay * 1e6);
617 s = format (s, "%.1f ms", delay * 1e3);
619 s = format (s, "%f sec", delay);
625 format_bandwidth (u8 *s, va_list *args)
627 f64 bandwidth = va_arg (*args, f64);
629 if (bandwidth >= 1e9)
630 s = format (s, "%.1f gbps", bandwidth / 1e9);
631 else if (bandwidth >= 1e6)
632 s = format (s, "%.1f mbps", bandwidth / 1e6);
633 else if (bandwidth >= 1e3)
634 s = format (s, "%.1f kbps", bandwidth / 1e3);
636 s = format (s, "%f bps", bandwidth);
642 format_nsim_config (u8 * s, va_list * args)
644 int verbose = va_arg (*args, int);
645 nsim_main_t *nsm = &nsim_main;
647 s = format (s, "configuration\n");
648 s = format (s, " delay: %U\n", format_delay, nsm->delay);
649 if (nsm->drop_fraction)
650 s = format (s, " drop fraction: %.5f\n", nsm->drop_fraction);
652 s = format (s, " drop fraction: 0\n");
653 if (nsm->reorder_fraction)
654 s = format (s, " reorder fraction: %.5f\n", nsm->reorder_fraction);
656 s = format (s, " reorder fraction: 0\n");
657 s = format (s, " packet size: %u\n", nsm->packet_size);
658 s = format (s, " worker wheel size: %u\n", nsm->wheel_slots_per_wrk);
659 s = format (s, " throughput: %U\n", format_bandwidth, nsm->bandwidth);
663 s = format (s, " poll main thread: %u\n", nsm->poll_main_thread);
664 s = format (s, " memory: %U bytes per thread %U bytes total\n",
665 format_memory_size, nsm->mmap_size, format_memory_size,
666 nsm->mmap_size * vlib_num_workers ());
669 s = format (s, "\n");
671 if (nsm->sw_if_index0 != 0)
673 s = format (s, "cross-connect\n %U and %U\n",
674 format_vnet_sw_if_index_name, nsm->vnet_main,
675 nsm->sw_if_index0, format_vnet_sw_if_index_name,
676 nsm->vnet_main, nsm->sw_if_index1);
678 else if (vec_len (nsm->output_next_index_by_sw_if_index))
681 s = format (s, "output feature arcs to:\n");
682 for (i = 0; i < vec_len (nsm->output_next_index_by_sw_if_index); i++)
684 if (nsm->output_next_index_by_sw_if_index[i] != ~0)
685 s = format (s, " %U %u\n", format_vnet_sw_if_index_name,
686 nsm->vnet_main, i, i);
691 s = format (s, " nsim not enabled\n");
697 static clib_error_t *
698 set_nsim_command_fn (vlib_main_t * vm,
699 unformat_input_t * input, vlib_cli_command_t * cmd)
701 f64 drop_fraction = 0.0, reorder_fraction = 0.0, delay, bandwidth;
702 u32 packets_per_drop, packets_per_reorder, packet_size = 1500;
703 nsim_main_t *nsm = &nsim_main;
706 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
708 if (unformat (input, "delay %U", unformat_delay, &delay))
710 else if (unformat (input, "bandwidth %U", unformat_bandwidth,
713 else if (unformat (input, "packet-size %u", &packet_size))
715 else if (unformat (input, "packets-per-drop %d", &packets_per_drop))
717 if (packets_per_drop > 0)
718 drop_fraction = 1.0 / ((f64) packets_per_drop);
720 else if (unformat (input, "packets-per-reorder %d",
721 &packets_per_reorder))
723 if (packets_per_reorder > 0)
724 reorder_fraction = 1.0 / ((f64) packets_per_reorder);
726 else if (unformat (input, "drop-fraction %f", &drop_fraction))
728 if (drop_fraction < 0.0 || drop_fraction > 1.0)
729 return clib_error_return
730 (0, "drop fraction must be between zero and 1");
732 else if (unformat (input, "reorder-fraction %f", &reorder_fraction))
734 if (reorder_fraction < 0.0 || reorder_fraction > 1.0)
735 return clib_error_return
736 (0, "reorder fraction must be between zero and 1");
738 else if (unformat (input, "poll-main-thread"))
739 nsm->poll_main_thread = 1;
744 rv = nsim_configure (nsm, bandwidth, delay, packet_size, drop_fraction,
749 case VNET_API_ERROR_INVALID_VALUE:
750 return clib_error_return (0, "invalid bandwidth %.2f", bandwidth);
752 case VNET_API_ERROR_INVALID_VALUE_2:
753 return clib_error_return (0, "invalid delay %.2f", delay);
755 case VNET_API_ERROR_INVALID_VALUE_3:
756 return clib_error_return (0, "invalid packet size %.2f", packet_size);
758 case VNET_API_ERROR_INVALID_VALUE_4:
759 return clib_error_return (0, "invalid reorder fraction %.3f for "
760 "delay %.2f", reorder_fraction, delay);
763 return clib_error_return (0, "error %d", rv);
769 vlib_cli_output (vm, "%U", format_nsim_config, 1);
775 * Configure the network simulation cross-connect
776 * Once the simulator is configured, use the "nsim enable-disable" command
777 * to set up a cross-connect with the supplied delay characteristics.
779 * The cross connect configuration may be changed without restarting vpp
780 * but it is good practice to shut down the interfaces.
783 * To configure the network delay simulator:
785 * set nsim delay 10.0 ms bandwidth 5.5 gbit packet-size 128
788 * @cliexcmd{set nsim delay <nn> bandwidth <bb> packet-size <nn>}
790 VLIB_CLI_COMMAND (set_nsim_command, static) =
793 .short_help = "set nsim delay <time> bandwidth <bps> packet-size <nbytes>\n"
794 " [packets-per-drop <nn>][drop-fraction <f64: 0.0 - 1.0>]",
795 .function = set_nsim_command_fn,
799 static clib_error_t *
800 show_nsim_command_fn (vlib_main_t * vm,
801 unformat_input_t * input, vlib_cli_command_t * cmd)
803 nsim_main_t *nsm = &nsim_main;
806 if (nsm->is_configured == 0)
807 return clib_error_return (0, "Network simulator not configured");
809 if (unformat (input, "verbose"))
812 vlib_cli_output (vm, "%U", format_nsim_config, verbose);
818 * Display state info for the network delay simulator.
821 * To display the state of the network simulator
824 * Network simulator cross-connects TenGigabitEthernet2/0/0 and TenGigabitEthernet2/0/1
825 * ...inserting link delay of 10.00 ms, 20.00 ms round-trip
826 * Configured bandwidth: 10.10 gbit/sec
827 * Configured packet size: 128
828 * Sim uses 157814784 bytes total
830 * @cliexcmd{show nsim}
833 VLIB_CLI_COMMAND (show_nsim_command, static) =
836 .short_help = "Display network delay simulator configuration",
837 .function = show_nsim_command_fn,
841 * fd.io coding-style-patch-verification: ON
844 * eval: (c-set-style "gnu")