+static u8 *
+format_delay (u8 *s, va_list *args)
+{
+ f64 delay = va_arg (*args, f64);
+
+ if (delay < 1e-3)
+ s = format (s, "%.1f us", delay * 1e6);
+ else if (delay < 1)
+ s = format (s, "%.1f ms", delay * 1e3);
+ else
+ s = format (s, "%f sec", delay);
+
+ return s;
+}
+
+static u8 *
+format_bandwidth (u8 *s, va_list *args)
+{
+ f64 bandwidth = va_arg (*args, f64);
+
+ if (bandwidth >= 1e9)
+ s = format (s, "%.1f gbps", bandwidth / 1e9);
+ else if (bandwidth >= 1e6)
+ s = format (s, "%.1f mbps", bandwidth / 1e6);
+ else if (bandwidth >= 1e3)
+ s = format (s, "%.1f kbps", bandwidth / 1e3);
+ else
+ s = format (s, "%f bps", bandwidth);
+
+ return s;
+}
+
+static u8 *
+format_nsim_config (u8 * s, va_list * args)
+{
+ int verbose = va_arg (*args, int);
+ nsim_main_t *nsm = &nsim_main;
+
+ s = format (s, "configuration\n");
+ s = format (s, " delay: %U\n", format_delay, nsm->delay);
+ if (nsm->drop_fraction)
+ s = format (s, " drop fraction: %.5f\n", nsm->drop_fraction);
+ else
+ s = format (s, " drop fraction: 0\n");
+ if (nsm->reorder_fraction)
+ s = format (s, " reorder fraction: %.5f\n", nsm->reorder_fraction);
+ else
+ s = format (s, " reorder fraction: 0\n");
+ s = format (s, " packet size: %u\n", nsm->packet_size);
+ s = format (s, " worker wheel size: %u\n", nsm->wheel_slots_per_wrk);
+ s = format (s, " throughput: %U\n", format_bandwidth, nsm->bandwidth);
+
+ if (verbose)
+ {
+ s = format (s, " poll main thread: %u\n", nsm->poll_main_thread);
+ s = format (s, " memory: %U bytes per thread %U bytes total\n",
+ format_memory_size, nsm->mmap_size, format_memory_size,
+ nsm->mmap_size * vlib_num_workers ());
+ }
+
+ s = format (s, "\n");
+
+ if (nsm->sw_if_index0 != 0)
+ {
+ s = format (s, "cross-connect\n %U and %U\n",
+ format_vnet_sw_if_index_name, nsm->vnet_main,
+ nsm->sw_if_index0, format_vnet_sw_if_index_name,
+ nsm->vnet_main, nsm->sw_if_index1);
+ }
+ else if (vec_len (nsm->output_next_index_by_sw_if_index))
+ {
+ int i;
+ s = format (s, "output feature arcs to:\n");
+ for (i = 0; i < vec_len (nsm->output_next_index_by_sw_if_index); i++)
+ {
+ if (nsm->output_next_index_by_sw_if_index[i] != ~0)
+ s = format (s, " %U %u\n", format_vnet_sw_if_index_name,
+ nsm->vnet_main, i, i);
+ }
+ }
+ else
+ {
+ s = format (s, " nsim not enabled\n");
+ }
+
+ return s;
+}
+