Non Drop Rate Plugin API

The following snippet shows a simple yet general implementation of the API

import stl_path

class DUT():
    def __init__(self, name):
        self.counter = 0
        self.name = name

    def QoS(self, rate_tx_bps, rate_rx_bps):
        pass

    def prepare(self, rate_tx_bps, rate_rx_bps):
        self.QoS(rate_tx_bps, rate_rx_bps)

    def should_stop(self, drop_percentage, queue_full_percentage):
        self.counter += 1
        if self.counter > 2 and drop_percentage < 3 and queue_full_percentage < 1:
            return True
        return False

class DeviceUnderTestNDRPlugin():
    def __init__(self):
        self.dut = DUT(name="Cisco Catalyst 3850x")

    def pre_iteration(self, finding_max_rate, run_results=None, **kwargs):
        if run_results is not None:
            self.dut.prepare(run_results['rate_tx_bps'], run_results['rate_rx_bps'])

    def post_iteration(self, finding_max_rate, run_results, **kwargs):
        return self.dut.should_stop(run_results['drop_rate_percentage'], run_results['queue_full_percentage'])


# dynamic load of python module
def register():
    return DeviceUnderTestNDRPlugin()

MyNDRPlugin class

class trex.examples.stl.ndr_plugin.MyNDRPlugin[source]
pre_iteration(finding_max_rate, run_results=None, **kwargs)[source]

Function ran before each iteration.

Parameters
finding_max_rate: boolean

Indicates whether we are running for the first time, trying to find the max rate. In this is the case, the run_results will be None.

run_results: dict
A dictionary that contains the following keys:

queue_full_percentage: Percentage of packets that are queued.

drop_rate_percentage: Percentage of packets that were dropped.

rate_tx_bps: TX rate in bps.

rate_rx_bps: RX rate in bps.

tx_util: TX utilization percentage.

latency: Latency groups.

cpu_util: CPU utilization percentage.

tx_pps: TX in pps.

rx_pps: RX in pps.

tx_bps: TX in bps.

rx_bps: RX in bps.

bw_per_core: Bandwidth per core.

rate_p: Running rate in percentage out of max.

total_tx_L1: Total TX L1.

total_rx_L1: Total RX L1.

iteration: Description of iteration (not necessarily a number)

Pay attention: The rate is of the upcoming iteration. All the rest are of the previous iteration.

kwargs: dict

List of tunables passed as parameters.

post_iteration(finding_max_rate, run_results, **kwargs)[source]

Function ran after each iteration.

Parameters
finding_max_rate: boolean

Indicates whether we are running for the first time, trying to find the max rate. If this is the case, some values of run_results (like iteration for example) are not relevant.

run_results: dict
A dictionary that contains the following keys:

queue_full_percentage: Percentage of packets that are queued.

drop_rate_percentage: Percentage of packets that were dropped.

rate_tx_bps: TX rate in bps.

rate_rx_bps: RX rate in bps.

tx_util: TX utilization percentage.

latency: Latency groups.

cpu_util: CPU utilization percentage.

tx_pps: TX in pps.

rx_pps: RX in pps.

tx_bps: TX in bps.

rx_bps: RX in bps.

bw_per_core: Bandwidth per core.

rate_p: Running rate in percentage out of max.

total_tx_L1: Total TX L1.

total_rx_L1: Total RX L1.

iteration: Description of iteration (not necessarily a number)

kwargs: dict

List of tunables passed as parameters.

Returns

bool: should stop the benchmarking or not.