NTP
NTP copied to clipboard
Using local port of 123 for UDP listening
Using Ethernet.h and NTP.h with an Arduino Uno R3 and an Ethernet Shield R3.
NTP client won't receive responses from remote NTP server when local/source UDP port is 123.
Changing line 54 to use a different local/source UDP port allows it to function. https://github.com/sstaub/NTP/blob/564a820bd313284cdb376ad158922577a52f3380/NTP.cpp#L54
Original, doesn't work with my hardware configuration:
udp->begin(NTP_PORT);
Changed, works with my hardware configuration:
udp->begin(8888);
Could we possibly create a mechanism to allow local modification of this local/source UDP port?
Example sketches available upon request.
As long as I start UDP with "random" (non-port 123) port after starting NTP, it works.
NTPinstance.begin();
Udp.begin(8888);
Would be nice to specify the local/source UDP port
The port number is fixed by design, see RFC5906. You can change the NTP port also in the ntp.h line 41.
Thanks for setting me straight about source and destination ports for NTP. I figured the source (client) port would be a random one but you're right--they're both supposed to be 123.
I'm starting to think that my issue is with Ethernet's UDP implementation. I can't seem to communicate to a remote NTP server unless I do something like this:
NTPclient:8888-->NTPserver:123
by putting the following code in my setup()
UDPinstance.begin(8888);