diff options
author | Vratko Polak <vrpolak@cisco.com> | 2020-10-27 19:09:44 +0100 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2020-10-29 20:25:50 +0000 |
commit | 023fa41e51c966a1956bda6b915ffd894ff10e84 (patch) | |
tree | cdb96c99a8ade4855176c43969cbd9a06adf693b /resources/libraries/python | |
parent | e31998ea56c55879fbaae8e58b0dad0bc6549dae (diff) |
Support existing test types with ASTF
+ Add UDP_CPS, TCP_CPS, UDP_PPS and TCP_PPS suites.
+ Update existing cps traffic profiles.
+ Add missing traffic profiles.
+ UDP:
+ Single burst of 32 packets was confirmed as safe enough for TRex.
+ Maybe 64 could work, but not enough testing for that.
+ Multiple bursts have lead to reduced TRex performance,
as overlaping bursts (from different client instances)
tend to fill up the buffers.
+ TCP:
+ Data size set to 11111 bytes, completely arbitrarily.
+ Results look reasonable, so I have kept that.
- MSS not set at all
- No tested support for frame size other than 64B.
- Frame size does not even factor into TCP profiles.
+ So other frame sizes are skipped in autogen.
+ Update tags in related suites.
- HOSTS_{n} and SRC_USER_{n} should be unified.
- Questionable clarification on difference between IP4BASE and SCALE.
+ Add NAT state resetters to tests that need them.
+ Resetter is called (if set) before each measurement.
+ If ramp-up is detected, resetter is not set.
+ Rename "mult" argument to "multiplier".
+ Abstracted from packets to transactions.
+ Transaction corresponds to profile.
+ TRex multiplier argument sets target rate in transactions per second.
+ The familiar STL traffic:
+ Bidirectional is considered to be 2 packets per transaction.
+ Unidirectional is considered to be 1 packet per transaction.
+ The newer ASTF traffic:
+ 4 subtypes, each has different number of packets per transaction.
+ For max rate computation:
+ Packets in the more numerous direction are considered.
+ Rely on TRex reported traffic duration for ASTF:
+ Use the server side value.
- Client side value is higher by an overhead.
- TRex is not sending traffic during that time.
+ Remove delays from traffic profiles.
- Those delays would increase the reprted traffic time.
+ Support for scale lmited trials.
+ Only for ASTF profiles, each ASTF profile has limited scale.
+ Scale defined in suite variables.
+ For TRex to send all transactions provided duration value is ignored.
+ The appropriate value is computed in TrafficGenerator.
+ An ad-hoc time constant is added to match the TRex client side time overhead.
+ The profile driver receives the computed duration.
+ Measurement for PLRsearch add a sleep if the computed duration is smaller.
+ Alternative argument for search algos if scale is limited.
+ Both need higher timeout to accomodate big scales.
+ MLRsearch can afford fewer phases.
+ Added a parameter to optionally shorten the duration.
+ Use short duration for runtime stats trial and failure stats trial.
+ Use very large keepalive values in udp profiles to avoid ka packets.
+ No polling in ASTF profile driver.
- Polling could eliminate the time overhead value.
+ But polling proved to introduce some loss, affecting the results.
+ Handle duration stretching in ASTF by stopping traffic.
+ The stop has several steps so that:
+ The traffic is really stopped entirely.
+ Late packets do not count (maybe as errors).
+ Stats are preserved to read for results (and cleared afterwards).
+ Several quantities added to ReceiveRateMeasurement:
+ Original target duration is preserved (algos need that).
+ Input estimate (tps) for early search iterations.
+ Output estimate (maybe pps) for MRR output.
+ Strict result (unsent counts as loss) for NDR.
+ Use L2 counters (opackets, ipackets) where possible.
- TRex has trouble processing packets for the L7 ones at high loads.
+ Remove warmup from profile drivers and keywords.
+ Suites should call "Send ramp-up traffic" explicitly if needed.
+ Added parsing for few more counters.
+ Both to use in formulas or just for debug purposes.
- Only 64B cases in autogen, framesize support to be added later.
+ Latency streams during search can be enabled via PERF_USE_LATENCY env var.
+ MLRsearch improvments:
+ Rename argument names to min_rate and max_rate.
+ Use relative receive rate in initial phase.
+ PLRsearch improvements:
+ Careful computation when output (pps) does not match input (tps).
+ Use geometric distribution (instead of Poisson).
+ Helps agains math errors.
+ This should improve estimate stability.
- But in practice big losses still lead to significant jumps.
+ Traffic generator improvements:
+ send_traffic_on_tg now calls the full set_rate_provider_defaults.
+ _send_traffic_on_tg_internal for the logic without provider defaults.
+ As the internal function is re-used by measure() without affecting defaults.
+ Move _parse_traffic_results just before get_measurement_result.
+ As the latter uses fields set bu the former, it is now easier to read.
+ Multiple sources for approximate duration.
+ Tried from more precise to more available.
+ Includes logic for _pps tests (added in later change).
+ Move explicit type conversions to earlier occurences.
+ Profile driver output field uses semicolons to simplify parsing.
+ Performance Robot lib file split to several smaller ones.
+ performance_actions.robot:
+ Hosts Additional Statistics Action For * keywords.
+ performance_display.robot:
+ Hosts keyword for displaying and verifying results.
+ Change test message to use the correct unit (pps or cps).
+ performance_limits.robot renamed to performance_vars.robot
+ Added many keywords, mostly for accessing test variables.
+ Moved variables for Policer into a new keyword there.
+ Some keywords need sophisticated logic.
- Other are basically Get Variable Value.
+ But in future more logic can be added, without editing callers.
+ Documentation for the new keywords acts as a documentation for test variables.
+ performance_utils.robot has the rest.
+ Eliminated arguments if the value is in test variable.
+ Small improvements to documentation.
- Still not enough cleanup with respect to arguments and test variables.
+ Keywords are sorted alphabetically now in each one.
+ Suites:
+ Unified variables table:
+ No colons in comments.
+ ${n_hosts}, ${n_ports} and use them instead hardcoded numbers.
+ Add -cps to existing cps suite names.
+ Remove "trial data overwrite".
+ Compute max rate as in STL suites.
+ Each NAT suite has ip4base suite to compare results to.
- Those act as indirect TRex calibration.
- VPP does not lose packets in those.
+ Latency in ASTF suites is disabled hard.
- As we do not support latency in ASTF profiles yet.
+ Unidirectional tests governed by suite variable, not an argument.
+ Write long argument lists vertically.
+ Prefer to use argument names.
+ In Python, also the last argument is followed by comma.
+ It makes renaming and reordering easier.
+ Similarly applies to prints with long lists of values.
+ A TODO to update api crc file comments.
Change-Id: I84729355edbec051298a9de1162107f88ff5737d
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python')
9 files changed, 766 insertions, 378 deletions
diff --git a/resources/libraries/python/Constants.py b/resources/libraries/python/Constants.py index 3775d98377..faf861d89d 100644 --- a/resources/libraries/python/Constants.py +++ b/resources/libraries/python/Constants.py @@ -232,6 +232,9 @@ class Constants: # Duration of one trial in MRR test. PERF_TRIAL_DURATION = get_float_from_env(u"PERF_TRIAL_DURATION", 1.0) + # Whether to use latency streams in main search trials. + PERF_USE_LATENCY = get_pessimistic_bool_from_env(u"PERF_USE_LATENCY") + # Duration of one latency-specific trial in NDRPDR test. PERF_TRIAL_LATENCY_DURATION = get_float_from_env( u"PERF_TRIAL_LATENCY_DURATION", 5.0) diff --git a/resources/libraries/python/MLRsearch/AbstractMeasurer.py b/resources/libraries/python/MLRsearch/AbstractMeasurer.py index 622b8fdba6..82116f2e43 100644 --- a/resources/libraries/python/MLRsearch/AbstractMeasurer.py +++ b/resources/libraries/python/MLRsearch/AbstractMeasurer.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2020 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -24,7 +24,7 @@ class AbstractMeasurer(metaclass=ABCMeta): """Perform trial measurement and return the result. :param duration: Trial duration [s]. - :param transmit_rate: Target transmit rate [pps]. + :param transmit_rate: Target transmit rate [tps]. :type duration: float :type transmit_rate: float :returns: Structure containing the result of the measurement. diff --git a/resources/libraries/python/MLRsearch/AbstractSearchAlgorithm.py b/resources/libraries/python/MLRsearch/AbstractSearchAlgorithm.py index f4f2d3f096..f2bf04e1b1 100644 --- a/resources/libraries/python/MLRsearch/AbstractSearchAlgorithm.py +++ b/resources/libraries/python/MLRsearch/AbstractSearchAlgorithm.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2020 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -30,16 +30,19 @@ class AbstractSearchAlgorithm(metaclass=ABCMeta): @abstractmethod def narrow_down_ndr_and_pdr( - self, fail_rate, line_rate, packet_loss_ratio): + self, min_rate, max_rate, packet_loss_ratio): """Perform measurements to narrow down intervals, return them. This will be renamed when custom loss ratio lists are supported. - :param fail_rate: Minimal target transmit rate [pps]. - :param line_rate: Maximal target transmit rate [pps]. + :param min_rate: Minimal target transmit rate [tps]. + Usually, tests are set to fail if search reaches this or below. + :param max_rate: Maximal target transmit rate [tps]. + Usually computed from line rate and various other limits, + to prevent failures or duration stretching in Traffic Generator. :param packet_loss_ratio: Fraction of packets lost, for PDR [1]. - :type fail_rate: float - :type line_rate: float + :type min_rate: float + :type max_rate: float :type packet_loss_ratio: float :returns: Structure containing narrowed down intervals and their measurements. diff --git a/resources/libraries/python/MLRsearch/MultipleLossRatioSearch.py b/resources/libraries/python/MLRsearch/MultipleLossRatioSearch.py index 2db65ef755..87dc784cbc 100644 --- a/resources/libraries/python/MLRsearch/MultipleLossRatioSearch.py +++ b/resources/libraries/python/MLRsearch/MultipleLossRatioSearch.py @@ -157,7 +157,7 @@ class MultipleLossRatioSearch(AbstractSearchAlgorithm): :returns: The relative width of double logarithmic size. :rtype: float """ - return 1.999 * relative_width - relative_width * relative_width + return 1.99999 * relative_width - relative_width * relative_width # The number should be 2.0, but we want to avoid rounding errors, # and ensure half of double is not larger than the original value. @@ -255,52 +255,50 @@ class MultipleLossRatioSearch(AbstractSearchAlgorithm): 1.0 - MultipleLossRatioSearch.half_relative_width(relative_width) ) - def narrow_down_ndr_and_pdr( - self, minimum_transmit_rate, maximum_transmit_rate, - packet_loss_ratio): + def narrow_down_ndr_and_pdr(self, min_rate, max_rate, packet_loss_ratio): """Perform initial phase, create state object, proceed with next phases. - :param minimum_transmit_rate: Minimal target transmit rate [pps]. - :param maximum_transmit_rate: Maximal target transmit rate [pps]. + :param min_rate: Minimal target transmit rate [tps]. + :param max_rate: Maximal target transmit rate [tps]. :param packet_loss_ratio: Fraction of packets lost, for PDR [1]. - :type minimum_transmit_rate: float - :type maximum_transmit_rate: float + :type min_rate: float + :type max_rate: float :type packet_loss_ratio: float :returns: Structure containing narrowed down intervals and their measurements. :rtype: NdrPdrResult.NdrPdrResult :raises RuntimeError: If total duration is larger than timeout. """ - minimum_transmit_rate = float(minimum_transmit_rate) - maximum_transmit_rate = float(maximum_transmit_rate) + minimum_transmit_rate = float(min_rate) + maximum_transmit_rate = float(max_rate) packet_loss_ratio = float(packet_loss_ratio) - line_measurement = self.measurer.measure( + max_measurement = self.measurer.measure( self.initial_trial_duration, maximum_transmit_rate) initial_width_goal = self.final_relative_width for _ in range(self.number_of_intermediate_phases): initial_width_goal = self.double_relative_width(initial_width_goal) max_lo = maximum_transmit_rate * (1.0 - initial_width_goal) - mrr = max( - minimum_transmit_rate, min(max_lo, line_measurement.receive_rate) - ) + mrr = max(minimum_transmit_rate, min( + max_lo, max_measurement.relative_receive_rate + )) mrr_measurement = self.measurer.measure( self.initial_trial_duration, mrr ) # Attempt to get narrower width. if mrr_measurement.loss_fraction > 0.0: max2_lo = mrr * (1.0 - initial_width_goal) - mrr2 = min(max2_lo, mrr_measurement.receive_rate) + mrr2 = min(max2_lo, mrr_measurement.relative_receive_rate) else: mrr2 = mrr / (1.0 - initial_width_goal) if minimum_transmit_rate < mrr2 < maximum_transmit_rate: - line_measurement = mrr_measurement + max_measurement = mrr_measurement mrr_measurement = self.measurer.measure( self.initial_trial_duration, mrr2) if mrr2 > mrr: - line_measurement, mrr_measurement = \ - (mrr_measurement, line_measurement) + max_measurement, mrr_measurement = \ + (mrr_measurement, max_measurement) starting_interval = ReceiveRateInterval( - mrr_measurement, line_measurement) + mrr_measurement, max_measurement) starting_result = NdrPdrResult(starting_interval, starting_interval) state = self.ProgressState( starting_result, self.number_of_intermediate_phases, diff --git a/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py b/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py index 31a6f8202e..c732e66026 100644 --- a/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py +++ b/resources/libraries/python/MLRsearch/ReceiveRateMeasurement.py @@ -1,4 +1,4 @@ -# Copyright (c) 2019 Cisco and/or its affiliates. +# Copyright (c) 2020 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -17,18 +17,39 @@ class ReceiveRateMeasurement: """Structure defining the result of single Rr measurement.""" - def __init__(self, duration, target_tr, transmit_count, loss_count): + def __init__( + self, duration, target_tr, transmit_count, loss_count, + approximated_duration=0.0, partial_transmit_count=0): """Constructor, normalize primary and compute secondary quantities. + If approximated_duration is nonzero, it is stored. + If approximated_duration is zero, duration value is stored. + Either way, additional secondary quantities are computed + from the store value. + + If there is zero transmit_count, fractions are set to zero. + + In some cases, traffic generator does not attempt all the needed + transactions. In that case, nonzero partial_transmit_count + holds (an estimate of) count of the actually attempted transactions. + This is used to populate some secondary quantities. + + TODO: Use None instead of zero? + :param duration: Measurement duration [s]. :param target_tr: Target transmit rate [pps]. If bidirectional traffic is measured, this is bidirectional rate. :param transmit_count: Number of packets transmitted [1]. :param loss_count: Number of packets transmitted but not received [1]. + :param approximated_duration: Estimate of the actual time of the trial. + :param partial_transmit_count: Estimate count of actually attempted + transactions. :type duration: float :type target_tr: float :type transmit_count: int :type loss_count: int + :type approximated_duration: float + :type partial_transmit_count: int """ self.duration = float(duration) self.target_tr = float(target_tr) @@ -38,8 +59,41 @@ class ReceiveRateMeasurement: self.transmit_rate = transmit_count / self.duration self.loss_rate = loss_count / self.duration self.receive_rate = self.receive_count / self.duration - self.loss_fraction = float(self.loss_count) / self.transmit_count - # TODO: Do we want to store also the real time (duration + overhead)? + self.loss_fraction = ( + float(self.loss_count) / self.transmit_count + if self.transmit_count > 0 else 1.0 + ) + self.receive_fraction = ( + float(self.receive_count) / self.transmit_count + if self.transmit_count > 0 else 0.0 + ) + self.approximated_duration = ( + float(approximated_duration) if approximated_duration + else self.duration + ) + self.approximated_receive_rate = ( + self.receive_count / self.approximated_duration + if self.approximated_duration > 0.0 else 0.0 + ) + # If the traffic generator is unreliable and sends less packets, + # the absolute receive rate might be too low for next target. + self.partial_transmit_count = ( + int(partial_transmit_count) if partial_transmit_count + else self.transmit_count + ) + self.partial_receive_fraction = ( + float(self.receive_count) / self.partial_transmit_count + if self.partial_transmit_count > 0 else 0.0 + ) + self.partial_receive_rate = ( + self.target_tr * self.partial_receive_fraction + ) + # We use relative packet ratios in order to support cases + # where target_tr is in transactions per second, + # but there are multiple packets per transaction. + self.relative_receive_rate = ( + self.target_tr * self.receive_count / self.transmit_count + ) def __str__(self): """Return string reporting input and loss fraction.""" @@ -51,4 +105,6 @@ class ReceiveRateMeasurement: return f"ReceiveRateMeasurement(duration={self.duration!r}," \ f"target_tr={self.target_tr!r}," \ f"transmit_count={self.transmit_count!r}," \ - f"loss_count={self.loss_count!r})" + f"loss_count={self.loss_count!r}," \ + f"approximated_duration={self.approximated_duration!r}," \ + f"partial_transmit_count={self.partial_transmit_count!r})" diff --git a/resources/libraries/python/NATUtil.py b/resources/libraries/python/NATUtil.py index a9f760768e..422feaedb8 100644 --- a/resources/libraries/python/NATUtil.py +++ b/resources/libraries/python/NATUtil.py @@ -159,6 +159,10 @@ class NATUtil: flag=u"NAT_IS_NONE"): """Set NAT44 address range. + The return value is a callable (zero argument Python function) + which can be used to reset NAT state, so repeated trial measurements + hit the same slow path. + :param node: DUT node. :param start_ip: IP range start. :param end_ip: IP range end. @@ -169,6 +173,8 @@ class NATUtil: :type end_ip: str :type vrf_id: int :type flag: str + :returns: Resetter of the NAT state. + :rtype: Callable[[], None] """ cmd = u"nat44_add_del_address_range" err_msg = f"Failed to set NAT44 address range on host {node[u'host']}" @@ -183,6 +189,18 @@ class NATUtil: with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args_in).get_reply(err_msg) + # A closure, accessing the variables above. + def resetter(): + """Delete and re-add the NAT range setting.""" + with PapiSocketExecutor(node) as papi_exec: + args_in[u"is_add"] = False + papi_exec.add(cmd, **args_in) + args_in[u"is_add"] = True + papi_exec.add(cmd, **args_in) + papi_exec.get_replies(err_msg) + + return resetter + @staticmethod def show_nat_config(node): """Show the NAT configuration. @@ -345,6 +363,10 @@ class NATUtil: def set_det44_mapping(node, ip_in, subnet_in, ip_out, subnet_out): """Set DET44 mapping. + The return value is a callable (zero argument Python function) + which can be used to reset NAT state, so repeated trial measurements + hit the same slow path. + :param node: DUT node. :param ip_in: Inside IP. :param subnet_in: Inside IP subnet. @@ -369,6 +391,18 @@ class NATUtil: with PapiSocketExecutor(node) as papi_exec: papi_exec.add(cmd, **args_in).get_reply(err_msg) + # A closure, accessing the variables above. + def resetter(): + """Delete and re-add the deterministic NAT mapping.""" + with PapiSocketExecutor(node) as papi_exec: + args_in[u"is_add"] = False + papi_exec.add(cmd, **args_in) + args_in[u"is_add"] = True + papi_exec.add(cmd, **args_in) + papi_exec.get_replies(err_msg) + + return resetter + @staticmethod def get_det44_mapping(node): """Get DET44 mapping data. @@ -391,14 +425,12 @@ class NATUtil: def get_det44_sessions_number(node): """Get number of established DET44 sessions from actual DET44 mapping data. - :param node: DUT node. :type node: dict :returns: Number of established DET44 sessions. :rtype: int """ det44_data = NATUtil.get_det44_mapping(node) - return det44_data.get(u"ses_num", 0) @staticmethod diff --git a/resources/libraries/python/PLRsearch/PLRsearch.py b/resources/libraries/python/PLRsearch/PLRsearch.py index ec58fbd10f..226b482d76 100644 --- a/resources/libraries/python/PLRsearch/PLRsearch.py +++ b/resources/libraries/python/PLRsearch/PLRsearch.py @@ -54,7 +54,7 @@ class PLRsearch: def __init__( self, measurer, trial_duration_per_trial, packet_loss_ratio_target, - trial_number_offset=0, timeout=1800.0, trace_enabled=False): + trial_number_offset=0, timeout=7200.0, trace_enabled=False): """Store rate measurer and additional parameters. The measurer must never report negative loss count. @@ -205,7 +205,7 @@ class PLRsearch: if (trial_number - self.trial_number_offset) <= 1: next_load = max_rate elif (trial_number - self.trial_number_offset) <= 3: - next_load = (measurement.receive_rate / ( + next_load = (measurement.relative_receive_rate / ( 1.0 - self.packet_loss_ratio_target)) else: next_load = (avg1 + avg2) / 2.0 @@ -439,7 +439,7 @@ class PLRsearch: :param lfit_func: Fitting function, typically lfit_spread or lfit_erf. :param trial_result_list: List of trial measurement results. :param mrr: The mrr parameter for the fitting function. - :param spread: The spread parameter for the fittinmg function. + :param spread: The spread parameter for the fitting function. :type trace: function (str, object) -> None :type lfit_func: Function from 3 floats to float. :type trial_result_list: list of MLRsearch.ReceiveRateMeasurement @@ -455,20 +455,21 @@ class PLRsearch: trace(u"for tr", result.target_tr) trace(u"lc", result.loss_count) trace(u"d", result.duration) - log_avg_loss_per_second = lfit_func( + # _rel_ values use units of target_tr (transactions per second). + log_avg_rel_loss_per_second = lfit_func( trace, result.target_tr, mrr, spread ) - log_avg_loss_per_trial = ( - log_avg_loss_per_second + math.log(result.duration) + # _abs_ values use units of loss count (maybe packets). + # There can be multiple packets per transaction. + log_avg_abs_loss_per_trial = log_avg_rel_loss_per_second + math.log( + result.transmit_count / result.target_tr ) - # Poisson probability computation works nice for logarithms. - log_trial_likelihood = ( - result.loss_count * log_avg_loss_per_trial - - math.exp(log_avg_loss_per_trial) - ) - log_trial_likelihood -= math.lgamma(1 + result.loss_count) + # Geometric probability computation for logarithms. + log_trial_likelihood = log_plus(0.0, -log_avg_abs_loss_per_trial) + log_trial_likelihood *= -result.loss_count + log_trial_likelihood -= log_plus(0.0, +log_avg_abs_loss_per_trial) log_likelihood += log_trial_likelihood - trace(u"avg_loss_per_trial", math.exp(log_avg_loss_per_trial)) + trace(u"avg_loss_per_trial", math.exp(log_avg_abs_loss_per_trial)) trace(u"log_trial_likelihood", log_trial_likelihood) return log_likelihood diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index f44ff870bd..80248add03 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -67,7 +67,7 @@ class TGDropRateSearchImpl(DropRateSearch): def measure_loss( self, rate, frame_size, loss_acceptance, loss_acceptance_type, - traffic_profile, skip_warmup=False): + traffic_profile): """Runs the traffic and evaluate the measured results. :param rate: Offered traffic load. @@ -76,13 +76,11 @@ class TGDropRateSearchImpl(DropRateSearch): :param loss_acceptance_type: Type of permitted loss. :param traffic_profile: Module name as a traffic profile identifier. See GPL/traffic_profiles/trex for implemented modules. - :param skip_warmup: Start TRex without warmup traffic if true. :type rate: float :type frame_size: str :type loss_acceptance: float :type loss_acceptance_type: LossAcceptanceType :type traffic_profile: str - :type skip_warmup: bool :returns: Drop threshold exceeded? (True/False) :rtype: bool :raises NotImplementedError: If TG is not supported. @@ -96,15 +94,9 @@ class TGDropRateSearchImpl(DropRateSearch): subtype = check_subtype(tg_instance.node) if subtype == NodeSubTypeTG.TREX: unit_rate = str(rate) + self.get_rate_type_str() - if skip_warmup: - tg_instance.trex_stl_start_remote_exec( - self.get_duration(), unit_rate, frame_size, traffic_profile, - warmup_time=0.0 - ) - else: - tg_instance.trex_stl_start_remote_exec( - self.get_duration(), unit_rate, frame_size, traffic_profile - ) + tg_instance.trex_stl_start_remote_exec( + self.get_duration(), unit_rate, frame_size, traffic_profile + ) loss = tg_instance.get_loss() sent = tg_instance.get_sent() if self.loss_acceptance_type_is_percentage(): @@ -145,6 +137,8 @@ class TrafficGenerator(AbstractMeasurer): ROBOT_LIBRARY_SCOPE = u"TEST SUITE" def __init__(self): + # TODO: Separate into few dataclasses/dicts. + # Pylint dislikes large unstructured state, and it is right. self._node = None self._mode = None # TG interface order mapping @@ -160,14 +154,23 @@ class TrafficGenerator(AbstractMeasurer): self._l7_data = None # Measurement input fields, needed for async stop result. self._start_time = None + self._stop_time = None self._rate = None + self._target_duration = None + self._duration = None # Other input parameters, not knowable from measure() signature. self.frame_size = None self.traffic_profile = None - self.warmup_time = None self.traffic_directions = None self.negative_loss = None self.use_latency = None + self.ppta = None + self.resetter = None + self.transaction_scale = None + self.transaction_duration = None + self.sleep_till_duration = None + self.transaction_type = None + self.duration_limit = None # Transient data needed for async measurements. self._xstats = (None, None) # TODO: Rename "xstats" to something opaque, so T-Rex is not privileged? @@ -454,108 +457,6 @@ class TrafficGenerator(AbstractMeasurer): message=u"T-Rex kill failed!" ) - def _parse_traffic_results(self, stdout): - """Parse stdout of scripts into fields of self. - - Block of code to reuse, by sync start, or stop after async. - - :param stdout: Text containing the standard output. - :type stdout: str - """ - subtype = check_subtype(self._node) - if subtype == NodeSubTypeTG.TREX: - # Last line from console output - line = stdout.splitlines()[-1] - results = line.split(u",") - if results[-1] in (u" ", u""): - results.pop(-1) - self._result = dict() - for result in results: - key, value = result.split(u"=", maxsplit=1) - self._result[key.strip()] = value - logger.info(f"TrafficGen results:\n{self._result}") - self._received = self._result.get(u"total_received") - self._sent = self._result.get(u"total_sent") - self._loss = self._result.get(u"frame_loss") - self._approximated_duration = \ - self._result.get(u"approximated_duration") - self._approximated_rate = self._result.get(u"approximated_rate") - self._latency = list() - self._latency.append(self._result.get(u"latency_stream_0(usec)")) - self._latency.append(self._result.get(u"latency_stream_1(usec)")) - if self._mode == TrexMode.ASTF: - self._l7_data = dict() - self._l7_data[u"client"] = dict() - self._l7_data[u"client"][u"active_flows"] = \ - self._result.get(u"client_active_flows") - self._l7_data[u"client"][u"established_flows"] = \ - self._result.get(u"client_established_flows") - self._l7_data[u"client"][u"err_rx_throttled"] = \ - self._result.get(u"client_err_rx_throttled") - self._l7_data[u"client"][u"err_c_nf_throttled"] = \ - self._result.get(u"client_err_nf_throttled") - self._l7_data[u"client"][u"err_flow_overflow"] = \ - self._result.get(u"client_err_flow_overflow") - self._l7_data[u"server"] = dict() - self._l7_data[u"server"][u"active_flows"] = \ - self._result.get(u"server_active_flows") - self._l7_data[u"server"][u"established_flows"] = \ - self._result.get(u"server_established_flows") - self._l7_data[u"server"][u"err_rx_throttled"] = \ - self._result.get(u"client_err_rx_throttled") - if u"udp" in self.traffic_profile: - self._l7_data[u"client"][u"udp"] = dict() - self._l7_data[u"client"][u"udp"][u"established_flows"] = \ - self._result.get(u"client_udp_connects") - self._l7_data[u"client"][u"udp"][u"closed_flows"] = \ - self._result.get(u"client_udp_closed") - self._l7_data[u"client"][u"udp"][u"tx_bytes"] = \ - self._result.get(u"client_udp_tx_bytes") - self._l7_data[u"client"][u"udp"][u"rx_bytes"] = \ - self._result.get(u"client_udp_rx_bytes") - self._l7_data[u"client"][u"udp"][u"tx_packets"] = \ - self._result.get(u"client_udp_tx_packets") - self._l7_data[u"client"][u"udp"][u"rx_packets"] = \ - self._result.get(u"client_udp_rx_packets") - self._l7_data[u"client"][u"udp"][u"keep_drops"] = \ - self._result.get(u"client_udp_keep_drops") - self._l7_data[u"server"][u"udp"] = dict() - self._l7_data[u"server"][u"udp"][u"accepted_flows"] = \ - self._result.get(u"server_udp_accepts") - self._l7_data[u"server"][u"udp"][u"closed_flows"] = \ - self._result.get(u"server_udp_closed") - self._l7_data[u"server"][u"udp"][u"tx_bytes"] = \ - self._result.get(u"server_udp_tx_bytes") - self._l7_data[u"server"][u"udp"][u"rx_bytes"] = \ - self._result.get(u"server_udp_rx_bytes") - self._l7_data[u"server"][u"udp"][u"tx_packets"] = \ - self._result.get(u"server_udp_tx_packets") - self._l7_data[u"server"][u"udp"][u"rx_packets"] = \ - self._result.get(u"server_udp_rx_packets") - elif u"tcp" in self.traffic_profile: - self._l7_data[u"client"][u"tcp"] = dict() - self._l7_data[u"client"][u"tcp"][u"initiated_flows"] = \ - self._result.get(u"client_tcp_connect_inits") - self._l7_data[u"client"][u"tcp"][u"established_flows"] = \ - self._result.get(u"client_tcp_connects") - self._l7_data[u"client"][u"tcp"][u"closed_flows"] = \ - self._result.get(u"client_tcp_closed") - self._l7_data[u"client"][u"tcp"][u"tx_bytes"] = \ - self._result.get(u"client_tcp_tx_bytes") - self._l7_data[u"client"][u"tcp"][u"rx_bytes"] = \ - self._result.get(u"client_tcp_rx_bytes") - self._l7_data[u"server"][u"tcp"] = dict() - self._l7_data[u"server"][u"tcp"][u"accepted_flows"] = \ - self._result.get(u"server_tcp_accepts") - self._l7_data[u"server"][u"tcp"][u"established_flows"] = \ - self._result.get(u"server_tcp_connects") - self._l7_data[u"server"][u"tcp"][u"closed_flows"] = \ - self._result.get(u"server_tcp_closed") - self._l7_data[u"server"][u"tcp"][u"tx_bytes"] = \ - self._result.get(u"server_tcp_tx_bytes") - self._l7_data[u"server"][u"tcp"][u"rx_bytes"] = \ - self._result.get(u"server_tcp_rx_bytes") - def trex_astf_stop_remote_exec(self, node): """Execute T-Rex ASTF script on remote node over ssh to stop running traffic. @@ -612,59 +513,77 @@ class TrafficGenerator(AbstractMeasurer): :raises ValueError: If TG traffic profile is not supported. """ subtype = check_subtype(self._node) - if subtype == NodeSubTypeTG.TREX: - if u"trex-astf" in self.traffic_profile: - self.trex_astf_stop_remote_exec(self._node) - elif u"trex-stl" in self.traffic_profile: - self.trex_stl_stop_remote_exec(self._node) - else: - raise ValueError(u"Unsupported T-Rex traffic profile!") + if subtype != NodeSubTypeTG.TREX: + raise ValueError(f"Unsupported TG subtype: {subtype!r}") + if u"trex-astf" in self.traffic_profile: + self.trex_astf_stop_remote_exec(self._node) + elif u"trex-stl" in self.traffic_profile: + self.trex_stl_stop_remote_exec(self._node) + else: + raise ValueError(u"Unsupported T-Rex traffic profile!") + self._stop_time = time.monotonic() return self.get_measurement_result() def trex_astf_start_remote_exec( - self, duration, mult, frame_size, traffic_profile, async_call=False, - latency=True, warmup_time=5.0, traffic_directions=2, tx_port=0, - rx_port=1): + self, duration, multiplier, async_call=False): """Execute T-Rex ASTF script on remote node over ssh to start running traffic. In sync mode, measurement results are stored internally. In async mode, initial data including xstats are stored internally. - :param duration: Time expresed in seconds for how long to send traffic. - :param mult: Traffic rate expressed with units (pps, %) - :param frame_size: L2 frame size to send (without padding and IPG). - :param traffic_profile: Module name as a traffic profile identifier. - See GPL/traffic_profiles/trex for implemented modules. + This method contains the logic to compute duration as maximum time + if transaction_scale is nonzero. + The transaction_scale argument defines (limits) how many transactions + will be started in total. As that amount of transaction can take + considerable time (sometimes due to explicit delays in the profile), + the real time a trial needs to finish is computed here. For now, + in that case the duration argument is ignored, assuming it comes + from ASTF-unaware search algorithm. The overall time a single + transaction needs is given in parameter transaction_duration, + it includes both explicit delays and implicit time it takes + to transfer data (or whatever the transaction does). + + Currently it is observed TRex does not start the ASTF traffic + immediately, an ad-hoc constant is added to the computed duration + to compensate for that. + + If transaction_scale is zero, duration is not recomputed. + It is assumed the subsequent result parsing gets the real duration + if the traffic stops sooner for any reason. + + Currently, it is assumed traffic profile defines a single transaction. + To avoid heavy logic here, the input rate is expected to be in + transactions per second, as that directly translates to TRex multiplier, + (assuming the profile does not override the default cps value of one). + + :param duration: Time expressed in seconds for how long to send traffic. + :param multiplier: Traffic rate in transactions per second. :param async_call: If enabled then don't wait for all incoming traffic. - :param latency: With latency measurement. - :param warmup_time: Warmup time period. - :param traffic_directions: Traffic is bi- (2) or uni- (1) directional. - Default: 2 - :param tx_port: Traffic generator transmit port for first flow. - Default: 0 - :param rx_port: Traffic generator receive port for first flow. - Default: 1 :type duration: float - :type mult: int - :type frame_size: str - :type traffic_profile: str + :type multiplier: int :type async_call: bool - :type latency: bool - :type warmup_time: float - :type traffic_directions: int - :type tx_port: int - :type rx_port: int :raises RuntimeError: In case of T-Rex driver issue. """ self.check_mode(TrexMode.ASTF) - p_0, p_1 = (rx_port, tx_port) if self._ifaces_reordered \ - else (tx_port, rx_port) + p_0, p_1 = (1, 0) if self._ifaces_reordered else (0, 1) if not isinstance(duration, (float, int)): duration = float(duration) - if not isinstance(warmup_time, (float, int)): - warmup_time = float(warmup_time) + + # Duration logic. + computed_duration = duration + if duration > 0.0: + if self.transaction_scale: + computed_duration = self.transaction_scale / multiplier + # Log the computed duration, + # so we can compare with what telemetry suggests + # the real duration was. + logger.debug(f"Expected duration {computed_duration}") + computed_duration += 0.1115 + # Else keep -1. + if self.duration_limit: + computed_duration = min(computed_duration, self.duration_limit) command_line = OptionString().add(u"python3") dirname = f"{Constants.REMOTE_FW_DIR}/GPL/tools/trex" @@ -672,31 +591,31 @@ class TrafficGenerator(AbstractMeasurer): command_line.change_prefix(u"--") dirname = f"{Constants.REMOTE_FW_DIR}/GPL/traffic_profiles/trex" command_line.add_with_value( - u"profile", f"'{dirname}/{traffic_profile}.py'" + u"profile", f"'{dirname}/{self.traffic_profile}.py'" ) - command_line.add_with_value(u"duration", f"{duration!r}") - command_line.add_with_value(u"frame_size", frame_size) - command_line.add_with_value(u"mult", int(mult)) - command_line.add_with_value(u"warmup_time", f"{warmup_time!r}") + command_line.add_with_value(u"duration", f"{computed_duration!r}") + command_line.add_with_value(u"frame_size", self.frame_size) + command_line.add_with_value(u"multiplier", multiplier) command_line.add_with_value(u"port_0", p_0) command_line.add_with_value(u"port_1", p_1) - command_line.add_with_value(u"traffic_directions", traffic_directions) + command_line.add_with_value( + u"traffic_directions", self.traffic_directions + ) command_line.add_if(u"async_start", async_call) - command_line.add_if(u"latency", latency) + command_line.add_if(u"latency", self.use_latency) command_line.add_if(u"force", Constants.TREX_SEND_FORCE) + self._start_time = time.monotonic() + self._rate = multiplier stdout, _ = exec_cmd_no_error( - self._node, command_line, - timeout=int(duration) + 600 if u"tcp" in self.traffic_profile - else 60, + self._node, command_line, timeout=computed_duration + 10.0, message=u"T-Rex ASTF runtime error!" ) - self.traffic_directions = traffic_directions if async_call: # no result - self._start_time = time.time() - self._rate = float(mult) + self._target_duration = None + self._duration = None self._received = None self._sent = None self._loss = None @@ -706,24 +625,28 @@ class TrafficGenerator(AbstractMeasurer): self._l7_data[u"client"] = dict() self._l7_data[u"client"][u"active_flows"] = None self._l7_data[u"client"][u"established_flows"] = None + self._l7_data[u"client"][u"traffic_duration"] = None self._l7_data[u"server"] = dict() self._l7_data[u"server"][u"active_flows"] = None self._l7_data[u"server"][u"established_flows"] = None + self._l7_data[u"server"][u"traffic_duration"] = None if u"udp" in self.traffic_profile: self._l7_data[u"client"][u"udp"] = dict() - self._l7_data[u"client"][u"udp"][u"established_flows"] = None + self._l7_data[u"client"][u"udp"][u"connects"] = None self._l7_data[u"client"][u"udp"][u"closed_flows"] = None + self._l7_data[u"client"][u"udp"][u"err_cwf"] = None self._l7_data[u"server"][u"udp"] = dict() self._l7_data[u"server"][u"udp"][u"accepted_flows"] = None self._l7_data[u"server"][u"udp"][u"closed_flows"] = None elif u"tcp" in self.traffic_profile: self._l7_data[u"client"][u"tcp"] = dict() self._l7_data[u"client"][u"tcp"][u"initiated_flows"] = None - self._l7_data[u"client"][u"tcp"][u"established_flows"] = None + self._l7_data[u"client"][u"tcp"][u"connects"] = None self._l7_data[u"client"][u"tcp"][u"closed_flows"] = None + self._l7_data[u"client"][u"tcp"][u"connattempt"] = None self._l7_data[u"server"][u"tcp"] = dict() self._l7_data[u"server"][u"tcp"][u"accepted_flows"] = None - self._l7_data[u"server"][u"tcp"][u"established_flows"] = None + self._l7_data[u"server"][u"tcp"][u"connects"] = None self._l7_data[u"server"][u"tcp"][u"closed_flows"] = None else: logger.warn(u"Unsupported T-Rex ASTF traffic profile!") @@ -736,53 +659,36 @@ class TrafficGenerator(AbstractMeasurer): break self._xstats = tuple(xstats) else: + self._target_duration = duration + self._duration = computed_duration self._parse_traffic_results(stdout) - self._start_time = None - self._rate = None - def trex_stl_start_remote_exec( - self, duration, rate, frame_size, traffic_profile, async_call=False, - latency=False, warmup_time=5.0, traffic_directions=2, tx_port=0, - rx_port=1): + def trex_stl_start_remote_exec(self, duration, rate, async_call=False): """Execute T-Rex STL script on remote node over ssh to start running traffic. In sync mode, measurement results are stored internally. In async mode, initial data including xstats are stored internally. + Mode-unaware code (e.g. in search algorithms) works with transactions. + To keep the logic simple, multiplier is set to that value. + As bidirectional traffic profiles send packets in both directions, + they are treated as transactions with two packets (one per direction). + :param duration: Time expressed in seconds for how long to send traffic. - :param rate: Traffic rate expressed with units (pps, %) - :param frame_size: L2 frame size to send (without padding and IPG). - :param traffic_profile: Module name as a traffic profile identifier. - See GPL/traffic_profiles/trex for implemented modules. + :param rate: Traffic rate in transactions per second. :param async_call: If enabled then don't wait for all incoming traffic. - :param latency: With latency measurement. - :param warmup_time: Warmup time period. - :param traffic_directions: Traffic is bi- (2) or uni- (1) directional. - Default: 2 - :param tx_port: Traffic generator transmit port for first flow. - Default: 0 - :param rx_port: Traffic generator receive port for first flow. - Default: 1 :type duration: float :type rate: str - :type frame_size: str - :type traffic_profile: str :type async_call: bool - :type latency: bool - :type warmup_time: float - :type traffic_directions: int - :type tx_port: int - :type rx_port: int :raises RuntimeError: In case of T-Rex driver issue. """ self.check_mode(TrexMode.STL) - p_0, p_1 = (rx_port, tx_port) if self._ifaces_reordered \ - else (tx_port, rx_port) + p_0, p_1 = (1, 0) if self._ifaces_reordered else (0, 1) if not isinstance(duration, (float, int)): duration = float(duration) - if not isinstance(warmup_time, (float, int)): - warmup_time = float(warmup_time) + if self.duration_limit: + duration = min(duration, self.duration_limit) command_line = OptionString().add(u"python3") dirname = f"{Constants.REMOTE_FW_DIR}/GPL/tools/trex" @@ -790,29 +696,32 @@ class TrafficGenerator(AbstractMeasurer): command_line.change_prefix(u"--") dirname = f"{Constants.REMOTE_FW_DIR}/GPL/traffic_profiles/trex" command_line.add_with_value( - u"profile", f"'{dirname}/{traffic_profile}.py'" + u"profile", f"'{dirname}/{self.traffic_profile}.py'" ) command_line.add_with_value(u"duration", f"{duration!r}") - command_line.add_with_value(u"frame_size", frame_size) + command_line.add_with_value(u"frame_size", self.frame_size) command_line.add_with_value(u"rate", f"{rate!r}") - command_line.add_with_value(u"warmup_time", f"{warmup_time!r}") command_line.add_with_value(u"port_0", p_0) command_line.add_with_value(u"port_1", p_1) - command_line.add_with_value(u"traffic_directions", traffic_directions) + command_line.add_with_value( + u"traffic_directions", self.traffic_directions + ) command_line.add_if(u"async_start", async_call) - command_line.add_if(u"latency", latency) + command_line.add_if(u"latency", self.use_latency) command_line.add_if(u"force", Constants.TREX_SEND_FORCE) + # TODO: This is ugly. Handle parsing better. + self._start_time = time.monotonic() + self._rate = float(rate[:-3]) if u"pps" in rate else float(rate) stdout, _ = exec_cmd_no_error( self._node, command_line, timeout=int(duration) + 60, message=u"T-Rex STL runtime error" ) - self.traffic_directions = traffic_directions if async_call: # no result - self._start_time = time.time() - self._rate = float(rate[:-3]) if u"pps" in rate else float(rate) + self._target_duration = None + self._duration = None self._received = None self._sent = None self._loss = None @@ -828,14 +737,25 @@ class TrafficGenerator(AbstractMeasurer): break self._xstats = tuple(xstats) else: + self._target_duration = duration + self._duration = duration self._parse_traffic_results(stdout) - self._start_time = None - self._rate = None def send_traffic_on_tg( - self, duration, rate, frame_size, traffic_profile, warmup_time=5, - async_call=False, latency=False, traffic_directions=2, tx_port=0, - rx_port=1): + self, + duration, + rate, + frame_size, + traffic_profile, + async_call=False, + ppta=1, + traffic_directions=2, + transaction_duration=0.0, + transaction_scale=0, + transaction_type=u"packet", + duration_limit=0.0, + use_latency=False, + ): """Send traffic from all configured interfaces on TG. In async mode, xstats is stored internally, @@ -843,61 +763,102 @@ class TrafficGenerator(AbstractMeasurer): In both modes, stdout is returned, but _parse_traffic_results only works in sync output. - Note that bidirectional traffic also contains flows - transmitted from rx_port and received in tx_port. - But some tests use asymmetric traffic, so those arguments are relevant. - - Also note that traffic generator uses DPDK driver which might + Note that traffic generator uses DPDK driver which might reorder port numbers based on wiring and PCI numbering. This method handles that, so argument values are invariant, but you can see swapped valued in debug logs. + When transaction_scale is specified, the duration value is ignored + and the needed time is computed. For cases where this results in + to too long measurement (e.g. teardown trial with small rate), + duration_limit is applied (of non-zero), so the trial is stopped sooner. + + Bidirectional STL profiles are treated as transactions with two packets. + :param duration: Duration of test traffic generation in seconds. - :param rate: Traffic rate. - - T-Rex stateless mode => Offered load per interface in pps, - - T-Rex advanced stateful mode => multiplier of profile CPS. + :param rate: Traffic rate in transactions per second. :param frame_size: Frame size (L2) in Bytes. :param traffic_profile: Module name as a traffic profile identifier. See GPL/traffic_profiles/trex for implemented modules. - :param warmup_time: Warmup phase in seconds. :param async_call: Async mode. - :param latency: With latency measurement. + :param ppta: Packets per transaction, aggregated over directions. + Needed for udp_pps which does not have a good transaction counter, + so we need to compute expected number of packets. + Default: 1. :param traffic_directions: Traffic is bi- (2) or uni- (1) directional. Default: 2 - :param tx_port: Traffic generator transmit port for first flow. - Default: 0 - :param rx_port: Traffic generator receive port for first flow. - Default: 1 + :param transaction_duration: Total expected time to close transaction. + :param transaction_scale: Number of transactions to perform. + 0 (default) means unlimited. + :param transaction_type: An identifier specifying which counters + and formulas to use when computing attempted and failed + transactions. Default: "packet". + :param duration_limit: Zero or maximum limit for computed (or given) + duration. + :param use_latency: Whether to measure latency during the trial. + Default: False. :type duration: float :type rate: float :type frame_size: str :type traffic_profile: str - :type warmup_time: float :type async_call: bool - :type latency: bool + :type ppta: int :type traffic_directions: int - :type tx_port: int - :type rx_port: int + :type transaction_duration: float + :type transaction_scale: int + :type transaction_type: str + :type duration_limit: float + :type use_latency: bool + :returns: TG results. + :rtype: str + :raises ValueError: If TG traffic profile is not supported. + """ + self.set_rate_provider_defaults( + frame_size=frame_size, + traffic_profile=traffic_profile, + ppta=ppta, + traffic_directions=traffic_directions, + transaction_duration=transaction_duration, + transaction_scale=transaction_scale, + transaction_type=transaction_type, + duration_limit=duration_limit, + use_latency=use_latency, + ) + self._send_traffic_on_tg_internal(duration, rate, async_call) + + def _send_traffic_on_tg_internal(self, duration, rate, async_call=False): + """Send traffic from all configured interfaces on TG. + + This is an internal function, it assumes set_rate_provider_defaults + has been called to remember most values. + The reason why need to remember various values is that + the traffic can be asynchronous, and parsing needs those values. + The reason why this is is a separate function from the one + which calls set_rate_provider_defaults is that some search algorithms + need to specify their own values, and we do not want the measure call + to overwrite them with defaults. + + :param duration: Duration of test traffic generation in seconds. + :param rate: Traffic rate in transactions per second. + :param async_call: Async mode. + :type duration: float + :type rate: float + :type async_call: bool :returns: TG results. :rtype: str :raises ValueError: If TG traffic profile is not supported. """ subtype = check_subtype(self._node) if subtype == NodeSubTypeTG.TREX: - if self.traffic_profile != str(traffic_profile): - self.traffic_profile = str(traffic_profile) if u"trex-astf" in self.traffic_profile: self.trex_astf_start_remote_exec( - duration, int(rate), frame_size, self.traffic_profile, - async_call, latency, warmup_time, traffic_directions, - tx_port, rx_port + duration, float(rate), async_call ) elif u"trex-stl" in self.traffic_profile: unit_rate_str = str(rate) + u"pps" + # TODO: Suport transaction_scale et al? self.trex_stl_start_remote_exec( - duration, unit_rate_str, frame_size, self.traffic_profile, - async_call, latency, warmup_time, traffic_directions, - tx_port, rx_port + duration, unit_rate_str, async_call ) else: raise ValueError(u"Unsupported T-Rex traffic profile!") @@ -918,6 +879,8 @@ class TrafficGenerator(AbstractMeasurer): def fail_if_no_traffic_forwarded(self): """Fail if no traffic forwarded. + TODO: Check number of passed transactions instead. + :returns: nothing :raises Exception: If no traffic forwarded. """ @@ -952,74 +915,234 @@ class TrafficGenerator(AbstractMeasurer): f"Traffic loss {loss} above loss acceptance: {loss_acceptance}" ) - def set_rate_provider_defaults( - self, frame_size, traffic_profile, warmup_time=0.0, - traffic_directions=2, negative_loss=True, latency=False): - """Store values accessed by measure(). + def _parse_traffic_results(self, stdout): + """Parse stdout of scripts into fields of self. - :param frame_size: Frame size identifier or value [B]. - :param traffic_profile: Module name as a traffic profile identifier. - See GPL/traffic_profiles/trex for implemented modules. - :param warmup_time: Traffic duration before measurement starts [s]. - :param traffic_directions: Traffic is bi- (2) or uni- (1) directional. - Default: 2 - :param negative_loss: If false, negative loss is reported as zero loss. - :param latency: Whether to measure latency during the trial. - Default: False. - :type frame_size: str or int - :type traffic_profile: str - :type warmup_time: float - :type traffic_directions: int - :type negative_loss: bool - :type latency: bool + Block of code to reuse, by sync start, or stop after async. + + :param stdout: Text containing the standard output. + :type stdout: str """ - self.frame_size = frame_size - self.traffic_profile = str(traffic_profile) - self.warmup_time = float(warmup_time) - self.traffic_directions = traffic_directions - self.negative_loss = negative_loss - self.use_latency = latency + subtype = check_subtype(self._node) + if subtype == NodeSubTypeTG.TREX: + # Last line from console output + line = stdout.splitlines()[-1] + results = line.split(u";") + if results[-1] in (u" ", u""): + results.pop(-1) + self._result = dict() + for result in results: + key, value = result.split(u"=", maxsplit=1) + self._result[key.strip()] = value + logger.info(f"TrafficGen results:\n{self._result}") + self._received = int(self._result.get(u"total_received"), 0) + self._sent = int(self._result.get(u"total_sent", 0)) + self._loss = int(self._result.get(u"frame_loss", 0)) + self._approximated_duration = \ + self._result.get(u"approximated_duration", 0.0) + if u"manual" not in str(self._approximated_duration): + self._approximated_duration = float(self._approximated_duration) + self._latency = list() + self._latency.append(self._result.get(u"latency_stream_0(usec)")) + self._latency.append(self._result.get(u"latency_stream_1(usec)")) + if self._mode == TrexMode.ASTF: + self._l7_data = dict() + self._l7_data[u"client"] = dict() + self._l7_data[u"client"][u"sent"] = \ + int(self._result.get(u"client_sent", 0)) + self._l7_data[u"client"][u"received"] = \ + int(self._result.get(u"client_received", 0)) + self._l7_data[u"client"][u"active_flows"] = \ + int(self._result.get(u"client_active_flows", 0)) + self._l7_data[u"client"][u"established_flows"] = \ + int(self._result.get(u"client_established_flows", 0)) + self._l7_data[u"client"][u"traffic_duration"] = \ + float(self._result.get(u"client_traffic_duration", 0.0)) + self._l7_data[u"client"][u"err_rx_throttled"] = \ + int(self._result.get(u"client_err_rx_throttled", 0)) + self._l7_data[u"client"][u"err_c_nf_throttled"] = \ + int(self._result.get(u"client_err_nf_throttled", 0)) + self._l7_data[u"client"][u"err_flow_overflow"] = \ + int(self._result.get(u"client_err_flow_overflow", 0)) + self._l7_data[u"server"] = dict() + self._l7_data[u"server"][u"active_flows"] = \ + int(self._result.get(u"server_active_flows", 0)) + self._l7_data[u"server"][u"established_flows"] = \ + int(self._result.get(u"server_established_flows", 0)) + self._l7_data[u"server"][u"traffic_duration"] = \ + float(self._result.get(u"server_traffic_duration", 0.0)) + self._l7_data[u"server"][u"err_rx_throttled"] = \ + int(self._result.get(u"client_err_rx_throttled", 0)) + if u"udp" in self.traffic_profile: + self._l7_data[u"client"][u"udp"] = dict() + self._l7_data[u"client"][u"udp"][u"connects"] = \ + int(self._result.get(u"client_udp_connects", 0)) + self._l7_data[u"client"][u"udp"][u"closed_flows"] = \ + int(self._result.get(u"client_udp_closed", 0)) + self._l7_data[u"client"][u"udp"][u"tx_bytes"] = \ + int(self._result.get(u"client_udp_tx_bytes", 0)) + self._l7_data[u"client"][u"udp"][u"rx_bytes"] = \ + int(self._result.get(u"client_udp_rx_bytes", 0)) + self._l7_data[u"client"][u"udp"][u"tx_packets"] = \ + int(self._result.get(u"client_udp_tx_packets", 0)) + self._l7_data[u"client"][u"udp"][u"rx_packets"] = \ + int(self._result.get(u"client_udp_rx_packets", 0)) + self._l7_data[u"client"][u"udp"][u"keep_drops"] = \ + int(self._result.get(u"client_udp_keep_drops", 0)) + self._l7_data[u"client"][u"udp"][u"err_cwf"] = \ + int(self._result.get(u"client_err_cwf", 0)) + self._l7_data[u"server"][u"udp"] = dict() + self._l7_data[u"server"][u"udp"][u"accepted_flows"] = \ + int(self._result.get(u"server_udp_accepts", 0)) + self._l7_data[u"server"][u"udp"][u"closed_flows"] = \ + int(self._result.get(u"server_udp_closed", 0)) + self._l7_data[u"server"][u"udp"][u"tx_bytes"] = \ + int(self._result.get(u"server_udp_tx_bytes", 0)) + self._l7_data[u"server"][u"udp"][u"rx_bytes"] = \ + int(self._result.get(u"server_udp_rx_bytes", 0)) + self._l7_data[u"server"][u"udp"][u"tx_packets"] = \ + int(self._result.get(u"server_udp_tx_packets", 0)) + self._l7_data[u"server"][u"udp"][u"rx_packets"] = \ + int(self._result.get(u"server_udp_rx_packets", 0)) + elif u"tcp" in self.traffic_profile: + self._l7_data[u"client"][u"tcp"] = dict() + self._l7_data[u"client"][u"tcp"][u"initiated_flows"] = \ + int(self._result.get(u"client_tcp_connect_inits", 0)) + self._l7_data[u"client"][u"tcp"][u"connects"] = \ + int(self._result.get(u"client_tcp_connects", 0)) + self._l7_data[u"client"][u"tcp"][u"closed_flows"] = \ + int(self._result.get(u"client_tcp_closed", 0)) + self._l7_data[u"client"][u"tcp"][u"connattempt"] = \ + int(self._result.get(u"client_tcp_connattempt", 0)) + self._l7_data[u"client"][u"tcp"][u"tx_bytes"] = \ + int(self._result.get(u"client_tcp_tx_bytes", 0)) + self._l7_data[u"client"][u"tcp"][u"rx_bytes"] = \ + int(self._result.get(u"client_tcp_rx_bytes", 0)) + self._l7_data[u"server"][u"tcp"] = dict() + self._l7_data[u"server"][u"tcp"][u"accepted_flows"] = \ + int(self._result.get(u"server_tcp_accepts", 0)) + self._l7_data[u"server"][u"tcp"][u"connects"] = \ + int(self._result.get(u"server_tcp_connects", 0)) + self._l7_data[u"server"][u"tcp"][u"closed_flows"] = \ + int(self._result.get(u"server_tcp_closed", 0)) + self._l7_data[u"server"][u"tcp"][u"tx_bytes"] = \ + int(self._result.get(u"server_tcp_tx_bytes", 0)) + self._l7_data[u"server"][u"tcp"][u"rx_bytes"] = \ + int(self._result.get(u"server_tcp_rx_bytes", 0)) - def get_measurement_result(self, duration=None, transmit_rate=None): + def get_measurement_result(self): """Return the result of last measurement as ReceiveRateMeasurement. Separate function, as measurements can end either by time or by explicit call, this is the common block at the end. + The target_tr field of ReceiveRateMeasurement is in + transactions per second. Transmit count and loss count units + depend on the transaction type. Usually they are in transactions + per second, or aggregate packets per second. + TODO: Fail on running or already reported measurement. - :param duration: Measurement duration [s] if known beforehand. - For explicitly stopped measurement it is estimated. - :param transmit_rate: Target aggregate transmit rate [pps]. - If not given, computed assuming it was bidirectional. - :type duration: float or NoneType - :type transmit_rate: float or NoneType :returns: Structure containing the result of the measurement. :rtype: ReceiveRateMeasurement """ - if duration is None: - duration = time.time() - self._start_time - self._start_time = None - if transmit_rate is None: - transmit_rate = self._rate * self.traffic_directions - transmit_count = int(self.get_sent()) - loss_count = int(self.get_loss()) - if loss_count < 0 and not self.negative_loss: - loss_count = 0 + try: + # Client duration seems to include a setup period + # where TRex does not send any packets yet. + # Server duration does not include it. + server_data = self._l7_data[u"server"] + approximated_duration = float(server_data[u"traffic_duration"]) + except (KeyError, AttributeError, ValueError, TypeError): + approximated_duration = None + try: + if not approximated_duration: + approximated_duration = float(self._approximated_duration) + except ValueError: # "manual" + approximated_duration = None + if not approximated_duration: + if self._duration and self._duration > 0: + # Known recomputed or target duration. + approximated_duration = self._duration + else: + # It was an explicit stop. + if not self._stop_time: + raise RuntimeError(u"Unable to determine duration.") + approximated_duration = self._stop_time - self._start_time + target_duration = self._target_duration + if not target_duration: + target_duration = approximated_duration + transmit_rate = self._rate + if self.transaction_type == u"packet": + partial_attempt_count = self._sent + expected_attempt_count = self._sent + fail_count = self._loss + elif self.transaction_type == u"udp_cps": + if not self.transaction_scale: + raise RuntimeError(u"Add support for no-limit udp_cps.") + partial_attempt_count = self._l7_data[u"client"][u"sent"] + # We do not care whether TG is slow, it should have attempted all. + expected_attempt_count = self.transaction_scale + pass_count = self._l7_data[u"client"][u"received"] + fail_count = expected_attempt_count - pass_count + elif self.transaction_type == u"tcp_cps": + if not self.transaction_scale: + raise RuntimeError(u"Add support for no-limit tcp_cps.") + ctca = self._l7_data[u"client"][u"tcp"][u"connattempt"] + partial_attempt_count = ctca + # We do not care whether TG is slow, it should have attempted all. + expected_attempt_count = self.transaction_scale + # TODO: Is there a better packet-based counter? + pass_count = self._l7_data[u"server"][u"tcp"][u"connects"] + fail_count = expected_attempt_count - pass_count + elif self.transaction_type == u"udp_pps": + if not self.transaction_scale: + raise RuntimeError(u"Add support for no-limit udp_pps.") + partial_attempt_count = self._sent + expected_attempt_count = self.transaction_scale * self.ppta + fail_count = self._loss + (expected_attempt_count - self._sent) + elif self.transaction_type == u"tcp_pps": + if not self.transaction_scale: + raise RuntimeError(u"Add support for no-limit tcp_pps.") + partial_attempt_count = self._sent + expected_attempt_count = self.transaction_scale * self.ppta + # One loss-like scenario happens when TRex receives all packets + # on L2 level, but is not fast enough to process them all + # at L7 level, which leads to retransmissions. + # Those manifest as opackets larger than expected. + # A simple workaround is to add absolute difference. + # Probability of retransmissions exactly cancelling + # packets unsent due to duration stretching is quite low. + fail_count = self._loss + abs(expected_attempt_count - self._sent) + else: + raise RuntimeError(f"Unknown parsing {self.transaction_type!r}") + if fail_count < 0 and not self.negative_loss: + fail_count = 0 measurement = ReceiveRateMeasurement( - duration, transmit_rate, transmit_count, loss_count + duration=target_duration, + target_tr=transmit_rate, + transmit_count=expected_attempt_count, + loss_count=fail_count, + approximated_duration=approximated_duration, + partial_transmit_count=partial_attempt_count, ) measurement.latency = self.get_latency_int() return measurement def measure(self, duration, transmit_rate): - """Run trial measurement, parse and return aggregate results. + """Run trial measurement, parse and return results. - Aggregate means sum over traffic directions. + The input rate is for transactions. Stateles bidirectional traffic + is understood as sequence of (asynchronous) transactions, + two packets each. + + The result units depend on test type, generally + the count either transactions or packets (aggregated over directions). + + Optionally, this method sleeps if measurement finished before + the time specified as duration. :param duration: Trial duration [s]. - :param transmit_rate: Target aggregate transmit rate [pps] / Connections - per second (CPS) for UDP/TCP flows. + :param transmit_rate: Target rate in transactions per second. :type duration: float :type transmit_rate: float :returns: Structure containing the result of the measurement. @@ -1029,18 +1152,93 @@ class TrafficGenerator(AbstractMeasurer): :raises NotImplementedError: If TG is not supported. """ duration = float(duration) - # TG needs target Tr per stream, but reports aggregate Tx and Dx. - unit_rate_int = transmit_rate / float(self.traffic_directions) - self.send_traffic_on_tg( - duration, - unit_rate_int, - self.frame_size, - self.traffic_profile, - warmup_time=self.warmup_time, - latency=self.use_latency, - traffic_directions=self.traffic_directions + time_start = time.monotonic() + time_stop = time_start + duration + if self.resetter: + self.resetter() + self._send_traffic_on_tg_internal( + duration=duration, + rate=transmit_rate, + async_call=False, ) - return self.get_measurement_result(duration, transmit_rate) + result = self.get_measurement_result() + logger.debug(f"trial measurement result: {result!r}") + # In PLRsearch, computation needs the specified time to complete. + if self.sleep_till_duration: + sleeptime = time_stop - time.monotonic() + if sleeptime > 0.0: + # TODO: Sometimes we have time to do additional trials here, + # adapt PLRsearch to accept all the results. + time.sleep(sleeptime) + return result + + def set_rate_provider_defaults( + self, + frame_size, + traffic_profile, + ppta=1, + resetter=None, + traffic_directions=2, + transaction_duration=0.0, + transaction_scale=0, + transaction_type=u"packet", + duration_limit=0.0, + negative_loss=True, + sleep_till_duration=False, + use_latency=False, + ): + """Store values accessed by measure(). + + :param frame_size: Frame size identifier or value [B]. + :param traffic_profile: Module name as a traffic profile identifier. + See GPL/traffic_profiles/trex for implemented modules. + :param ppta: Packets per transaction, aggregated over directions. + Needed for udp_pps which does not have a good transaction counter, + so we need to compute expected number of packets. + Default: 1. + :param resetter: Callable to reset DUT state for repeated trials. + :param traffic_directions: Traffic from packet counting point of view + is bi- (2) or uni- (1) directional. + Default: 2 + :param transaction_duration: Total expected time to close transaction. + :param transaction_scale: Number of transactions to perform. + 0 (default) means unlimited. + :param transaction_type: An identifier specifying which counters + and formulas to use when computing attempted and failed + transactions. Default: "packet". + TODO: Does this also specify parsing for the measured duration? + :param duration_limit: Zero or maximum limit for computed (or given) + duration. + :param negative_loss: If false, negative loss is reported as zero loss. + :param sleep_till_duration: If true and measurement returned faster, + sleep until it matches duration. Needed for PLRsearch. + :param use_latency: Whether to measure latency during the trial. + Default: False. + :type frame_size: str or int + :type traffic_profile: str + :type ppta: int + :type resetter: Optional[Callable[[], None]] + :type traffic_directions: int + :type transaction_duration: float + :type transaction_scale: int + :type transaction_type: str + :type duration_limit: float + :type negative_loss: bool + :type sleep_till_duration: bool + :type use_latency: bool + """ + self.frame_size = frame_size + self.traffic_profile = str(traffic_profile) + self.resetter = resetter + self.ppta = ppta + self.traffic_directions = int(traffic_directions) + self.transaction_duration = float(transaction_duration) + self.transaction_scale = int(transaction_scale) + self.transaction_type = str(transaction_type) + self.duration_limit = float(duration_limit) + self.negative_loss = bool(negative_loss) + self.sleep_till_duration = bool(sleep_till_duration) + self.use_latency = bool(use_latency) class OptimizedSearch: @@ -1052,20 +1250,38 @@ class OptimizedSearch: @staticmethod def perform_optimized_ndrpdr_search( - frame_size, traffic_profile, minimum_transmit_rate, - maximum_transmit_rate, packet_loss_ratio=0.005, - final_relative_width=0.005, final_trial_duration=30.0, - initial_trial_duration=1.0, number_of_intermediate_phases=2, - timeout=720.0, doublings=1, traffic_directions=2, latency=False): + frame_size, + traffic_profile, + minimum_transmit_rate, + maximum_transmit_rate, + packet_loss_ratio=0.005, + final_relative_width=0.005, + final_trial_duration=30.0, + initial_trial_duration=1.0, + number_of_intermediate_phases=2, + timeout=720.0, + doublings=1, + ppta=1, + resetter=None, + traffic_directions=2, + transaction_duration=0.0, + transaction_scale=0, + transaction_type=u"packet", + use_latency=False, + ): """Setup initialized TG, perform optimized search, return intervals. + If transaction_scale is nonzero, all non-init trial durations + are set to 2.0 (as they do not affect the real trial duration) + and zero intermediate phases are used. + The initial phase still uses 1.0 seconds, to force remeasurement. + That makes initial phase act as a warmup. + :param frame_size: Frame size identifier or value [B]. :param traffic_profile: Module name as a traffic profile identifier. See GPL/traffic_profiles/trex for implemented modules. - :param minimum_transmit_rate: Minimal uni-directional - target transmit rate [pps]. - :param maximum_transmit_rate: Maximal uni-directional - target transmit rate [pps]. + :param minimum_transmit_rate: Minimal load in transactions per second. + :param maximum_transmit_rate: Maximal load in transactions per second. :param packet_loss_ratio: Fraction of packets lost, for PDR [1]. :param final_relative_width: Final lower bound transmit rate cannot be more distant that this multiple of upper bound [1]. @@ -1079,9 +1295,20 @@ class OptimizedSearch: :param doublings: How many doublings to do in external search step. Default 1 is suitable for fairly stable tests, less stable tests might get better overal duration with 2 or more. + :param ppta: Packets per transaction, aggregated over directions. + Needed for udp_pps which does not have a good transaction counter, + so we need to compute expected number of packets. + Default: 1. + :param resetter: Callable to reset DUT state for repeated trials. :param traffic_directions: Traffic is bi- (2) or uni- (1) directional. Default: 2 - :param latency: Whether to measure latency during the trial. + :param transaction_duration: Total expected time to close transaction. + :param transaction_scale: Number of transactions to perform. + 0 (default) means unlimited. + :param transaction_type: An identifier specifying which counters + and formulas to use when computing attempted and failed + transactions. Default: "packet". + :param use_latency: Whether to measure latency during the trial. Default: False. :type frame_size: str or int :type traffic_profile: str @@ -1094,53 +1321,85 @@ class OptimizedSearch: :type number_of_intermediate_phases: int :type timeout: float :type doublings: int + :type ppta: int + :type resetter: Optional[Callable[[], None]] :type traffic_directions: int - :type latency: bool + :type transaction_duration: float + :type transaction_scale: int + :type transaction_type: str + :type use_latency: bool :returns: Structure containing narrowed down NDR and PDR intervals and their measurements. :rtype: NdrPdrResult :raises RuntimeError: If total duration is larger than timeout. """ - minimum_transmit_rate *= traffic_directions - maximum_transmit_rate *= traffic_directions # we need instance of TrafficGenerator instantiated by Robot Framework # to be able to use trex_stl-*() tg_instance = BuiltIn().get_library_instance( u"resources.libraries.python.TrafficGenerator" ) + # Overrides for fixed transaction amount. + # TODO: Move to robot code? We have two call sites, so this saves space, + # even though this is surprising for log readers. + if transaction_scale: + initial_trial_duration = 1.0 + final_trial_duration = 2.0 + number_of_intermediate_phases = 0 + timeout = 3600.0 tg_instance.set_rate_provider_defaults( - frame_size, - traffic_profile, + frame_size=frame_size, + traffic_profile=traffic_profile, + sleep_till_duration=False, + ppta=ppta, + resetter=resetter, traffic_directions=traffic_directions, - latency=latency + transaction_duration=transaction_duration, + transaction_scale=transaction_scale, + transaction_type=transaction_type, + use_latency=use_latency, ) algorithm = MultipleLossRatioSearch( - measurer=tg_instance, final_trial_duration=final_trial_duration, + measurer=tg_instance, + final_trial_duration=final_trial_duration, final_relative_width=final_relative_width, number_of_intermediate_phases=number_of_intermediate_phases, - initial_trial_duration=initial_trial_duration, timeout=timeout, - doublings=doublings + initial_trial_duration=initial_trial_duration, + timeout=timeout, + doublings=doublings, ) result = algorithm.narrow_down_ndr_and_pdr( - minimum_transmit_rate, maximum_transmit_rate, packet_loss_ratio + min_rate=minimum_transmit_rate, + max_rate=maximum_transmit_rate, + packet_loss_ratio=packet_loss_ratio, ) return result @staticmethod def perform_soak_search( - frame_size, traffic_profile, minimum_transmit_rate, - maximum_transmit_rate, plr_target=1e-7, tdpt=0.1, - initial_count=50, timeout=1800.0, trace_enabled=False, - traffic_directions=2, latency=False): + frame_size, + traffic_profile, + minimum_transmit_rate, + maximum_transmit_rate, + plr_target=1e-7, + tdpt=0.1, + initial_count=50, + timeout=7200.0, + ppta=1, + resetter=None, + trace_enabled=False, + traffic_directions=2, + transaction_duration=0.0, + transaction_scale=0, + transaction_type=u"packet", + use_latency=False, + ): """Setup initialized TG, perform soak search, return avg and stdev. :param frame_size: Frame size identifier or value [B]. :param traffic_profile: Module name as a traffic profile identifier. See GPL/traffic_profiles/trex for implemented modules. - :param minimum_transmit_rate: Minimal uni-directional - target transmit rate [pps]. - :param maximum_transmit_rate: Maximal uni-directional - target transmit rate [pps]. + :param minimum_transmit_rate: Minimal load in transactions per second. + :param maximum_transmit_rate: Maximal load in transactions per second. :param plr_target: Fraction of packets lost to achieve [1]. :param tdpt: Trial duration per trial. The algorithm linearly increases trial duration with trial number, @@ -1150,10 +1409,24 @@ class OptimizedSearch: This is needed because initial "search" phase of integrator takes significant time even without any trial results. :param timeout: The search will stop after this overall time [s]. + :param ppta: Packets per transaction, aggregated over directions. + Needed for udp_pps which does not have a good transaction counter, + so we need to compute expected number of packets. + Default: 1. + :param resetter: Callable to reset DUT state for repeated trials. :param trace_enabled: True if trace enabled else False. + This is very verbose tracing on numeric computations, + do not use in production. + Default: False :param traffic_directions: Traffic is bi- (2) or uni- (1) directional. Default: 2 - :param latency: Whether to measure latency during the trial. + :param transaction_duration: Total expected time to close transaction. + :param transaction_scale: Number of transactions to perform. + 0 (default) means unlimited. + :param transaction_type: An identifier specifying which counters + and formulas to use when computing attempted and failed + transactions. Default: "packet". + :param use_latency: Whether to measure latency during the trial. Default: False. :type frame_size: str or int :type traffic_profile: str @@ -1162,29 +1435,48 @@ class OptimizedSearch: :type plr_target: float :type initial_count: int :type timeout: float + :type ppta: int + :type resetter: Optional[Callable[[], None]] :type trace_enabled: bool :type traffic_directions: int - :type latency: bool + :type transaction_duration: float + :type transaction_scale: int + :type transaction_type: str + :type use_latency: bool :returns: Average and stdev of estimated aggregate rate giving PLR. :rtype: 2-tuple of float """ - minimum_transmit_rate *= traffic_directions - maximum_transmit_rate *= traffic_directions tg_instance = BuiltIn().get_library_instance( u"resources.libraries.python.TrafficGenerator" ) + # Overrides for fixed transaction amount. + # TODO: Move to robot code? We have a single call site + # but MLRsearch has two and we want the two to be used similarly. + if transaction_scale: + timeout = 7200.0 tg_instance.set_rate_provider_defaults( - frame_size, - traffic_profile, - traffic_directions=traffic_directions, + frame_size=frame_size, + traffic_profile=traffic_profile, negative_loss=False, - latency=latency + sleep_till_duration=True, + ppta=ppta, + resetter=resetter, + traffic_directions=traffic_directions, + transaction_duration=transaction_duration, + transaction_scale=transaction_scale, + transaction_type=transaction_type, + use_latency=use_latency, ) algorithm = PLRsearch( - measurer=tg_instance, trial_duration_per_trial=tdpt, + measurer=tg_instance, + trial_duration_per_trial=tdpt, packet_loss_ratio_target=plr_target, - trial_number_offset=initial_count, timeout=timeout, - trace_enabled=trace_enabled + trial_number_offset=initial_count, + timeout=timeout, + trace_enabled=trace_enabled, + ) + result = algorithm.search( + min_rate=minimum_transmit_rate, + max_rate=maximum_transmit_rate, ) - result = algorithm.search(minimum_transmit_rate, maximum_transmit_rate) return result diff --git a/resources/libraries/python/autogen/Regenerator.py b/resources/libraries/python/autogen/Regenerator.py index e6474e566d..76501d6ad0 100644 --- a/resources/libraries/python/autogen/Regenerator.py +++ b/resources/libraries/python/autogen/Regenerator.py @@ -160,6 +160,9 @@ def add_default_testcases(testcase, iface, suite_id, file_out, tc_kwargs_list): emit = False if kwargs[u"frame_size"] not in MIN_FRAME_SIZE_VALUES: emit = False + if u"-cps-" in suite_id or u"-pps-" in suite_id: + if kwargs[u"frame_size"] not in MIN_FRAME_SIZE_VALUES: + emit = False if emit: file_out.write(testcase.generate(**kwargs)) |