EmbeddedRelated.com
Forums

How much RAM needed for low end Ethernet application?

Started by Ulf Samuelsson March 1, 2005
I would be interested to understand the RAM needs when
you have simple Ethernet applications.

Is 32kB/64 kB SRAM enough for a decent application or do you need more?
I think there are simple applications where you dont need too much info
but will they fit?

-- 
Best Regards,
Ulf Samuelsson
ulf@a-t-m-e-l.com
This message is intended to be my own personal view and it
may or may not be shared by my employer Atmel Nordic AB


"Ulf Samuelsson" <ulf@a-t-m-e-l.com> wrote in message
news:38k0cdF5omil2U1@individual.net...
> I would be interested to understand the RAM needs when > you have simple Ethernet applications. > > Is 32kB/64 kB SRAM enough for a decent application or do you need more? > I think there are simple applications where you dont need too much info > but will they fit? >
It depends on what you want to do with your Ethernet. Are you talking about TCP/IP? There is a trade of with speed and resource. It is possible to run TCP/IP in very little RAM, but it will be slow(er). Take a look at: http://www.sics.se/~adam/uip/size.html. I have used uIP with tiny amounts of RAM quite successfully. Regards, Richard. http://www.FreeRTOS.org
On 2005-03-01, Ulf Samuelsson <ulf@a-t-m-e-l.com> wrote:

> I would be interested to understand the RAM needs when > you have simple Ethernet applications.
You probably need at least enough for 1 Ethernet frame (1500 bytes).
> Is 32kB/64 kB SRAM enough for a decent application or do you need more? > I think there are simple applications where you dont need too much info > but will they fit?
Above and beyond the 1500 byte requirement, it depends entirely on what sort of protocol you want to impliment. -- Grant Edwards grante Yow! Two with FLUFFO, at hold th' BEETS...side of visi.com SOYETTES!
On Tue, 1 Mar 2005 20:47:22 +0100, "Ulf Samuelsson"
<ulf@a-t-m-e-l.com> wrote:

>Is 32kB/64 kB SRAM enough for a decent application or do you need more? >I think there are simple applications where you dont need too much info >but will they fit?
Unless you plan to support Jumbo frames, 2000 bytes should be more than enough of RAM :-). Of course you may need some extra data space for the application data. Paul
On Tue, 01 Mar 2005 20:47:22 +0100, Ulf Samuelsson wrote:

> I would be interested to understand the RAM needs when you have simple > Ethernet applications. > > Is 32kB/64 kB SRAM enough for a decent application or do you need more? I > think there are simple applications where you dont need too much info but > will they fit?
As Richard says in another reply, there is a size/throughput trade-off involved. If you intend to run TCP/IP on top of the Ethernet, the lower bound on RAM is 14 (size of Ethernet header) + 40 (size of TCP/IP headers) + 20 (estimated size of TCP options in TCP SYN segment) + 11 (the size of one ARP table entry) + the RAM requirements for one TCP connection. For uIP, this would be around 120 bytes. With this type of configuration, throughput would be very low. This might be OK, however, as memory constrained systems are likely to have only small amounts of data to send anyway (even though this may not always be the case). Also, this configuration is not guaranteed to work as it violates the RFCs (too small packet buffer, no IP fragment reassembly). The minimum size for an RFC compliant TCP/IP application would be 14 (size of Ethernet header) + 576 (minimum RFC compliant packet size) + 576 (buffer for IP fragment reassembly) + 11 (the size of one ARP table entry) + RAM size of one TCP connection. For uIP, this would be around 1210 bytes of RAM. This configuration would provide a modest throughput, but would not be too useful in practice because it would only be able to support a single TCP connection. A good estimate for the minimum RAM size for an RFC compliant low-end application with multiple TCP connections would be around 2k. The smallest RAM size for a uIP deployment that I know of was 183 bytes, but that particular application did not use Ethernet. The simple uIP web server running on http://uip-demo.sics.se/ (www.ethernut.de board with ATMega128 + RTL8019as) is configured with just over 1k RAM. /adam -- Adam Dunkels, Swedish Institute of Computer Science http://www.sics.se/~adam/, <adam@sics.nospam.se>
Richard wrote:
> "Ulf Samuelsson" <ulf@a-t-m-e-l.com> wrote in message > news:38k0cdF5omil2U1@individual.net... >> I would be interested to understand the RAM needs when >> you have simple Ethernet applications. >> >> Is 32kB/64 kB SRAM enough for a decent application or do you need >> more? I think there are simple applications where you dont need too >> much info but will they fit? >> > > It depends on what you want to do with your Ethernet. Are you > talking about TCP/IP? > > There is a trade of with speed and resource. It is possible to run > TCP/IP in very little RAM, but it will be slow(er). Take a look at: > http://www.sics.se/~adam/uip/size.html. I have used uIP with tiny > amounts of RAM quite successfully.
I think my approach is even better. :-) "~adam" (Dunkels) is visiting me Thursday! I talked to someone else using "lwIP", and he was using 100 kB.
> Regards, > Richard. > > http://www.FreeRTOS.org
-- Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This message is intended to be my own personal view and it may or may not be shared by my employer Atmel Nordic AB
On Tue, 01 Mar 2005 23:32:51 +0100, Ulf Samuelsson wrote:

> Assuming you want to have maximum throughput with TCP/IP + PPP over a 56 > kbps (7 kB/s) line and a ping delay of 100, 200 or 500 ms, sending web > pages of x kB. Don't you really have to have enough RAM to store > everything until you get the acknowledge. So if you have a ping delay of > 500 ms, you have to store 7 kB * 0,5 = 3,5 kB. > > If you have a 500 kbps ADSL connection and 500 ms ping, then you need to > store 500 kbit * 0,5 = 250 kbit = roughly 30 kByte. > > If you s&#4294967295;nd data in both directions, then you need 2 x memory and you are > quickly close to 100 kB. > > Did I misunderstand this?
Your thinking is basically correct. Two comments however: first, if you wish to maximize throughput, you will probably need a lot of memory in order to buffer data for retransmissions. Second, if you are sending static web pages, there is no need to buffer those in RAM. If the application does not require maximum throughput, you can get away with much less RAM. (Again, that size/throughput trade-off.) Regards, /adam -- Adam Dunkels, Swedish Institute of Computer Science http://www.sics.se/~adam/, <adam@sics.nospam.se>
Paul Keinanen wrote:
> On Tue, 1 Mar 2005 20:47:22 +0100, "Ulf Samuelsson" > <ulf@a-t-m-e-l.com> wrote: > >> Is 32kB/64 kB SRAM enough for a decent application or do you need >> more? I think there are simple applications where you dont need too >> much info but will they fit? > > Unless you plan to support Jumbo frames, 2000 bytes should be more > than enough of RAM :-). Of course you may need some extra data space > for the application data. > > Paul
2000 bytes fit one frame of TCP/IP , and not more. I am thinking along the line: Small http server but decent performance over a wide area network with some delay when you download a web page. In TCP/IP there is a window. I.E: you can send several packets before you get an acknowledge. You cannot discard a sent packet until you get an acknowledge. If you can only store one packet, then you need to wait for that acknowledge before you send the next. If the ping delay is 200 ms (just tried), then you can send 5 packets per second. At 1000 bytes per packet, this is 40 kbps. - Not a lot... 200 ms is quite good for pinging US from Sweden. Frequently see > 1 second. giving me 8 kbps. If the connection ends up over GSM, then you are limited to low speed transmission and I think you want to utilize the bandwidth as much as possible, which means transmitting all the time Maybe the question should be more like: Assuming you want to have maximum throughput with TCP/IP + PPP over a 56 kbps (7 kB/s) line and a ping delay of 100, 200 or 500 ms, sending web pages of x kB. Don't you really have to have enough RAM to store everything until you get the acknowledge. So if you have a ping delay of 500 ms, you have to store 7 kB * 0,5 = 3,5 kB. If you have a 500 kbps ADSL connection and 500 ms ping, then you need to store 500 kbit * 0,5 = 250 kbit = roughly 30 kByte. If you s&#4294967295;nd data in both directions, then you need 2 x memory and you are quickly close to 100 kB. Did I misunderstand this? -- Best Regards, Ulf Samuelsson ulf@a-t-m-e-l.com This message is intended to be my own personal view and it may or may not be shared by my employer Atmel Nordic AB
On Tue, 01 Mar 2005 23:24:57 +0100, Ulf Samuelsson wrote:

> Richard wrote: >> "Ulf Samuelsson" <ulf@a-t-m-e-l.com> wrote in message >> news:38k0cdF5omil2U1@individual.net... >>> I would be interested to understand the RAM needs when you have simple >>> Ethernet applications. >>> >>> Is 32kB/64 kB SRAM enough for a decent application or do you need more? >>> I think there are simple applications where you dont need too much info >>> but will they fit? >>> >>> >> It depends on what you want to do with your Ethernet. Are you talking >> about TCP/IP? >> >> There is a trade of with speed and resource. It is possible to run >> TCP/IP in very little RAM, but it will be slow(er). Take a look at: >> http://www.sics.se/~adam/uip/size.html. I have used uIP with tiny >> amounts of RAM quite successfully. > > I think my approach is even better. :-) "~adam" (Dunkels) is visiting me > Thursday! I talked to someone else using "lwIP", and he was using 100 kB.
lwIP typically requires more RAM than uIP. The reasons for this are that it buffers data for retransmissions in RAM and that it is designed to be able to achieve much higher throughput. With lwIP, it should be possible to maximize throughput given your delay*bandwidth example. We can discuss this in detail on Thursday :-) Regards, /adam -- Adam Dunkels, Swedish Institute of Computer Science http://www.sics.se/~adam/, <adam@sics.nospam.se>
>I would be interested to understand the RAM needs when >you have simple Ethernet applications. > >Is 32kB/64 kB SRAM enough for a decent application or do you need more? >I think there are simple applications where you dont need too much info >but will they fit?
Even though you have not spcified close enough what kind of "Ethernet applications" you have in mind, I asume this is going to be some application that needs TCP connectivity. Basically it boils down to how many buffers you want/need to have. On the lower end there are those implementations which mostly exclusively use the NIC's io buffer space which are usually limitted to one single TCP session (if at all) or UDP based comunication only. In case of TCP such implementations also do not have a flight size > 1. That said only one segment is sent out and processing waits up until this segment gets ack'ed from the other end. Such implementations are fine if you want a little simply webpage showing some data you may collect with the device or where such a page is used to configure the device etc. On the other end of the rope are those implementations where you need to process multiple TCP sessions in paralell and where you want a reasonable througput. If you want a reasonable speed, you need to have a minimum of two buffers per connection so as you can send out two segments which are not yet ack'ed by the other end (in other words a "flight size" of two buffers) and where it's likely that buffers are available for the reciver too. So, as a rough estimate, I sugest to calculate 1500 bytes per buffer times number of buffers per connection times TCP sessions in paralell. Add probably 20% to this to have something left to maintain task/socket state and there you go. Of course this asumes that the buffers are held in a pool and are not strictly assigned to a given connection. HTH Markus