Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using local port of 123 for UDP listening #27

Open
JGifford opened this issue Apr 5, 2024 · 3 comments
Open

Using local port of 123 for UDP listening #27

JGifford opened this issue Apr 5, 2024 · 3 comments

Comments

@JGifford
Copy link

JGifford commented Apr 5, 2024

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.

NTP/NTP.cpp

Line 54 in 564a820

udp->begin(NTP_PORT);

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.

@JGifford
Copy link
Author

JGifford commented Apr 5, 2024

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

@sstaub
Copy link
Owner

sstaub commented Apr 5, 2024

The port number is fixed by design, see RFC5906. You can change the NTP port also in the ntp.h line 41.

@JGifford
Copy link
Author

JGifford commented Apr 9, 2024

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants