+ 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.
+
+ Internal state is updated with measurement results.
+
+ :param node: T-Rex generator node.
+ :type node: dict
+ :raises RuntimeError: If stop traffic script fails.
+ """
+ command_line = OptionString().add(u"python3")
+ dirname = f"{Constants.REMOTE_FW_DIR}/GPL/tools/trex"
+ command_line.add(f"'{dirname}/trex_astf_stop.py'")
+ command_line.change_prefix(u"--")
+ for index, value in enumerate(self._xstats):
+ if value is not None:
+ value = value.replace(u"'", u"\"")
+ command_line.add_equals(f"xstat{index}", f"'{value}'")
+ stdout, _ = exec_cmd_no_error(
+ node, command_line,
+ message=u"T-Rex ASTF runtime error!"
+ )
+ self._parse_traffic_results(stdout)