diff options
author | Vratko Polak <vrpolak@cisco.com> | 2019-09-06 10:14:45 +0200 |
---|---|---|
committer | Vratko Polak <vrpolak@cisco.com> | 2019-09-12 18:14:55 +0200 |
commit | 4fa06bcfa9ef951b9062ddfc85ce58dcb742bcf7 (patch) | |
tree | 0bf7a98cf1cbfe808c97984aefdbec58323a7c1c /resources/libraries/python | |
parent | 84bbb1ef886173f8e5a2234681e135ea524c3b99 (diff) |
Support unidirection in all searches
+ Rename bool unidirection to int traffic_directions.
+ Rename "untagged" to "initial" for bandwidth calculation.
+ Fix latency measurement for unidirectional traffic.
+ Remove duplicate colon in soak test message.
+ Edit PAL to accept both forms.
+ Fix minor documentation issues.
Change-Id: I6c76f2dc090ae493f2fbd7e9ccd45229d2306dea
Signed-off-by: Vratko Polak <vrpolak@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r-- | resources/libraries/python/TrafficGenerator.py | 83 |
1 files changed, 54 insertions, 29 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 2e59459773..f6020299c5 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -428,7 +428,7 @@ class TrafficGenerator(AbstractMeasurer): def trex_stl_start_remote_exec( self, duration, rate, frame_size, traffic_profile, async_call=False, - latency=True, warmup_time=5.0, unidirection=False, tx_port=0, + latency=True, warmup_time=5.0, traffic_directions=2, tx_port=0, rx_port=1): """Execute script on remote node over ssh to start traffic. @@ -440,7 +440,8 @@ class TrafficGenerator(AbstractMeasurer): :param async_call: If enabled then don't wait for all incomming trafic. :param latency: With latency measurement. :param warmup_time: Warmup time period. - :param unidirection: Traffic is unidirectional. Default: False + :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. @@ -452,7 +453,7 @@ class TrafficGenerator(AbstractMeasurer): :type async_call: bool :type latency: bool :type warmup_time: float - :type unidirection: bool + :type traffic_directions: int :type tx_port: int :type rx_port: int :raises RuntimeError: In case of TG driver issue. @@ -472,17 +473,16 @@ class TrafficGenerator(AbstractMeasurer): "sh -c '{tool}/resources/tools/trex/trex_stateless_profile.py" " --profile {prof}/resources/traffic_profiles/trex/{traffic}.py" " --duration {duration!r} --frame_size {frame_size} --rate {rate!r}" - " --warmup_time {warmup!r} --port_0 {p_0} --port_1 {p_1}").format( + " --warmup_time {warmup!r} --port_0 {p_0} --port_1 {p_1}" + " --traffic_directions {dirs}").format( tool=Constants.REMOTE_FW_DIR, prof=Constants.REMOTE_FW_DIR, traffic=traffic_profile, duration=duration, frame_size=frame_size, rate=rate, warmup=warmup_time, p_0=p_0, - p_1=p_1) + p_1=p_1, dirs=traffic_directions) if async_call: command += " --async" if latency: command += " --latency" - if unidirection: - command += " --unidirection" command += "'" stdout, _ = exec_cmd_no_error( @@ -514,7 +514,7 @@ class TrafficGenerator(AbstractMeasurer): def send_traffic_on_tg( self, duration, rate, frame_size, traffic_profile, warmup_time=5, - async_call=False, latency=True, unidirection=False, tx_port=0, + async_call=False, latency=True, traffic_directions=2, tx_port=0, rx_port=1): """Send traffic from all configured interfaces on TG. @@ -540,7 +540,8 @@ class TrafficGenerator(AbstractMeasurer): :param warmup_time: Warmup phase in seconds. :param async_call: Async mode. :param latency: With latency measurement. - :param unidirection: Traffic is unidirectional. Default: False + :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. @@ -552,7 +553,7 @@ class TrafficGenerator(AbstractMeasurer): :type warmup_time: float :type async_call: bool :type latency: bool - :type unidirection: bool + :type traffic_directions: int :type tx_port: int :type rx_port: int :returns: TG output. @@ -565,7 +566,7 @@ class TrafficGenerator(AbstractMeasurer): if subtype == NodeSubTypeTG.TREX: self.trex_stl_start_remote_exec( duration, rate, frame_size, traffic_profile, async_call, - latency, warmup_time, unidirection, tx_port, rx_port) + latency, warmup_time, traffic_directions, tx_port, rx_port) return self._result @@ -617,20 +618,24 @@ class TrafficGenerator(AbstractMeasurer): loss, loss_acceptance)) def set_rate_provider_defaults(self, frame_size, traffic_profile, - warmup_time=0.0): + warmup_time=0.0, traffic_directions=2): """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 resources/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 :type frame_size: str or int :type traffic_profile: str :type warmup_time: float + :type traffic_directions: int """ self.frame_size = frame_size self.traffic_profile = str(traffic_profile) self.warmup_time = float(warmup_time) + self.traffic_directions = traffic_directions def get_measurement_result(self, duration=None, transmit_rate=None): """Return the result of last measurement as ReceiveRateMeasurement. @@ -653,8 +658,7 @@ class TrafficGenerator(AbstractMeasurer): duration = time.time() - self._start_time self._start_time = None if transmit_rate is None: - # Assuming bi-directional traffic here. - transmit_rate = self._rate * 2.0 + transmit_rate = self._rate * (1.0 if self.uinidirection else 2.0) transmit_count = int(self.get_sent()) loss_count = int(self.get_loss()) measurement = ReceiveRateMeasurement( @@ -663,10 +667,12 @@ class TrafficGenerator(AbstractMeasurer): return measurement def measure(self, duration, transmit_rate): - """Run bi-directional measurement, parse and return results. + """Run trial measurement, parse and return aggregate results. + + Aggregate means sum over traffic directions. :param duration: Trial duration [s]. - :param transmit_rate: Target bidirectional transmit rate [pps]. + :param transmit_rate: Target aggregate transmit rate [pps]. :type duration: float :type transmit_rate: float :returns: Structure containing the result of the measurement. @@ -678,15 +684,21 @@ class TrafficGenerator(AbstractMeasurer): duration = float(duration) transmit_rate = float(transmit_rate) # TG needs target Tr per stream, but reports aggregate Tx and Dx. - unit_rate = str(transmit_rate / 2.0) + "pps" + unit_rate_int = transmit_rate / float(self.traffic_directions) + unit_rate_str = str(unit_rate_int) + "pps" self.send_traffic_on_tg( - duration, unit_rate, self.frame_size, self.traffic_profile, - warmup_time=self.warmup_time, latency=True) + duration, unit_rate_str, self.frame_size, self.traffic_profile, + warmup_time=self.warmup_time, latency=True, + traffic_directions=self.traffic_directions) return self.get_measurement_result(duration, transmit_rate) class OptimizedSearch(object): - """Class to be imported as Robot Library, containing a single keyword.""" + """Class to be imported as Robot Library, containing search keywords. + + Aside of setting up measurer and forwarding arguments, + the main business is to translate min/max rate from unidir to aggregate. + """ @staticmethod def perform_optimized_ndrpdr_search( @@ -694,15 +706,15 @@ class OptimizedSearch(object): 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): + timeout=720.0, doublings=1, traffic_directions=2): """Setup initialized TG, perform optimized search, return intervals. :param frame_size: Frame size identifier or value [B]. :param traffic_profile: Module name as a traffic profile identifier. See resources/traffic_profiles/trex for implemented modules. - :param minimum_transmit_rate: Minimal bidirectional + :param minimum_transmit_rate: Minimal uni-directional target transmit rate [pps]. - :param maximum_transmit_rate: Maximal bidirectional + :param maximum_transmit_rate: Maximal uni-directional target transmit rate [pps]. :param packet_loss_ratio: Fraction of packets lost, for PDR [1]. :param final_relative_width: Final lower bound transmit rate @@ -717,6 +729,8 @@ class OptimizedSearch(object): :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 traffic_directions: Traffic is bi- (2) or uni- (1) directional. + Default: 2 :type frame_size: str or int :type traffic_profile: str :type minimum_transmit_rate: float @@ -728,16 +742,20 @@ class OptimizedSearch(object): :type number_of_intermediate_phases: int :type timeout: float :type doublings: int + :type traffic_directions: int :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( 'resources.libraries.python.TrafficGenerator') - tg_instance.set_rate_provider_defaults(frame_size, traffic_profile) + tg_instance.set_rate_provider_defaults( + frame_size, traffic_profile, traffic_directions=traffic_directions) algorithm = MultipleLossRatioSearch( measurer=tg_instance, final_trial_duration=final_trial_duration, final_relative_width=final_relative_width, @@ -752,15 +770,16 @@ class OptimizedSearch(object): 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): + initial_count=50, timeout=1800.0, trace_enabled=False, + traffic_directions=2): """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 resources/traffic_profiles/trex for implemented modules. - :param minimum_transmit_rate: Minimal bidirectional + :param minimum_transmit_rate: Minimal uni-directional target transmit rate [pps]. - :param maximum_transmit_rate: Maximal bidirectional + :param maximum_transmit_rate: Maximal uni-directional target transmit rate [pps]. :param plr_target: Fraction of packets lost to achieve [1]. :param tdpt: Trial duration per trial. @@ -771,6 +790,8 @@ class OptimizedSearch(object): 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 traffic_directions: Traffic is bi- (2) or uni- (1) directional. + Default: 2 :type frame_size: str or int :type traffic_profile: str :type minimum_transmit_rate: float @@ -778,12 +799,16 @@ class OptimizedSearch(object): :type plr_target: float :type initial_count: int :type timeout: float - :returns: Average and stdev of estimated bidirectional rate giving PLR. + :type traffic_directions: int + :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( 'resources.libraries.python.TrafficGenerator') - tg_instance.set_rate_provider_defaults(frame_size, traffic_profile) + tg_instance.set_rate_provider_defaults( + frame_size, traffic_profile, traffic_directions=traffic_directions) algorithm = PLRsearch( measurer=tg_instance, trial_duration_per_trial=tdpt, packet_loss_ratio_target=plr_target, |