WiFi problems after waking up from sleep, Ubuntu 16.10

After installing Ubuntu 16.10 I occasionally had problems with WiFi after waking up from sleep.

But of course there’s a workaround (credit to Joakim Koed on askubuntu.com and the solution).

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
sudo bash -c 'cat >/etc/systemd/system/wake-up.service <<EOF
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
 
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service
 
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target
EOF'
sudo systemctl enable wake-up.service

Measure WiFi signal strength

When installing a wireless network in our cabins, I had to make some optimizations, like buying bigger antennas. To verify that the signal got better at some key areas I went around and checked the signal, with this little script:

#!/usr/bin/env bash
wifi_interface="$(nmcli d | awk '$2 ~ /wifi/ {print $1}')"
description="${1:-${wifi_interface}}"
sudo true
samples=10
sequences=($(seq 1 ${samples}))
total_link=0
total_level=0
for index in "${sequences[@]}"
do
# shellcheck disable=SC2016
values=($(sudo awk '$1 ~ /'"${wifi_interface}"'/ {print $3" "$4}' /proc/net/wireless | sed 's/\.//g'))
link="${values[0]}"
level="${values[1]}"
total_link=$((total_link+link))
total_level=$((total_level+level))
echo "Sample ${index}: ${description};${link};${level}"
[[ "${index}" -lt "${samples}" ]] && sleep 10
done
average_link=$((total_link/samples))
average_level=$((total_level/samples))
echo ""
echo "Average:"
echo "${description};${average_link};${average_level}"

Then I imported the result in Google Sheets and drew a really simple blueprint over the cabins and plotted the measured areas to see how good the signal was.