Slow ethernet?

16 Mar 2011

Hi guys!

I have been playing around with the mbed and a magjack from sparkfun. I used the FSHandler example to get a very simple webserver running from my mbed. I wanted to test the speed, so I put a 1 megabyte jpeg on the onboard flash chip, and tried downloading it. I was averaging about 10 kb/s. I thought maybe the flash chip was the bottleneck, so I hooked up a USB flash drive and tried hosting off that, and i got similar results. (Although i did see a peak of about 120kb/s for 1-2 seconds)I also tried a very simple web client example that tries to download the page at google.com. It took about 60 seconds to load 4096 characters from google...

Am I doing something wrong, or is this normal? Surely a 100 MHz ARM Cortex M3 should be able to do better than THAT?

(would hooking up the magnetics improperly hurt performance? because i am unsure if i hooked them up correctly, as i was cutting corners because i was so excited :D)

Thanks guys

EDIT: here is the client code:

#include "mbed.h"
#include "HTTPClient.h"

HTTPClient http;

int main() {
    char buffer[4096];
    char * url = "http://www.google.com/";
    
    printf("Aquiring IP and attempting to access webpage...\n");
    http.get(url, buffer, 4096);
    printf("Downloaded from %s:\n%s\n", url, buffer);
}
16 Mar 2011

kb = kilobits?

Note too the default MTU size (recently increased in a new/beta version)

16 Mar 2011

Hi John,

I've been doing some experiments with the low level ethernet drivers which show good results:

Seemingly can max out a 100Mbit link :)

So I suspect the bottlenecks are higher up, in the tcp/ip or http server itself (I don't know this codebase myself). I also wouldn't be surprised if any inefficiencies may be compounded by some sort of server rate limiting kicking in to try and avoid packet resends, and therefore it being slowed down at that level too. Should be scope for some great improvements.

Simon

16 Mar 2011

john loopah wrote:

(Although i did see a peak of about 120kb/s for 1-2 seconds)I also tried a very simple web client example that tries to download the page at google.com. It took about 60 seconds to load 4096 characters from google...

No, the network is faster than that. I see turnaround times below one second (I call a google web service, and it takes about 300 ms to deliver 2k of data).

john loopah wrote:

#include "mbed.h"
#include "HTTPClient.h"

HTTPClient http;

int main() {
    char buffer[4096];
    char * url = "http://www.google.com/";
    
    printf("Aquiring IP and attempting to access webpage...\n");
    http.get(url, buffer, 4096);
    printf("Downloaded from %s:\n%s\n", url, buffer);
}

I think your code is missing the Net::poll calls which execute the network stack functions.

17 Mar 2011

steve: kb = kiloBYTES, sorry about that i have updated my libraries, and there isnt any significant change.

Simon: That is great. I tried your benchmark and got similar results, around 95000kbit/s. Now, correct me if I am wrong, but this is proving that the hardware is not at fault for the low speeds, which means it is software based.

hendrik: You see those speeds using the code I posted? Wow, seeing as it takes me some 200 times longer. I was under the impression the Net::poll() was only used in a server, because the client code I found didnt use it, but the server code from the same poster (donatien garnier) did.

I dont think I am the only one having this problem, as I remember seeing a thread similar to this before (although I cant seem to find it...) What would you recommend I do? I am messing around with lower level ethernet stuff, but I dont know all that much C, and I know nothing about the ethernet protocol, so this would be a huge amount of work for me.

Thanks for the help guys

17 Mar 2011

john loopah wrote:

You see those speeds using the code I posted? Wow, seeing as it takes me some 200 times longer.

No, it's my own code (using the SimpleWebService library). I haven't tested with large data, though.

I think what you see is the same problem as described here.

john loopah wrote:

I was under the impression the Net::poll() was only used in a server, because the client code I found didnt use it, but the server code from the same poster (donatien garnier) did.

Actually it's only needed when doing asynchronous calls. Since you do a synchronous call, you don't need it. But since you see the problem mentioned above, you either need to switch to HTTPStream or do the HTTP handling by yourself - and then you will need the Net::poll() cals. (If you want to do the latter, look at the SimpleWebService library, or at the TCPLineStream library - they can serve as examples.