1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Performance testing traffic generator library."""
16 from robot.api import logger
17 from robot.libraries.BuiltIn import BuiltIn
19 from .DropRateSearch import DropRateSearch
20 from .Constants import Constants
22 from .topology import NodeType
23 from .topology import NodeSubTypeTG
24 from .topology import Topology
25 from .MLRsearch.AbstractMeasurer import AbstractMeasurer
26 from .MLRsearch.MultipleLossRatioSearch import MultipleLossRatioSearch
27 from .MLRsearch.ReceiveRateMeasurement import ReceiveRateMeasurement
28 from .PLRsearch.PLRsearch import PLRsearch
30 __all__ = ['TGDropRateSearchImpl', 'TrafficGenerator', 'OptimizedSearch']
33 class TGDropRateSearchImpl(DropRateSearch):
34 """Drop Rate Search implementation."""
37 super(TGDropRateSearchImpl, self).__init__()
39 def measure_loss(self, rate, frame_size, loss_acceptance,
40 loss_acceptance_type, traffic_profile, skip_warmup=False):
41 """Runs the traffic and evaluate the measured results.
43 :param rate: Offered traffic load.
44 :param frame_size: Size of frame.
45 :param loss_acceptance: Permitted drop ratio or frames count.
46 :param loss_acceptance_type: Type of permitted loss.
47 :param traffic_profile: Module name as a traffic profile identifier.
48 See resources/traffic_profiles/trex for implemented modules.
49 :param skip_warmup: Start TRex without warmup traffic if true.
52 :type loss_acceptance: float
53 :type loss_acceptance_type: LossAcceptanceType
54 :type traffic_profile: str
55 :type skip_warmup: bool
56 :returns: Drop threshold exceeded? (True/False)
58 :raises NotImplementedError: If TG is not supported.
59 :raises RuntimeError: If TG is not specified.
61 # we need instance of TrafficGenerator instantiated by Robot Framework
62 # to be able to use trex_stl-*()
63 tg_instance = BuiltIn().get_library_instance(
64 'resources.libraries.python.TrafficGenerator')
66 if tg_instance.node['subtype'] is None:
67 raise RuntimeError('TG subtype not defined')
68 elif tg_instance.node['subtype'] == NodeSubTypeTG.TREX:
69 unit_rate = str(rate) + self.get_rate_type_str()
71 tg_instance.trex_stl_start_remote_exec(self.get_duration(),
72 unit_rate, frame_size,
76 tg_instance.trex_stl_start_remote_exec(self.get_duration(),
77 unit_rate, frame_size,
79 loss = tg_instance.get_loss()
80 sent = tg_instance.get_sent()
81 if self.loss_acceptance_type_is_percentage():
82 loss = (float(loss) / float(sent)) * 100
84 logger.trace("comparing: {} < {} {}".format(loss,
86 loss_acceptance_type))
87 if float(loss) > float(loss_acceptance):
92 raise NotImplementedError("TG subtype not supported")
94 def get_latency(self):
95 """Returns min/avg/max latency.
97 :returns: Latency stats.
100 tg_instance = BuiltIn().get_library_instance(
101 'resources.libraries.python.TrafficGenerator')
102 return tg_instance.get_latency_int()
105 class TrafficGenerator(AbstractMeasurer):
106 """Traffic Generator.
108 FIXME: Describe API."""
110 # TODO: Decrease friction between various search and rate provider APIs.
111 # TODO: Remove "trex" from lines which could work with other TGs.
113 # Use one instance of TrafficGenerator for all tests in test suite
114 ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
121 self._received = None
123 # T-REX interface order mapping
124 self._ifaces_reordered = False
125 # Parameters not given by measure().
126 self.frame_size = None
127 self.traffic_profile = None
128 self.warmup_time = None
134 :returns: Traffic generator node.
140 """Return number of lost packets.
142 :returns: Number of lost packets.
148 """Return number of sent packets.
150 :returns: Number of sent packets.
155 def get_received(self):
156 """Return number of received packets.
158 :returns: Number of received packets.
161 return self._received
163 def get_latency_int(self):
164 """Return rounded min/avg/max latency.
166 :returns: Latency stats.
171 def initialize_traffic_generator(
172 self, tg_node, tg_if1, tg_if2, tg_if1_adj_node, tg_if1_adj_if,
173 tg_if2_adj_node, tg_if2_adj_if, osi_layer, tg_if1_dst_mac=None,
174 tg_if2_dst_mac=None):
175 """TG initialization.
177 TODO: Document why do we need (and how do we use) _ifaces_reordered.
179 :param tg_node: Traffic generator node.
180 :param tg_if1: TG - name of first interface.
181 :param tg_if2: TG - name of second interface.
182 :param tg_if1_adj_node: TG if1 adjecent node.
183 :param tg_if1_adj_if: TG if1 adjecent interface.
184 :param tg_if2_adj_node: TG if2 adjecent node.
185 :param tg_if2_adj_if: TG if2 adjecent interface.
186 :param osi_layer: 'L2', 'L3' or 'L7' - OSI Layer testing type.
187 :param tg_if1_dst_mac: Interface 1 destination MAC address.
188 :param tg_if2_dst_mac: Interface 2 destination MAC address.
192 :type tg_if1_adj_node: dict
193 :type tg_if1_adj_if: str
194 :type tg_if2_adj_node: dict
195 :type tg_if2_adj_if: str
197 :type tg_if1_dst_mac: str
198 :type tg_if2_dst_mac: str
200 :raises RuntimeError: In case of issue during initialization.
202 if tg_node['type'] != NodeType.TG:
203 raise RuntimeError('Node type is not a TG')
206 if tg_node['subtype'] == NodeSubTypeTG.TREX:
210 (ret, _, _) = ssh.exec_command(
211 "sudo -E sh -c '{0}/resources/tools/trex/"
212 "trex_installer.sh {1}'".format(Constants.REMOTE_FW_DIR,
213 Constants.TREX_INSTALL_VERSION),
216 raise RuntimeError('TRex installation failed.')
218 if1_pci = Topology().get_interface_pci_addr(tg_node, tg_if1)
219 if2_pci = Topology().get_interface_pci_addr(tg_node, tg_if2)
220 if1_addr = Topology().get_interface_mac(tg_node, tg_if1)
221 if2_addr = Topology().get_interface_mac(tg_node, tg_if2)
223 if osi_layer == 'L2':
224 if1_adj_addr = if2_addr
225 if2_adj_addr = if1_addr
226 elif osi_layer == 'L3':
227 if1_adj_addr = Topology().get_interface_mac(tg_if1_adj_node,
229 if2_adj_addr = Topology().get_interface_mac(tg_if2_adj_node,
231 elif osi_layer == 'L7':
232 if1_addr = Topology().get_interface_ip4(tg_node, tg_if1)
233 if2_addr = Topology().get_interface_ip4(tg_node, tg_if2)
234 if1_adj_addr = Topology().get_interface_ip4(tg_if1_adj_node,
236 if2_adj_addr = Topology().get_interface_ip4(tg_if2_adj_node,
239 raise ValueError("Unknown Test Type")
241 # in case of switched environment we can override MAC addresses
242 if tg_if1_dst_mac is not None and tg_if2_dst_mac is not None:
243 if1_adj_addr = tg_if1_dst_mac
244 if2_adj_addr = tg_if2_dst_mac
246 if min(if1_pci, if2_pci) != if1_pci:
247 if1_pci, if2_pci = if2_pci, if1_pci
248 if1_addr, if2_addr = if2_addr, if1_addr
249 if1_adj_addr, if2_adj_addr = if2_adj_addr, if1_adj_addr
250 self._ifaces_reordered = True
252 if osi_layer == 'L2' or osi_layer == 'L3':
253 (ret, _, _) = ssh.exec_command(
254 "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
257 " interfaces: [\"{0}\",\"{1}\"]\n"
259 " - dest_mac: [{2}]\n"
261 " - dest_mac: [{4}]\n"
264 .format(if1_pci, if2_pci,
265 "0x"+if1_adj_addr.replace(":", ",0x"),
266 "0x"+if1_addr.replace(":", ",0x"),
267 "0x"+if2_adj_addr.replace(":", ",0x"),
268 "0x"+if2_addr.replace(":", ",0x")))
269 elif osi_layer == 'L7':
270 (ret, _, _) = ssh.exec_command(
271 "sudo sh -c 'cat << EOF > /etc/trex_cfg.yaml\n"
274 " interfaces: [\"{0}\",\"{1}\"]\n"
277 " default_gw: [{3}]\n"
279 " default_gw: [{5}]\n"
281 .format(if1_pci, if2_pci,
282 if1_addr, if1_adj_addr,
283 if2_addr, if2_adj_addr))
285 raise ValueError("Unknown Test Type")
287 raise RuntimeError('TRex config generation error')
289 for _ in range(0, 3):
290 # kill TRex only if it is already running
292 "sh -c 'pgrep t-rex && sudo pkill t-rex && sleep 3'")
295 (ret, _, _) = ssh.exec_command(
296 "sh -c 'cd {0}/scripts/ && sudo ./trex-cfg'"\
297 .format(Constants.TREX_INSTALL_DIR))
299 raise RuntimeError('trex-cfg failed')
302 if osi_layer == 'L2' or osi_layer == 'L3':
303 (ret, _, _) = ssh.exec_command(
304 "sh -c 'cd {0}/scripts/ && "
305 "sudo nohup ./t-rex-64 -i -c 7 --iom 0 > /tmp/trex.log "
306 "2>&1 &' > /dev/null"\
307 .format(Constants.TREX_INSTALL_DIR))
308 elif osi_layer == 'L7':
309 (ret, _, _) = ssh.exec_command(
310 "sh -c 'cd {0}/scripts/ && "
311 "sudo nohup ./t-rex-64 --astf -i -c 7 --iom 0 > "
312 "/tmp/trex.log 2>&1 &' > /dev/null"\
313 .format(Constants.TREX_INSTALL_DIR))
315 raise ValueError("Unknown Test Type")
317 ssh.exec_command("sh -c 'cat /tmp/trex.log'")
318 raise RuntimeError('t-rex-64 startup failed')
320 # get TRex server info
321 (ret, _, _) = ssh.exec_command(
323 "{0}/resources/tools/trex/trex_server_info.py'"\
324 .format(Constants.REMOTE_FW_DIR),
327 # If we get info TRex is running
329 # after max retries TRex is still not responding to API
330 # critical error occurred
331 raise RuntimeError('t-rex-64 startup failed')
334 def is_trex_running(node):
335 """Check if TRex is running using pidof.
337 :param node: Traffic generator node.
339 :returns: True if TRex is running otherwise False.
341 :raises RuntimeError: If node type is not a TG.
343 if node['type'] != NodeType.TG:
344 raise RuntimeError('Node type is not a TG')
348 ret, _, _ = ssh.exec_command_sudo("pidof t-rex")
349 return bool(int(ret) == 0)
352 def teardown_traffic_generator(node):
355 :param node: Traffic generator node.
358 :raises RuntimeError: If node type is not a TG,
359 or if TRex teardown fails.
361 if node['type'] != NodeType.TG:
362 raise RuntimeError('Node type is not a TG')
363 if node['subtype'] == NodeSubTypeTG.TREX:
366 (ret, _, _) = ssh.exec_command(
367 "sh -c 'sudo pkill t-rex && sleep 3'")
369 raise RuntimeError('pkill t-rex failed')
372 def trex_stl_stop_remote_exec(node):
373 """Execute script on remote node over ssh to stop running traffic.
375 :param node: TRex generator node.
378 :raises RuntimeError: If stop traffic script fails.
383 (ret, _, _) = ssh.exec_command(
384 "sh -c '{}/resources/tools/trex/"
385 "trex_stateless_stop.py'".format(Constants.REMOTE_FW_DIR))
388 raise RuntimeError('TRex stateless runtime error')
390 def trex_stl_start_remote_exec(
391 self, duration, rate, frame_size, traffic_profile, async_call=False,
392 latency=True, warmup_time=5.0, unidirection=False, tx_port=0,
394 """Execute script on remote node over ssh to start traffic.
396 :param duration: Time expresed in seconds for how long to send traffic.
397 :param rate: Traffic rate expressed with units (pps, %)
398 :param frame_size: L2 frame size to send (without padding and IPG).
399 :param traffic_profile: Module name as a traffic profile identifier.
400 See resources/traffic_profiles/trex for implemented modules.
401 :param async_call: If enabled then don't wait for all incomming trafic.
402 :param latency: With latency measurement.
403 :param warmup_time: Warmup time period.
404 :param unidirection: Traffic is unidirectional. Default: False
405 :param tx_port: Traffic generator transmit port for first flow.
407 :param rx_port: Traffic generator receive port for first flow.
409 :type duration: float
411 :type frame_size: str
412 :type traffic_profile: str
413 :type async_call: bool
415 :type warmup_time: float
416 :type unidirection: bool
419 :raises RuntimeError: In case of TG driver issue.
422 ssh.connect(self._node)
423 reorder = self._ifaces_reordered # Just to make the next line fit.
424 p_0, p_1 = (rx_port, tx_port) if reorder else (tx_port, rx_port)
425 # Values from Robot can introduce type unicode,
426 # we need to encode them, so that repr() does not lead with 'u'.
427 if isinstance(rate, unicode):
428 rate = rate.encode("utf-8")
429 if isinstance(duration, unicode):
430 duration = duration.encode("utf-8")
431 if isinstance(warmup_time, unicode):
432 warmup_time = warmup_time.encode("utf-8")
434 "sh -c '{tool}/resources/tools/trex/trex_stateless_profile.py"
435 " --profile {prof}/resources/traffic_profiles/trex/{traffic}.py"
436 " --duration {duration!r} --frame_size {frame_size} --rate {rate!r}"
437 " --warmup_time {warmup!r} --port_0 {p_0} --port_1 {p_1}").format(
438 tool=Constants.REMOTE_FW_DIR, prof=Constants.REMOTE_FW_DIR,
439 traffic=traffic_profile, duration=duration,
440 frame_size=frame_size, rate=rate, warmup=warmup_time, p_0=p_0,
443 command += " --async"
445 command += " --latency"
447 command += " --unidirection"
450 (ret, stdout, _) = ssh.exec_command(
451 command, timeout=float(duration) + 60)
454 raise RuntimeError('TRex stateless runtime error')
457 self._received = None
462 # last line from console output
463 line = stdout.splitlines()[-1]
465 logger.info('TrafficGen result: {0}'.format(self._result))
466 self._received = self._result.split(', ')[1].split('=')[1]
467 self._sent = self._result.split(', ')[2].split('=')[1]
468 self._loss = self._result.split(', ')[3].split('=')[1]
470 self._latency.append(self._result.split(', ')[4].split('=')[1])
471 self._latency.append(self._result.split(', ')[5].split('=')[1])
473 def stop_traffic_on_tg(self):
474 """Stop all traffic on TG.
477 :raises RuntimeError: If TG is not set.
479 if self._node is None:
480 raise RuntimeError("TG is not set")
481 if self._node['subtype'] == NodeSubTypeTG.TREX:
482 self.trex_stl_stop_remote_exec(self._node)
484 def send_traffic_on_tg(
485 self, duration, rate, frame_size, traffic_profile, warmup_time=5,
486 async_call=False, latency=True, unidirection=False, tx_port=0,
488 """Send traffic from all configured interfaces on TG.
490 Note that bidirectional traffic also contains flows
491 transmitted from rx_port and received in tx_port.
492 But some tests use asymmetric traffic, so those arguments are relevant.
494 Also note that traffic generator uses DPDK driver which might
495 reorder port numbers based on wiring and PCI numbering.
496 This method handles that, so argument values are invariant,
497 but you can see swapped valued in debug logs.
499 TODO: Is it better to have less descriptive argument names
500 just to make them less probable to be viewed as misleading or confusing?
501 See https://gerrit.fd.io/r/#/c/17625/11/resources/libraries/python\
502 /TrafficGenerator.py@406
504 :param duration: Duration of test traffic generation in seconds.
505 :param rate: Offered load per interface (e.g. 1%, 3gbps, 4mpps, ...).
506 :param frame_size: Frame size (L2) in Bytes.
507 :param traffic_profile: Module name as a traffic profile identifier.
508 See resources/traffic_profiles/trex for implemented modules.
509 :param warmup_time: Warmup phase in seconds.
510 :param async_call: Async mode.
511 :param latency: With latency measurement.
512 :param unidirection: Traffic is unidirectional. Default: False
513 :param tx_port: Traffic generator transmit port for first flow.
515 :param rx_port: Traffic generator receive port for first flow.
519 :type frame_size: str
520 :type traffic_profile: str
521 :type warmup_time: float
522 :type async_call: bool
524 :type unidirection: bool
529 :raises RuntimeError: If TG is not set, or if node is not TG,
530 or if subtype is not specified.
531 :raises NotImplementedError: If TG is not supported.
536 raise RuntimeError("TG is not set")
538 if node['type'] != NodeType.TG:
539 raise RuntimeError('Node type is not a TG')
541 if node['subtype'] is None:
542 raise RuntimeError('TG subtype not defined')
543 elif node['subtype'] == NodeSubTypeTG.TREX:
544 self.trex_stl_start_remote_exec(
545 duration, rate, frame_size, traffic_profile, async_call,
546 latency, warmup_time, unidirection, tx_port, rx_port)
548 raise NotImplementedError("TG subtype not supported")
552 def no_traffic_loss_occurred(self):
553 """Fail if loss occurred in traffic run.
556 :raises Exception: If loss occured.
558 if self._loss is None:
559 raise RuntimeError('The traffic generation has not been issued')
560 if self._loss != '0':
561 raise RuntimeError('Traffic loss occurred: {0}'.format(self._loss))
563 def fail_if_no_traffic_forwarded(self):
564 """Fail if no traffic forwarded.
567 :raises Exception: If no traffic forwarded.
569 if self._received is None:
570 raise RuntimeError('The traffic generation has not been issued')
571 if self._received == '0':
572 raise RuntimeError('No traffic forwarded')
574 def partial_traffic_loss_accepted(self, loss_acceptance,
575 loss_acceptance_type):
576 """Fail if loss is higher then accepted in traffic run.
578 :param loss_acceptance: Permitted drop ratio or frames count.
579 :param loss_acceptance_type: Type of permitted loss.
580 :type loss_acceptance: float
581 :type loss_acceptance_type: LossAcceptanceType
583 :raises Exception: If loss is above acceptance criteria.
585 if self._loss is None:
586 raise Exception('The traffic generation has not been issued')
588 if loss_acceptance_type == 'percentage':
589 loss = (float(self._loss) / float(self._sent)) * 100
590 elif loss_acceptance_type == 'frames':
591 loss = float(self._loss)
593 raise Exception('Loss acceptance type not supported')
595 if loss > float(loss_acceptance):
596 raise Exception("Traffic loss {} above loss acceptance: {}".format(
597 loss, loss_acceptance))
599 def set_rate_provider_defaults(self, frame_size, traffic_profile,
601 """Store values accessed by measure().
603 :param frame_size: Frame size identifier or value [B].
604 :param traffic_profile: Module name as a traffic profile identifier.
605 See resources/traffic_profiles/trex for implemented modules.
606 :param warmup_time: Traffic duration before measurement starts [s].
607 :type frame_size: str or int
608 :type traffic_profile: str
609 :type warmup_time: float
611 self.frame_size = frame_size
612 self.traffic_profile = str(traffic_profile)
613 self.warmup_time = float(warmup_time)
615 def measure(self, duration, transmit_rate):
616 """Run bi-directional measurement, parse and return results.
618 :param duration: Trial duration [s].
619 :param transmit_rate: Target bidirectional transmit rate [pps].
620 :type duration: float
621 :type transmit_rate: float
622 :returns: Structure containing the result of the measurement.
623 :rtype: ReceiveRateMeasurement
624 :raises RuntimeError: If TG is not set, or if node is not TG,
625 or if subtype is not specified.
626 :raises NotImplementedError: If TG is not supported.
628 duration = float(duration)
629 transmit_rate = float(transmit_rate)
630 # Trex needs target Tr per stream, but reports aggregate Tx and Dx.
631 unit_rate = str(transmit_rate / 2.0) + "pps"
632 self.send_traffic_on_tg(
633 duration, unit_rate, self.frame_size, self.traffic_profile,
634 warmup_time=self.warmup_time, latency=True)
635 transmit_count = int(self.get_sent())
636 loss_count = int(self.get_loss())
637 measurement = ReceiveRateMeasurement(
638 duration, transmit_rate, transmit_count, loss_count)
639 measurement.latency = self.get_latency_int()
643 class OptimizedSearch(object):
644 """Class to be imported as Robot Library, containing a single keyword."""
647 def perform_optimized_ndrpdr_search(
648 frame_size, traffic_profile, minimum_transmit_rate,
649 maximum_transmit_rate, packet_loss_ratio=0.005,
650 final_relative_width=0.005, final_trial_duration=30.0,
651 initial_trial_duration=1.0, number_of_intermediate_phases=2,
652 timeout=720.0, doublings=1):
653 """Setup initialized TG, perform optimized search, return intervals.
655 :param frame_size: Frame size identifier or value [B].
656 :param traffic_profile: Module name as a traffic profile identifier.
657 See resources/traffic_profiles/trex for implemented modules.
658 :param minimum_transmit_rate: Minimal bidirectional
659 target transmit rate [pps].
660 :param maximum_transmit_rate: Maximal bidirectional
661 target transmit rate [pps].
662 :param packet_loss_ratio: Fraction of packets lost, for PDR [1].
663 :param final_relative_width: Final lower bound transmit rate
664 cannot be more distant that this multiple of upper bound [1].
665 :param final_trial_duration: Trial duration for the final phase [s].
666 :param initial_trial_duration: Trial duration for the initial phase
667 and also for the first intermediate phase [s].
668 :param number_of_intermediate_phases: Number of intermediate phases
669 to perform before the final phase [1].
670 :param timeout: The search will fail itself when not finished
671 before this overall time [s].
672 :param doublings: How many doublings to do in external search step.
673 Default 1 is suitable for fairly stable tests,
674 less stable tests might get better overal duration with 2 or more.
675 :type frame_size: str or int
676 :type traffic_profile: str
677 :type minimum_transmit_rate: float
678 :type maximum_transmit_rate: float
679 :type packet_loss_ratio: float
680 :type final_relative_width: float
681 :type final_trial_duration: float
682 :type initial_trial_duration: float
683 :type number_of_intermediate_phases: int
686 :returns: Structure containing narrowed down NDR and PDR intervals
687 and their measurements.
689 :raises RuntimeError: If total duration is larger than timeout.
691 # we need instance of TrafficGenerator instantiated by Robot Framework
692 # to be able to use trex_stl-*()
693 tg_instance = BuiltIn().get_library_instance(
694 'resources.libraries.python.TrafficGenerator')
695 tg_instance.set_rate_provider_defaults(frame_size, traffic_profile)
696 algorithm = MultipleLossRatioSearch(
697 measurer=tg_instance, final_trial_duration=final_trial_duration,
698 final_relative_width=final_relative_width,
699 number_of_intermediate_phases=number_of_intermediate_phases,
700 initial_trial_duration=initial_trial_duration, timeout=timeout,
702 result = algorithm.narrow_down_ndr_and_pdr(
703 minimum_transmit_rate, maximum_transmit_rate, packet_loss_ratio)
707 def perform_soak_search(
708 frame_size, traffic_profile, minimum_transmit_rate,
709 maximum_transmit_rate, plr_target=1e-7, tdpt=0.1,
710 initial_count=50, timeout=1800.0, trace_enabled=False):
711 """Setup initialized TG, perform soak search, return avg and stdev.
713 :param frame_size: Frame size identifier or value [B].
714 :param traffic_profile: Module name as a traffic profile identifier.
715 See resources/traffic_profiles/trex for implemented modules.
716 :param minimum_transmit_rate: Minimal bidirectional
717 target transmit rate [pps].
718 :param maximum_transmit_rate: Maximal bidirectional
719 target transmit rate [pps].
720 :param plr_target: Fraction of packets lost to achieve [1].
721 :param tdpt: Trial duration per trial.
722 The algorithm linearly increases trial duration with trial number,
723 this is the increment between succesive trials, in seconds.
724 :param initial_count: Offset to apply before the first trial.
725 For example initial_count=50 makes first trial to be 51*tdpt long.
726 This is needed because initial "search" phase of integrator
727 takes significant time even without any trial results.
728 :param timeout: The search will stop after this overall time [s].
729 :type frame_size: str or int
730 :type traffic_profile: str
731 :type minimum_transmit_rate: float
732 :type maximum_transmit_rate: float
733 :type plr_target: float
734 :type initial_count: int
736 :returns: Average and stdev of estimated bidirectional rate giving PLR.
737 :rtype: 2-tuple of float
739 tg_instance = BuiltIn().get_library_instance(
740 'resources.libraries.python.TrafficGenerator')
741 tg_instance.set_rate_provider_defaults(frame_size, traffic_profile)
742 algorithm = PLRsearch(
743 measurer=tg_instance, trial_duration_per_trial=tdpt,
744 packet_loss_ratio_target=plr_target,
745 trial_number_offset=initial_count, timeout=timeout,
746 trace_enabled=trace_enabled)
747 result = algorithm.search(minimum_transmit_rate, maximum_transmit_rate)