drio

Quantifying the quality of ssh sessions

There is nothing more annoying than a ssh session over a poor network connection. When in a ssh session, we are looking for good latency values. We don't care much about bandwidth since we are sending keystrokes back and forth between servers.

Latency is the average ping speed. How long does it take for a keystroke to travel from the source to the destination and back? Another important metric is jitter, which measures the deviation from the average latency. High values on those two metrics guaranty a horrible user experience in your ssh session.

Can we quantify qualitatively how good a ssh connection is? Looking around I found sshping which is a c++ tool that computes average and jitter over a ssh connection. Exactly what we wanted.

There are no precompiled binaries for sshping so you have to build it yourself. If you are in OSX you can:

$ brew install libssh
$ git clone github.com/spook/sshping
$ cd sshping/src
$ g++ -I /opt/homebrew/Cellar/libssh/0.10.4/include \
-I ../ext -L /opt/homebrew/Cellar/libssh/0.10.4/lib \
-lssh sshping.cxx -o sshping

Now, let's run the tool against a local machine (local wifi network) vs a remote server:

➜ ./sshping -H localbox
ssh-Login-Time:               2.09  s
Minimum-Latency:              2.18 ms
Median-Latency:               4.22 ms
Average-Latency:              9.36 ms
Average-Deviation:            27.0 ms
Maximum-Latency:               422 ms
Echo-Count:                  1.00 kB
Upload-Size:                 8.00 MB
Upload-Rate:                 9.66 MB/s
Download-Size:               8.00 MB
Download-Rate:               4.45 MB/s

➜ ./sshping -H remotebox
ssh-Login-Time:               2.94  s
Minimum-Latency:              60.2 ms
Median-Latency:               65.5 ms
Average-Latency:              99.0 ms
Average-Deviation:            76.5 ms
Maximum-Latency:              1.18  s
Echo-Count:                  1.00 kB
Upload-Size:                 8.00 MB
Upload-Rate:                 3.30 MB/s
Download-Size:               8.00 MB
Download-Rate:               1.36 MB/s

Wires matter

The previous numbers are over a wifi connection. See what happens when we use a wired Ethernet connection (1Gb/s switches):


➜ ./sshping -H localbox
ssh-Login-Time:               1.98  s
Minimum-Latency:              1.32 ms
Median-Latency:               2.17 ms
Average-Latency:              2.34 ms
Average-Deviation:             531 us
Maximum-Latency:              7.04 ms
Echo-Count:                  1.00 kB
Upload-Size:                 8.00 MB
Upload-Rate:                 23.9 MB/s
Download-Size:               8.00 MB
Download-Rate:               7.72 MB/s

➜ ./sshping -H remotebox
ssh-Login-Time:               3.01  s
Minimum-Latency:              71.4 ms
Median-Latency:               77.4 ms
Average-Latency:              81.7 ms
Average-Deviation:            15.5 ms
Maximum-Latency:               358 ms
Echo-Count:                  1.00 kB
Upload-Size:                 8.00 MB
Upload-Rate:                 5.06 MB/s
Download-Size:               8.00 MB
Download-Rate:               1.52 MB/s

The local machine goes from:

Average-Latency:              9.36 ms
Average-Deviation:            27.0 ms

to:

Average-Latency:              2.34 ms
Average-Deviation:             531 us

And the remote box one goes from:

Average-Latency:              99.0 ms
Average-Deviation:            76.5 ms

to:

Average-Latency:              81.7 ms
Average-Deviation:            15.5 ms

So, yes, cables matter.

What values on those metrics define a good ssh connection?

A good connection typically means a latency <60ms with a jitter <10ms. By the way, jitter in the output above is (Average-Deviation).

We observe then that, as expected, the local ssh connection will be more pleasant than the remote connection. That being said, the expirience of running a real ssh session against that remote box is just fine. So the previous latency and jitter values make for a extremely good ssh connection. In my experience, a <100ms latency and a jitter of <75ms results in acceptable ssh connection sessions.