I think the consumption is achieved with the cat to /dev/null. That is why head in 1st example or echo in 2nd example keeps showing new values.
@moeller0 what do you make of this:
With:
#!/bin/bash
while true
do
ping -D -c 1 1.1.1.1
sleep 0.1
done
~
root@OpenWrt:~/CAKE-autorate# ./test.sh
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760047.759557] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=56.3 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 56.296/56.296/56.296/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760047.914019] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=46.3 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 46.310/46.310/46.310/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760048.073018] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=50.5 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 50.492/50.492/50.492/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760048.234065] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=53.0 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 52.970/52.970/52.970/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760048.397008] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=55.2 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 55.199/55.199/55.199/0.000 ms
^C
Or here is with 0.05 sleep:
root@OpenWrt:~/CAKE-autorate# ./test.sh
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760047.759557] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=56.3 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 56.296/56.296/56.296/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760047.914019] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=46.3 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 46.310/46.310/46.310/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760048.073018] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=50.5 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 50.492/50.492/50.492/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760048.234065] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=53.0 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 52.970/52.970/52.970/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760048.397008] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=55.2 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 55.199/55.199/55.199/0.000 ms
^C
root@OpenWrt:~/CAKE-autorate# ^C
root@OpenWrt:~/CAKE-autorate# vi test.sh
root@OpenWrt:~/CAKE-autorate# ./test.sh
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760182.527140] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=62.3 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 62.291/62.291/62.291/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760182.649151] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=63.6 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 63.590/63.590/63.590/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760182.769452] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=62.7 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 62.749/62.749/62.749/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760182.889985] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=63.1 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 63.124/63.124/63.124/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760183.009447] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=61.2 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 61.191/61.191/61.191/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760183.126431] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=58.0 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 58.030/58.030/58.030/0.000 ms
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
[1646760183.258458] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=72.1 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 72.063/72.063/72.063/0.000 ms
^C
How important is it to have even spacing? I guess we really want the most up to date samples we can achieve. Won't doing this at 10Hz for 4 reflectors result in massive CPU overhead given 40Hz calls of ping and passing back and forth to bash.
I can try again if you think worthwhile.
For comparison purposes, here is the output from a fifo approach:
#!/bin/bash
pipe=/tmp/test
mkfifo $pipe
ping -D -i 0.1 1.1.1.1 > $pipe&
cat $pipe > /dev/null&
while true
do
head -1 $pipe
done
root@OpenWrt:~/CAKE-autorate# ./test.sh
[1646761665.736721] 64 bytes from 1.1.1.1: icmp_seq=1 ttl=54 time=44.6 ms
[1646761665.950656] 64 bytes from 1.1.1.1: icmp_seq=3 ttl=54 time=56.1 ms
[1646761666.139707] 64 bytes from 1.1.1.1: icmp_seq=5 ttl=54 time=45.2 ms
[1646761666.354629] 64 bytes from 1.1.1.1: icmp_seq=7 ttl=54 time=58.3 ms
[1646761666.556416] 64 bytes from 1.1.1.1: icmp_seq=9 ttl=54 time=58.1 ms
[1646761666.750159] 64 bytes from 1.1.1.1: icmp_seq=11 ttl=54 time=50.2 ms
[1646761666.964655] 64 bytes from 1.1.1.1: icmp_seq=13 ttl=54 time=63.3 ms
[1646761667.152936] 64 bytes from 1.1.1.1: icmp_seq=15 ttl=54 time=52.8 ms
[1646761667.354276] 64 bytes from 1.1.1.1: icmp_seq=17 ttl=54 time=53.1 ms
[1646761667.565643] 64 bytes from 1.1.1.1: icmp_seq=19 ttl=54 time=63.3 ms
[1646761667.768973] 64 bytes from 1.1.1.1: icmp_seq=21 ttl=54 time=65.3 ms
[1646761667.951002] 64 bytes from 1.1.1.1: icmp_seq=23 ttl=54 time=45.7 ms
[1646761668.180158] 64 bytes from 1.1.1.1: icmp_seq=25 ttl=54 time=73.9 ms
[1646761668.373990] 64 bytes from 1.1.1.1: icmp_seq=27 ttl=54 time=66.7 ms
[1646761668.555103] 64 bytes from 1.1.1.1: icmp_seq=29 ttl=54 time=46.1 ms
[1646761668.757098] 64 bytes from 1.1.1.1: icmp_seq=31 ttl=54 time=46.8 ms