2021-09-27 04:26 PM
I am putting a Webserver in a STM32F407. I have static and dynamic pages working and am now working on a file upload function. The browser sends me a single packet that is 887 bytes long according to Wireshark. I am using Netconn with LWIP so when I call netconn_recv, I only get 536 bytes in the first call then 297 bytes in the second call. It's clear that these are supposed to be connected together (printed them in the debugger).
There is no way to see that these should be connected to each other. With both packets the Len and Tot_Len are the same! Also they are not linked to each other...two separate netbufs!
Any ideas?
Solved! Go to Solution.
2021-09-27 05:36 PM
>There is no way to see that these should be connected to each other
TCP is a stream. So long as all the bytes arrive and in order, lwIP has done its job.
2021-09-27 05:36 PM
>There is no way to see that these should be connected to each other
TCP is a stream. So long as all the bytes arrive and in order, lwIP has done its job.
2021-09-28 08:33 AM
@alister OK, I re-read the LWIP wiki and I guess I am not supposed to have any expectations on how much data is given to me at a time regardless of the size chunk that was sent.
So I have one question. How am I supposed to figure out when I receive a chunk that I have not received everything the sender sent? In my case I am receiving a POST upload.cgi. It has a "Content Length" of 192 which doesn't give me a clue as to how long the packet should be. In this case it's not the file size because the filename is blank.
Mike.
2021-09-28 11:01 AM
I ended up answering my question by doing a lot of digging on the web and running trials with Wireshark... Are we having fun yet?
2021-09-28 03:29 PM
https://datatracker.ietf.org/doc/html/rfc7230#section-3
You parse the receive stream, get the Content Length header value, and use that from the start of the body which is delineated from the headers by two CRLF sequences.
2021-09-28 04:15 PM
I hadn't noticed that, but I did see that the body is bounded by Boundary Markers which are included in the Content Length, so I am parsing the stream for the Boundary Markers to find the uploaded file data.
Thanks for your help!
2021-11-11 03:00 AM
Hello MStra.3.
change this define TCP_MSS
Own project\Middlewares\Third_Party\LwIP\src\include\lwip\opt.h -> #define TCP_MSS