SOLVED
The issued came from a bug in the lwip file dns.c using ip_addr_cmp instead of ip_addr_eq in my version which was wrong
Updated to:
/* Check whether response comes from the same network address to which the
question was sent. (RFC 5452) */
if (!ip_addr_eq(addr, &dns_servers[entry->server_idx])) {
goto ignore_packet; /* ignore this packet */
}
Hi!
I'm running a webserver on a ESP32-S3-Wroom-1 using Wiznet W6100 ethernet module. I'm trying to receive ntp sync via pool.ntp.org.
It works fine when running on Wifi-STA static and dhcp IP and also on with ethernet dhcp. The problem occurs when running ethernet with static ip, then it does not work.
This is debug log from when it does not receive the ntp sync:
I (4900) esp_netif_handlers: eth ip: 192.168.1.100, mask: 255.255.255.0, gw: 192.168.1.1
I (4909) network_cfg: IP assigned statically.
I (4914) network_cfg: Ethernet Got IP Address
I (4919) network_cfg: ~~~~~~~~~~~
I (4923) network_cfg: ETHIP:192.168.1.100
I (4927) network_cfg: ETHMASK:255.255.255.0
I (4932) network_cfg: ETHGW:192.168.1.1
I (4937) network_cfg: ~~~~~~~~~~~
I (4941) network_cfg: Ethernet Main DNS: 8.8.8.8
...
udp_bind(ipaddr = 192.168.1.100, port = 0)
udp_bind: bound to 192.168.1.100, port 59533)
udp_send: added header in given pbuf 0x3fcd192c
udp_send: sending datagram of length 123
udp_send: UDP packet length 123
udp_send: UDP checksum 0x6da8
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd192c
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0x7495
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd192c
udp_send: sending datagram of length 123
udp_send: UDP packet length 123
udp_send: UDP checksum 0x6e29
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd192c
udp_send: sending datagram of length 123
udp_send: UDP packet length 123
udp_send: UDP checksum 0x6e29
udp_send: ip_output_if (,,,,0x11,)
udp_send
udp_send: added header in given pbuf 0x3fcce65c
udp_send: sending datagram of length 52
udp_send: UDP packet length 52
udp_send: UDP checksum 0x4a0e
udp_send: ip_output_if (,,,,0x11,)
udp_input: received datagram of length 52
UDP header:
+-------------------------------+
| 59533 | 514 | (src port, dest port)
+-------------------------------+
| 52 | 0x0e4a | (len, chksum)
+-------------------------------+
udp (192.168.1.100, 514) <-- (192.168.1.100, 59533)
pcb (192.168.1.100, 59533) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 5353) <-- (0.0.0.0, 5353)
pcb (192.168.4.1, 67) <-- (0.0.0.0, 0)
pcb (127.0.0.1, 32768) <-- (0.0.0.0, 0)
udp_input: calculating checksum
udp_input: not for us.
udp_send
udp_send: added header in given pbuf 0x3fcce65c
udp_send: sending datagram of length 40
udp_send: UDP packet length 40
udp_send: UDP checksum 0x6306
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd1ab0
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0xae9a
udp_send: ip_output_if (,,,,0x11,)
udp_input: received datagram of length 40
UDP header:
+-------------------------------+
| 59533 | 514 | (src port, dest port)
+-------------------------------+
| 40 | 0x0663 | (len, chksum)
+-------------------------------+
udp (192.168.1.100, 514) <-- (192.168.1.100, 59533)
pcb (192.168.1.100, 59533) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 5353) <-- (0.0.0.0, 5353)
pcb (192.168.4.1, 67) <-- (0.0.0.0, 0)
pcb (127.0.0.1, 32768) <-- (0.0.0.0, 0)
udp_input: calculating checksum
udp_input: not for us.
udp_send: added header in given pbuf 0x3fcd1a34
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0x7495
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd1a34
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0xae9a
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd1a34
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0xae9a
udp_send: ip_output_if (,,,,0x11,)
dns_enqueue: "pool.ntp.org": use DNS entry 0
udp_bind(ipaddr = 0.0.0.0, port = 35565)
udp_bind: bound to 0.0.0.0, port 35565)
dns_enqueue: "pool.ntp.org": use DNS pcb 0
dns_send: dns_servers[0] "pool.ntp.org": request
sending DNS request ID 17995 for name "pool.ntp.org" to server 0
udp_send
udp_send: added header in given pbuf 0x3fcce65c
udp_send: sending datagram of length 38
udp_send: UDP packet length 38
udp_send: UDP checksum 0x47c6
udp_send: ip_output_if (,,,,0x11,)
sntp_request: Waiting for server address to be resolved.
dns_tmr: dns_check_entries
dns_send: dns_servers[0] "pool.ntp.org": request
sending DNS request ID 17995 for name "pool.ntp.org" to server 0
udp_send
udp_send: added header in given pbuf 0x3fccd298
udp_send: sending datagram of length 38
udp_send: UDP packet length 38
udp_send: UDP checksum 0x47c6
udp_send: ip_output_if (,,,,0x11,)
dns_tmr: dns_check_entries
dns_send: dns_servers[0] "pool.ntp.org": request
sending DNS request ID 17995 for name "pool.ntp.org" to server 0
udp_send
udp_send: added header in given pbuf 0x3fcd192c
udp_send: sending datagram of length 38
udp_send: UDP packet length 38
udp_send: UDP checksum 0x47c6
udp_send: ip_output_if (,,,,0x11,)
dns_tmr: dns_check_entries
dns_tmr: dns_check_entries
dns_send: dns_servers[0] "pool.ntp.org": request
sending DNS request ID 17995 for name "pool.ntp.org" to server 0
udp_send
udp_send: added header in given pbuf 0x3fcd19ac
udp_send: sending datagram of length 38
udp_send: UDP packet length 38
udp_send: UDP checksum 0x47c6
udp_send: ip_output_if (,,,,0x11,)
dns_send returned error: Out of memory error.
and this is how it looks when using dhcp and it works:
udp_bind(ipaddr = 0.0.0.0, port = 0)
udp_bind: bound to 0.0.0.0, port 52911)
I (4765) SYSLOG: Syslog server set to 192.168.1.100:514
I (4771) RS485_ECHO_APP: Syslog task initialized.
udp_input: received datagram of length 308
UDP header:
+-------------------------------+
| 67 | 68 | (src port, dest port)
+-------------------------------+
| 308 | 0x5866 | (len, chksum)
+-------------------------------+
udp (100.67.11.165, 68) <-- (100.67.8.1, 67)
pcb (0.0.0.0, 52911) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 68) <-- (0.0.0.0, 67)
udp_input: calculating checksum
Custom DHCP Option: D5 50 62 02 D5 50 65 03
udp_send: added header in given pbuf 0x3fcd1f1c
udp_send: sending datagram of length 316
udp_send: UDP packet length 316
udp_send: UDP checksum 0x2840
udp_send: ip_output_if (,,,,0x11,)
udp_input: received datagram of length 308
UDP header:
+-------------------------------+
| 67 | 68 | (src port, dest port)
+-------------------------------+
| 308 | 0x5566 | (len, chksum)
+-------------------------------+
udp (100.67.11.165, 68) <-- (100.67.8.1, 67)
pcb (0.0.0.0, 68) <-- (0.0.0.0, 67)
udp_input: calculating checksum
Custom DHCP Option: D5 50 62 02 D5 50 65 03
sntp: Rejected 3.101.80.213 as NTP server #0 via DHCP
udp_send: added header in given pbuf 0x3fcd1900
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0x7495
udp_send: ip_output_if (,,,,0x11,)
dns_tmr: dns_check_entries
dns_send: dns_servers[0] "pool.ntp.org": request
sending DNS request ID 30340 for name "pool.ntp.org" to server 0
udp_send
udp_send: No route to 213.80.98.2
dns_send returned error: Routing problem.
I (5716) esp_netif_handlers: eth ip: 100.67.11.165, mask: 255.255.252.0, gw: 100.67.8.1
I (5717) network_cfg: IP assigned by DHCP server.
I (5720) network_cfg: Ethernet Got IP Address
I (5725) network_cfg: ~~~~~~~~~~~
I (5729) network_cfg: ETHIP:100.67.11.165
I (5733) network_cfg: ETHMASK:255.255.252.0
I (5738) network_cfg: ETHGW:100.67.8.1
I (5743) network_cfg: ~~~~~~~~~~~
I (5747) network_cfg: Ethernet Main DNS: 213.80.98.2
udp_send
udp_send: added header in given pbuf 0x3fcd1a2c
udp_send: sending datagram of length 52
udp_send: UDP packet length 52
udp_send: UDP checksum 0x4c7a
udp_send: ip_output_if (,,,,0x11,)
udp_send
udp_send: added header in given pbuf 0x3fcd1b40
udp_send: sending datagram of length 40
udp_send: UDP packet length 40
udp_send: UDP checksum 0x6572
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd1b30
udp_send: sending datagram of length 123
udp_send: UDP packet length 123
udp_send: UDP checksum 0xe41e
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd1b30
udp_send: sending datagram of length 123
udp_send: UDP packet length 123
udp_send: UDP checksum 0xe49f
udp_send: ip_output_if (,,,,0x11,)
udp_send: added header in given pbuf 0x3fcd1b30
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0x7495
udp_send: ip_output_if (,,,,0x11,)
dns_tmr: dns_check_entries
dns_send: dns_servers[0] "pool.ntp.org": request
sending DNS request ID 30340 for name "pool.ntp.org" to server 0
udp_send
udp_send: added header in given pbuf 0x3fcd1a2c
udp_send: sending datagram of length 38
udp_send: UDP packet length 38
udp_send: UDP checksum 0x35ad
udp_send: ip_output_if (,,,,0x11,)
udp_input: received datagram of length 102
UDP header:
+-------------------------------+
| 53 | 40615 | (src port, dest port)
+-------------------------------+
| 102 | 0x431f | (len, chksum)
+-------------------------------+
udp (100.67.11.165, 40615) <-- (213.80.98.2, 53)
pcb (0.0.0.0, 68) <-- (0.0.0.0, 67)
pcb (0.0.0.0, 52911) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 40615) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 5353) <-- (0.0.0.0, 5353)
pcb (192.168.4.1, 67) <-- (0.0.0.0, 0)
pcb (127.0.0.1, 32768) <-- (0.0.0.0, 0)
udp_input: calculating checksum
dns_recv: "pool.ntp.org": response = 194.58.205.148
sntp_dns_found: Server address resolved, sending request
sntp_send_request: Sending request to server
udp_send
udp_send: not yet bound to a port, binding now
udp_bind(ipaddr = 0.0.0.0, port = 0)
udp_bind: bound to 0.0.0.0, port 52912)
udp_send: added header in given pbuf 0x3fcce5b8
udp_send: sending datagram of length 56
udp_send: UDP packet length 56
udp_send: UDP checksum 0x9b0d
udp_send: ip_output_if (,,,,0x11,)
udp_input: received datagram of length 56
UDP header:
+-------------------------------+
| 123 | 52912 | (src port, dest port)
+-------------------------------+
| 56 | 0x258d | (len, chksum)
+-------------------------------+
udp (100.67.11.165, 52912) <-- (194.58.205.148, 123)
pcb (0.0.0.0, 52912) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 68) <-- (0.0.0.0, 67)
pcb (0.0.0.0, 52911) <-- (0.0.0.0, 0)
pcb (0.0.0.0, 5353) <-- (0.0.0.0, 5353)
pcb (192.168.4.1, 67) <-- (0.0.0.0, 0)
pcb (127.0.0.1, 32768) <-- (0.0.0.0, 0)
udp_input: calculating checksum
I (6603) time_handler: System time updated from NTP: 1743176346
I (6609) time_handler: NTP sync event posted to queue
sntp_process: Fri Mar 28 16:39:06 2025
, 794312 us
sntp_recv: Scheduled next time request: 60000 ms
udp_send: added header in given pbuf 0x3fcce5b8
udp_send: sending datagram of length 123
udp_send: UDP packet length 123
udp_send: UDP checksum 0xe49f
udp_send: ip_output_if (,,,,0x11,)
I (6764) time_handler: NTP server[0]: pool.ntp.org (194.58.205.148)
I (6765) time_handler: NTP sync completed with server: pool.ntp.org (194.58.205.148)
I (6769) time_handler: Updated last_sync to: 2025-03-28 16:39:06
I (6776) time_handler: UTC Offset: +01:00
I (6780) main: Setting RTC time from NTP: 2025-03-28 16:39:06
udp_send: added header in given pbuf 0x3fcd1b30
udp_send: sending datagram of length 198
udp_send: UDP packet length 198
udp_send: UDP checksum 0xf73e
udp_send: ip_output_if (,,,,0x11,)
I (6937) main: RTC time updated successfully.
Does anyone have any idea what could be the issue?
Thanks,
ESP-IDF v5.3 ESP32-S3 W6100 Static Ethernet SNTP error. [SOLVED]
-
espressoplease
- Posts: 1
- Joined: Fri Mar 28, 2025 2:52 pm
Who is online
Users browsing this forum: ChatGPT-User and 2 guests