Real time embedded FreeRTOS RSS feed 
Homepage FreeRTOS+ Products FreeRTOS Labs Support Forum Contact / Enquiries
FreeRTOS+UDP was removed from the FreeRTOS kernel download from FreeRTOS V10.1.0. See the FreeRTOS+TCP stack, which can be configured for UDP only use, as an alternative.

Network Buffers Allocation Schemes
and their implication on CPU load and throughput performance


Summary Bullet Points

  • FreeRTOS+UDP has a very efficient zero copy architecture. Depending on the implementation of the embedded Ethernet peripheral driver, and the user's choice of API calling semantics, Ethernet packets can be passed by reference from the receiving DMA buffer, through the stack, all the way back to the transmitting DMA buffer.

  • Performance limiting factors:

    1. Reentrancy

      FreeRTOS+UDP is fully reentrant and thread aware, meaning the IP stack can be safely used by all the RTOS tasks simultaneously. The flexibility does however come with the small time penalty introduced by the message passing and context switching that is necessary to ensure accesses to the IP stack are serialised (happen in a controlled manner so as not to cause corruption).

    2. Buffer Allocation

      Data that is received by the embedded Ethernet (or other embedded networking) peripheral is placed into buffers that are pre-allocated by the IP stack. When the user sends a message the message contents are placed in a buffer that is allocated by the IP stack. Different buffer allocation schemes suite different embedded applications. FreeRTOS+UDP currently includes two buffer allocation schemes - each with different trade offs between simplicity, RAM usage efficiency, and performance. The two schemes are described on this page.


Buffer Allocation Schemes

The C source files that implement the buffer allocation schemes are located in the FreeRTOS-Plus/FreeRTOS-Plus-UDP/portable/BufferManagement directory. Only one scheme can be used at a time.


Scheme 1: Implemented by BufferAllocation_1.c

Description  
  • Ethernet buffer descriptors are statically allocated by the IP stack (at compile time).
  • Ethernet buffers are statically allocated by the embedded Ethernet peripheral driver (at compile time). This ensures the buffers can be aligned as required by the specific Ethernet hardware.

Attributes  
  • Fast run time performance.
  • Ethernet buffers can be allocated and freed from interrupts, allowing for more efficient embedded Ethernet peripheral drivers.
  • Inefficient use of RAM - all the buffers are the same size making BufferAllocation_1.c unsuitable for some RAM constrained embedded systems.
  • More complex to configure and tune than the scheme implemented by BufferAllocation_2.
  • Simpler to achieve any special buffer alignment requirements imposed by the embedded Ethernet peripheral DMA.
  • Requires support from the network interface driver (see the description bullet points above).

Usage  
  • The ipconfigNUM_NETWORK_BUFFERS constant (defined in FreeRTOSIPConfig.h) defines the total number of available buffers.
  • The ipconfigNETWORK_MTU constant (defined in FreeRTOSIPConfig.h) defines the size of each Ethernet frame (the total size being the defined MTU size plus the number of bytes needed by the Ethernet header).


Scheme 2: Implemented by BufferAllocation_2.c

Description  
  • Ethernet buffer descriptors are statically allocated by the IP stack (at compile time). This allows the user to limit the total number of Ethernet frames that can exist at any time to prevent memory exhaustion.
  • Ethernet buffers of exactly the required size are dynamically allocated and freed as required.

Attributes  
  • Dynamic allocation results in slower run time performance when compared with the scheme implemented by BufferAllocation_1.c.
  • Ethernet buffers cannot be allocated and freed from interrupts, necessitating the use of deferred interrupt handling tasks in embedded Ethernet peripheral drivers.
  • Very efficient RAM usage - only the exact amount of RAM required is allocated making BufferAllocation_2.c particularly suited for RAM constrained small embedded systems.
  • Easier to configure and tune than the scheme implemented by BufferAllocation_1.

Usage  
  • The ipconfigNUM_NETWORK_BUFFERS constant (defined in FreeRTOSIPConfig.h) defines the total number of available network buffer descriptors. The descriptors contain pointers to Ethernet buffers, but do not actually contain buffers themselves. Buffers are allocated as required.
  • Ethernet buffers are allocated from the FreeRTOS heap. To avoid memory fragmentation problems, BufferAllocation_2.c can only be used reliably with a memory allocation scheme that combines free blocks of heap memory (a coalescence algorithm). The FreeRTOS memory allocation scheme implemented in heap_4.c is suitable.
  • The IP stack will recover from an attempt to allocate a network buffer failing because there is too little heap memory. Such a failure will however result in the malloc failed hook function being called (if configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h).


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ FreeRTOS+ Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.