-->
Page 1 of 1

Multi competitor sports timer / wifi latency

PostPosted: Wed Dec 20, 2017 10:15 am
by warwickw
Hi, I'm considering developing a wifi sports timer for swimming competitions, where a touchpad and/or a human operated pushbutton will trigger a simple wifi transmission (on a dedicated SSID) from an esp8266 to a dedicated local server as the competitor finishes.

My open ended questions are: 1) What latency would you expect to see from a button push to a wifi transmission (the esp8266 does not need to be asleep/ low power) 2) how much variability would there be in this and 3) what happens if two units try to transmit at the same time.

Would I be correct in thinking that with a dedicated wifi network, transmission ranges of 10 metres max, and possibly just simple UDP connections, we are in the single millisecond range, or is that too optimistic. Results are typical expected to be accurate to 0.01 seconds (ignoring the human element of the button push!!)

Thanks in advance for any info, or indeed any alternative approaches. Similar products exist commercially, but I'm not sure if they take this approach or time 'locally' to each stopwatch and then transmit the results. I know that the 'start' signal is synced across all watches, so its effectively the same problem but in reverse?

Re: Multi competitor sports timer / wifi latency

PostPosted: Fri Dec 22, 2017 1:24 pm
by rudy
TCP will be reliable but at a cost, time. If for some reason the initial packet doesn't get there it will try again after a timeout. For this reason I would use UDP, but send three times. On the receive end be ready to accept more than one packet. Make the code so that it only acts on the first received packet.

It might be worthwhile to look into websockets. A connection could be kept open, so you don't need to establish a connection when using TCP. But I am not familiar what it does about missed packets.

I'm not sure if this will help you. https://gafferongames.com/post/udp_vs_tcp/

Re: Multi competitor sports timer / wifi latency

PostPosted: Fri Dec 22, 2017 8:11 pm
by dragondaud
According to https://sarwiki.informatik.hu-berlin.de/Packet_transmission_time_in_802.11 the time to send 1500 bytes at 54Mbps with 802.11g is only 326μs (millionth), so shorter packets would go even quicker. But, I would suggest you simply synchronize everybody with NTP, and send TCP packets with timestamps, and collate the results, without worrying about resending or collisions and such.