3 # Limitations: if the number extracted files in too big, finding identical
4 # files might fail due to '*' in cmdline
5 # This would require to split sha256sum symlinks in xx/yyyyy
9 echo "Usage: $0 <file.pcap> <output-dir>"
10 echo "Compares tcpreassembly against tcpflow"
17 return # comment me for debug
34 find "$path" -type f -name "$filter" -print0 |
35 while IFS= read -r -d $'\0' f; do
36 local sha256="$(sha256sum "$f" | cut -d ' ' -f 1)"
37 local target="$(dirname $f)/../sha256/$sha256"
39 mkdir -p "$(dirname "$target")" || return 1
40 if [ ! -f "$target" ]; then
41 ln -sr "$f" "$target" || return 1
55 extra="$extra -cpuprofile "$out/gopacket/cpu.prof""
56 extra="$extra -memprofile "$out/gopacket/mem.prof""
58 [ ! -f "$src" ] && usage "Missing pcap"
59 [ ! -d "$out" ] && ( mkdir "$out" || die "Failed to create $out" )
61 mkdir -p "$out/gopacket/all" || die "Failed to create $out/gopacket/all"
62 mkdir -p "$out/tcpflow/all" || die "Faield to create $out/tcpflow/all"
64 echo " * Running go reassembly"
65 time ./reassemblydump -r "$src" $debug -output "$out/gopacket/all" $extra -writeincomplete -ignorefsmerr -nooptcheck -allowmissinginit port 80 &> "$out/gopacket.txt" || die "Failed to run reassmbly. Check $out/gopacket.txt"
66 echo " * Running tcpflow"
67 time tcpflow -e http -r "$src" -o "$out/tcpflow/all" port 80 &> "$out/tcpflow.txt" || die "Failed to run tcpflow. Check $out/tcpflow.txt"
69 echo " * Creating sha256sum symlinks for gopacket"
70 rename "$out/gopacket/all" '*' || die "Failed to rename in $out/gopacket"
71 echo " * Creating sha256sum symlinks for tcpflow"
72 rename "$out/tcpflow/all" '*HTTPBODY*' || die "Failed to rename in $out/tcpflow"
74 # Remove identical files
75 echo " * Finding identical files"
77 mkdir -p "$out/gopacket/sha256-equal"
78 mkdir -p "$out/tcpflow/sha256-equal"
79 for f in "$out/gopacket/sha256/"*; do
80 local f="$(basename "$f")"
81 [ -f "$out/tcpflow/sha256/$f" ] && {
83 mv "$out/gopacket/sha256/$f" "$out/gopacket/sha256-equal"
84 mv "$out/tcpflow/sha256/$f" "$out/tcpflow/sha256-equal"
88 echo " → found $nb files"
90 echo " * Diffing {gopacket,tcpflow}/sha256"
92 for p in "gopacket" "tcpflow"; do
93 local nb=$(ls -1 "$out/$p/sha256/" | wc -l)
94 if [ $nb -ne 0 ]; then
96 echo " → $nb files in $out/$p/sha256"