[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] memp_memory and ram_heap
From: |
narke |
Subject: |
Re: [lwip-users] memp_memory and ram_heap |
Date: |
Fri, 6 Jan 2012 10:53:14 +0800 |
Hi,
Found I may know where is the problem, but not sure how to deal with it.
The max object in memp_memory is allocated for PBUF_POOL, my
PBUF_POOL_SIZE is set to 8 and each of them is sized about 676 bytes.
The size of each PBUF is determined by
LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_HLEN), so because the TCP_MSS
is 536, that's why it results in such a large value.
By far, it's reasonable.
Then, I see the ram_heap size is determined by MEM_SIZE setting. There
is a comments: "If the application will send a lot of data that needs
to be copied, this should be set high", so I defined my mem_size by
some calculation from TCP_MSS.
Now, it clear, why I increased the TCP_MSS value, both the ram_heap
and memp_memory get increased.
How should I set the MEM_SIZE? It has nothing to do with TCP_MSS?
Thanks in advance.
On 5 January 2012 21:17, narke <address@hidden> wrote:
> On 5 January 2012 17:53, Simon Goldschmidt <address@hidden> wrote:
>> narke <address@hidden> wrote:
>>> I found memp_memory and ram_heap are two most biggest ram variables in
>>> my setup, they are now each 5.5k bytes around. These two variables
>>> are similar in size and their sizes changes when I change the MEM_SIZE
>>> constant.
>>>
>>> I want to ask, is this normal? And, what's the relationship between
>>> these two variable?
>>
>> No, not normal. Normally, MEM_SIZE should only influence the heap
>> (ram_heap), not the pools (memp_memory). ram_heap should be about the size
>> of MEM_SIZE (a little more, say 16 bytes or so). memp_memory is made up of
>> many configuration options (and depending on target pointer size, etc) and
>> its size cannot be easily calculated.
>>
>> Simon
>
> Thanks, Simon. Now I see hope, otherwise, every amount of value I
> increased on MEM_SIZE, I would got double the amount of bytes occupied
> by ram_heap and memp_memory. This was really depressing me.
>
> Well, the problem is, what's wrong with my configuration. Could you
> have a look at my lwipoptions.h file? Or you can show me some possible
> clues.
>
> Below is the file. And, thanks in advance.
>
> --lwiooptions.h---
>
> #ifndef __LWIPOPTS_H__
> #define __LWIPOPTS_H__
> #include "Cfg_Decl.h"
>
> #define NO_SYS 1
> #define LWIP_SOCKET 0
> #define LWIP_NETCONN 0
>
> /* ---------- Memory options ---------- */
> /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which
> lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2
> byte alignment -> define MEM_ALIGNMENT to 2. */
>
> #define MEM_ALIGNMENT 4
>
> #include "LatDefs.h"
> #include "LogStrHdr.h"
> #ifdef __DEBUG_CHANNEL__
> #define MEM_SIZE (1500 + PPP_FRAME_RX_BUF_SIZE
> + PPP_FRAME_TX_BUF_SIZE + LOG_STREAM_BUF_SIZE)
> #else
> #define MEM_SIZE (1500 + PPP_FRAME_RX_BUF_SIZE
> + PPP_FRAME_TX_BUF_SIZE)
> #endif
>
> #define MEMP_NUM_RAW_PCB 2
>
> /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application
> sends a lot of data out of ROM (or other static memory), this
> should be set high. */
> #define MEMP_NUM_PBUF 2
>
> /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
> per active UDP "connection". */
> #define MEMP_NUM_UDP_PCB 1
> /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
> connections. */
> #define MEMP_NUM_TCP_PCB 4
>
> /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP
> connections. */
> #define MEMP_NUM_TCP_PCB_LISTEN 1
>
> /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP
> segments. */
> #define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
>
> /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
> timeouts. */
> #define MEMP_NUM_SYS_TIMEOUT 5
>
> /* The following four are used only with the sequential API and can be
> set to 0 if the application only will use the raw API. */
> /* MEMP_NUM_NETBUF: the number of struct netbufs. */
> #define MEMP_NUM_NETBUF 0
>
> /* MEMP_NUM_NETCONN: the number of struct netconns. */
> #define MEMP_NUM_NETCONN 0
>
> /* ---------- Pbuf options ---------- */
> /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
> #define PBUF_POOL_SIZE 8
>
> /* ---------- ARP options ---------- */
>
> /** Number of active hardware address, IP address pairs cached */
> #define ARP_TABLE_SIZE 3
>
> /* ---------- IP options ---------- */
>
> /** IP reassembly and segmentation. Even if they both deal with IP
> * fragments, note that these are orthogonal, one dealing with incoming
> * packets, the other with outgoing packets
> */
>
> /** Reassemble incoming fragmented IP packets */
> #define IP_REASSEMBLY 0 /* TODO: clarify
> this and prepare test cases (woody) */
>
> /** Fragment outgoing IP packets if their size exceeds MTU */
> #define IP_FRAG 0
>
> /* ---------- DHCP options ---------- */
> #define LWIP_DHCP 1 /* bbv roki */
>
> /* 1 if you want to do an ARP check on the offered address
> (recommended). */
> #define DHCP_DOES_ARP_CHECK 0
>
> /* ---------- TCP options ---------- */
> #define TCP_WND (2 * TCP_MSS)
> #define TCP_SYNMAXRTX 4
>
> /* Controls if TCP should queue segments that arrive out of
> order. Define to 0 if your device is low on memory. */
> #define TCP_QUEUE_OOSEQ 0
>
> /* TCP sender buffer space (bytes). */
> #define TCP_SND_BUF (2 * TCP_MSS)
>
> /* TCP sender buffer space (pbufs). This must be at least = 2 *
> TCP_SND_BUF/TCP_MSS for things to work. */
> #define TCP_SND_QUEUELEN (2 * TCP_SND_BUF/TCP_MSS)
>
> #define LWIP_TCP_KEEPALIVE 1
>
> /* ---------- PPP options ---------- */
>
> #define PPP_SUPPORT 1
>
> #if PPP_SUPPORT
>
> #define PAP_SUPPORT 1
> #define MD5_SUPPORT 1 /* don't want to use
> srand in standard library */
> #define PPP_MAXIDLEFLAG 1 /* I prefer PPP frame
> flag is always sent */
> /* #define LCP_ECHOINTERVAL 2 */
>
> /*
> * type of log messages I have interests
> */
>
> #ifdef __DEBUG__
> #define LWIP_DEBUG
> #define TCP_DEBUG LWIP_DBG_ON
> #define TCP_RST_DEBUG LWIP_DBG_ON
> #define TCP_INPUT_DEBUG LWIP_DBG_ON
> #define TCP_OUTPUT_DEBUG LWIP_DBG_ON
> #define PPP_DEBUG LWIP_DBG_ON
> #define NETIF_DEBUG LWIP_DBG_ON
> #define MEMP_DEBUG LWIP_DBG_ON
> #define MEM_DEBUG LWIP_DBG_ON
> #if 0
> #define TCP_RTO_DEBUG LWIP_DBG_ON
> #define TCPIP_DEBUG LWIP_DBG_ON
> #define TCP_CWND_DEBUG LWIP_DGB_ON
> #define PBUF_DEBUG LWIP_DBG_ON
> #define TCP_CWND_DEBUG LWIP_DBG_ON
> #define TCP_WND_DEBUG LWIP_DBG_ON
> #define SYS_DEBUG LWIP_DBG_ON
> #define TIMERS_DEBUG LWIP_DBG_ON
> #endif
> #endif /* __DEBUG__ */
>
> #endif /* PPP_SUPPORT */
>
> #endif /* __LWIPOPTS_H__ */
> -------------------
>
>
> --
> Life is the only flaw in an otherwise perfect nonexistence
> -- Schopenhauer
>
> narke
> public key at http://subkeys.pgp.net:11371 (address@hidden)
--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer
narke
public key at http://subkeys.pgp.net:11371 (address@hidden)