Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

FreeRTOS TCP Stack running out of headp creating a stream

Posted by lciummo on August 10, 2015

I'm trying to chase down an out of heap memory problem when a TCP socket is created. heap2 malloc fails requesting 5872 bytes. This looks like it's based on creating stream buffers via...

ifndef ipconfigTCPRXBUF_LEN
#define ipconfigTCP_RX_BUF_LEN			( 4 * ipconfigTCP_MSS )	/* defaults to 5840 bytes */
endif

/* Define the size of Tx stream buffer for TCP sockets */

ifndef ipconfigTCPTXBUF_LEN
define ipconfigTCPTXBUFLEN ( 4 * ipconfigTCPMSS ) /* defaults to 5840 bytes */

This seems ot add up to >10K per tcp socket. Can I reduce TCP_MSS to something smaller? Can it be less than an ethernet Mtu?

Thanks Larry


FreeRTOS TCP Stack running out of headp creating a stream

Posted by heinbali01 on August 10, 2015

Hi Larry,

About posting: you can include literal code if you put it between two lines which only contain 5 tildas ~~~~~, as here:

~~~~~ int function( void ) { /* This is a comment */ return 0; } ~~~~~

I'm glad you traced down the problem.

This seems ot add up to >10K per tcp socket. Can I reduce TCP_MSS to something smaller? Can it be less than an ethernet Mtu?

This is a TCP packet:

1) Ethernet header = 14 bytes
2) IP-header = 20 bytes
3) TCP-header = 20 bytes
4) TCP contents/payload <= MSS

MTU (Maximum Transmission Unit) equals MSS + 40.

The 'Ethernet header' of 14 bytes is not included in the MTU.

I would recommend bringing down the MTU for testing, e.g.:

#define ipconfigNETWORK_MTU    800

The value of MSS will automatically adapt:

#define ipconfigTCP_MSS ( ipconfigNETWORK_MTU - ipSIZE_OF_IP_HEADER - ipSIZE_OF_TCP_HEADER )

which is 1000 - 40 = 960 bytes.

This post might also be interesting for you:

https://sourceforge.net/p/freertos/discussion/382005/thread/a9c8fc93/?limit=25#5a90

Regards, Hein


FreeRTOS TCP Stack running out of headp creating a stream

Posted by rtel on August 10, 2015

Are you using BufferAllocation2.c? If so, please note you need to use heap4.c, not heap2.c: http://www.freertos.org/FreeRTOS-Plus/FreeRTOSPlusTCP/EmbeddedEthernetBufferManagement.html

Regards.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists