NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
DOCA Telemetry NetFlow
Collaboration diagram for DOCA Telemetry NetFlow:

Macros

#define DOCA_NETFLOW_APP_ID
 NetFlow Application ID. More...
 
#define DOCA_NETFLOW_DEFAULT_PORT   2055
 NetFlow collector default port. More...
 

Functions

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_init (uint16_t source_id)
 Init exporter memory, set configs and open connection. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_collector_addr (const char *collector_addr)
 Set collector address. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_collector_port (uint16_t collector_port)
 Set collector port. See DOCA_NETFLOW_DEFAULT_PORT for default value. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_max_packet_size (uint16_t max_packet_size)
 Set max packet size. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_field_create (struct doca_telemetry_exporter_netflow_flowset_field **field)
 Create new telemetry netflow field. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_field_set_type (struct doca_telemetry_exporter_netflow_flowset_field *field, uint16_t type)
 Set doca telemetry netflow field type. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_field_set_len (struct doca_telemetry_exporter_netflow_flowset_field *field, uint16_t length)
 Set doca telemetry netflow field length. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_field_destroy (struct doca_telemetry_exporter_netflow_flowset_field *field)
 Destructor for DOCA netflow field. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_buf_size (uint64_t size)
 Set buffer size Default value is 60000 bytes. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_buf_size (uint64_t *size)
 Get buffer size. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_buf_data_root (const char *path)
 Set buffer data root Default path is "/opt/mellanox/doca/services/telemetry/data/". More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_buf_data_root (const char **path)
 Get data root path. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_template_create (struct doca_telemetry_exporter_netflow_template **netflow_template)
 Create new telemetry netflow template. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_template_add_field (struct doca_telemetry_exporter_netflow_template *netflow_template, struct doca_telemetry_exporter_netflow_flowset_field *field)
 Add DOCA telemetry netflow field to netflow_template. The user loses the ownership of the field after a successful invocation of the function. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_template_destroy (struct doca_telemetry_exporter_netflow_template *netflow_template)
 Destructor for DOCA netflow template. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_file_write_enabled (void)
 Enable file write file write is disabled by default. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_file_write_max_size (size_t size)
 Set file maximum size Default value is 1MB. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_file_write_max_size (size_t *size)
 Get file maximum size. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_file_write_max_age (doca_telemetry_exporter_timestamp_t max_age)
 Set file maximum age Default value is 1 hour. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_file_write_max_age (doca_telemetry_exporter_timestamp_t *max_age)
 Get file maximum age. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_ipc_enabled (void)
 Enable IPC IPC is disabled by default. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_ipc_sockets_dir (const char *path)
 Set IPC socket directory. Default path is "/opt/mellanox/doca/services/telemetry/ipc_sockets". More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_ipc_sockets_dir (const char **path)
 Get IPC socket directory. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_source_set_id (const char *source_id)
 Set source id. More...
 
DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_source_set_tag (const char *source_tag)
 Set source tag. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_start (void)
 Finalizes netflow setup. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_send (const struct doca_telemetry_exporter_netflow_template *netflow_template, const void **records, size_t nof_records, size_t *nof_records_sent)
 Sending netflow records. Need to init first. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_flush (void)
 Immediately flush the data of the DOCA internal Netflow source. More...
 
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_destroy (void)
 Free the exporter memory and close the connection. More...
 

Detailed Description

DOCA lib for exporting a netflow packet to a netflow collector through the telemetry service.

This lib simplifies and centralizes the formatting and exporting of netflow packets. Netflow is a protocol for exporting information about the device network flows to a netflow collector that will aggregate and analyze the data. After creating conf file and invoke init function, the lib send function can be called with netflow struct to send a netflow packet with the format to the collector of choice specified in the conf file. The lib uses the netflow protocol specified by cisco.

See also
https://netflow.caligare.com/netflow_v9.htm

Limitations:

The lib supports the netflow V9 format. The lib is not thread safe.

Macro Definition Documentation

◆ DOCA_NETFLOW_APP_ID

#define DOCA_NETFLOW_APP_ID
Value:
{ \
0x99, 0x10, 0xc1, 0x28, 0x39, 0x61, 0x47, 0xe6, 0xbe, 0x6c, 0x71, 0x5a, 0x0f, 0x03, 0xad, 0xd6 \
}

NetFlow Application ID.

Note
This GUID cannot change

Definition at line 58 of file doca_telemetry_exporter_netflow.h.

◆ DOCA_NETFLOW_DEFAULT_PORT

#define DOCA_NETFLOW_DEFAULT_PORT   2055

NetFlow collector default port.

Definition at line 64 of file doca_telemetry_exporter_netflow.h.

Function Documentation

◆ doca_telemetry_exporter_netflow_destroy()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_destroy ( void  )

Free the exporter memory and close the connection.

Returns
DOCA_SUCCESS - in case of success.

◆ doca_telemetry_exporter_netflow_field_create()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_field_create ( struct doca_telemetry_exporter_netflow_flowset_field **  field)

Create new telemetry netflow field.

Parameters
[out]fieldPointer to the newly allocated telemetry field.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.
  • DOCA_ERROR_NO_MEMORY - failed to allocate doca telemetry netflow field.

◆ doca_telemetry_exporter_netflow_field_destroy()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_field_destroy ( struct doca_telemetry_exporter_netflow_flowset_field *  field)

Destructor for DOCA netflow field.

Parameters
[in]fieldfield to destroy.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - if netflow_template is NULL.

◆ doca_telemetry_exporter_netflow_field_set_len()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_field_set_len ( struct doca_telemetry_exporter_netflow_flowset_field *  field,
uint16_t  length 
)

Set doca telemetry netflow field length.

Parameters
[in]fieldPointer to doca telemetry netflow field.
[in]lengthField type.
Note
Passing a field value of NULL will result in an undefined behavior.

◆ doca_telemetry_exporter_netflow_field_set_type()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_field_set_type ( struct doca_telemetry_exporter_netflow_flowset_field *  field,
uint16_t  type 
)

Set doca telemetry netflow field type.

Parameters
[in]fieldPointer to doca telemetry netflow field.
[in]typeField type.
Note
Passing a field value of NULL will result in an undefined behavior.

◆ doca_telemetry_exporter_netflow_flush()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_flush ( void  )

Immediately flush the data of the DOCA internal Netflow source.

Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_BAD_STATE - if the netflow has not been started.

◆ doca_telemetry_exporter_netflow_get_buf_data_root()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_buf_data_root ( const char **  path)

Get data root path.

Parameters
[out]pathThe buffer data root
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.
  • DOCA_ERROR_NO_MEMORY - failed to allocate memory.

◆ doca_telemetry_exporter_netflow_get_buf_size()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_buf_size ( uint64_t *  size)

Get buffer size.

Parameters
[out]sizeThe buffer size
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.

◆ doca_telemetry_exporter_netflow_get_file_write_max_age()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_file_write_max_age ( doca_telemetry_exporter_timestamp_t max_age)

Get file maximum age.

Parameters
[out]max_ageMaximum file age. Once current file is older than this threshold a new file will be created.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.

◆ doca_telemetry_exporter_netflow_get_file_write_max_size()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_file_write_max_size ( size_t size)

Get file maximum size.

Parameters
[out]sizeMaximum size of binary data file.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.

◆ doca_telemetry_exporter_netflow_get_ipc_sockets_dir()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_get_ipc_sockets_dir ( const char **  path)

Get IPC socket directory.

Parameters
[out]pathPath to a folder containing DOCA Telemetry Service (DTS) sockets.
Note
Ownership of the returned string is transferred to the caller.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.
  • DOCA_ERROR_NO_MEMORY - failed to allocate memory.

◆ doca_telemetry_exporter_netflow_init()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_init ( uint16_t  source_id)

Init exporter memory, set configs and open connection.

The Source ID field is a 32-bit value that is used to guarantee uniqueness for all flows exported from a particular device (see link).

This function can be called again only after doca_telemetry_exporter_netflow_destroy was called.

Parameters
[in]source_idUnique source ID.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_BAD_STATE - if the netflow has been initialized before this call.
  • DOCA_ERROR_NO_MEMORY - failed to allocate memory.
  • DOCA_ERROR_INITIALIZATION - failed to initialize netflow.

◆ doca_telemetry_exporter_netflow_send()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_send ( const struct doca_telemetry_exporter_netflow_template *  netflow_template,
const void **  records,
size_t  nof_records,
size_t nof_records_sent 
)

Sending netflow records. Need to init first.

Parameters
[in]netflow_templateTemplate pointer of how the records are structured. For more info refer to doca_telemetry_exporter_netflow_template.
[in]recordsArray of pointers to the flows structs to send, must be packed. Strings must be an array in the struct, not a pointer.
[in]nof_recordsRecords array size.
[out]nof_records_sentIf not NULL, it will be filled with amount of records sent.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_BAD_STATE - if the netflow has not been initialized or the netflow has started.
  • DOCA_ERROR_NO_MEMORY - failed to allocate memory.
Note
When sending more then 30 records the lib splits the records to multiple packets because each packet can only send up to 30 records (Netflow protocol limit)

◆ doca_telemetry_exporter_netflow_set_buf_data_root()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_buf_data_root ( const char *  path)

Set buffer data root Default path is "/opt/mellanox/doca/services/telemetry/data/".

Parameters
[in]pathPath to a folder where the data and schema will be stored.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_buf_size()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_buf_size ( uint64_t  size)

Set buffer size Default value is 60000 bytes.

Parameters
[in]sizeBuffer size
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_collector_addr()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_collector_addr ( const char *  collector_addr)

Set collector address.

Parameters
[in]collector_addrUser defined netflow collector's IP address.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_collector_port()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_collector_port ( uint16_t  collector_port)

Set collector port. See DOCA_NETFLOW_DEFAULT_PORT for default value.

Parameters
[in]collector_portUser defined netflow collector's port.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_file_write_enabled()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_file_write_enabled ( void  )

Enable file write file write is disabled by default.

Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_file_write_max_age()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_file_write_max_age ( doca_telemetry_exporter_timestamp_t  max_age)

Set file maximum age Default value is 1 hour.

Parameters
[in]max_ageMaximum file age. Once current file is older than this threshold a new file will be created.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_file_write_max_size()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_file_write_max_size ( size_t  size)

Set file maximum size Default value is 1MB.

Parameters
[in]sizeMaximum size of binary data file. Once this size is reached, a new binary file will be created.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_ipc_enabled()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_ipc_enabled ( void  )

Enable IPC IPC is disabled by default.

Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_ipc_sockets_dir()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_ipc_sockets_dir ( const char *  path)

Set IPC socket directory. Default path is "/opt/mellanox/doca/services/telemetry/ipc_sockets".

Parameters
[in]pathPath to a folder containing DOCA Telemetry Service (DTS) sockets.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_set_max_packet_size()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_set_max_packet_size ( uint16_t  max_packet_size)

Set max packet size.

Parameters
[in]max_packet_sizeUser defined netflow packet's max size.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_source_set_id()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_source_set_id ( const char *  source_id)

Set source id.

Parameters
[in]source_idHostname or guid.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_source_set_tag()

DOCA_EXPERIMENTAL void doca_telemetry_exporter_netflow_source_set_tag ( const char *  source_tag)

Set source tag.

Parameters
[in]source_tagUser defined data-file name prefix.
Note
This function should be called after doca_telemetry_exporter_netflow_init().

◆ doca_telemetry_exporter_netflow_start()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_start ( void  )

Finalizes netflow setup.

Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_BAD_STATE - if the netflow has not been initialized or the netflow has started.
  • DOCA_ERROR_NO_MEMORY - failed to allocate memory.

◆ doca_telemetry_exporter_netflow_template_add_field()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_template_add_field ( struct doca_telemetry_exporter_netflow_template *  netflow_template,
struct doca_telemetry_exporter_netflow_flowset_field *  field 
)

Add DOCA telemetry netflow field to netflow_template. The user loses the ownership of the field after a successful invocation of the function.

Note
field should NOT be passed to another group after calling this function.
Parameters
[in]netflow_templatePointer to netflow_template.
[in]fieldDOCA Telemetry netflow field to add.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.
  • DOCA_ERROR_NO_MEMORY - failed to allocate doca telemetry netflow field.

◆ doca_telemetry_exporter_netflow_template_create()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_template_create ( struct doca_telemetry_exporter_netflow_template **  netflow_template)

Create new telemetry netflow template.

Parameters
[out]netflow_templatePointer to the newly allocated telemetry netflow template.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - NULL parameter.
  • DOCA_ERROR_NO_MEMORY - failed to allocate doca telemetry netflow template.

◆ doca_telemetry_exporter_netflow_template_destroy()

DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_netflow_template_destroy ( struct doca_telemetry_exporter_netflow_template *  netflow_template)

Destructor for DOCA netflow template.

Parameters
[in]netflow_templatenetflow template to destroy.
Returns
DOCA_SUCCESS - in case of success. Error code - in case of failure:
  • DOCA_ERROR_INVALID_VALUE - if netflow_template is NULL.