TAPI to manage Cisco TRex
Overview
TAPI to manage Cisco TRex. More…
// typedefs typedef enum tapi_trex_port_stat_enum tapi_trex_port_stat_enum; typedef struct tapi_trex_port_stat_flt tapi_trex_port_stat_flt; typedef struct tapi_trex_per_port_stat_flts tapi_trex_per_port_stat_flts; typedef struct tapi_trex_port_stat tapi_trex_port_stat; typedef struct tapi_trex_per_port_stat tapi_trex_per_port_stat; typedef struct tapi_trex_app tapi_trex_app; typedef enum tapi_trex_verbose tapi_trex_verbose_t; typedef enum tapi_trex_iom tapi_trex_iom_t; typedef enum tapi_trex_so tapi_trex_so_t; typedef struct tapi_trex_interface tapi_trex_interface; typedef struct tapi_trex_common_config tapi_trex_common_config; typedef struct tapi_trex_client_config tapi_trex_client_config; typedef struct tapi_trex_server_config tapi_trex_server_config; typedef struct tapi_trex_opt tapi_trex_opt; typedef struct tapi_trex_report tapi_trex_report; // enums enum tapi_trex_iom; enum tapi_trex_port_stat_enum; enum tapi_trex_so; enum tapi_trex_verbose; // structs struct tapi_trex_app; struct tapi_trex_client_config; struct tapi_trex_common_config; struct tapi_trex_opt; struct tapi_trex_per_port_stat; struct tapi_trex_per_port_stat_flts; struct tapi_trex_port_stat; struct tapi_trex_port_stat_flt; struct tapi_trex_report; struct tapi_trex_server_config; // global variables const tapi_trex_client_config tapi_trex_client_config_default; const tapi_trex_server_config tapi_trex_server_config_default; const tapi_trex_opt tapi_trex_default_opt; // global functions te_errno tapi_trex_create(tapi_job_factory_t* factory, const tapi_trex_opt* opt, tapi_trex_app** app); te_errno tapi_trex_start(const tapi_trex_app* app); te_errno tapi_trex_wait(const tapi_trex_app* app, int timeout_ms); te_errno tapi_trex_stop(const tapi_trex_app* app); te_errno tapi_trex_kill(const tapi_trex_app* app, int signum); te_errno tapi_trex_destroy(const char* ta, tapi_trex_app* app, tapi_trex_opt* opt); te_errno tapi_trex_get_report(tapi_trex_app* app, tapi_trex_report* report); te_errno tapi_trex_report_mi_log(const tapi_trex_report* report); te_errno tapi_trex_destroy_report(tapi_trex_report* report); void tapi_trex_port_stat_param_series_get(tapi_trex_report* report, tapi_trex_port_stat_enum param, unsigned int index, bool absolute_value, bool by_time, double** vals, unsigned int* n_vals); static void tapi_trex_port_stat_time_series_get(tapi_trex_report* report, double** vals, unsigned int* n_vals); static void tapi_trex_port_stat_param_series_by_time_get(tapi_trex_report* report, tapi_trex_port_stat_enum param, unsigned int index, double** vals, unsigned int* n_vals); te_errno tapi_trex_port_stat_data_get(tapi_trex_report* report, tapi_trex_port_stat_enum param, unsigned int index, double time_start, double time_end, double* min, double* avg, double* median, double* max); tapi_trex_interface* tapi_trex_interface_init_oid(bool use_kernel_interface, const char* oid_fmt, ...); void tapi_trex_interface_free(tapi_trex_interface* interface); // macros #define TAPI_TREX_CLIENT(...) #define TAPI_TREX_CLIENTS(...) #define TAPI_TREX_DEFAULT_CLIENT_HTTP_PAYLOAD #define TAPI_TREX_DEFAULT_SERVER_HTTP_PAYLOAD #define TAPI_TREX_LINUX_IFACE(ta_, iface_) #define TAPI_TREX_PCI_BY_BDF(ta_, addr_) #define TAPI_TREX_PCI_BY_IFACE(ta_, iface_) #define TAPI_TREX_SERVER(...) #define TAPI_TREX_SERVERS(...)
Detailed Documentation
TAPI to manage Cisco TRex.
Typedefs
typedef enum tapi_trex_port_stat_enum tapi_trex_port_stat_enum
List of parameters in per port statistics.
typedef struct tapi_trex_port_stat_flt tapi_trex_port_stat_flt
TRex port stat filter.
typedef struct tapi_trex_per_port_stat_flts tapi_trex_per_port_stat_flts
TRex per port stat filters.
typedef struct tapi_trex_port_stat tapi_trex_port_stat
TRex statistics for a single port.
typedef struct tapi_trex_per_port_stat tapi_trex_per_port_stat
TRex per-port statistics.
typedef struct tapi_trex_app tapi_trex_app
TRex tool information.
typedef enum tapi_trex_verbose tapi_trex_verbose_t
Representation of possible values for tapi_trex_opt::verbose option.
typedef enum tapi_trex_iom tapi_trex_iom_t
Representation of possible values for tapi_trex_opt::iom option.
typedef enum tapi_trex_so tapi_trex_so_t
Representation of possible values for tapi_trex_opt ::*-so options.
typedef struct tapi_trex_interface tapi_trex_interface
TRex interface description.
typedef struct tapi_trex_common_config tapi_trex_common_config
Common TRex client/server options.
typedef struct tapi_trex_client_config tapi_trex_client_config
Specific TRex client options.
typedef struct tapi_trex_server_config tapi_trex_server_config
Specific TRex server options.
typedef struct tapi_trex_opt tapi_trex_opt
Specific TRex options.
Before starting tapi_trex it is necessary to initialize its options tapi_trex_opt
and call tapi_trex_create() to create configuration files and properly bind PCI functions (if DPDK is used).
Base tapi_trex_opt
example:
tapi_trex_opt trex_opt = tapi_trex_default_opt; trex_opt.astf_template = getenv("TE_TREX_ASTF_TEMPLATE"); trex_opt.trex_exec = getenv("TE_TREX_EXEC"); trex_opt.force_close_at_end = true; trex_opt.no_monitors = true; trex_opt.lro_disable = true; // Setup servers trex_opt.servers = TAPI_TREX_SERVERS( TAPI_TREX_SERVER( .common.interface = TAPI_TREX_PCI_BY_IFACE("Agt_A", "eth0"), .common.ip = agtA_addr, .common.gw = agtB_addr, .common.ip_range_beg = agtA_addr, .common.ip_range_end = agtA_addr, .common.payload = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\nConnection: keep-alive\r\n" "Content-Length: 18\r\n\r\n<html>Hello</html>" )); // Setup clients trex_opt.clients = ...;
typedef struct tapi_trex_report tapi_trex_report
TRex information from the stdout.
Global Variables
const tapi_trex_client_config tapi_trex_client_config_default
Default TRex client options initializer.
const tapi_trex_server_config tapi_trex_server_config_default
Default TRex server options initializer.
const tapi_trex_opt tapi_trex_default_opt
Default TRex options initializer.
Global Functions
te_errno tapi_trex_create(tapi_job_factory_t* factory, const tapi_trex_opt* opt, tapi_trex_app** app)
Create TRex app.
Parameters:
factory |
Job factory. |
opt |
TRex options. |
app |
TRex app handle. |
Returns:
Status code.
te_errno tapi_trex_start(const tapi_trex_app* app)
Start TRex.
Parameters:
app |
TRex app handle. |
Returns:
Status code.
te_errno tapi_trex_wait(const tapi_trex_app* app, int timeout_ms)
Wait for TRex completion.
Parameters:
app |
TRex app handle. |
timeout_ms |
Wait timeout in milliseconds. |
Returns:
Status code.
te_errno tapi_trex_stop(const tapi_trex_app* app)
Stop TRex. It can be started over with tapi_trex_start().
Parameters:
app |
TRex app handle. |
Returns:
Status code.
te_errno tapi_trex_kill(const tapi_trex_app* app, int signum)
Send a signal to TRex.
Parameters:
app |
TRex app handle. |
signum |
Signal to send. |
Returns:
Status code.
te_errno tapi_trex_destroy(const char* ta, tapi_trex_app* app, tapi_trex_opt* opt)
Destroy TRex.
Parameters:
ta |
TRex Test Agent name. |
app |
TRex app handle. |
opt |
TRex options. |
Returns:
Status code.
te_errno tapi_trex_get_report(tapi_trex_app* app, tapi_trex_report* report)
Get TRex report.
Parameters:
app |
TRex app handle. |
report |
TRex statistics report. |
Returns:
Status code.
te_errno tapi_trex_report_mi_log(const tapi_trex_report* report)
Add TRex report to MI logger.
Parameters:
report |
TRex statistics report. |
Returns:
Status code.
te_errno tapi_trex_destroy_report(tapi_trex_report* report)
Destroy TRex report to MI logger and freed memory.
Parameters:
report |
TRex statistics report. |
Returns:
Status code.
void tapi_trex_port_stat_param_series_get(tapi_trex_report* report, tapi_trex_port_stat_enum param, unsigned int index, bool absolute_value, bool by_time, double** vals, unsigned int* n_vals)
Get all the values of a given parameter from the per port statistics.
Parameters:
report |
TRex report. |
param |
Type of param. |
index |
Port index. |
absolute_value |
If |
by_time |
If |
vals |
Array of values. |
n_vals |
Number of values. |
static void tapi_trex_port_stat_time_series_get(tapi_trex_report* report, double** vals, unsigned int* n_vals)
Get time series from the per port statistics.
Parameters:
report |
TRex report. |
vals |
Array of values. |
n_vals |
Number of values. |
static void tapi_trex_port_stat_param_series_by_time_get(tapi_trex_report* report, tapi_trex_port_stat_enum param, unsigned int index, double** vals, unsigned int* n_vals)
Get the value of the port statistics parameter change for each time interval.
Parameters:
report |
TRex report. |
param |
Type of param. |
index |
Port index. |
vals |
Array of values. |
n_vals |
Number of values. |
te_errno tapi_trex_port_stat_data_get(tapi_trex_report* report, tapi_trex_port_stat_enum param, unsigned int index, double time_start, double time_end, double* min, double* avg, double* median, double* max)
Get the statisctical data for a given parameter from the per-port statistics.
c 0 The result is successful.
Parameters:
report |
TRex report. |
param |
Type of param. |
index |
Port index. |
time_start |
Use values starting from the specified time (in seconds). |
time_end |
Use values up to the specified time (in seconds). |
min |
Minimal value (may be |
avg |
Average value (may be |
median |
Median value (may be |
max |
Maximum value (may be |
TE_ENODATA |
Per-port statistics do not contain data. |
TE_ERANGE |
Returns:
Status code.
tapi_trex_interface* tapi_trex_interface_init_oid(bool use_kernel_interface, const char* oid_fmt, ...)
Create tapi_trex_interface
with PCI address (e.g. "0000:00:04.0"
).
tapi_trex_interface *iface = tapi_trex_interface_init_oid( false, "/agent:%s/interface:%s", "Agt_A", "eth0"); ... tapi_trex_interface_free(iface);
Function result should be tapi_trex_interface_free() ‘d.
If use_kernel_interface
is true
, then only '/agent/interface'
OIDs are supported and the name of the interface is used. If use_kernel_interface
is false
, then OIDs are resolved to a PCI address.
OID can be one the following:
'/agent/hardware/pci/vendor/device/instance'
'/agent/hardware/pci/device'
'/agent/interface'
Parameters:
use_kernel_interface |
Use kernel or DPDK interface. |
oid_fmt |
OID format string. |
… |
Arguments for the format string. |
Returns:
Allocated tapi_trex_interface
structure.
void tapi_trex_interface_free(tapi_trex_interface* interface)
Free allocated tapi_trex_interface
.
Parameters:
interface |
TAPI TRex interface. |
Macros
#define TAPI_TREX_CLIENT(...)
Convenience TRex client constructor.
See also:
#define TAPI_TREX_CLIENTS(...)
Convenience TRex clients vector constructor.
tapi_trex_opt trex_opt; trex_opt.clients = TAPI_TREX_CLIENTS( TAPI_TREX_CLIENT( .common.interface = TAPI_TREX_PCI_BY_IFACE("Agt_A", "eth0"), .common.port = 80, .common.payload = "GET /3384 HTTP/1.1\r\nHo" ));
#define TAPI_TREX_DEFAULT_CLIENT_HTTP_PAYLOAD
TRex default client payload.
#define TAPI_TREX_DEFAULT_SERVER_HTTP_PAYLOAD
TRex default server payload.
#define TAPI_TREX_LINUX_IFACE(ta_, iface_)
Set linux interface for TRex without binding.
tapi_trex_opt trex_opt; trex_opt.servers = TAPI_TREX_SERVERS( TAPI_TREX_SERVER( .common.interface = TAPI_TREX_LINUX_IFACE("Agt_A", "eth0"), ... ));
#define TAPI_TREX_PCI_BY_BDF(ta_, addr_)
Set the PCI address interface for TRex with binding.
tapi_trex_opt trex_opt; trex_opt.clients = TAPI_TREX_CLIENTS( TAPI_TREX_CLIENT( .common.interface = TAPI_TREX_PCI_BY_BDF("Agt_A", "0000:00:04.0"), ... ));
#define TAPI_TREX_PCI_BY_IFACE(ta_, iface_)
Set linux interface for TRex with binding.
tapi_trex_opt trex_opt; trex_opt.clients = TAPI_TREX_CLIENTS( TAPI_TREX_CLIENT( .common.interface = TAPI_TREX_PCI_BY_IFACE("Agt_A", "eth0"), ... ));
#define TAPI_TREX_SERVER(...)
Convenience TRex server constructor.
See also:
#define TAPI_TREX_SERVERS(...)
Convenience TRex servers vector constructor.
tapi_trex_opt trex_opt; trex_opt.servers = TAPI_TREX_SERVERS( TAPI_TREX_SERVER( .common.interface = TAPI_TREX_PCI_BY_IFACE("Agt_A", "eth0"), .common.payload = "HTTP/1.1 200 OK\r\n" "Content-Type: text/html\r\nConnection: keep-alive\r\n" "Content-Length: 18\r\n\r\n<html>Hello</html>" ));