nsim: basic reorder support

Reorder delayed packets, i.e., flush instead of delay, with a configured
rate.

Type: feature

Change-Id: Ib1294f5f1c9b6e98a12b1bb0be655e54facfed3a
Signed-off-by: Florin Coras <fcoras@cisco.com>
This commit is contained in:
Florin Coras
2020-07-28 19:20:40 -07:00
committed by Dave Barach
parent b2f44bd8e7
commit e6c3e8f0ee
6 changed files with 417 additions and 388 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@
* @brief VPP control-plane API messages for the network delay simulator
*/
option version = "2.1.1";
option version = "2.2.1";
import "vnet/interface_types.api";
/** \brief enable / disable the network delay simulation cross-connect
@ -61,6 +61,7 @@ autoreply define nsim_output_feature_enable_disable
*/
autoreply define nsim_configure
{
option deprecated="v21.01";
/* Client identifier, set from api_main.my_client_index */
u32 client_index;
@ -75,4 +76,27 @@ autoreply define nsim_configure
option vat_help = "delay <time> bandwidth <bw> [packet-size <nn>] [packets-per-drop <nnnn>]";
};
/** \brief configure the network delay simulation cross-connect
@param client_index - opaque cookie to identify the sender
@param context - sender context, to match reply w/ request
@param delay_in_usec - microseconds of link delay to simulate
@param average_packet_size - average packet size for wheel sizing
@param bandwidth_in_bits_per_second - bps for wheel sizing
*/
autoreply define nsim_configure2
{
/* Client identifier, set from api_main.my_client_index */
u32 client_index;
/* Arbitrary context, so client can match reply to request */
u32 context;
/* Configuration parameters */
u32 delay_in_usec;
u32 average_packet_size;
u64 bandwidth_in_bits_per_second;
u32 packets_per_drop;
u32 packets_per_reorder;
option vat_help = "delay <time> bandwidth <bw> [packet-size <nn>] [packets-per-drop <nnnn>]";
};

File diff suppressed because it is too large Load Diff

View File

@ -45,11 +45,44 @@ typedef struct
CLIB_CACHE_LINE_ALIGN_MARK (pad);
} nsim_wheel_t;
typedef struct nsim_node_ctx
{
vnet_feature_config_main_t *fcm;
f64 expires;
u32 *drop;
u32 *reord;
u16 *reord_nexts;
u8 *action;
u64 n_buffered;
u64 n_loss;
} nsim_node_ctx_t;
#define foreach_nsm_action \
_(DROP, "Packet loss") \
_(REORDER, "Packet reorder")
enum nsm_action_bit
{
#define _(sym, str) NSIM_ACTION_##sym##_BIT,
foreach_nsm_action
#undef _
};
typedef enum nsm_action
{
#define _(sym, str) NSIM_ACTION_##sym = 1 << NSIM_ACTION_##sym##_BIT,
foreach_nsm_action
#undef _
} nsm_action_e;
typedef struct
{
/* API message ID base */
u16 msg_id_base;
/* output feature arc index */
u16 arc_index;
/* Two interfaces, cross-connected with delay */
u32 sw_if_index0, sw_if_index1;
u32 output_next_index0, output_next_index1;
@ -68,6 +101,7 @@ typedef struct
f64 bandwidth;
f64 packet_size;
f64 drop_fraction;
f64 reorder_fraction;
u32 poll_main_thread;
u64 mmap_size;

View File

@ -214,6 +214,58 @@ api_nsim_configure (vat_main_t * vam)
return ret;
}
static int
api_nsim_configure2 (vat_main_t * vam)
{
vl_api_nsim_configure2_t *mp;
unformat_input_t *i = vam->input;
f64 delay = 0.0, bandwidth = 0.0;
f64 packet_size = 1500.0;
u32 packets_per_drop = 0, packets_per_reorder;
int ret;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
if (unformat (i, "delay %U", unformat_delay, &delay))
;
else if (unformat (i, "bandwidth %U", unformat_bandwidth, &bandwidth))
;
else if (unformat (i, "packet-size %f", &packet_size))
;
else if (unformat (i, "packets-per-drop %u", &packets_per_drop))
;
else if (unformat (i, "packets-per-reorder %u", &packets_per_reorder))
;
else
break;
}
if (delay == 0.0 || bandwidth == 0.0)
{
errmsg ("must specify delay and bandwidth");
return -99;
}
/* Construct the API message */
M (NSIM_CONFIGURE2, mp);
mp->delay_in_usec = (u32) (delay * 1e6);
mp->delay_in_usec = ntohl (mp->delay_in_usec);
mp->average_packet_size = (u32) (packet_size);
mp->average_packet_size = ntohl (mp->average_packet_size);
mp->bandwidth_in_bits_per_second = (u64) (bandwidth);
mp->bandwidth_in_bits_per_second =
clib_host_to_net_u64 (mp->bandwidth_in_bits_per_second);
mp->packets_per_drop = ntohl (packets_per_drop);
mp->packets_per_reorder = ntohl (packets_per_reorder);
/* send it... */
S (mp);
/* Wait for a reply... */
W (ret);
return ret;
}
#include <nsim/nsim.api_test.c>
/*

View File

@ -157,6 +157,7 @@ _(LIMIT_EXCEEDED, -162, "limit exceeded") \
_(IKE_NO_PORT, -163, "port not managed by IKE") \
_(UDP_PORT_TAKEN, -164, "UDP port already taken") \
_(EAGAIN, -165, "Retry stream call with cursor") \
_(INVALID_VALUE_4, -166, "Invalid value #4") \
typedef enum
{