Page 1 of 1

raw lwip socket very slow

Posted: Fri Sep 20, 2019 2:27 pm
by pacoandres
I'm working on a project with an esp32-cam that sends images through lwip sockets

The problem is that sending is very slow. I've measured the time that the send function takes for the image buffer obtaining an average bandwidth of 400kb/s.

I've tried to modify some of the socket options, send buffer, wait timeout, etc. with no luck.

Then I decided to test one of the esp32-cam that are on the internet (https://github.com/RuiSantosdotme/ESP32-CAM-Arduino-IDE) and surprisingly it has an average bandwitdh of 2Mb/s, measuring the time that httpd_resp_send_chunk takes for the image buffer, which is the speed I need.
It's strange because this function encodes the image data and should be slower.

I've search in the esp_http_server code for differences between the use of sockets in this library and my project. But I couldn't find them.

I've also analized the traffic with wireshark. In both cases the image buffer is splitted in blocks of 1430 bytes, but with httpd_resp_send_chunk takes much less time.

Does anybody know why httpd_resp_send_chunk is that fast and why I can't reach this transfer speed?

Thanks.

Re: raw lwip socket very slow

Posted: Sun Nov 24, 2019 7:47 am
by pacoandres
This is not a solution, only a workaround.

Using UDP sockets I can get those speeds. But now I don't know if the packet arrives or not.

Re: raw lwip socket very slow

Posted: Mon Nov 25, 2019 3:38 am
by ESP_Angus
Hi pacoandres,

Impossible to tell without analyzing your code, and possibly difficult even then. However you may find some of the tips here helpful:
https://docs.espressif.com/projects/esp ... timization

(Note: this guide was only added for the IDF master branch, but most of the tips here apply to earlier versions as well.)

Angus