[Interest] Packet arrival-time resolution? QUdpSocket

Konrad Rosenbaum konrad at silmor.de
Mon Nov 27 16:45:01 CET 2017


On Mon, November 27, 2017 15:05, Jason H wrote:
> I was wondering what the maximum packet arrival time granularity is for Qt
> (On linux) using a normal timestamp, I can easily do 1ms. However if I was
> dealing with a raw socket descriptor, timing below this there is a ioctl()
> call I can do to get a lower resolution for the packet arrival time. I'm
> not sure how well this would play with Qt's internals though. For now my
> packet is UDP,  but if needed, I'd like to be able to extend it to TCP.
> I'm trying to time sync 2-3 systems on the same LAN. Ultimately, actual
> time of day isn't needed, just the amount of time of travel between the
> hosts. On a RaspberyPi zero
>
> Has anyone done anything like this? Any tips? Many thanks in advance.

Yes, the NTP people have done this. Extensively over several decades.
Please defer to their expertise and use NTP for time sync. ;-)

Using TCP for this purpose is really a bad idea too - because of the built
in delays and repeat intervals.

As for estimates of accuracy:

If you are not a real-time process you can rely on 100ms accuracy 99% of
the time if the system load is low; anything below 10ms is simply noise.
If system load is high: forget about it, your data is worthless!

If you use TCP this amount increases by a factor of at least 10 if both
computers are on the same LAN segment, worse if there are several busy
segments in between.

You need real-time and a really intimate understanding of network
behavior, advanced statistics, as well as the system clock and its various
system calls for getting and setting time (there are about a dozen!).
Otherwise you will make your clock just more unreliable.

There are probably ready made NTP packages that you can use. Use them.

   regards, Konrad




More information about the Interest mailing list