[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TCPIP stack size




> Trevor Higgins wrote:
> > 
> > Hi,
> > 
> > Can anyone give some data on size of BSD tcpip stack in code bytes and
> > memory bytes.
> > I want to get a feel for what are the minimum resources likely to
> > be consumed to see if it is likely to fit in available ram/rom.
> > (prefereble less than 128k of each).
> > (I laughed at the README comment that suggested changing the heap from
> > 256K to 512K when using tcpip, as I dont expect to be using more than
> > about 20K of heap all up.)
> > 
> 
> I think that you may have a lot of work ahead of you to make RTEMS and
> the FreeBSD network stack fit into 128kbytes of ROM.  

Me too.

> For my 68360 target machine, a minimal RTEMS program (`hello world')
> takes:
>    text    data     bss     dec     hex filename
>   91904    3456   90016  185376   2d420 o-gen68360/cjnk.exe

hello world uses printf via a termios based console. I have done some work
with a "minimal app" that can be reduced to about 60K of code space.  
This brings up 1 task and shuts down.  It does not print, use clock ticks,
etc.  The RTEMS Hello World is more indicative of a small "reasonable"
application to me.  There is actually a lot of functionality already in
that build (malloc, semaphores, some stdio, shutdown, console, termios,
etc.)

> Adding in the FreeBSD stack (before enlarging the heap) takes:
>    text    data     bss     dec     hex filename
>  191344    5120   94416  290880   47040 o-gen68360/cjnk.exe

Most of the 100K difference in code space is almost certainly either the
TCP/IP stack or network device driver.  The TCP/IP itself probably results
in a couple of RTEMS managers being pulled in -- the clock tick device
driver needs to be enabled and the event manager is used inside the TCP/IP
service tasks.

> You may laugh at the recommendation of the larger heap size, but that's
> what I've found the BSD stack likes to use.  You can certainly get away
> with less if:
> 	1) Your network driver reserves fewer buffers for incoming packets
> 	2) Your network traffic is low
> 	3) You disable reception of broadcast packets
> I can't see *any* way for RTEMS/FreeBSD to work with 20 kbytes of heap,
> though.

20K of C heap is not a lot.  Most of that would be consumed by the buffers
the C library allocates. :)

> When I ported the FreeBSD code to RTEMS my main goal was to provide a
> complete BSD socket-style API for RTEMS applications and to do so with
> minimal modifications to the BSD code.   I've found that the combination
> of the FreeBSD stack and RTEMS provides a very stable, high-performance
> TCP/IP environment.  Nothing comes for free, though, and the cost here
> is in memory usage.  There are small-footprint TCP/IP stacks available
> but this certainly is not one of them.

And this is the philosophy we have tried to stick with.  Keep the code as
intact as possible to ease maintenance and reduce the risk of breakage.  

--joel
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985