Re: CLOCK_MONOTONIC datagram timestamps by the kernel

From: Andi Kleen
Date: Mon Feb 26 2007 - 07:21:44 EST



Mr Anonymous,

>
> My app expects a stream of UDP datagrams containing compressed video.
> These datagrams have been time stamped by the source using a high
> resolution clock.

Why do you need another time stamp them?
>
> The video stream is played out in real-time. I buffer several packets,
> then repeatedly arm a one-shot timer (with TIMER_ABSTIME set) to wait
> until it's time to send the oldest packet.
>
> AFAIU, if I use the CLOCK_REALTIME clock in my app, and if the sysadmin
> changes the date, hell will break loose in my app.

Only if your app cannot handle time going backwards.

> I suppose that if I change sock_get_timestamp() in core/sock.c to call
> __get_realtime_clock_ts() instead of do_gettimeofday() I'll break 50
> billion applications (ping? traceroute?) that expect a struct timeval?

Not that many, but some probably.

Letting the kernel do the time stamping is usually quite useless anyways.
You can as well do it in your application when you receive it. After all
you're interested in when you can read the packet in your app,
not when the driver processes it.

The kernel time stamping is mainly for sniffing applications that want
to know exactly what's going on on the wire. But even then it's fairly
arbitary because it can be a long time between the packet arriving
on the PHY and being processed by the driver.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/