IPFix¶
- class trex.emu.emu_plugins.emu_plugin_ipfix.IPFIXPlugin(emu_client)[source]¶
Defines a Netflow/IPFIX plugin according of Netflow v9 - RFC 3954 or Netflow v10 (IPFix) - RFC 7011
Initialize an IPFixPlugin.
- parameters
- emu_client:
trex.emu.trex_emu_client.EMUClient Valid EMU client.
- emu_client:
- INIT_JSON_NS = None¶
There is currently no NS init json for IPFix.
- INIT_JSON_CLIENT = {'ipfix': 'Pointer to INIT_JSON_CLIENT below'}¶
-
- Parameters
- netflow_version: uint16
Netflow version. Might be 9 or 10, notice version 9 doesn’t support variable length fields or per enterprise fields. Defaults to 10.
- dst: string
The destination address. It is a string of the format host:port, where host can be an Ipv4 or an Ipv6 while the port should be a valid transport port. Example are ‘127.0.0.1:8080’, ‘[2001:db8::1]:4739’
- domain_id: uint32
The observation domain ID as defined in IPFix. If not provided, it will be randomly generated.
- generators: list
List of generators, where each generator is a dictionary.
- Generators
- name: string
Name of the generator. This field is required.
- auto_start: bool
If true will automatically start sending IPFix packets upon creation.
- template_rate_pps: float32
Rate of IPFix template packets (in pps), defaults to 1.
- rate_pps: float32
Rate of IPFix data packets (in pps), defaults to 3.
- data_records_num: uint32
Number of data records in each data packet. If not provided, it will default to the maximum number of data packets which doesn’t exceed the MTU.
- template_id: uint16
The template ID for this generator. Must be greater than 255. This field is required. Each generator must have a unique template identifier.
- is_options_template: bool
Indicates if this is generator will send Options Template (True) packets or Data Template packets (False). Defaults to False.
- scope_count: uint16
Scope count in case of Options Template packets. Must be bigger than 0.
- fields: list
List of fields for this generator. Fields are very much alike the fields of Netflow. Each field is represented by a dictionary.
- engines: list
List of engines for this generator. Each engine is represented by a dictionary.
- Fields
- name: string
Name of this field. The name is required.
- type: uint16
A uint16 that is unique per type. One can consult the RFC for specific values of types.
- length: uint16
Length of this field in bytes. If the value is 0xFFFF, this indicates variable length fields. Variable length fields are not supported at the moment. Variable lengths are supported only in V10.
- enterprise_number: uint32
Enterprise number in case the field is specific per enterprise and the type’s MSB equals 1 to indicate this is an enterprise field. Enterprise fields are supported only in V10.
- data: [length]bytes
List of bytes of size length. This will be the initial data in data packets and can be modified by the engines.
- Engines
- engine_name: string
Name of the engine. Must be the name of one of the fields.
- engine_type: string
Type of engine, can be {uint, histogram_uint, histogram_uint_range, histogram_uint_list, histogram_uint64, histogram_uint64_range, histogram_uint64_list}
- params: dictionary
Dictionary of params for the engine. Each engine type has different params. Explore the EMU documentation engine section for more information on engines.
- get_counters(c_key, cnt_filter=None, zero=True, verbose=True)[source]¶
Get the IPFIX counters of a client.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- cnt_filter: list
List of counters types as strings. i.e: [‘INFO’, ‘ERROR’, ‘WARNING’]. Default is None, means no filter. If verbosity is off, this filter can’t be used.
- zero: bool
Get zero values, default is True.
- verbose: bool
Show verbose version of each counter, default is True.
- c_key:
- Returns
Dictionary of all wanted counters. When verbose is True, each plugin contains a list of counter dictionaries.
{'pluginName': [{'help': 'Explanation 1', 'info': 'INFO', 'name': 'counterOne', 'unit': 'pkts', 'value': 8, 'zero': False}, {'help': 'Explanation 2', 'info': 'ERROR', 'name': 'counterTwo', 'unit': 'pkts', 'value': 6, 'zero': False}]}
When verbose is False, each plugins returns a dictionary of counterName, value pairs.
{'pluginName': {'counterOne': 8, 'counterTwo': 6}}
- Raises
TRexError
- clear_counters(c_key)[source]¶
Clear the IPFIX counters of a client.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- c_key:
- Returns
- Boolean indicating if clearing was successful.
True: Clearing was successful.
False: Clearing was not successful.
- Raises
TRexError
- get_gen_info(c_key)[source]¶
Gets information about all the generators of a client.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- c_key:
- Returns
list of dictionaries
For each generator we get a key value mapping of name with the following parameters:
- { ‘enabled’: bool
Flag indicating if generator is enabled.
- ’options_template’: bool
Flag indicating if we are sending options templates for this generator or data templates.
- ’scope_count’: uint16
Scope count in case of options template, otherwise will be 0.
- ’template_rate_pps’: float32
The rate of template packets in pps.
- ’data_rate_pps’: float32
The rate of data packets in pps.
- ’data_records_num’: float32
The number of data records in a packet as user specified.
- ’data_records_num_send’: float32
The actual number of data records in a packet as TRex calculated. For example, if user provided 0, then TRex calculates the maximum number based on the MTU.
- ’fields_num’: int
Number of fields in this generator.
- ’engines_num’: int
Number of engines in this generator.}
- set_gen_rate(c_key, gen_name, template_rate, rate)[source]¶
Set a new rate of data packets for an IPFix generator.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- gen_name: string
The name of the generator we are trying to alter.
- template_rate: float32
New rate for template packets, in pps.
- rate: float32
New rate for data packets, in pps.
- c_key:
- Returns
bool : Flag indicating the result of the operation.
- enable_generator(c_key, gen_name, enable)[source]¶
Enable/disable an IPFix generator.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- gen_name: string
The name of the generator to alter.
- enable: bool
True if we wish to enable the generator, False if we wish to disable it.
- c_key:
- Returns
bool : Flag indicating the result of the operation.
- enable_ipfix(c_key, enable)[source]¶
Enable/disable IPFix plugin for a client. It enable/disable all generators and the exporter.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- enable: bool
True if we wish to enable ipfix for the client, False if we wish to disable it.
- c_key:
- Returns
bool : Flag indicating the result of the operation.
- tear_down_ns(ns_key)¶
This function will be called before removing this plugin from namespace.
- parameters
- ns_key: EMUNamespaceKey
- get_exporter_info(c_key)[source]¶
Gets information about the exporter used by the client.
- Parameters
- c_key:
trex.emu.trex_emu_profile.EMUClientKey EMUClientKey
- c_key:
- Returns
A json dictionary with the following fields:
- ’exporter_type’: string
Exporter type - emu-udp, udp, http, file
- ’files’: list
Only for HTTP exporter - contains a list of objects reporting the status of the most recent (up to 30) file export sessions.
- { ‘name’: string
Name of the exported file
- ’time’: bool
The time when the file was exported
- ’status’: string
Final status of the export session
- ’transport_status’: string
Transport status of the export session
- ’http_status_code’: string
HTTP status code received from the server (collector)
- ’http_response_msg’: string
HTTP response message received from the server (collector)
- ’bytes_uploaded’: int
Number of bytes successfully uploaded by the file
- ’temp_records_uploaded’: int
Number of template records successfully uploaded by the file
- ’data_records_uploaded’: int
Number of data records successfully uploaded by the file}
- trex.emu.emu_plugins.emu_plugin_ipfix.wraps(func)¶
Replaces functools.wraps in order to undo wrapping.
Can be used to preserve the decorated function’s signature in the documentation generated by Sphinx.