aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/TrafficGenerator.py
diff options
context:
space:
mode:
authorVratko Polak <vrpolak@cisco.com>2018-11-30 14:49:10 +0100
committerTibor Frank <tifrank@cisco.com>2019-01-29 08:06:17 +0000
commit27a56cad3679e4decbcca90acfb22c55a22153e0 (patch)
tree994a0b7fed07a33e5c2093393909d19e3ad71e2a /resources/libraries/python/TrafficGenerator.py
parent15648d7c4f98cc90a406519362b0d7f548893859 (diff)
PLRsearch: Initial implementation and suites
Missing bits: - Add up-to-date .rst document (in child Change). - Prepare for releasing to PyPI.org (in child Change): -- Either copy dependencies from MLRsearch, or list in requirements. -- Perhaps move common dependencies to separate package for both search to depend on. -- All the other metadata stuff. Jira: CSIT-1276 Change-Id: I277efdb63dbb90b30e11f4e30a82e2130ac8efc3 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python/TrafficGenerator.py')
-rw-r--r--resources/libraries/python/TrafficGenerator.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py
index b5558e663d..60915117fc 100644
--- a/resources/libraries/python/TrafficGenerator.py
+++ b/resources/libraries/python/TrafficGenerator.py
@@ -25,6 +25,7 @@ from .topology import Topology
from .MLRsearch.AbstractMeasurer import AbstractMeasurer
from .MLRsearch.MultipleLossRatioSearch import MultipleLossRatioSearch
from .MLRsearch.ReceiveRateMeasurement import ReceiveRateMeasurement
+from .PLRsearch.PLRsearch import PLRsearch
__all__ = ['TGDropRateSearchImpl', 'TrafficGenerator', 'OptimizedSearch']
@@ -757,3 +758,46 @@ class OptimizedSearch(object):
result = algorithm.narrow_down_ndr_and_pdr(
minimum_transmit_rate, maximum_transmit_rate, packet_loss_ratio)
return result
+
+ @staticmethod
+ def perform_soak_search(
+ frame_size, traffic_type, minimum_transmit_rate,
+ maximum_transmit_rate, plr_target=1e-7, tdpt=0.2,
+ initial_count=50, timeout=1800.0):
+ """Setup initialized TG, perform soak search, return avg and stdev.
+
+ :param frame_size: Frame size identifier or value [B].
+ :param traffic_type: Module name as a traffic type identifier.
+ See resources/traffic_profiles/trex for implemented modules.
+ :param minimum_transmit_rate: Minimal bidirectional
+ target transmit rate [pps].
+ :param maximum_transmit_rate: Maximal bidirectional
+ target transmit rate [pps].
+ :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,
+ this is the increment between succesive trials, in seconds.
+ :param initial_count: Offset to apply before the first trial.
+ For example initial_count=50 makes first trial to be 51*tdpt long.
+ 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].
+ :type frame_size: str or int
+ :type traffic_type: str
+ :type minimum_transmit_rate: float
+ :type maximum_transmit_rate: float
+ :type plr_target: float
+ :type initial_count: int
+ :type timeout: float
+ :returns: Average and stdev of estimated bidirectional rate giving PLR.
+ :rtype: 2-tuple of float
+ """
+ tg_instance = BuiltIn().get_library_instance(
+ 'resources.libraries.python.TrafficGenerator')
+ tg_instance.set_rate_provider_defaults(frame_size, traffic_type)
+ algorithm = PLRsearch(
+ measurer=tg_instance, trial_duration_per_trial=tdpt,
+ packet_loss_ratio_target=plr_target,
+ trial_number_offset=initial_count, timeout=timeout)
+ result = algorithm.search(minimum_transmit_rate, maximum_transmit_rate)
+ return result