My ThinkPad T440s (wireless chipset Intel Corporation Wireless 7260
) running Ubuntu 22.10 has been exhibiting unexplained periodic latency spikes on WiFi.
Observed behavior
- The spikes occur exactly every 5min and cause the latency to spike from below 10ms to over 100ms.
- The behavior occurs only on WiFi and not on a wired connection.
- The latency spikes are not correlated with other devices (e.g. my phone or MacBook).
Cause
A default Ubuntu install automatically runs geoclue to provide location services. Per default, geoclue scans for nearby WiFi access points every 300s (5min) which causes a freeze in WiFi traffic for the duration of the scan. This is not a new issue and has been reported before. The behavior can be reproduced by triggering a manual scan:
iw wlp3s0 scan
Solution
Disable WiFi scanning in geoclue
by editing /etc/geoclue/geoclue.conf
:
# WiFi source configuration options
[wifi]
# Enable WiFi source
enable=false
Tooling
Sampling latency
Sample WiFi latency by running ping
every 0.1s
.
This produces a row containing the timestamp and latency for each ping (rg
is ripgrep).
ping -s 64 -i 0.1 -D 192.168.1.1 | rg '\[(.*)\].*time=(.*) ms' -r '$1,$2' --line-buffered | tee latency.csv
Plot latency
The results can be plotted using gnuplot
.
gnuplot -e "file='latency.csv'" plot.gnu
plot.gnu
script:
set datafile separator ","
set xdata time
set timefmt "%s"
set format x "%M:%S"
p file u 1:2, file u 1:2 smooth bezier with lines
# Automatically refresh every 1s, comment out to disable
pause 1
reread
Other useful tools
blip can be used as a secondary method for sampling latency.
nethogs can be used to monitor application network usage.
wavemon can be used to monitor WiFi signal health.