lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Sizes


From: Jeff Barber
Subject: Re: [lwip-users] Sizes
Date: Wed, 27 May 2009 15:38:31 -0400

On Wed, May 27, 2009 at 9:47 AM, John Kennedy
<address@hidden> wrote:
> I’m using Lwip with sockets on MicroBlaze.  I have an MTU of 1500.  I want
> to maximize the Ethernet TX/RX data rates (bits/sec) in my embedded system.
> Memory is not an issue (512Mbytes avail).
>
> How does one determine the values for:
>
> ·         MEM_SIZE
>
> ·         PBUF_POOL_SIZE
>
> ·         PBUF_POOL_BUFSIZE
>
> ·         TCP_MSS
>
> ·         TCP_SND_BUF
>
> ·         TCP_SND_QUEUELEN
>
>  to maximize the Ethernet TX/RX data rates?

I wish there were a better source of information on this as well.  I
spent quite a while trolling through the source trying to understand
what all the different settings are for.  Some I figured out, others
I'm still not sure of.

Like you, my environment is not memory-constrained.  Furthermore, I am
using my own malloc implementation rather than the lwip built-in
mem_malloc and memp_malloc (this is partially because I trust my own
allocation functions and partially because I had a hard time
understanding how to configure the lwIP implementation :-).  As best I
can tell, when using one's own allocation routines, several of the
memory-related defines are "don't care".  So MEM_SIZE and all the
MEMP_* and PBUF_POOL_SIZE are (I think) not actually used -- beyond
the sanity tests in lwip/src/core/init.c.

Caveat: my port is very young -- my driver came up for the first time
a couple of days ago, and it hasn't yet done much more than answer
ping packets and ARP (no TCP yet).  FWIW, though, here's my lwipopts.h
(for everything else, I accept the default values from <lwip/opt.h>):

#define NO_SYS                      1
#define MEM_LIBC_MALLOC             1
#define MEMP_MEM_MALLOC             1
#define MEM_ALIGNMENT               4
#define MEM_SIZE                    (4 * 1024 * 1024)
#define MEMP_NUM_PBUF               1024
#define MEMP_NUM_UDP_PCB            20
#define MEMP_NUM_TCP_PCB            20
#define MEMP_NUM_TCP_PCB_LISTEN     16
#define MEMP_NUM_TCP_SEG            128
#define MEMP_NUM_REASSDATA          32
#define MEMP_NUM_ARP_QUEUE          10
#define PBUF_POOL_SIZE              512
#define LWIP_ARP                    1
#define IP_REASS_MAX_PBUFS          64
#define IP_FRAG_USES_STATIC_BUF     0
#define IP_DEFAULT_TTL              255
#define IP_SOF_BROADCAST            1
#define IP_SOF_BROADCAST_RECV       1
#define LWIP_ICMP                   1
#define LWIP_BROADCAST_PING         1
#define LWIP_MULTICAST_PING         1
#define LWIP_RAW                    0
#define TCP_WND                     (4 * TCP_MSS)
#define TCP_MSS                     1460
#define TCP_SND_BUF                 (8 * TCP_MSS)
#define TCP_LISTEN_BACKLOG          1
#define LWIP_NETIF_STATUS_CALLBACK  1
#define LWIP_NETIF_LINK_CALLBACK    1
#define LWIP_NETIF_HWADDRHINT       1
#define LWIP_NETCONN                0
#define LWIP_SOCKET                 0
#define LWIP_STATS_DISPLAY          1
#define ETHARP_TRUST_IP_MAC         0

#define mem_init()
#define mem_free                    my_free
#define mem_malloc                  my_malloc
#define mem_calloc(c, n)            my_zalloc((c) * (n))
#define mem_realloc                 my_realloc


For the MSS value, specifically, I worked backwards from the standard
max ethernet frame size: 1514.  Subtract 14 bytes for layer 2 header;
subtract 20 bytes for IP header and another 20 for TCP header; that
leaves 1460.  There are a couple of ports in contrib/ that define it
to 1476 but I couldn't figure out how they came up with that.  I will
have a direct ethernet connection to my peer so don't need to worry
about any additional fragmentation.

BTW, any comments on my settings would be greatly appreciated.

Hope this helps.
Jeff




reply via email to

[Prev in Thread] Current Thread [Next in Thread]