openssl enc -aes-256-ctr -iter 1 -pass pass:a -nosalt </dev/zero | pv -qL 10M | pv -i0.1 | pixz -4tk >/dev/null

27.6M/s pixz -1tk
22.8M/s pixz -2tk
20.8M/s pixz -3tk
19.3M/s pixz -4tk

25.5M/s xz -1T0
20.8M/s xz -2T0
19.2M/s xz -3T0


# start capture
tcpdump -nni eth0 -w cap-$(date +%s.%N).pcap
tcpdump -nni eth0 -w- | (pixz -1tk >cap-$(date +%s.%N).pcap &)

# configure browser
d=/tmp/ffprof; rm -rf $d; mkdir $d;
firefox --profile $d --no-remote about:config
  network.http.spdy.enabled.http2 = false
  devtools.netmonitor.responseBodyLimit = 0
tar -c $d > $d.tar

# start browser
export SSLKEYLOGFILE=$HOME/keylog.tls
rm $SSLKEYLOGFILE; rm -rf $d; tar -xC/ -f$d.tar
firefox --profile $d --no-remote --devtools https://dootnode.org

# load capture
wireshark $(ls -1tra cap-*.pcap* | tail -n 1)

# load tls keys
edit » preferences » protocols » tls »
  "(pre)-master-secret log filename" => ~ed/keylog.tls



# tcpdump | pixz = OK
# lk=$(mktemp -d); while true; do [ -e $lk ] || { echo DONE; break; }; sleep 0.1; done & tcpdump -nni eth0 -w- | ((pixz -1tk >cap-$(date +%s.%N).pcap; rmdir $lk )&)
(sleep 0.5; curl https://dootnode.org/index/bgm.ogg >/dev/null) &
tcpdump -nni eth0 -w- | (pixz -1tk >cap-$(date +%s.%N).pcap &)
pixz -dtk <$(ls -1tra cap-*.pcap | tail -n1) | tcpdump -nnr- | wc -c

# tcpdump | xz = OK
# lk=$(mktemp -d); while true; do [ -e $lk ] || { echo DONE; break; }; sleep 0.1; done & tcpdump -nni eth0 -w- | ((xz -4T0 >cap-$(date +%s.%N).pcap; rmdir $lk )&)
(sleep 0.5; curl https://dootnode.org/index/bgm.ogg >/dev/null) &
tcpdump -nni eth0 -w- | (xz -4T0 >cap-$(date +%s.%N).pcap &)
xz -d <$(ls -1tra cap-*.pcap | tail -n1) | tcpdump -nnr- | wc -c



# tests
auto_v1() { (sleep 0.5; curl https://dootnode.org/index/bgm.ogg >/dev/null) & stdbuf -o0 tcpdump --immediate-mode -Unni eth0 -w- | ($pk >cap-$(date +%s.%N).pcap &) & (sleep 1.5; killall tcpdump); $un <$(ls -1tra cap-*.pcap | tail -n 1) | tcpdump -nnr- >/dev/null; }
auto() { lk=$(mktemp -d); (sleep 0.5; curl https://dootnode.org/index/bgm.ogg >/dev/null) & tcpdump -nni eth0 -w- | ($pk >cap-$(date +%s.%N).pcap && rmdir $lk &) & (sleep 1.5; killall tcpdump); echo A; wait; echo A; while true; do [ -e $lk ] || break; sleep 0.1; done; echo A; $un <$(ls -1tra cap-*.pcap | tail -n 1) | tcpdump -nnr- >/dev/null; };
man1() { (sleep 0.5; curl https://dootnode.org/index/bgm.ogg >/dev/null) & tcpdump -nni eth0 -w- | ($pk >cap-$(date +%s.%N).pcap &); }
man2() { $un <$(ls -1tra cap-*.pcap | tail -n1) | tcpdump -nnr- >/dev/null; }

pk='pigz -c';    un='pigz -d';   auto; printf '\n\n\n'; man1  # NOPE
pk='gzip -c';    un='gzip -d';   auto; printf '\n\n\n'; man1  # OK
pk='bzip2 -c';   un='bzip2 -d';  auto; printf '\n\n\n'; man1  # OK
pk='lbzip2 -cu'; un='lbzip2 -d'; auto; printf '\n\n\n'; man1  # NOPE
pk='pixz -1tk';  un='pixz -dtk'; auto; printf '\n\n\n'; man1  # OK
pk='xz -4T0';    un='xz -d';     auto; printf '\n\n\n'; man1  # OK
