Browse by type
Merge multiple pcap files together, gracefully.
go get:bash
go get -u github.com/assafmo/joincap
bash
curl -SsL https://assafmo.github.io/ppa/ubuntu/KEY.gpg | sudo apt-key add -
sudo curl -SsL -o /etc/apt/sources.list.d/assafmo.list https://assafmo.github.io/ppa/ubuntu/assafmo.list
sudo apt update
sudo apt install joincap
Usage:
joincap [OPTIONS] InFiles...
Application Options:
-v, --verbose Explain when skipping packets or entire input files
-V, --version Print the version and exit
-w= Sets the output filename. If the name is '-', stdout will be used (default: -)
-c= An integer argument for limiting the pcap size (default: 9223372036854775807)
-p=[micros|nanos] Sets timestamp precision (default: micros)
Help Options:
-h, --help Show this help message
I believe skipping corrupt packets is better than failing the entire merge job.
When using tcpslice or mergecap sometimes pcapfix is needed to fix bad input pcap files.
mergecap/tcpslice), if we get errors then run pcapfix on the bad pcaps and then run merge again.pcapfix processes)pcapfix on the input pcap files and then merge.pcapfix processes)pcapfix "in memory" with process substitution: mergecap -w out.pcap <(pcapfix -o /dev/stdout 1.pcap) <(pcapfix -o /dev/stdout 2.pcap).pcapfix processes)tcpslice -w out.pcap *.pcap)tcpslice (seeks the last packets to calculate time ranges - cannot do this with pipes)joincap vs mergecap vs tcpslice| Use case | joincap | mergecap v2.4.5 | tcpslice v1.2a3 |
|---|---|---|---|
| Corrupt input global header | :heavy_check_mark: | :x: | :x: |
| Corrupt input packet header | :heavy_check_mark: | :x: | :x: |
| Unexpectd EOF |
(last packet data is truncated) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | Input pcap has no packets
(global header is ok, no first packet header) | :heavy_check_mark: | :heavy_check_mark: | :x: | | Input file size is smaller than 24 bytes
(global header is truncated) | :heavy_check_mark: | :heavy_check_mark: | :x: | | Input file size is between 24 and 40 bytes
(global header is ok, first packet header is truncated) | :heavy_check_mark: | :x: | :x: | | Input file doesn't exists | :heavy_check_mark: | :x: | :x: | | Input file is a directory | :heavy_check_mark: | :x: | :x: | | Input file end is garbage | :heavy_check_mark: | :heavy_check_mark: | :x: | | Input file is gzipped (.pcap.gz) | :heavy_check_mark: | :heavy_check_mark: | :x: |
| Use case | Error outputs |
|---|---|
| Corrupt input global header |
|
| Corrupt input packet header |
|
| Unexpectd EOF |
(last packet data is truncated) | | | Input pcap has no packets
(global header is ok, no first packet header) |
(global header is truncated) |
tcpslice: bad tcpdump file test_pcaps/empty: truncated dump file; tried to read 4 file header bytes, only got 0(global header is ok, first packet header is truncated) |
tcpslice: bad status reading first packet in test_pcaps/partial_first_header.pcap: truncated dump file; tried to read 16 header bytes, only got 11mergecap: The file "test_pcaps/partial_first_header.pcap" appears to have been cut short in the middle of a paket.tcpslice: bad tcpdump file ./not_here: ./not_here: No such file or directorymergecap: The file "./not_here" doesn't exist.tcpslice: bad tcpdump file examples: error reading dump file: Is a directorymergecap: "examples" is a directory (folder), not a file.tcpslice: problems finding end packet of file test_pcaps/bad_end.pcaptcpslice: bad tcpdump file test_pcaps/ok.pcap.gz: unknown file format| Use case | How to reproduce |
|---|---|
| Corrupt input global header |
|
| Corrupt input packet header |
|
| Unexpectd EOF |
(last packet data is truncated) |
joincap -w out_joincap.pcap test_pcaps/unexpected_eof_on_first_packet.pcapmergecap -w out_mergecap.pcap test_pcaps/unexpected_eof_on_first_packet.pcaptcpslice -D -w out_tcpslice.pcap test_pcaps/unexpected_eof_on_first_packet.pcapjoincap -w out_joincap.pcap test_pcaps/unexpected_eof_on_second_packet.pcapmergecap -w out_mergecap.pcap test_pcaps/unexpected_eof_on_second_packet.pcaptcpslice -D -w out_tcpslice.pcap test_pcaps/unexpected_eof_on_second_packet.pcap(global header is ok, no first packet header) |
joincap -w out_joincap.pcap test_pcaps/ok.pcap test_pcaps/no_packets.pcapmergecap -w out_mergecap.pcap test_pcaps/ok.pcap test_pcaps/no_packets.pcaptcpslice -D -w out_tcpslice.pcap test_pcaps/ok.pcap test_pcaps/no_packets.pcap(global header is truncated) |
joincap -w out_joincap.pcap test_pcaps/ok.pcap test_pcaps/emptymergecap -w out_mergecap.pcap test_pcaps/ok.pcap test_pcaps/empty<$ claude mcp add joincap \
-- python -m otcore.mcp_server <graph>