3

I have to measure and verify the latency of messages being sent wirelessly via WiFi/Bluetooth from smartphone to pc. The distance varies between 5 and 10 meters.

Example: message sent from smartphone at time X, received and processed at time Y. Duration: 35ms.

Since these messages are non-trivial (safety and security commands to further machines) its neccesary to synchronize the time between the smartphone and the pc to the most precise accuracy(milliseconds).

This was an easy task using net time for two PCs connected via LAN, but I'm uncertain with smartphones using iOS/Android..

Is it accurately enough to lets say sync both, smartphone and PC with NTP time, or do you know a better way to synchronize time between them?

From what I read, synchronizing time with NTP provides accuracy from ~ 1 to 20 ms. But this range is too vague..

Does anyone had similar problems?

Gannic
  • 263
  • 1
  • 3
  • 10

2 Answers2

1

Must this all be handled over the network or have you considered a physical timing trigger between the two?

If they are located near each other, I would recommend using a O-Scope. Sending a timing pulse from the phone's headset saying the message was sent. Then a Pulse from the PC that it was received and processed, via serial port or such.

If you use this route, you would want to take into account the latency between when the SW sends the command and when the pulse is sent out the hardware. I would do this using a tight loop that just toggles the signal, then see what the frequency is. Your latency for each would be half the period. And your total latency would be the difference between the PC and Phone's latency (which could be positive or negative).

  • 1
    No, it does not have to be handled over the network. I do consider some physical timing triggers, but I didn't consider an oscilloscope. At first, I thought of something like a debug brigde, but then I don't want to falsify any values. So you say NTP sync is not an accurate approach? – Gannic Nov 05 '15 at 08:15
  • 1
    I'm not saying NTP isn't accurate, actually I'm not sure about it. I'm just a fan of KISS... and physical triggers seams like a simple and accurate way to go. – NickOverflow Nov 05 '15 at 18:43
  • Yes, you are right. I really like this idea. Is it also possible to do some automatic testing with an o-scope with this scenario? Also can the results be some what exported, or do you have to manually compare the difference of the timing pulses? – Gannic Nov 06 '15 at 08:48
  • With my scope I can manually measure using the cursors. But the method I'd prefer, is to use the Math function to combine the 2 signals. After they are combined it can automatically measure the pulse width. Both Exporting and Math will depend on the scope, with my Tektronix scope, I can export a Image or CSV file. – NickOverflow Nov 08 '15 at 05:47
1

With a rooted Android smartphone, it is possible to use PTP to synchronise the time between itself and a computer. PTPd (https://github.com/ptpd/ptpd), or PTP daemon is the implementation of the protocol. It is able to achieve micro- and nano-second accuracy which is good news if you're measuring on the milli-second level.

The only caveat is that it only works on Ethernet and WiFi - synchronising on 4G and 5G networks seems to not function at all.

poabloa
  • 11
  • 3