DEMO - RFC 2030 (SNTP) Simple Network Time Protocol with UDP packets over port 123
Beau Schwabe
Posts: 6,566
Has anyone attempted using ICMP protocol with the Spinneret? ... Specifically to receive a Time stamp from the Internet? ... To eventually auto set/sync the built in RTC on the Spinneret.
Just curious.
Edit Update: 02/08/2011
See this link further down in this thread.
Just curious.
Edit Update: 02/08/2011
See this link further down in this thread.
Comments
http://www.agaverobotics.com/spinneret/datetime.aspx
I did the same kind of thing to find my IP.
http://www.agaverobotics.com/spinneret/myip.aspx
http://tuxgraphics.org/electronics/200710/avr-ntp-clock.shtml
or
http://3meterclock.com
I need to find time to get my head around it as well.
Excellent, this will be an perfect match with the spinneret.
http://xxxxxxxxx
Thanks (I think)
"...I don't have an RTC on my board,..." - If your using a Spinneret, then there is an RTC built-in to the board.
BTW) Without providing code, nobody can benefit from your solution to keep your server up and running.
Reference: (See page 4 for RTC)
Spinneret PDF
I'm happy to share what I did, it's very simple. Just send a dummy (contents don't matter, it's just discarded anyway) UDP packet to a TIME server (list is here: http://tf.nist.gov/tf-cgi/servers.cgi) on port 37. Listen for a UDP packet on port 37. You'll receive a 12 byte packet (4 byte payload) containing a big-endian value representing the number of seconds since midnight Jan 1, 1900.
[NOTE: I suspect there is a bug in the WizNet driver, but I haven't had a chance to confirm & repair. Don't try to send a packet with an empty payload, be sure to have at least one byte payload]
At the moment, I'm prototyping a dozen things all at once, and my code is a disaster: a rudimentary HTTP server, DHCP client, TIME client, UDP streaming client, bootloader over Ethernet, and a few more. If actual code for this TIME client will be helpful (beyond the simple description above) I'll take the time to clean up what I have, modularize it and post it. If it's not needed (now) then I'll wait until I go through and scrub my existing code and then post it.
@Timothy: I think I see you in the other end of the rabbit hole I'm stuck in. I'm trying to figure out the same thing myself: how to have multiple applications/protocols using the WizNet module when only one cog can be running the driver. I'm reluctant to build a huge loop that looks for every possibility and dispatches accordingly. I'm concerned that would make the response of anything that actually is active unsatisfactory. I'm new to the Propeller, so still think in terms of interrupts. That might be my mistake, but I'm thinking it also might be that in this case, where a resource (the WizNet) is limited, one can't use the same solution (start another cog) that allows the Propeller to not need interrupts. I'm open to ideas at this point.
As noted earlier, I'm using the simpler, less accurate TIME protocol. For my needs, it's adequate.
Thanks, attached is a version that will work with the Spinneret. The returned time is in RFC-868 format where the 32 bit binary value represents the number of seconds since Jan 1st, 1900 with an accuracy of 1 second.
What concerns me is that this protocol is being phased out, and there may be others to choose from. For example ... .RFC-1305 ... this protocol uses port 123 (instead of 37) and returns a 64 bit binary value representing the number of seconds since Jan 1st, 1900 with an accuracy of 200 pico seconds.
Another one to look at might be RFC-867 ... this server listens on port 13 and returns the TIME stamp in standard ASCII characters over a tcp/ip or udp/ip connection.
"I just don't have the time right now".
Note: The same server (64.147.116.229) is used and can be located among several other time servers here: http://tf.nist.gov/tf-cgi/servers.cgi
The SNTP time is returned as a 64 bit standard time stamp, but for this application the fractional time data is omitted. The date and time is decoded from the 'Transmit Timestamp' and the 'time of flight' data is available to be derived but it is not implemented in this example.
In the next update >>HERE<<I will implement a method that will allow the Spinneret to set/sync it's own RTC (Real Time Clock) over an internet connection.
You can compare the output results to this sight: http://wwp.greenwichmeantime.com/
PST output example: