cancel
Showing results for 
Search instead for 
Did you mean: 

Why would I receive 2 unlinked netbufs for one packet transmission?

MStra.3
Associate III

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?

1 ACCEPTED SOLUTION

Accepted Solutions
alister
Lead

>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.

View solution in original post

6 REPLIES 6
alister
Lead

>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.

MStra.3
Associate III

@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.

MStra.3
Associate III

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?

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.

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!

MRost
Associate

Hello MStra.3.

change this define TCP_MSS 

Own project\Middlewares\Third_Party\LwIP\src\include\lwip\opt.h -> #define TCP_MSS