Tool to measure ssh latency ("sshping") ?
Philipp Marek
philipp at marek.priv.at
Fri Jul 28 15:25:47 AEST 2023
> while true
> do
> time echo test | ssh user at machine.somewhere
> <mailto:user at machine.somewhere> cat
> done
Well, shouldn't it be more like this?
while true
do
echo foobar
done | ssh user at machine > /dev/null
> But for a remote rpc service that requires low latency, take a look
> at multiplexing
> https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Multiplexing and
> daemonize the Master connection
Yeah, that keeps a common SSH connection as well.
My €0.02: just use existing tools.
for nr in $(seq 0 3600)
do
id=$(date +%s.%N,$$,$nr | md5sum)
echo $id
sleep 1
done | strace -o /tmp/ssh.trace -tt -s 30 --trace=read,write >
/dev/null
Please note that "strace" does a dup() of STDIN, STDOUT, and STDERR,
so it's not fd 0,1,2 but 4,5,6 for me.
Sadly I couldn't get strace to log _only_ these fd --
but but by associating the read() and write() requests by the MD5-ID
it should be fairly easy to associate the matching calls,
and subtracting the timestamps should get a fairly accurate picture
of the latency.
(Also you should be able to see the communication to/from the ssh
process vs. the communication of ssh to the other host - ie. you can
measure "input encryption time, latency to remote answer, output
decryption time".)
That doesn't include processing _outside_ ssh, of course.
If the machine you're doing that on has a fairly recent linux kernel
running, you could also use bpftrace to get better filtered results.
More information about the openssh-unix-dev
mailing list