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 ...
随机推荐
- js事件、事件委托
事件流 事件流:页面中接收事件的顺序: IE的事件流是冒泡流,其他的浏览器是捕获流,如下图: DOM事件流 DOM 事件流同时支持这两种事件流,并且规定DOM任何事件流都包含三个阶段:事件捕获阶段.处 ...
- Django Authentication 用户认证系统
一. Django的认证系统 Django自带一个用户认证系统,用于处理用户账户.群组.许可和基于cookie的用户会话. 1.1 概览 Django的认证系统包含了身份验证和权限管理两部分.简单地说 ...
- Django 1.10文档中文版Part4
2.10 高级教程:如何编写可重用的apps 2.10.1 重用的概念 The Python Package Index (PyPI)有大量的现成可用的Python库.https://www.djan ...
- HDU 2066 一个人的旅行(dijkstra水题+判重边)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2066 题目大意:输入数据有多组,每组的第一行是三个整数T,S和D,表示有T条路,和草儿家相邻的城市的有 ...
- mongodb与mysql传统的关系数据库区别
转自:易百教程 MongoDB中的数据具有灵活的模式.文档在同一集合,但它们不需要具有相同的字段或结构集合,集合文档中的公共字段可以包含不同类型的数据. MongoDB中的数据具有灵活的模式.与SQL ...
- FreeMarker使用之比较if
1. =或者==:判断两个值是否相等. 2. !=:判断两个值是否不等. 3. >或者gt:判断左边值是否大于右边值 4. >=或者gte:判断左边值是否大于等于右边值 5. <或者 ...
- Robot Framework + Selenium2Lib
Robot Framework + Selenium2Lib 最近一段时间,公司在推行自动化测试流程,本人有幸参与了自定义通用控件的关键字封装和脚本辅助编写.数据驱动管理.测试用例执行管理等一系列工具 ...
- Windows 消息循环(2) - WPF中的消息循环
接上文: Windows 消息循环(1) - 概览 win32/MFC/WinForm/WPF 都依靠消息循环驱动,让程序跑起来. 本文介绍 WPF 中是如何使用消息循环来驱动程序的. 4 消息循环在 ...
- java浅拷贝和深拷贝(基础也是很重要的)
对象的copy你兴许只是懵懂,或者是并没在意,来了解下吧. 对于的github基础代码https://github.com/chywx/JavaSE 最近学习c++,跟java很是相像,在慕课网学习c ...
- Hibernate对象的状态转换
Hibernate中的实体对象可以分为三种状态:Transient(临时).Persistent(持久).Detached(游离) Transient 用new创建出对象,这些对象还没有与数据库发生任 ...