31 #ifndef CLIB_MARCH_VARIANT 43 "simulated network loss" :
"no space in ring");
45 s =
format (s,
"NSIM: tx time %.6f sw_if_index %d",
54 #define foreach_nsim_error \ 55 _(BUFFERED, "Packets buffered") \ 56 _(DROPPED, "Packets dropped due to lack of space") \ 57 _(LOSS, "Network loss simulation drop packets") 61 #define _(sym,str) NSIM_ERROR_##sym, 67 #ifndef CLIB_MARCH_VARIANT 69 #define _(sym,string) string, 86 u32 n_left_from, *from;
94 u32 no_error = node->
errors[NSIM_ERROR_BUFFERED];
95 u32 no_buffer_error = node->
errors[NSIM_ERROR_DROPPED];
96 u32 loss_error = node->
errors[NSIM_ERROR_LOSS];
109 while (n_left_from > 0)
111 b[0]->
error = no_error;
121 if (rnd <= nsm->drop_fraction)
123 b[0]->
error = loss_error;
146 b[0]->
error = no_buffer_error;
153 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
181 #ifndef CLIB_MARCH_VARIANT 185 .vector_size =
sizeof (
u32),
#define WHEEL_ENTRY_DATA_SIZE
#define clib_memcpy_fast(a, b, c)
static f64 vlib_time_now(vlib_main_t *vm)
#define VLIB_NODE_FN(node)
vlib_node_registration_t nsim_node
(constructor) VLIB_REGISTER_NODE (nsim_node)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static char * nsim_error_strings[]
#define foreach_nsim_error
u8 data[WHEEL_ENTRY_DATA_SIZE]
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_REGISTER_NODE(x,...)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
nsim_wheel_entry_t * entries
static uword nsim_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_trace)
nsim_wheel_t ** wheel_by_thread
static f64 random_f64(u32 *seed)
Generate f64 random number in the interval [0,1].
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
struct _vlib_node_registration vlib_node_registration_t
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
static u8 * format_nsim_trace(u8 *s, va_list *args)