Deleted obsolete files, actually add the new features and help
This commit is contained in:
parent
ea91119775
commit
38be8eca7c
4 changed files with 92 additions and 34 deletions
99
bench.sh
99
bench.sh
|
|
@ -1,10 +1,25 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# shellcheck disable=SC3000-SC4000
|
||||||
|
|
||||||
mode=$1
|
mode=$1
|
||||||
dest=$2
|
dest=$2
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: ${0} <'connect'|'send'|'receive'> <destination>"
|
echo "Usage: ${0} <mode> <destination> [show [<number>]|<iterations>]"
|
||||||
|
echo
|
||||||
|
echo "Mode is one of 'connect', 'send' or 'receive'."
|
||||||
|
echo
|
||||||
|
echo "Destination is a host name or IP, optionally prefixed by username@."
|
||||||
|
echo
|
||||||
|
echo "If 'show' is given, benchmarking is skipped and existing results are shown."
|
||||||
|
echo "The optional <number> specifies how many of the results are shown; by"
|
||||||
|
echo "default only the top 10 fastest are displayed."
|
||||||
|
echo
|
||||||
|
echo "Alternatively, if instead of 'show' a number is given for <iterations>,"
|
||||||
|
echo "the benchmark is run that many times before showing the results. The"
|
||||||
|
echo "<number> can in this case not be overridden."
|
||||||
|
echo
|
||||||
|
echo "Results shown are an average of all collected results for the given host/mode."
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -18,18 +33,33 @@ if [ ! "$dest" ] ; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
kex=$(ssh -Q kex|grep -Ev -- '-(group-exchange|sha1|sha512|md5|nistp[^2])')
|
||||||
|
if [ -f "kex.lst" ] ; then
|
||||||
|
kex=$(cat kex.lst)
|
||||||
|
fi
|
||||||
|
|
||||||
|
macs=$(ssh -Q macs|grep -Ev -- '-(sha1|512|md5)')
|
||||||
|
if [ -f "macs.lst" ] ; then
|
||||||
|
macs=$(cat macs.lst)
|
||||||
|
fi
|
||||||
|
|
||||||
|
ciphers=$(ssh -Q cipher | grep -Ev -- '(3des|aes1[^2]|aes2)')
|
||||||
|
if [ -f "ciphers.lst" ] ; then
|
||||||
|
ciphers=$(cat ciphers.lst)
|
||||||
|
fi
|
||||||
|
|
||||||
case "$mode" in
|
case "$mode" in
|
||||||
'connect')
|
'connect')
|
||||||
prefix=''
|
prefix=''
|
||||||
command='echo -n'
|
command='echo -n'
|
||||||
;;
|
;;
|
||||||
'send')
|
'send')
|
||||||
prefix='dd if=/dev/zero bs=4k count=256 | '
|
prefix='dd if=/dev/zero bs=4k count=2048'
|
||||||
command='cat > /dev/null'
|
command='cat > /dev/null'
|
||||||
;;
|
;;
|
||||||
'receive')
|
'receive')
|
||||||
prefix=''
|
prefix=''
|
||||||
command='dd if=/dev/zero bs=4k count=256'
|
command='dd if=/dev/zero bs=4k count=2048'
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Mode must be one of connect, send, receive"
|
echo "Mode must be one of connect, send, receive"
|
||||||
|
|
@ -37,25 +67,66 @@ case "$mode" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
showstats() {
|
||||||
|
local _dest="$1"
|
||||||
|
local _mode="$2"
|
||||||
|
local _top="$3"
|
||||||
|
local f
|
||||||
|
|
||||||
|
local headcmd="head -10"
|
||||||
|
if [ "${_top}" ] ; then
|
||||||
|
if top=$(echo "${_top}" | grep -Ev '[^0-9]' | grep -E '[0-9]') ; then
|
||||||
|
headcmd="head -${top}"
|
||||||
|
elif [ "${_top}" = 'all' ] ; then
|
||||||
|
headcmd="cat"
|
||||||
|
else
|
||||||
|
echo "Could not decipher number of lines to show (${_top}); ignoring"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$_dest" ] ; then
|
||||||
|
(
|
||||||
|
echo 'Destination Mode MAC Cipher KEX Time'
|
||||||
|
for f in "${_dest}"/"${_mode}"__*.log ; do
|
||||||
|
echo -n "$f " | sed -e 's/\.log//' -e 's/\// /'
|
||||||
|
cut -f 2 -w < "$f" | awk '{s+=$0}END{print s/NR}' RS=" "
|
||||||
|
done | sort -gk 2 | $headcmd | tr '_' ' '
|
||||||
|
) | column -t
|
||||||
|
else
|
||||||
|
echo "${_dest} directory not found!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
runbench() {
|
||||||
mkdir -p "$dest"
|
mkdir -p "$dest"
|
||||||
for m in $(cat macs) ; do
|
for m in $macs ; do
|
||||||
for c in $(cat ciphers) ; do
|
for c in $ciphers ; do
|
||||||
for k in $(cat kex) ; do
|
for k in $kex ; do
|
||||||
echo
|
echo
|
||||||
echo "${dest}/${mode}__${m}__${c}__${k}.log"
|
echo "${dest}/${mode}__${m}__${c}__${k}.log"
|
||||||
$prefix /usr/bin/time ssh -o MACs=$m -o Ciphers=$c -o KexAlgorithms=$k $dest "${command}" 2>&1 >/dev/null |
|
if [ "$prefix" ] ; then
|
||||||
|
$prefix 2>/dev/null | /usr/bin/time ssh -o MACs="$m" -o Ciphers="$c" -o KexAlgorithms="$k" "$dest" "${command} 2>/dev/null" 2>&1 >/dev/null |
|
||||||
tee -a "${dest}/${mode}__${m}__${c}__${k}.log"
|
tee -a "${dest}/${mode}__${m}__${c}__${k}.log"
|
||||||
|
else
|
||||||
|
/usr/bin/time ssh -o MACs="$m" -o Ciphers="$c" -o KexAlgorithms="$k" "$dest" "${command} 2>/dev/null" 2>&1 >/dev/null |
|
||||||
|
tee -a "${dest}/${mode}__${m}__${c}__${k}.log"
|
||||||
|
fi
|
||||||
sleep 0.1 || break
|
sleep 0.1 || break
|
||||||
done
|
done
|
||||||
sleep 0.1 || break
|
sleep 0.1 || break
|
||||||
done
|
done
|
||||||
sleep .01 || break
|
sleep .01 || break
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
(
|
if ! [ "$3" = 'show' ] ; then
|
||||||
echo 'Mode MAC Cipher KEX Time'
|
if iterations=$(echo "$3" | grep -Ev '[^0-9]' | grep -E '[0-9]') ; then
|
||||||
for f in ${dest}/*.log ; do
|
for i in $(jot -n "$iterations") ; do
|
||||||
echo -n "$f "
|
echo "Executing iteration $i of $iterations .."
|
||||||
cut -f 2 -w < $f | awk '{s+=$0}END{print s/NR}' RS=" "
|
runbench
|
||||||
done | sort -gk 2 | head -10 | tr '_' ' '
|
done
|
||||||
) | column -t
|
else
|
||||||
|
runbench
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
showstats "$dest" "$mode" "$4"
|
||||||
|
|
|
||||||
3
ciphers
3
ciphers
|
|
@ -1,3 +0,0 @@
|
||||||
chacha20-poly1305@openssh.com
|
|
||||||
aes128-ctr
|
|
||||||
aes128-gcm@openssh.com
|
|
||||||
1
kex
1
kex
|
|
@ -1 +0,0 @@
|
||||||
ecdh-sha2-nistp256
|
|
||||||
9
macs
9
macs
|
|
@ -1,9 +0,0 @@
|
||||||
umac-64-etm@openssh.com
|
|
||||||
umac-128-etm@openssh.com
|
|
||||||
hmac-sha2-256-etm@openssh.com
|
|
||||||
hmac-sha2-512-etm@openssh.com
|
|
||||||
hmac-sha1-etm@openssh.com
|
|
||||||
umac-64@openssh.com
|
|
||||||
umac-128@openssh.com
|
|
||||||
hmac-sha2-256
|
|
||||||
hmac-sha1
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue