Number of TCP Socket Connections

22 Feb 2011

Hi all,

I have a HTTPServer running on my mbed - the problem occurs when you have two people try to get the same web page at the same time: the mbed crashes.

Does the TCP Socket API allow for multiple connection? Or does anyone know how to only allow one TCP connection at a time?

Thanks in advance.

22 Feb 2011

The NetServices library is configured to allow 4 parallel connections, IIRC. But the HTTPServer might be a different thing...

22 Feb 2011

It has been my experience so far that the HTTPServer barely works with one client connecting. I have a web page served by HTTPServer with a few RPCvariables that are fetched from mbed. The page works about half the time, the other times the mbed stops sending the page part way through. Once in a while it does a complete crash. This is with a single connection. The page is around 880 bytes.

23 Feb 2011

I created my own Handler so I could have dynamic pages. I've got the one page working - after having the same problem you had. It appears that the reliable limit on the send buffer is around 700. (As you have seen if the buffer is bigger it does sometimes send).

24 Feb 2011

I've spent quite a bit of time on this and have come to the conclusion that the mbed, using the libraries here, is painfully slow. I never would have guessed that a 100 Mhz ARM could be such a dog.

24 Feb 2011

Hi Tom, Tim,

We're just looking at ethernet at the moment, and seeing if we can move to supporting the full 1500 MTU, which might help things run much more smoothly. I'll post something when I've got a build for testing, and would be interested in the results.

Simon

24 Feb 2011

Hi Tim, Tom, All,

A test version of the mbed library with 1500 byte MTU ethernet support is now available for testing by anyone interested. To try it out, delete your mbed library from your program, choose "Import Library..." and use the URL http://mbed.org/projects/libraries-testing/svn/bugfix-670. This is a test version of the full mbed library, but with a re-written ethernet driver to support full 1500 MTU. (Note, it allocates more of the Ethernet/AHB1 RAM to achieve this)

I've run some initial tests and it seems to handle all packet sizes at volume quite happily. Would be interested how it functions with any of your projects.

Thanks, Simon

24 Feb 2011

Hi,

Here is the results of a little benchmark to see what throughput the ethernet driver transmit channel has:

/media/uploads/simon/ethernet-tx-benchmark.png

generated by:

Import programEthernetTxBenchmark

Simple text for Tx bandwidth of ethernet

Hopefully that looks pretty respectable (if i've got my numbers right!)

Simon

25 Feb 2011

I deleted the mbed library, imported the above bugfix-670, then renamed it mbed, compiled and ran my project. There's a slight improvement in operability, i.e. the network functions seem to be more stable and crash less, however the httpserver still is pretty painful. A simple webpage with 5 RPCVariables only loads sometimes.

Interestingly, once the page is loaded into the browser, variables can update on the page forever. (Javascript runnning in the browser is retrieving the variables from the mbed and displaying them in the appropriate spot on the page).

This is a huge improvement. The javascript timer kicks off the RPCVariable read function every 5 seconds. Previously it would only run a few seconds before crashing the mbed. Now it seems to be able to run forever (once the page is finally displayed).

25 Feb 2011

My mbed with bug-fix library and ethernet benchmark test:

/media/uploads/tomgle/eth_bench.jpg

25 Feb 2011

I an very interested in getting an 'over Ethernet RPC' working, but I have never managed to get it to do anything. I am guessing that I need some more files (non MBED), can you send me some working examples of the html code/pages (I know nothing of this!)

and you have also mentioned Java-script ???

Basically, I want to read ADC, Set/Clear LED's, Read/Write I/O pins.

Cheers Ceri.

25 Feb 2011

"A test version of the mbed library with 1500 byte MTU ethernet support is now available for testing by anyone interested. To try it out, delete your mbed library from your program, choose "Import Library..." and use the URL http://mbed.org/projects/libraries-testing/svn/bugfix-670. This is a test version of the full mbed library, but with a re-written ethernet driver to support full 1500 MTU. (Note, it allocates more of the Ethernet/AHB1 RAM to achieve this)"

Hi Simon, what is the reason that the compiler is not importing this lib version? I did as you wrote above, but i did not mage to import anything.

25 Feb 2011

Hi Voy,

It should be working, and a couple of the previous posters appear to have tried it so I think all is fine.

To import, you right-click on your program, select Import Library, and use this URL (ensure you don't include the dot etc). That should be all you need to do. If that approach does not work, can you explain a little more about what is not working? Is it giving you an error, permissions, not working once imported, or just not letting you import?

Thanks for testing it! We're running some more benchmarks now.

Simon

25 Feb 2011

Hi Simon,

i just tried what you suggested and it did not work. I am including a snapshot. You can see that i cannot use the import button for loading.

/media/uploads/microfreak/bildschirmfoto_2011-02-25_um_13.18.04.jpg

25 Feb 2011

voy ager: You don't have a target name. As soon as you put the mouse cursor into the target name spot and supply a name, the import button becomes active.

25 Feb 2011

Nice work on the 1500 MTU, have you tried to have to different computers to connect to the webserver at the same time? When I try it one client gets the webpage the other keeps saying "loading..." and never gets the page.

Debug shows that when you have two TCPSockets avaliable - the two clients join the avaliable port but then the "onWriteable" TCPSocket event only is called for one socket.

25 Feb 2011

Hi Tim,

This is not related directly to any webserver code; it is the ethernet driver provided by us as part of the mbed library (see /handbook/Ethernet).

However, the various community contributed webservers that have been written (including the popular stack by Donatien) may be able to take advantage of this larger MTU. I suspect in fact that in general they not that optimised for high throughput or multiple connections anyway, and they could be greatly sped up. We're coninuing to do some low level analysis on ethernet level throughput, and I will try and do some analysis on some of these stacks to see if they have any obvious bottlenecks, but hopefully any limitations will not be with the mbed library now!

Simon

25 Feb 2011

Here is the Rx equivalent benchmark:

/media/uploads/simon/ethernet-rx-benchmark.png

Import programEthernetRxBenchmark

Simple program to determine Ethernet Rx bandwidth

based on a traffic generator something like:

import socket
data = bytes(1000 - 34)
dest = '234.234.234.234'
s = socket.socket(socket.AF_INET, socket.SOCK_RAW)
for i in range(300000):
    s.sendto(data, (dest, 0))

Note that the bandwidth is close to maximum 100Mbps, and the limitation here was actually the PC generating traffic; mbed kept up ok.

So things are looking pretty fast at the ethernet level.

Simon

07 Sep 2011

edit-

Didn't rename the bugfix file to mbed.h ;]

04 Oct 2011

Hi Simon, What's the status of the new Ethernet driver? My compiler says we're still version 28 with the old driver.

The performance is TCP/IP seems to be unusable still - single 50-byte packet HTTP header takes 200ms to send, 400ms between back-to-back 350 byte 1-packet HTTP GETs, due to delays from the TCP section. I don't understand how it can take so long.