+ :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.
+ :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 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)
+ if not isinstance(duration, (float, int)):
+ duration = float(duration)
+ if not isinstance(warmup_time, (float, int)):
+ warmup_time = float(warmup_time)
+
+ command_line = OptionString().add(u"python3")
+ dirname = f"{Constants.REMOTE_FW_DIR}/GPL/tools/trex"
+ command_line.add(f"'{dirname}/trex_astf_profile.py'")
+ 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'"
+ )
+ 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"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_if(u"async_start", async_call)
+ command_line.add_if(u"latency", latency)
+ command_line.add_if(u"force", Constants.TREX_SEND_FORCE)
+
+ stdout, _ = exec_cmd_no_error(
+ self._node, command_line,
+ timeout=int(duration) + 600 if u"tcp" in self.traffic_profile
+ else 60,
+ 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._received = None
+ self._sent = None
+ self._loss = None
+ self._latency = None
+ xstats = [None, None]
+ 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"server"] = dict()
+ self._l7_data[u"server"][u"active_flows"] = None
+ self._l7_data[u"server"][u"established_flows"] = 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"closed_flows"] = 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"closed_flows"] = 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"closed_flows"] = None
+ else:
+ logger.warn(u"Unsupported T-Rex ASTF traffic profile!")
+ index = 0
+ for line in stdout.splitlines():
+ if f"Xstats snapshot {index}: " in line:
+ xstats[index] = line[19:]
+ index += 1
+ if index == 2:
+ break
+ self._xstats = tuple(xstats)
+ else:
+ 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):
+ """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.
+
+ :param duration: Time expressed in seconds for how long to send traffic.