how to resolve packet loss issue?
how to resolve packet loss issue?
Use TCP socket.
I use this function "len = send(connect_socket, recvbuf + (count - to_write), to_write, 0);" to send data to PC server.(recvbuf almost 20~30KB)
Sometimes, It seems that the function "send" return ok. But the data that PC server got has lost some packet.
How could i resolve this issue?
Thanks!
I use this function "len = send(connect_socket, recvbuf + (count - to_write), to_write, 0);" to send data to PC server.(recvbuf almost 20~30KB)
Sometimes, It seems that the function "send" return ok. But the data that PC server got has lost some packet.
How could i resolve this issue?
Thanks!
Last edited by alvin_xie on Fri Jun 22, 2018 12:23 am, edited 1 time in total.
Re: how to resolve packet loss issue?
Not really enough to go here (opinion). Is this a TCP or UDP socket? What makes you think that packets get lost? Are you checking the return code from send()?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: how to resolve packet loss issue?
Compare the file before send and received, it is different.The file has lost some string after received.kolban wrote:Not really enough to go here (opinion). Is this a TCP or UDP socket? What makes you think that packets get lost? Are you checking the return code from send()?
Re: how to resolve packet loss issue?
Over multiple tests, is it the same "piece" of the received file that differs from the original file? Can we tell where data is being lost? Are you logging the lengths of received data and sent data? I'd like to determine whether the problem is in transmitting data or writing files. For example, if the file writing wasn't correct then that may also manifest as missing data. If we can see a match between sent data size and received data size that might be very useful.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: how to resolve packet loss issue?
Maybe it's the program on the PC. Maybe it times out on a recv and closes the file instead of trying another read. Maybe somebody set the recv timeout too low and thought any non ok return meant it was done. Hard to tell from the description of the problem.
John A
John A
Re: how to resolve packet loss issue?
Over multiple tests, is it the same "piece" of the received file that differs from the original file?kolban wrote:Over multiple tests, is it the same "piece" of the received file that differs from the original file? Can we tell where data is being lost? Are you logging the lengths of received data and sent data? I'd like to determine whether the problem is in transmitting data or writing files. For example, if the file writing wasn't correct then that may also manifest as missing data. If we can see a match between sent data size and received data size that might be very useful.
-->the file is different ever time, and the "piece" of the received file that differs from the original file is not the same.
PC use a sockettool to recevie. ESP32 send function return the right lenth(the return value of "send" is the size of file),but PC sockettool do not get the right lenth.
Re: how to resolve packet loss issue?
PC use a sockettool creat TCP server,ESP32 use as client, connect to PC TCP server, and send a 20-30KB file,(file is a picture,BASE64 format).fly135 wrote:Maybe it's the program on the PC. Maybe it times out on a recv and closes the file instead of trying another read. Maybe somebody set the recv timeout too low and thought any non ok return meant it was done. Hard to tell from the description of the problem.
John A
use function "len = send(connect_socket, recvbuf + (count - to_write), to_write, 0);" , the len return the right sizeof "recvbuf".
But sometimes PC server do not get enough length of the file that ESP32 send.
note: ESP32 and PC connected to the same Router.
Is it clearly description?
Thanks,
Re: how to resolve packet loss issue?
I stared at this for a while and can't figure out the logic....
"len = send(connect_socket, recvbuf + (count - to_write), to_write, 0);"
Assuming the recvbuf is actually the sendbuf, and assuming you are in some loop sending "to_write" number of bytes each time, I can't understand how "recvbuf + (count - to_write)" is computing the pointer of the buffer to send.
John A
"len = send(connect_socket, recvbuf + (count - to_write), to_write, 0);"
Assuming the recvbuf is actually the sendbuf, and assuming you are in some loop sending "to_write" number of bytes each time, I can't understand how "recvbuf + (count - to_write)" is computing the pointer of the buffer to send.
John A
Re: how to resolve packet loss issue?
count = total
to_write = remaining
to_write -= len
to_write = remaining
to_write -= len
Re: how to resolve packet loss issue?
Makes sense now. to_write = count in the beginning and decremented by len for each send.WiFive wrote:count = total
to_write = remaining
to_write -= len
Without seeing the rest of the code that escaped me.
Who is online
Users browsing this forum: amiral, Orange_Murker and 100 guests