Page 1 of 1

ENOMEM when sending udp packet to disconnected address

Posted: Mon Sep 09, 2024 1:41 pm
by harrison
I'm using a WT-32-S1 to send udp packets to another device over ethernet.
When the other device is connected to the network packets send without issue every 100ms however when the device is not connected to the network I receive an ENOMEM error after only two packets are sent.

When lwip debugging is on I can see the issue is:

Code: Select all

etharp_query: could not queue the packet 0x3ffafcf8 (queue is full)
I've increased the ETH_DMA_TX_BUFFER_NUM to the maximum with no effect.

Code: Select all

lwip_sendto(54, data=0x3ffb02dc, short_size=2, flags=0x8 to=192.168.4.200 port=9999
pbuf_alloc(length=2)
pbuf_alloc(length=2) == 0x3ffafcf8
netconn_send
netconn_send: sending 2 bytes
UDP_SENDTO
pbuf_add_header: old 0x3ffafd40 new 0x3ffafd38 (8)
pbuf_add_header: old 0x3ffafd38 new 0x3ffafd24 (20)
ip4_output_if: en0
IP header:
+-------------------------------+
| 4 | 5 |  0x00 |        30     | (v, hl, tos, len)
+-------------------------------+
|        3      |000|       0   | (id, flags, offset)
+-------------------------------+
|   64  |   17  |    0xf045     | (ttl, proto, chksum)
+-------------------------------+
|  192  |  168  |    4  |  110  | (src)
+-------------------------------+
|  192  |  168  |    4  |  200  | (dest)
+-------------------------------+
ip4_output_if: call netif->output()
etharp_find_entry: found matching entry 0
pbuf_free(0x3ffafcf8)
pbuf_free: 0x3ffafcf8 has ref 1, ending here.
etharp_query: could not queue the packet 0x3ffafcf8 (queue is full)
pbuf_free(0x3ffafcf8)
pbuf_free: deallocating 0x3ffafcf8
E (4413) NETSTOP: Error occurred during sending: errno 12, -1

Re: ENOMEM when sending udp packet to disconnected address

Posted: Wed Sep 11, 2024 6:24 am
by ondrej
What IDF version do you use? And what do you mean by "the device is not connected to the network"? Do you mean the cable is unplugged from WT-32-S1? Could you please be more specific about your setup?

Re: ENOMEM when sending udp packet to disconnected address

Posted: Sat Dec 14, 2024 4:36 pm
by BenSuffolk
I believe the ENOMEM in this case is caused by the fact the ARP lookup queue is full. The fact the other device is no online, means there is no entry in the ARP table for it. So when you try to send a UDP packet it first needs to lookup the MAC address of the remote host in the ARP table. It's not in there, so it will queue a request to try and get it. You are sending packets quicker than the those requests are timing out so you are getting the ENOMEM response.