AW: [En-Nut-Discussion] Standard C time functions for Nut/OS

Oliver Schulz olischulz at web.de
Thu Oct 16 21:39:48 CEST 2003


Hi Lars,

In the meanwhile you can download it from the Projects page of
www.ethernut.de (http://www.ethernut.de/arc/ostime.zip)
or look at this:

struct _sntpframe {
	u_char mode;
	u_char stratum;
	u_char poll;
	u_char precision;
	u_long root_delay;
	u_long root_dispersion;
	u_long reference_identifier;
	u_long reference_ts_sec;
	u_long reference_ts_frac;
	u_long originate_ts_sec;
	u_long originate_ts_frac;
	u_long receive_ts_sec;
	u_long receive_ts_frac;
	u_long transmit_ts_sec;
	u_long transmit_ts_frac;
};

The difference is, that the SNTP frame needs for each field mode, stratum,
poll and precision exactly one byte (u_char). The fields root_delay,
root_dispersion and reference_identifier are defined as 32 bit in the rfc,
so you must use u_long, or similar.
Overall it's a difference of 8 bytes at the beginning of the frame.
Therefore your code used the receive_ts instead of transmit_ts, what only
worked, if the server fills in the receive_ts.

Regards,
Oliver.

-----Ursprungliche Nachricht-----
Von: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de]Im Auftrag von Lars Andersson
Gesendet: Donnerstag, 16. Oktober 2003 21:11
An: en-nut-discussion at egnite.de
Betreff: RE: [En-Nut-Discussion] Standard C time functions for Nut/OS


Hi Oliver,
I would really appreciate if you would be so
kind as to donate the correct version of
the SNTPFRAME struct.

Thanks in advance,
Lars H. Andersson

-----Original Message-----
From: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de] On Behalf Of Oliver Schulz
Sent: Thursday, 16 October, 2003 08:39
To: en-nut-discussion at egnite.de
Subject: [En-Nut-Discussion] Standard C time functions for Nut/OS


Hi All,

I nearly finished the development of the standard c time functions. I
compared several implementations from MS, Borland, ... written for a old
system called "DOS". It was a bit tricky because of the massive
different calculations for converting the seconds counter to date/time
including leap year and so on.

But I implemented also the features for timezones and daylight saving
and added a correct version of Lars Anderson's SNTP idea (sorry Lars,
but your SNTPFRAME struct was wrong).

BTW, while testing the SNTP, I discovered that Win NT/2000 servers
respond to a SNTP packet sent to the broadcast address
(255.255.255.255). So if you have at least one server in your LAN, you
don't need to add official IP addresses for (S)NTP servers in your code.

Hopefully I can manage to write some readme files today and send my
modifications to Harald.

Oliver.
_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion


_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list