From 1142e8c4678b2c357b080f5ae31eca30fac46478 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 9 May 2016 17:16:58 +0300 Subject: added force option to local PCAP - for > 1MB files --- .../trex_control_plane/stl/examples/stl_pcap_remote.py | 10 ++++++---- .../trex_control_plane/stl/trex_stl_lib/trex_stl_client.py | 13 +++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'scripts/automation') diff --git a/scripts/automation/trex_control_plane/stl/examples/stl_pcap_remote.py b/scripts/automation/trex_control_plane/stl/examples/stl_pcap_remote.py index 2270b51c..c47eee31 100644 --- a/scripts/automation/trex_control_plane/stl/examples/stl_pcap_remote.py +++ b/scripts/automation/trex_control_plane/stl/examples/stl_pcap_remote.py @@ -13,8 +13,10 @@ def inject_pcap (c, pcap_file, port, loop_count, ipg_usec, duration): # assume 100 seconds is enough - but can be more c.wait_on_traffic(ports = [port], timeout = 100) - #stats = c.get_stats() - #opackets = stats[port]['opackets'] + stats = c.get_stats() + opackets = stats[port]['opackets'] + + return opackets #print("{0} packets were Tx on port {1}\n".format(opackets, port)) @@ -102,8 +104,8 @@ def start (args): for i, cap in enumerate(caps, start = 1): before = time.time() print ("{:} CAP {:} @ {:} - ".format(i, cap, sizeof_fmt(os.path.getsize(cap)))), - inject_pcap(c, cap, options.port, options.loop_count, options.ipg, options.duration) - print("took {:.2f} seconds").format(time.time()-before) + injected = inject_pcap(c, cap, options.port, options.loop_count, options.ipg, options.duration) + print("took {:.2f} seconds for {:} packets").format(time.time() - before, injected) except STLError as e: print(e) diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py index 9f96b237..d1352804 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py @@ -1931,7 +1931,8 @@ class STLClient(object): ipg_usec = None, speedup = 1.0, count = 1, - duration = -1): + duration = -1, + force = False): """ Push a local PCAP to the server This is equivalent to loading a PCAP file to a profile @@ -1958,6 +1959,9 @@ class STLClient(object): duration: float Limit runtime by duration in seconds + force: bool + Ignore file size limit - push any file size to the server + :raises: + :exc:`STLError` @@ -1972,8 +1976,8 @@ class STLClient(object): validate_type('duration', duration, (float, int)) # no support for > 1MB PCAP - use push remote - if os.path.getsize(pcap_filename) > (1024 * 1024): - raise STLError("PCAP size of {:,} B is too big for local push - consider using remote push".format(os.path.getsize(pcap_filename))) + if not force and os.path.getsize(pcap_filename) > (1024 * 1024): + raise STLError("PCAP size of {:} is too big for local push - consider using remote push or provide 'force'".format(format_num(os.path.getsize(pcap_filename), suffix = 'B'))) self.remove_all_streams(ports = ports) @@ -2695,7 +2699,8 @@ class STLClient(object): ipg_usec = opts.ipg_usec, speedup = opts.speedup, count = opts.count, - duration = opts.duration) + duration = opts.duration, + force = opts.force) -- cgit 1.2.3-korg