YUP LED With Send-echo-request

This is a sequel to the previous post on LED Configuration With OpenWRT, especially the part with the YUP LED (yield uplink please, i.e. “someone else is using the internet”).

To recap that previous post, I triggered one of the LEDs on my WRAP as a YUP LED with ICMP echo reply packets, which results in blinking patterns which let me read which other hosts are switched on. The ICMP echo replies arrive as replies to the packets sent by a bunch of ping processes.

Now I have written a new program send-echo-request to make the blinking pattern timing more precise and above all to avoid the race conditions caused by the two ping processes running in parallel.

Every 0.5s, send-echo-request sends an ICMP echo request to the two hosts which interest me, and the iptables rules then triggers the LED with a very short 0.1s flash for a reply from one host, and a much longer 0.4s one from the other host.

As the hosts on my local LAN reply within much less than 0.01s, the echo replies arrive practically in the same 0.5s pulse send-echo-request sends the echo requests in.

Here are the installation and setup steps in short:

Install packages
1
2
3
4
root@OpenWrt:~# opkg install kmod-ledtrig-netfilter
root@OpenWrt:~# opkt install kmod-ipt-led
root@OpenWrt:~# opkt install iptables-mod-led
root@OpenWrt:~#
/etc/config/system
1
2
3
4
5
6
7
[...]

config led otheruser_led
        option sysfs   'wrap::extra'
        option trigger 'netfilter-yup'

[...]
/etc/rc.local
1
2
3
4
5
6
[...]

# Check whether the other PCs with IP .23 and .42 are online.
(send-echo-request -qq --loop 192.168.1.23 192.168.1.42 2001:db8:dead:beef::1 &) &

[...]
/etc/firewall.user
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[...]

iptables -I INPUT -p icmp --icmp-type echo-reply \
         --source 192.168.1.23/32 \
         -j LED --led-trigger-id yup --led-delay 400
iptables -I INPUT -p icmp --icmp-type echo-reply \
         --source 192.168.0.0/16 \
         -j LED --led-trigger-id yup --led-delay 100

ip6tables -I INPUT -p icmpv6 --icmpv6-type echo-reply \
          --source 2001:db8:dead:beef::1 \
          -j LED --led-trigger-id yup --led-delay 250

[...]