cisco-system-traffic-generator / trex-core

trex-core site
https://trex-tgn.cisco.com/
Other
1.3k stars 462 forks source link

trex.common.trex_exceptions.TRexError: 'get_active_ports' - is not valid while disconnected #795

Open HouMinXi opened 2 years ago

HouMinXi commented 2 years ago

I use one port to send traffic on v2.93, but the wait_on_traffic function meet some issues. Could you please kindly have a look?

Here is my code pharse: def generate_single_port_traffic(stlclient, traffic, duration):

port_num = stlclient.get_port_count()
port_list = list(range(port_num))
real_ports = port_list[0]
stlclient.reset(ports=port_list)
stlclient.set_port_attr(ports=real_ports, link_up=True)
timeout_seconds = math.ceil(float(duration) + float(60))
# logger.info(f"get port info: {stlclient.get_port_attr(0)}")
stlclient.acquire(ports=port_list, force=True)
stlclient.remove_all_captures()
stlclient.set_service_mode(ports=port_list, enabled=False)
if TRAFFICGEN_TREX_FLOW_STATS:
    stlclient.set_port_attr(flow_ctrl=3, multicast=False)
# due to change src mac, need enable promiscuous
if TRAFFICGEN_TREX_ENABLE_PROMISC_MODE:
    stlclient.set_port_attr(port_list, promiscuous=True)
ports_info = stlclient.get_port_info(port_list)
# get max support speed
max_speed = 0
# if t-rex use debug mode, supp_speeds won't have value.
if ports_info[0]['supp_speeds']:
    max_speed_1 = max(ports_info[0]['supp_speeds'])
    max_speed = max_speed_1
elif ports_info[0]['speed']:
    # if max supported speed not in port info or set manually, just assume 10G

    max_speed_1 = int(ports_info[0]['speed'])
    max_speed = max_speed_1

gbps_speed = float((max_speed / 1000) * float(traffic['frame_rate']) / 100.0)

logger.info('Starting traffic at %s Gbps speed', gbps_speed)

# will use port 0 to send traffic
packet_1 = create_single_port_packets(traffic, ports_info)
# dump the packet
# logger.info(packet_1.show(dump=True))

stream_1, stream_1_lat = load_single_port_pkt(packet_1, traffic)

stlclient.add_streams(stream_1, ports=real_ports)
if stream_1_lat is not None:
    stlclient.add_streams(stream_1_lat, ports=real_ports)

# print(f"here is stream1: {stream_1.to_code()}, \n"
#         f"here is stream_1_lat: {stream_1_lat.to_code()}, \n")
stlclient.clear_stats()

try:
    stlclient.start(ports=real_ports, force=True, duration=duration, mult="{}gbps".format(gbps_speed),
                    core_mask=stlclient.CORE_MASK_PIN)
except Exception as e:
    logger.info(f"start trex error with {e}")
    stlclient.start(ports=real_ports, force=True, duration=duration, mult="{}%".format(traffic['frame_rate']))

try:
    stlclient.wait_on_traffic(ports=real_ports, timeout=timeout_seconds)
except TRexTimeoutError as e:
    stlclient.stop(ports=port_list)
    logger.error(f"TIMEOUT: The test did not end on it's own correctly within the allotted time.{e}")
except TRexError as e:
    stlclient.stop(ports=port_list)
    logger.error("wait_on_traffic: TRexError: %s" % (e))

# got final result
# print("generate_single_port_traffic stats", stlclient.get_stats())
stats = stlclient.get_stats(sync_now=True)

return stats

the error as below: Traceback (most recent call last): File "trex_rfc2544.py", line 794, in generate_single_port_traffic stlclient.wait_on_traffic(ports=real_ports, timeout=timeout_seconds) File "./current/automation/trex_control_plane/interactive/trex/common/trex_api_annotators.py", line 51, in wrap2 ret = f(*args, *kwargs) File "./current/automation/trex_control_plane/interactive/trex/stl/trex_stl_client.py", line 885, in wait_on_traffic TRexClient.wait_on_traffic(self, ports, timeout) File "./current/automation/trex_control_plane/interactive/trex/common/trex_api_annotators.py", line 51, in wrap2 ret = f(args, **kwargs) File "./current/automation/trex_control_plane/interactive/trex/common/trex_client.py", line 2095, in wait_on_traffic while set(self.get_active_ports()).intersection(ports): File "./current/automation/trex_control_plane/interactive/trex/common/trex_api_annotators.py", line 48, in wrap2 raise TRexError("'{0}' - is not valid while disconnected".format(func_name)) trex.common.trex_exceptions.TRexError: 'get_active_ports' - is not valid while disconnected

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "trex_rfc2544.py", line 1745, in lossrate=MyTRex.args.lose_rate) File "trex_rfc2544.py", line 1172, in single_port_send_rfc2544_throughput TRAFFICGEN_TREX_VERIFICATION_DURATION) File "trex_rfc2544.py", line 799, in generate_single_port_traffic stlclient.stop(ports=port_list) File "./current/automation/trex_control_plane/interactive/trex/common/trex_api_annotators.py", line 48, in wrap2 raise TRexError("'{0}' - is not valid while disconnected".format(func_name)) trex.common.trex_exceptions.TRexError: 'stop' - is not valid while disconnected Shutting down RPC client

HouMinXi commented 2 years ago

Here is my trex_cfg.yaml. I use xxv710 25G dual port as traffic generator. But in my test actually use one port to send and receive traffic.
`# cat /etc/trex_cfg.yaml

Config file generated by dpdk_setup_ports.py

Here is my start trex command ./t-rex-64 --no-ofed-check --no-scapy-server -i 1 -c 11 `

HouMinXi commented 2 years ago

attach the nic info as below:

ethtool -i ens3f0

driver: i40e version: 4.18.0-305.el8_4.x firmware-version: 8.15 0x800096ca 20.0.17 expansion-rom-version: bus-info: 0000:13:00.0 supports-statistics: yes supports-test: yes supports-eeprom-access: yes supports-register-dump: yes supports-priv-flags: yes

when I send a long time test about 1H, this issue can occur.