Montecri / GNSSTimeServer

WiFi-enabled GNSS (GPS, BeiDou, GLONASS, Galileo) fed NTP/RDATE server based on ESP8266/ESP32 and Arduino
MIT License
137 stars 21 forks source link

Additional DHCP options to announce NTP Server address. #11

Closed mfreymond closed 1 year ago

mfreymond commented 1 year ago

DHCP has the ability to announce network time servers as part of the DHCP Offer.

Option 004 specifies servers that provide TIME/ITP (as per RFC 868). This is not a recommended protocol/service in a Windows environment.

Option 042 specifies servers that provide NTP/SNTP (RFC 1769). This is the preferred time service in a Windows environment.

By adding these options, pointing to the ESP8266's IP address, some devices would be able to automatically learn the time servers IP address without further configuration.

These DHCP options are specified in the DHCP RFC (RFC 2132).

Montecri commented 1 year ago

Hi!

Sounds like a very good addition. Will work on that and let this open until done.

Thanks!

mfreymond commented 1 year ago

I'm not really a developer, but from poking around, it looks like the changes might need to take place in this file:

https://github.com/esp8266/Arduino/blob/master/cores/esp8266/LwipDhcpServer.cpp

Lines 127-138 define the existing options, where they get utilized later on in the code.

Thanks

Montecri commented 1 year ago

Hi!,

After reading a bit about the option, my understanding is that they need to be pre-set on the DHCP server, it's not something that a DHCP client can announce itself so the DHCP server can replicate the info to other clients. Under this understanding, we have two scenarios and consequences:

GPSTimeServer as an Access Point client: The ideal situation would be to announce itself to the DHCP server from the AP as an NTP time server, but that is not supported, so, no action here.

GPSTimeServer as an Access Point itself: In this mode, clients in need of a time update would connect to it, receive the DHCP option 42 (since GPSTimeServer is also acting as a DHCP server in this scenario), then the connected client would understand that an NTP server is available. However, the only reason a client connects to the GPSTimeServer in AP mode is the explicit intent of obtaining time from it and nothing else, so it's safe to assume that the connecting client will already treat the AP as an NTP server anyway, so, no action here either.

Thanks!