raw lwip socket very slow

pacoandres
Posts: 7
Joined: Fri Sep 20, 2019 9:28 am

raw lwip socket very slow

Postby pacoandres » Fri Sep 20, 2019 2:27 pm

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.

pacoandres
Posts: 7
Joined: Fri Sep 20, 2019 9:28 am

Re: raw lwip socket very slow

Postby pacoandres » Sun Nov 24, 2019 7:47 am

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.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: raw lwip socket very slow

Postby ESP_Angus » Mon Nov 25, 2019 3:38 am

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

Who is online

Users browsing this forum: No registered users and 41 guests