http://www.st.com/st-web-ui/static/active/cn/resource/technical/document/application_note/DM00036052.pdf

LwIP TCP/IP stack demonstration for STM32F4x7 microcontrollers

Packet buffer structure

LwIP manages packet buffers using a data structure called pbuf.

The pbuf structure enables the allocation of a dynamic memory to hold a packet content and lets packets reside in the static memory.

Pbufs can be linked together in a chain. This enables packets to span over several pbufs.

• next: pointer to next pbuf in a pbuf chain
• payload: pointer to packet data payload
• len: length of the data content of the pbuf
• tot_len: sum of pbuf len plus all the len fields of the next pbufs in the chain
• ref: (on 4 bits) reference count that indicates the number of pointers that reference the pbuf. A pbuf can be released from memory only when its reference count is zero.
• flags: (on 4 bits) indicate the type of pbuf.

LwIP defines three types of pbufs, depending on the allocation type:

• PBUF_POOL: pbuf allocation is performed from a pool of statically pre-allocated pbufs that have a predefined size.
Depending on the data size that needs to be allocated, one or multiple chained pbufs are allocated.

• PBUF_RAM: pbuf is dynamically allocated in memory (one contiguous chunk of memory for the full pbuf)

• PBUF_ROM: there is no allocation for memory space for user payload, the pbuf payload pointer points to data in the ROM memory (it can be used only for sending constant data).

For packet reception, the suitable pbuf type is PBUF_POOL; it allows to rapidly allocate memory for the received packet from the pool of pbufs.
Depending on the size of the received packet, one or multiple chained pbufs are allocated.
The PBUF_RAM is not suitable for packet reception because dynamic allocation takes some delay. It may also lead to memory fragmentation.

For packet transmission, depending on the data to be transmitted, the user can choose the most suitable pbuf type.

API for managing pbufs LwIP has a specific API for working with pbufs. This API is implemented in the pbuf.c core file.

Note: 1 “pbuf” can be a single pbuf or a chain of pbufs.
2 When working with the Netconn API, netbufs (network buffers) are used for sending/receiving data.
3 A netbuf is simply a wrapper for a pbuf structure. It can accommodate both allocated and referenced data.
4 A dedicated API (implemented in file netbuf.c) is provided for managing netbufs (allocating, freeing, chaining, extracting data,...).

LwIP has several memory configurations options.

These options allow the user to tune the allocated RAM memory usage depending on performance needs
and on application memory constraints.The user options for LwIP are changed in file LwIPopt.h
Table 13 provides a summary of the main options for RAM memory use.

As shown in Table 13, LwIP memory has two main types:

• Heap memory for all dynamic allocations defined by MEM_SIZE.
• Pool memory for static pool structures defined by MEMP_NUM_xx and PBUF_POOL_xx.

The allocation from these two types of memory will define the total size of memory allocated to LwIP.

Below are some recommendations when setting these options:

• MEM_SIZE should be set high when the application needs to send a lot of data to be copied from application buffers to the LwIP send buffer.

• PBUF_POOL_BUFSIZE should be set according to the average size of packets to be received.

• PBUF_POOL_SIZE should be tuned as high as possible in order to achieve the best receive data rate.

• TCP_SND_BUF limits the sender buffer space (data queued to be transmitted).

For optimal performance, this parameter should be equal to the TCP window size of the remote host.
Keep in mind that every active connection might buffer this amount of data, so make sure there is enough RAM (defined by MEM_SIZE)
or limit the number of concurrently active connections.

• TCP_WND is the advertised receive window and should be tuned as high as possible in order to achieve the best performance.

LwIP buffer management, memory configuration options的更多相关文章

  1. Server Memory Server Configuration Options 服务器内存服务配置选项

    Server Memory Server Configuration Options https://docs.microsoft.com/en-us/sql/database-engine/conf ...

  2. Lock-less buffer management scheme for telecommunication network applications

    A buffer management mechanism in a multi-core processor for use on a modem in a telecommunications n ...

  3. scheduler configuration options

    Table 4.53. Description of scheduler configuration options Configuration option = Default value Desc ...

  4. Determine YARN and MapReduce Memory Configuration Settings

    Determine YARN and MapReduce Memory Configuration Settings https://docs.hortonworks.com/HDPDocuments ...

  5. eclipse 中springboot2.0整合jsp 出现No Java compiler available for configuration options compilerClassName

    今天使用eclipse创建springboot整合jsp出现一个问题,在idea中并没有遇到这个问题.最后发现是需要在eclipse中添加一个eclipse依赖,依赖如下: <dependenc ...

  6. springboot No Java compiler available for configuration options compilerClassName: [null] and compil

    今天使用eclipse创建springboot整合jsp出现一个问题,在idea中并没有遇到这个问题.最后发现是需要在eclipse中添加一个eclipse依赖,依赖如下: <dependenc ...

  7. Pytest权威教程21-API参考-07-配置选项(Configuration Options)

    目录 配置选项(Configuration Options) addopts cache_dir confcutdir console_output_style doctest_encoding do ...

  8. Net6 Configuration & Options 源码分析 Part1

    Net6 Configuration & Options 源码分析 Part1 在Net6中配置系统一共由两个部分组成Options 模型与配置系统.它们是两个完全独立的系统. 第一部分主要记 ...

  9. Net6 Configuration & Options 源码分析 Part2 Options

    Net6 Configuration & Options 源码分析 Part2 Options 第二部分主要记录Options 模型 OptionsConfigurationServiceCo ...

随机推荐

  1. POJ - Problem 2282 - The Counting Problem

    整体思路:对于每一位,先将当前未达到$limit$部分的段 [如 $0$ ~ $10000$] 直接处理好,到下一位时再处理达到$limit$的部分. · $1 × 10 ^ n$以内每个数(包括$0 ...

  2. MINI_httpd移植,构建小型WEB服务器

    一.简介 目的:构建小型WEB站,具备SSL. mini_httpd is a small HTTP server. Its performance is not great, but for low ...

  3. 洛谷 P1652圆 题解

    题目传送门 这道题也就是考你对几何的了解: 圆与圆没有公共点且一个圆在另一个圆外面时,叫做圆与圆相离. 当圆心距大于两圆半径之和时,称为两圆外离: 当圆心距小于两圆半径之差的绝对值时,称为两圆内含. ...

  4. 在JAVA中生成RSA秘钥对实现SSH互信

    https://blog.csdn.net/u014196729/article/details/51496262 https://blog.csdn.net/u013066244/article/d ...

  5. MVC开发人员必备的五大工具

    1. Chirpy Zippy 下载地址:http://chirpy.codeplex.com/ 过去,在将JavaScript脚本和CSS文件部署到Web服务器之 前,我习惯使用压缩工具进行压缩再部 ...

  6. jquery 美化弹出提示 漂亮的Dialog 对话框

    三个不同的效果,分别是普通的警告,确认/取消,带一个输入框 本例用了jquery.alertify.js,请到演示页面查看 css文件也请到演示页面查看 JavaScript Code <scr ...

  7. Scrapy 笔记(三)

    摘抄自Python 一.随机user-agent 的设置 关于配置和代码 这里我找了一个之前写好的爬虫,然后实现随机更换User-Agent,在settings配置文件如下: DOWNLOADER_M ...

  8. 洛谷P1099 BZOJ1999 树网的核 [搜索,树的直径]

    洛谷传送门,BZOJ传送门 树网的核 Description 设T=(V, E, W) 是一个无圈且连通的无向图(也称为无根树),每条边带有正整数的权,我们称T为树网(treenetwork),其中V ...

  9. 洛谷P1221 最多因子数 [搜索,数学]

    题目传送门 最多因子数 目描述 数学家们喜欢各种类型的有奇怪特性的数.例如,他们认为945是一个有趣的数,因为它是第一个所有约数之和大于本身的奇数. 为了帮助他们寻找有趣的数,你将写一个程序扫描一定范 ...

  10. Calendar日期方法

    面试居然让我获取当前月份第一天跟最后一天,主要是尴尬的回答不上来. 废话不说,直接贴代码,工作应该是够用了 public class TestCalendar { // 日期也就是这了 public ...