charleslinquist
Posts: 107
Joined: Wed Sep 05, 2012 12:43 pm

Does a Raspberry multitask during a PING?

Sat Mar 16, 2019 5:27 pm

I need to know if a connection is active while I'm sending streaming video (via UDP) from a Raspberry pi. The only way I could think of was to perform a ping every 5 seconds (to 8.8.8.8) using the 'watch' command. While this works, I'm concerned that if the processor must wait for the return during a ping, that might sometimes screw up my video stream.

I'm also open to any better suggestions.

Andyroo
Posts: 3378
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Does a Raspberry multitask during a PING?

Sat Mar 16, 2019 5:45 pm

Problem is not if the Pi multi-tasks (it does though by default the kernel is not real time) it is that the link could fail 1 second after the ping...

If you are running a multi-core Pi than you could even force a program onto a core using the terminal taskset command if the ping is impacting too much!

Be aware UDP is NOT 100% guaranteed delivery by its very nature - it was designed for short messages :lol: and the protocol assumes that error-checking (and also correction even at the block level) is not required. The only thing you can check in the UDP package is the actual checksum to tell if the block is bad or not :lol:
Need Pi spray - these things are breeding in my house...

epoch1970
Posts: 3096
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Does a Raspberry multitask during a PING?

Sat Mar 16, 2019 6:24 pm

Pinging the Internet every 5 secs, that's not too neighborly. Feel free to ping your own router to death, however :D

Perhaps you can check the connection status with something like netstat instead?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

charleslinquist
Posts: 107
Joined: Wed Sep 05, 2012 12:43 pm

Re: Does a Raspberry multitask during a PING?

Sat Mar 16, 2019 7:44 pm

To the comment that a "ping is not too neighborly" - does a few bytes of data every 5 seconds "hurt" the net, or affect other users more than streaming a live video on YouTube? If that is true, please educate me as to why.

I understand that UDP packets are not ACKed. That is why I don't know if my video is getting through. I need to know - at the Raspberry end, if the video it is sending out is being received by the intended (or ANY) recipient. I need to know because I need to re-establish the SSH connection. Perhaps I'm not really using UDP at all. I'm using a webRTC server running in the Raspberry to stream live video to my web browser.

Netstat hasn't proved to be reliable. I'm connecting to a 4G/LTE network (Verizon) through a Pantech 925 USB 'dongle'. The Pantech appears to the Raspberry as eth1. When the Verizon signal 'disappears', ifconfig still shows eth1. I get no indication that the connection is gone, other than the fact that I can no longer ping any outside server. I'm connecting via a reverse SSH tunnel using an Amazon ec2 server.

When the Verizon signal "went away" and later "reappeared", the connection would not re-establish itself unless I ran autossh again. That re-connected me to the Amazon server. My 'watch' script checks for outside connection, and when the ping fails and then returns a zero erorr value, I re-issue the autossh command and the connection is restored. It should be noted that I already have autossh set to retry, but that doesn't seem to do it. My autossh command starts with -

autossh -o "ServerAliveInterval 10" -o "ServerAliveCountMax 99" -N -R 0.0.....................

Any help would be appreciated.

epoch1970
Posts: 3096
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Does a Raspberry multitask during a PING?

Sat Mar 16, 2019 8:53 pm

But why don’t you heartbeat through the SSH tunnel?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

Return to “Networking and servers”