Tdl

class trex.emu.emu_plugins.emu_plugin_tdl.TDLPlugin(emu_client)[source]

Defines a new plugin implementing Cisco’s The Definition Language (TDL).

Initialize a TdlPlugin.

parameters
emu_client: trex.emu.trex_emu_client.EMUClient

Valid EMU client.

INIT_JSON_NS = None

There is currently no NS init json for TDL.

INIT_JSON_CLIENT = {'tdl': 'Pointer to INIT_JSON_CLIENT below'}
Parameters
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’

udp_debug: bool

Indicate if we are debugging and should use UDP instead of TCP.

rate_pps: float32

Rate of TDL packets (in pps), defaults to 1.

header: dict

Dictionary that contains TDL header fields. See header keys below.

meta_data: list

A list of dictionaries where each dictionary defines a new type by its metadata. See dictionary keys below.

object: dict

The TDL object we are serializing. See keys below.

init_values: list

List of dictionaries setting initial values for the TDL unconstructed types. See dictionary keys below.

engines: list

List of engines instructing how to change the TDL unconstructed types. See engine keys below.

Header
magic: byte

Magic Byte

fru: byte

Fru

src_chassis: byte

Source chassis

src_slot: byte

Source slot

dst_chassis: byte

Destination chassis

dst_slot: byte

Destination slot

bay: byte

Bay

state_tracking: byte

State tracking

flag: byte

Flag

domain_hash: int32

Domain Hash

len: int32

Length

uuid: int64

Universally unique ID

tenant_id: int16

Tenant ID

luid: LUID

Locally unique ID for the object we are serializing.

Meta_data
name: string

Name of this new type.

type: string

Type of this new type, it can be enum_def, flag_def, type_def etc.

data: dict

A dictionary that contains two entries:

luid: LUID

LUID of the new type we are defining

entries: list

Entries for the new type. Depends on the type.

Object
name: string

Name of the TDL object. Used only for reference to other values.

type: string

Type of the TDL object.

Init_values

list of dict

path: string

Path to the object. Hierarchy levels are represented by. For example var1.var2.var3 represents var3 that is defined in var2 which is defined in var1.

value: *

Initial value for the TDL object, depending on the type of object.

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 tdl 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.

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

tear_down_ns(ns_key)

This function will be called before removing this plugin from namespace.

parameters
ns_key: EMUNamespaceKey

see trex.emu.trex_emu_profile.EMUNamespaceKey

clear_counters(c_key)[source]

Clear the tdl counters of a client.

Parameters
c_key: trex.emu.trex_emu_profile.EMUClientKey

EMUClientKey

Returns

Boolean indicating if clearing was successful.
  • True: Clearing was successful.

  • False: Clearing was not successful.

Raises

TRexError

tdl_show_counters_line(line)[source]

Show Tdl counters.

trex.emu.emu_plugins.emu_plugin_tdl.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.