[Top][All Lists]

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

Re: [lwip-users] https mbed TLS lwip

From: Trampas Stern
Subject: Re: [lwip-users] https mbed TLS lwip
Date: Wed, 19 Feb 2020 13:38:40 -0500

So I normally have a breakpoint enabled in _sbrk() to catch mallocs, but forgot to define the symbol to enable.  So I found out that Mbedtls is calling malloc(), and is using around 176k of heap space which seems to be excessive, 

I also tried refreshing page several times to see what the maximum heap storage goes up to and seems to stabilize at 176k, however after a few refreshes the system stops working and I get the following:
tcp_out.c 1097: tcp_enqueue_flags: queueing 394913:394914 (0x12)
tcp_out.c 1546: tcp_output_segment: 394913:394913
tcp_out.c 1268: tcp_output: nothing to send (0)
tcp_out.c 1268: tcp_output: nothing to send (0)
tcp_out.c 1097: tcp_enqueue_flags: queueing 396664:396665 (0x12)
tcp_out.c 1546: tcp_output_segment: 396664:396664
tcp_out.c 1268: tcp_output: nothing to send (0)
tcp_out.c 1268: tcp_output: nothing to send (0)
tcp_out.c 1268: tcp_output: nothing to send (0)

Note I am using mbedtls 1.16.4 and lwip version 2.1.2


On Wed, Feb 19, 2020 at 11:05 AM Trampas Stern <address@hidden> wrote:
Does anyone have recommended configuration for https?  I have the following and still having problems:

#define MEM_SIZE                 42 * 1024
#define MEMP_NUM_TCP_PCB                20
#define MEMP_NUM_TCP_PCB_LISTEN        10
#define MEMP_NUM_TCP_SEG               100
#define MEMP_NUM_FRAG_PBUF              6
#define MEMP_NUM_PBUF                   8
#define PBUF_POOL_SIZE                 20
#define TCP_MSS                 1460
#define TCP_WND               (10 * TCP_MSS)
#define TCP_SND_BUF             (10 * TCP_MSS)

Maybe someone has an example lwipopts.h and config.h (for mbedtls) which works that I can compare? 


On Wed, Feb 19, 2020 at 10:45 AM Trampas Stern <address@hidden> wrote:
I will increase more...  

I am monitoring for alloc failures, but not seeing any. 

altcp_mbedtls_state_t *
altcp_mbedtls_alloc(void *conf)
  altcp_mbedtls_state_t *ret = (altcp_mbedtls_state_t *)mem_calloc(1, sizeof(altcp_mbedtls_state_t));
  if (ret != NULL) {
    ret->conf = conf;
  if (NULL == ret)
 ERROR("Malloc failed");
  return ret;

altcp_mbedtls_free(void *conf, altcp_mbedtls_state_t *state)
  LWIP_ASSERT("state != NULL", state != NULL);

void *
altcp_mbedtls_alloc_config(size_t size)
  void *ret;
  size_t checked_size = (mem_size_t)size;
  if (size != checked_size) {
    /* allocation too big (mem_size_t overflow) */
 ERROR("Alloc failed");
    return NULL;
  ret = (altcp_mbedtls_state_t *)mem_calloc(1, (mem_size_t)size);
  return ret;

On Wed, Feb 19, 2020 at 9:46 AM Simon Goldschmidt <address@hidden> wrote:
Trampas Stern wrote:
> right now I have the following settings:
> #define MEM_SIZE                 12 * 1024
> [..]
> It appears that I am getting handshake failures...
During runtime mbedTLS allocates hughe amounts of memory. Depending on your
configuration, this is routed to the lwIP heap (see altcp_tls_mbedtls_mem.c).
If so, this value is *much* too low!

The other values might be too low, too. Try to increase everything to the max
(that your system allows) and see how much you actually need by monitoring


lwip-users mailing list

reply via email to

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