mbed Ethernet TCP is really slow

06 Feb 2012

I know this topic has come up in other old posts but it has never been fully answered (or at least that I've found). I've been investigating comms using TCP communications to an application running on a PC. This is something I've done on other processors for live I/O control of robotic systems with great success. I am hoping the mbed can replace my previous processor as it has more useful features.

Sending a packet to the mbed and then having it transmit a reply I am getting a poor 4 packets/second out of it. On my other processor (which is actually lower specs) I get >250/sec so I know the comms+pc app are up to the task.

Investigating further I found that if I remove the reply from the mbed back to the PC I get around 3000 packets/sec transmitted to the mbed and these get received and processed ok by it. As soon as I reply back to the PC this drops back to 4. I came across the TCP_TMR_INTERVAL constant in the tcp_impl.h file and thought I was onto something as this is set to 250ms and wondered if it was something to do with the send buffer only getting checked 4 times a second, but changing this setting made no effect to throughput!

If anyone has any thoughts then please respond.

I've obviously also read a bit about the raw lwip implementations that some people are using but have yet to see a working example using TCP, if anyone can point me in the right direction for this I would appreciate it!!

Paul

07 Feb 2012

Ok, I've found a relevant source for this information for anyone else who is looking for the same information.

I have based my code on the example given here: http://mbed.org/projects/cookbook/svn/EMAC/lwip/examples/purehttpd/main.cpp

I used a static IP for my tests by setting the IP's as follows:

IP4_ADDR(&netmask, 255,255,255,0);
IP4_ADDR(&gateway, 10,0,0,1);
IP4_ADDR(&ipaddr, 10,0,0,2);

And then instead of starting DHCP I manually bring up the interface:

//dhcp_start(netif);
netif_set_up(netif);
printf("Is Up: %d\n", netif_is_up(netif));

I think where I might have been going wrong before was I was including the wrong library (or part of library?). I used the following link when importing the LWIP library into my project and it worked great! http://mbed.org/projects/cookbook/svn/EMAC/lwip/trunk/Core

I've implemented my full packet structure parsing using this method and instead of getting just 4 packets/sec I am now getting 900 packets/sec!! A 'slight' improvement!

07 Feb 2012

Hi Paul

I got the problem when I send more than 4 segment of TCP. I capture tcp with wireshark. It show a MSS=536 and it send only 3 segment the rest is drop. I have post in http://mbed.org/forum/bugs-suggestions/topic/1980/?page=1#comment-13249 and cannot find the answer.

Can you give more hint or some example? This will help a lot of people who struck in these TCP problem.

07 Feb 2012

Hi, I'm not sure if the two problems are related, mine was purely a speed/performance issue, dropped segments where not an issue. I always got exactly what I sent out but the rate was limited.