TCPSocket available buffer

13 May 2011

I am uploading a file through a TCPSocket, but every time the sockets read function return less bytes than I have read from the file I need to reinitialize my filepointer. This takes time when the file is 70mb in size and slow down my upload speed.

I would like to have access to the size available to send to my TCPSocket. It seems to be possible deep inside the lwip library, but I cant seem to figure out a way to access it from my program.

Its used like this inside lwipNetTcpSocket( ... )

int outLen = MIN( len, tcp_sndbuf( (tcp_pcb*) m_pPcb) );

Any idea on how to access the socket buffer size available.

Tax

13 May 2011

Hi Tax

Can you clarify which direction you are sending the file, and can you say how long it takes in total - so the data rate can be calculated?

I'm looking into the performance of the lwip stack on the mbed and would be interested in your results.

Thanks
Daniel

13 May 2011

Thanx for your quick reply :)

I am uploading a file from a sd card. After having increased the SPI frequency to 10MHz and increased its lwip's memory to 10K I get upload speeds around 20000 bytes second.

My bottleneck now is that fseek takes alot of time and I need to call it every time I send more than the socket buffer can handle. Therefore I would like to know how much buffer is available.

Tax

13 May 2011

Hi Tax

Without any tuning, with a raw TCP socket sending to a PC running iperf, I got around 50 kb/s - I calculate your rate to be around 160 kb/s.

It seems very slow. I'm approaching this from a slightly different angle so I can't answer your question directly yet, but I will let you know if I find any improvement - your application is a good test case.

Regards
Daniel

13 May 2011

I think my bottleneck is my SD card.