LwIP buffer management, memory configuration options
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的更多相关文章
- Server Memory Server Configuration Options 服务器内存服务配置选项
Server Memory Server Configuration Options https://docs.microsoft.com/en-us/sql/database-engine/conf ...
- 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 ...
- scheduler configuration options
Table 4.53. Description of scheduler configuration options Configuration option = Default value Desc ...
- Determine YARN and MapReduce Memory Configuration Settings
Determine YARN and MapReduce Memory Configuration Settings https://docs.hortonworks.com/HDPDocuments ...
- eclipse 中springboot2.0整合jsp 出现No Java compiler available for configuration options compilerClassName
今天使用eclipse创建springboot整合jsp出现一个问题,在idea中并没有遇到这个问题.最后发现是需要在eclipse中添加一个eclipse依赖,依赖如下: <dependenc ...
- springboot No Java compiler available for configuration options compilerClassName: [null] and compil
今天使用eclipse创建springboot整合jsp出现一个问题,在idea中并没有遇到这个问题.最后发现是需要在eclipse中添加一个eclipse依赖,依赖如下: <dependenc ...
- Pytest权威教程21-API参考-07-配置选项(Configuration Options)
目录 配置选项(Configuration Options) addopts cache_dir confcutdir console_output_style doctest_encoding do ...
- Net6 Configuration & Options 源码分析 Part1
Net6 Configuration & Options 源码分析 Part1 在Net6中配置系统一共由两个部分组成Options 模型与配置系统.它们是两个完全独立的系统. 第一部分主要记 ...
- Net6 Configuration & Options 源码分析 Part2 Options
Net6 Configuration & Options 源码分析 Part2 Options 第二部分主要记录Options 模型 OptionsConfigurationServiceCo ...
随机推荐
- Hadoop(一):概述
一.Hadoop是什么? Hadoop是一个由Apache基金会所开发的分布式系统基础架构.Hadoop框架最核心的设计包含两个方面,一是分布式文件系统(Hadoop Distributed File ...
- 产生唯一的临时文件mkstemp()
INUX下建立临时的方法(函数)有很多, mktemp, tmpfile等等. 今天只推荐最安全最好用的一种: mkstemp. mkstemp (建立唯一临时文件)头文件: #include < ...
- 连接数据库:ERROR:The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration prop
本打算在maven项目中配置mybatis试试看,想到mybatis如果不是在容器中运行,那么他的事务控制实际上可以使用的是jdbc的提交和回滚,这就要在pom.xml文件中配置mysql-conne ...
- Codeforces 798D - Mike and distribution(二维贪心、(玄学)随机排列)
题目链接:http://codeforces.com/problemset/problem/798/D 题目大意:从长度为n的序列A和序列B中分别选出k个下表相同的数要求,设这两个序列中k个数和分别为 ...
- 一张图解AlphaGo原理及弱点
声明:本文转载自(微信公众号:CKDD),作者郑宇 张钧波,仅作学习收录之用,不做商业目的. 近期AlphaGo在人机围棋比赛中连胜李世石3局,体现了人工智能在围棋领域的突破,作为人工智能领域的工作者 ...
- xcode上真机调试iphone4s出现“There was an internal API error.”解决方案
xcode7更新之后使用真机调试,在IOS8的一台Iphone5手机上面没什么问题,IOS8的一台iphone6也没问题.但是在IOS6的一台Iphone4s和 IOS7的ipad air2上面在最后 ...
- 使用 Python 的 sounddevice 包录制系统声音
博客中的文章均为meelo原创,请务必以链接形式注明本文地址 sounddevice是一个与Numpy兼容的录音以及播放声音的包. 安装sounddevice包 直接通过pip就能安装. pip in ...
- <<Javascript Patterns>>阅读笔记 -- 第2章 基本技巧(一)
第一次写这种东西, 有些生涩和蹩脚, 也是为了自己在表达或是总结方面有所提高, 同时为看过的东西留个痕迹, 以便日后查阅. 有错误或是不妥的地方, 还望各位指正, 谢谢! 第1章 简介 本章主要介绍了 ...
- lr_start_transaction/lr_end_transaction事物组合
lr_start_transaction/lr_end_transaction事物组合 总结一下: lr_start_transaction与lr_end_transaction 为使用最多的事物创造 ...
- javax.persistence.EntityNotFoundException: Unable to find报错
这类错id 可能是10,可能是27,也可能是其他数字 错误描述: javax.persistence.EntityNotFoundException: Unable to find 某个类 with ...