select on udp recvfrom doesn't work ???

Jamon Camisso jamon.camisso-H217xnMUJC0sA/PxXw9srA at public.gmane.org
Tue Aug 10 22:49:12 UTC 2010


On 8/10/2010 5:50 PM, Dave Cramer wrote:
> On Tue, Aug 10, 2010 at 5:29 PM, Lennart Sorensen
> <lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org>  wrote:
>> On Tue, Aug 10, 2010 at 05:25:03PM -0400, Dave Cramer wrote:
>>> Is there some reason that doing using select does not see the data
>>> coming to a udp socket that is not connected, but is bound and is
>>> listening.
>>>
>>> I am broadcasting data to the socket. I have confirmed that if I don't
>>> use select that it receives data.
>>>
>>> What I am trying to do is synchronize multiple linux embedded systems
>>> to within 10ms. My thought is to use a UDP broadcast to start the
>>> synchronization then use the internal clocks. If anyone has any
>>> interesting ideas I'm open to suggestions.
>>
>> Have you heard of ntp?  It does just that, and way more accurately,
>> and is done by people that understand time synchronization.  Don't try
>> to reinvent a wheel, when you don't know how a wheel works.
>>
>
> That was pleasant .... if ntp worked I would use it. Yes it will
> synchronize the clocks but then what do you do.
>
> Lets say you want to do something on the same  125ms on multiple
> machines. Your first problem is getting a starting point. One would
> think you could just do gettimeofday until you get to the 0th
> millisecond of the second, however you quickly find out that
> gettimeofday can't be called that quickly. So how do you set the start
> point ? I have thought about this a little more than your flippant
> response.

It might have been flippant, but NTP will sync to achieve 
sub-millisecond accuracy on a robust LAN. If you run your own ntp server 
on said LAN you can speed up the sync process using the iburst option on 
clients. 1/8th of a second should be ok as long as you a) have a good 
drift file on the clients and b) have a stable clock in each system, 
plus a very precise and accurate ntp server to poll.

Lots of caveats, but I wouldn't completely write off NTP. If this is 
over the public internet, then all bets are off ;)

Have you considered a hardware ntp clocksource?

Jamon
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list