[lwip-users] HELP with LWIPOPTS.H - how set these options and what does
From:
Piero 74
Subject:
[lwip-users] HELP with LWIPOPTS.H - how set these options and what does are they mean?
Date:
Tue, 4 Mar 2008 15:02:21 +0100
Hi all.
Below this message, i copied my lwipopts.h, so i hope i can explain better to all my problems.
I need help for some setting and understanding.
I use tcp (with listener) and udp sockets.
In particular, my questions are:
1. MEMP_NUM_PBUF: comments are: used for PBUF_ROM and PBUF_REF. So, if i use, for both udp and tcp, only packet build in my buffer in ram, i can set this value low. IS IT RIGHT?
sockets calls do copy of data, so, pbuf_rom and pbuf_ref are never used? 2. MEMP_NUM_NETBUF: i set this value equal to sum of tcp connections and udp connections. IS IT RIGHT?
3. MEMP_NUM_NETCONN: i set this value equal to sum of tcp connections and udp connections and tcp listeners. IS IT RIGHT? 4. MEMP_NUM_TCPIP_MSG_API and MEMP_NUM_TCPIP_MSG_INPKT: what does are they mean? how set these values? how they depends on tcp connections and udp connections?
5. PBUF_POOL_SIZE: i tryed to set this value low, but i saw problem with pbuf_alloc in my emac driver. What's the best or the minimal value for this option? 6. xxx_RECVMBOX_SIZE: my sys_arch implementation creates mbox using param passed... so i set these values equal to 8. I understood that a mbox is created for EACH connection. IS IT RIGHT? can i choose a low value if i will have packets
send to my board with low rate? 7. DEFAULT_ACCEPTMBOX_SIZE: I understood that a mbox is created for EACH listener. So, if i want to accept only 2 connections for each listener, can i set this value equal than 2?
please, I need your feedback as soon as possible!!!
Thanks to all, Piero.
-------------------------------------------------------------------------------------------------------------------------------------------
MY lwipopts.h -------------------------------------------------------------------------------------------------------------------------------------------
#ifndef _LWIPOPTS_H_ #define _LWIPOPTS_H_
/* ----------------------------------------------- ---------- Platform specific locking ---------- ----------------------------------------------- */
/** * SYS_LIGHTWEIGHT_PROT==1: if you want inter-task protection for certain * critical regions during buffer allocation, deallocation and memory * allocation and deallocation. */ #define SYS_LIGHTWEIGHT_PROT 1
/** * NO_SYS==1: Provides VERY minimal functionality. Otherwise, * use lwIP facilities. */ #define NO_SYS 0
/** * MEM_ALIGNMENT: should be set to the alignment of the CPU * 4 byte alignment -> #define MEM_ALIGNMENT 4 * 2 byte alignment -> #define MEM_ALIGNMENT 2
*/ #define MEM_ALIGNMENT 4
/** * MEM_SIZE: the size of the heap memory. If the application will send * a lot of data that needs to be copied, this should be set high. */ #define MEM_SIZE 2000
/** * MEMP_OVERFLOW_CHECK: memp overflow protection reserves a configurable * amount of bytes before and after each memp element in every pool and fills * it with a prominent default value. * MEMP_OVERFLOW_CHECK == 0 no checking
* MEMP_OVERFLOW_CHECK == 1 checks each element when it is freed * MEMP_OVERFLOW_CHECK >= 2 checks each element in every pool every time * memp_malloc() or memp_free() is called (useful but slow!)
*/ #define MEMP_OVERFLOW_CHECK 0
/** * MEMP_SANITY_CHECK==1: run a sanity check after each memp_free() to make * sure that there are no cycles in the linked lists. */ #define MEMP_SANITY_CHECK 0
/** * MEM_USE_POOLS==1: Use an alternative to malloc() by allocating from a set * of memory pools of various sizes. When mem_malloc is called, an element of * the smallest pool that can provide the lenght needed is returned.
*/ #define MEM_USE_POOLS 0
/** * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h * that defines additional pools beyond the "standard" ones required * by lwIP. If you set this to 1, you must have lwippools.h in your
* inlude path somewhere. */ #define MEMP_USE_CUSTOM_POOLS 0
/* ------------------------------------------------ ---------- Internal Memory Pool Sizes ---------- ------------------------------------------------
*/ /** * MEMP_NUM_PBUF: the number of memp struct pbufs (used for PBUF_ROM and PBUF_REF). * If the application sends a lot of data out of ROM (or other static memory), * this should be set high. */ #define MEMP_NUM_PBUF 5
// piero??
/** * MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One * per active UDP "connection". * (requires the LWIP_UDP option) */ #define MEMP_NUM_UDP_PCB 2
/** * MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. * (requires the LWIP_TCP option) */ #define MEMP_NUM_TCP_PCB 3
/** * MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections.
* (requires the LWIP_TCP option) */ #define MEMP_NUM_TCP_PCB_LISTEN 3
/** * MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. * (requires the LWIP_TCP option) */
#define MEMP_NUM_TCP_SEG 16
/** * MEMP_NUM_ARP_QUEUE: the number of simulateously queued outgoing * packets (pbufs) that are waiting for an ARP request (to resolve * their destination address) to finish.
* (requires the ARP_QUEUEING option) */ #define MEMP_NUM_ARP_QUEUE 6
/** * MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. * (requires NO_SYS==0) */ #define MEMP_NUM_SYS_TIMEOUT 6
/** * MEMP_NUM_NETBUF: the number of struct netbufs. * (only needed if you use the sequential API, like api_lib.c) */ #define MEMP_NUM_NETBUF 4 // piero: tcp+udp ?
/** * MEMP_NUM_NETCONN: the number of struct netconns.
* (only needed if you use the sequential API, like api_lib.c) */ #define MEMP_NUM_NETCONN 8 // piero: listen+tcp+udp?
/** * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used
* for callback/timeout API communication. * (only needed if you use tcpip.c) */ #define MEMP_NUM_TCPIP_MSG_API 8 // piero?
/** * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used
* for incoming packets. * (only needed if you use tcpip.c) */ #define MEMP_NUM_TCPIP_MSG_INPKT 8 // piero?
/** * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ #define PBUF_POOL_SIZE 4
// piero
/** * ARP_TABLE_SIZE: Number of active MAC-IP address pairs cached. */ #define ARP_TABLE_SIZE 5
/** * ARP_QUEUEING==1: Outgoing packets are queued during hardware address * resolution.
*/ #define ARP_QUEUEING 1
/** * ETHARP_TRUST_IP_MAC==1: Incoming IP packets cause the ARP table to be * updated with the source MAC and IP addresses supplied in the packet. * You may want to disable this if you do not trust LAN peers to have the
* correct addresses, or as a limited approach to attempt to handle * spoofing. If disabled, lwIP will need to make a new ARP request if * the peer is not already in the ARP table, adding a little latency. */
#define ETHARP_TRUST_IP_MAC 1
/* -------------------------------- ---------- IP options ---------- -------------------------------- */ /** * IP_FORWARD==1: Enables the ability to forward IP packets across network
* interfaces. If you are going to run lwIP on a device with only one network * interface, define this to 0. */ #define IP_FORWARD 0
/** * IP_OPTIONS_ALLOWED: Defines the behavior for IP options.
* IP_OPTIONS_ALLOWED==0: All packets with IP options are dropped. * IP_OPTIONS_ALLOWED==1: IP options are allowed (but not parsed). */ #define IP_OPTIONS_ALLOWED 1
/* --------------------------------- ---------- RAW options ---------- ---------------------------------
*/ /** * LWIP_RAW==1: Enable application layer to hook into the IP layer itself. */ #define LWIP_RAW 0
/* ---------------------------------- ---------- DNS options -----------
---------------------------------- */ /** * LWIP_DNS==1: Turn on DNS module. UDP must be available for DNS * transport. */ #define LWIP_DNS 0
/** DNS maximum number of entries to maintain locally. */
#define DNS_TABLE_SIZE 4
/** DNS maximum host name length supported in the name table. */ #define DNS_MAX_NAME_LENGTH 256
/** The maximum of DNS servers */ #define DNS_MAX_SERVERS 2
/** DNS do a name checking between the query and the response. */ #define DNS_DOES_NAME_CHECK 1
/** DNS use a local buffer if DNS_USES_STATIC_BUF=0, a static one if DNS_USES_STATIC_BUF=1, or a dynamic one if DNS_USES_STATIC_BUF=2.
The buffer will be of size DNS_MSG_SIZE */ #define DNS_USES_STATIC_BUF 1
/** DNS message max. size. Default value is RFC compliant. */ #define DNS_MSG_SIZE 512
/** * TCP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
*/ #define TCP_LISTEN_BACKLOG 1
/** * The maximum allowed backlog for TCP listen netconns. * This backlog is used unless another is explicitly specified. * 0xff is the maximum (u8_t).
*/ #define TCP_DEFAULT_LISTEN_BACKLOG 0xff
/** * LWIP_NETIF_API==1: Support netif api (in netifapi.c) */ #define LWIP_NETIF_API 0
/** * LWIP_NETIF_STATUS_CALLBACK==1: Support a callback function whenever an interface
* changes its up/down status (i.e., due to DHCP IP acquistion) */ #define LWIP_NETIF_STATUS_CALLBACK 0
/** * LWIP_NETIF_LINK_CALLBACK==1: Support a callback function from an interface * whenever the link changes (i.e., link down)
*/ #define LWIP_NETIF_LINK_CALLBACK 0
/** * LWIP_NETIF_HWADDRHINT==1: Cache link-layer-address hints (e.g. table * indices) in struct netif. TCP and UDP can make use of this to prevent * scanning the ARP table for every sent packet. While this is faster for big
* ARP tables or many concurrent connections, it might be counterproductive * if you have a tiny ARP table or if there never are concurrent connections. */ #define LWIP_NETIF_HWADDRHINT 0
/** * LWIP_LOOPIF_MULTITHREADING: Indicates whether threading is enabled in * the system, as LOOPIF must change how it behaves depending on this setting.
* Setting this is needed to avoid reentering non-reentrant functions like * tcp_input(). * LWIP_LOOPIF_MULTITHREADING==1: Indicates that the user is using a * multithreaded environment like tcpip.c. In this case, netif->input()
* is called directly. * LWIP_LOOPIF_MULTITHREADING==0: Indicates a polling (or NO_SYS) setup. * The packets are put on a list and loopif_poll() must be called in * the main application loop.
*/ #define LWIP_LOOPIF_MULTITHREADING 1
/* ------------------------------------ ---------- Thread options ---------- ------------------------------------ */ /** * TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
*/ #define TCPIP_THREAD_NAME "tcpip_thread"
/** * TCPIP_THREAD_STACKSIZE: The stack size used by the main tcpip thread. * The stack size value itself is platform-dependent, but is passed to
* sys_thread_new() when the thread is created. */ #define TCPIP_THREAD_STACKSIZE 300 // piero ?
/** * TCPIP_THREAD_PRIO: The priority assigned to the main tcpip thread. * The priority value itself is platform-dependent, but is passed to
* sys_thread_new() when the thread is created. */ #define TCPIP_THREAD_PRIO 1 // piero ?
/** * TCPIP_MBOX_SIZE: The mailbox size for the tcpip thread messages * The queue size value itself is platform-dependent, but is passed to
* sys_mbox_new() when tcpip_init is called. */ #define TCPIP_MBOX_SIZE 8 // piero?
/** * DEFAULT_UDP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a * NETCONN_UDP. The queue size value itself is platform-dependent, but is passed
* to sys_mbox_new() when the recvmbox is created. */ #define DEFAULT_UDP_RECVMBOX_SIZE 8 // piero?
/** * DEFAULT_TCP_RECVMBOX_SIZE: The mailbox size for the incoming packets on a * NETCONN_TCP. The queue size value itself is platform-dependent, but is passed
* to sys_mbox_new() when the recvmbox is created. */ #define DEFAULT_TCP_RECVMBOX_SIZE 8 // piero?
/** * DEFAULT_ACCEPTMBOX_SIZE: The mailbox size for the incoming connections. * The queue size value itself is platform-dependent, but is passed to
* sys_mbox_new() when the acceptmbox is created. */ #define DEFAULT_ACCEPTMBOX_SIZE 3 // piero
/** * LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c) */ #define LWIP_NETCONN 1
/* ------------------------------------
---------- Socket options ---------- ------------------------------------ */ /** * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c) */ #define LWIP_SOCKET 1
/** * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names. * (only used if you use sockets.c) */ #define LWIP_COMPAT_SOCKETS 1
/** * LWIP_COMPAT_SOCKETS==1: Enable POSIX-style sockets functions names. Disable
* this option if you use a POSIX operating system that uses the same names * (read, write & close). (only used if you use sockets.c) */ #define LWIP_POSIX_SOCKETS_IO_NAMES 1
/** * LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
* options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set * in seconds. (does not require sockets.c, and will affect tcp.c) */ #define LWIP_TCP_KEEPALIVE 0
/** * IP_STATS==1: Enable IP stats. */ #define IP_STATS 1
/**
* IPFRAG_STATS==1: Enable IP fragmentation stats. Default is * on if using either frag or reass. */ #define IPFRAG_STATS (IP_REASSEMBLY || IP_FRAG)
/* --------------------------------------- ---------- Debugging options ----------
--------------------------------------- */ /** * LWIP_DBG_MIN_LEVEL: After masking, the value of the debug is * compared against this value. If it is smaller, then debugging * messages are written.
*/ #define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_OFF
/** * LWIP_DBG_TYPES_ON: A mask that can be used to globally enable/disable * debug messages of certain types. */ #define LWIP_DBG_TYPES_ON LWIP_DBG_ON