From 89465f0dbdd059853e843b42580e324408528844 Mon Sep 17 00:00:00 2001 From: Yaroslav Brustinov Date: Tue, 14 Mar 2017 02:02:54 +0200 Subject: STL map() using flow stats: ignores network noise + avoid sending exponential number of packets from each consequential port. Change-Id: Ib5bebd5b64c8c316307181ba50c53df1e46a3466 Signed-off-by: Yaroslav Brustinov --- .../stl/trex_stl_lib/trex_stl_std.py | 69 ++++++++++++---------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py index 17bc7c6f..27f34092 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_std.py @@ -9,49 +9,57 @@ def stl_map_ports (client, ports = None): if ports is None: ports = client.get_all_ports() - client.reset(ports) - + client.acquire(ports, force = True, sync_streams = False) + unresolved_ports = list_difference(ports, client.get_resolved_ports()) if unresolved_ports: raise STLError("Port(s) {0} have unresolved destination addresses".format(unresolved_ports)) - + stl_send_3_pkts(client, ports) - tx_pkts = {} - pkts = 1 - base_pkt = STLPktBuilder(pkt = Ether()/IP()) + PKTS_SENT = 5 + pgid_per_port = {} + active_pgids = client.get_active_pgids()['ids'] + base_pkt = Ether()/IP()/UDP()/('x' * 18) + test_pgid = 10000000 + # add latency packet per checked port for port in ports: - tx_pkts[pkts] = port - stream = STLStream(packet = base_pkt, - mode = STLTXSingleBurst(pps = 100000, total_pkts = pkts * 3)) - - client.add_streams(stream, [port]) - - pkts *= 2 + for i in range(3): + while test_pgid in active_pgids: + test_pgid += 1 + stream = STLStream(packet = STLPktBuilder(pkt = base_pkt), + flow_stats = STLFlowLatencyStats(pg_id = test_pgid), + mode = STLTXSingleBurst(pps = 1e4, total_pkts = PKTS_SENT)) + try: + client.add_streams(stream, [port]) + except STLError: + continue + pgid_per_port[port] = test_pgid + test_pgid += 1 + break + + if len(pgid_per_port) != len(ports): + raise STLError('Could not add flow stats streams per port.') # inject - client.clear_stats() - client.start(ports, mult = "50%") + client.clear_stats(ports, clear_global = False, clear_flow_stats = True, clear_latency_stats = False, clear_xstats = False) + client.start(ports, mult = "5%") client.wait_on_traffic(ports) - - stats = client.get_stats() + + stats = client.get_stats()['flow_stats'] # cleanup - client.reset(ports = ports) + client.reset(ports) table = {'map': {}, 'bi' : [], 'unknown': []} # actual mapping - for port in ports: - - ipackets = int(round(stats[port]["ipackets"] / 3.0)) # majority out of 3 to clean random noises - table['map'][port] = None - - for pkts in tx_pkts.keys(): - if ( (pkts & ipackets) == pkts ): - tx_port = tx_pkts[pkts] - table['map'][port] = tx_port + for tx_port in ports: + table['map'][tx_port] = None + for rx_port in ports: + if stats[pgid_per_port[tx_port]]['rx_pkts'][rx_port] * 2 > PKTS_SENT: + table['map'][tx_port] = rx_port unmapped = list(ports) while len(unmapped) > 0: @@ -78,8 +86,9 @@ def stl_send_3_pkts(client, ports = None): stream = STLStream(packet = base_pkt, mode = STLTXSingleBurst(pps = 100000, total_pkts = 3)) - client.reset(ports) + client.remove_all_streams(ports) client.add_streams(stream, ports) - client.start(ports, mult = "50%") + client.start(ports, mult = "5%") client.wait_on_traffic(ports) - client.reset(ports) + client.remove_all_streams(ports) + -- cgit 1.2.3-korg