Page 1 of 1

ESP-IDF UDP

Posted: Thu Mar 05, 2020 9:54 pm
by Kaisha
I was looking to use UDP for communication between multiple ESP32 chips. The only example I could find was the lwip/sockets one, which seems like a lot of overhead/resources for some very small/simple UDP packets. Is there any lower level/simpler API that could be used instead?

Re: ESP-IDF UDP

Posted: Sat Mar 07, 2020 2:34 am
by PeterR
Whats not to love about:

Code: Select all

socket(AF_INET, SOCK_DGRAM, 0);
?
What else do you have going on that would stop you using Berkley sockets?
Socket storage is not huge. Buffer allocation may be an issue though.
re: Resource utilisation: You used to be able to change the Ethernet RX/TX buffers in 3.x. Not found/confirmed that option in 4.x.
You can change Wifi buffers in 3.x and 4.x. I know that Ethernet buffers changes wear well (for my application which has multiple sockets), not so sure about wifi.
It does depend what you are doing but are you really resource constrained?
EDIT: To be clear, you do get a big RAM hit when you first use the lwip stack on Ethernet. This includes some large static stuctures and larger dynamic buffers, the latter you can control through menuconfig (3.x). Wifi uses even more memory for Wifi functions and also dynamic wifi buffers. It is Wifi's nature (regardless of processor) I am afraid to trash your memory.

Re: ESP-IDF UDP

Posted: Tue Mar 10, 2020 12:32 pm
by Kaisha
I just don't like sockets or LWIP. I've used both before, they often have hard to find errors and quirks and the spaghetti code mess that is their implementation makes it near impossible to debug.

I'd prefer to manage my own buffers.

Sadly it seems that it is not supported :(

Re: ESP-IDF UDP

Posted: Wed Mar 11, 2020 11:11 am
by PeterR
Well, that is a point of view I guess.
I am guessing however that n thousand people using, testing and perhaps contributing to lwip would produce a better result than you or I.
The raw emac & phy interfaces are open to all '/components/ethernet' and so you can bypass lwip & sockets should you wish.

Re: ESP-IDF UDP

Posted: Sat Mar 14, 2020 1:48 pm
by Kaisha
Thank-you, I'll take a look.