I want to receive image data through UDP communication via wifi.
Image data consists of 160*120, or 19,200 bytes.
So I sent the 19200-byte hexadecimal data to ESP32-CAM, and I did Udp.read(packetData,19200) (of course, I defined it as char packetData), and I didn't get UDP data from ESP32-CAM.
So I realized through many attempts that I can receive up to 1472 bytes of data as I reduced data.
I need to increase the number of bytes that I can receive to this maximum.
What should I do?
So far, I've increased the size of the rx_Buffer defined in WiFiUdp.cpp to 19200.
I used program 'Packet Sender'
If your MTU is 1500, you have 1500-20-8 = 1472 bytes for your data indeed.
Why don’t you send multiple frames ?
Thanks to your reply, I got to know the concept of MTU. Thank you.
Since the size of TX_Buffer is 1460, we send it several times, 1460 bytes each, but I hoped to receive it at once. Then would it be better to store it in a two-dimensional array with 1460 col and 14 (19200/1460) raws?
a 2D array does not mean much if the original data is "linear" (I imagine the framebuffer of an image), the data is sequential and you want to use it as such.
you could have some sort of protocol to send multiple packets due to the nature of UDP (no guaranteed delivery), so may be a header is sent first with information about the upcoming transmission (number for frames, length, ...)
That would not be necessary (as @J-M-L already indicated). Below some pseudo-code to demonstrate the idea how to receive a smaller number of bytes repeatedly and store it in a larger array.
static uint8_t image;
uint16_t position = 0;
if (position + data_len >= sizeof(image))
// do something to prevent overflow
// copy received data to image array
memcpy(&image[position], received_data, data_len);
position += data_len;
if (position >= sizeof(image))
// image complete
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.