diff options
author | 2016-03-23 09:19:46 +0200 | |
---|---|---|
committer | 2016-03-23 13:01:08 +0200 | |
commit | 5e727474efe18b3800df6130c068e668fadd2e0b (patch) | |
tree | 1c9bce9e6367b892830df6a49798cd14bbe434d8 /scripts/automation/trex_control_plane/stl/trex_stl_lib/utils | |
parent | 46f110d0c728ba9299156cf92a59c27c2d0348fa (diff) |
Python 3 - another drop (package fixups)
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/utils')
-rwxr-xr-x | scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py | 2 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/pcap.py | 29 |
2 files changed, 30 insertions, 1 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py index 6ec2d189..c4f2b358 100755 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/parsing_opts.py @@ -225,7 +225,7 @@ OPTIONS_DB = {MULTIPLIER: ArgumentPack(['-m', '--multiplier'], IPG: ArgumentPack(['-i', '--ipg'], {'help': "IPG value in usec between packets. default will be from the pcap", 'dest': "ipg_usec", - 'default': 100.0, + 'default': None, 'type': float}), diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/pcap.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/pcap.py new file mode 100644 index 00000000..ab4f98a7 --- /dev/null +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/utils/pcap.py @@ -0,0 +1,29 @@ +import os +from ..trex_stl_packet_builder_scapy import RawPcapReader, RawPcapWriter + + +def __ts_key (a): + return float(a[1][0]) + (float(a[1][1]) / 1e6) + +def merge_cap_files (pcap_file_list, out_filename, delete_src = False): + + if not all([os.path.exists(f) for f in pcap_file_list]): + print("failed to merge cap file list...\nnot all files exist\n") + return + + out_pkts = [] + for src in pcap_file_list: + pkts = RawPcapReader(src) + out_pkts += pkts + if delete_src: + os.unlink(src) + + # sort by timestamp + out_pkts = sorted(out_pkts, key = __ts_key) + + writer = RawPcapWriter(out_filename, linktype = 1) + + writer._write_header(None) + for pkt in out_pkts: + writer._write_packet(pkt[0], sec=pkt[1][0], usec=pkt[1][1], caplen=pkt[1][2], wirelen=None) + |