ESP8266 TCP数据包碎片
我正在尝试使用WEMOS D1 MINI PRO(ESP8266)将TCP数据包发送到远程服务器,该Pro(ESP8266)在 lwip v2 high band bandwidth mode(tcp_mss = 1460
,lwip_功能= 1 )。
我将最大缓冲区大小设置为1810字节:
#define MAX_BUFFER_SIZE 1810
我将缓冲区声明为全局静态变量:
static uint8_t buffer[MAX_BUFFER_SIZE];
并且我使用tcp_write不断地发送packetsize
(用户定义的大小)数据包:
uint16_t sent = TCP.write((uint8_t*)buffer,packetSize);
大多数时间我得到<代码>已发送等于Packetsize,但是,一次函数返回较小的值。例如,如果Packetsize = 1135,则我通常会得到第一个不良值等于650和几个零值。发送几次失败后,正常操作会恢复。
我正在寻找这个分裂问题的原因。
思想:无论packetsize
是否实际上小于tcp_mss
,我是否应该使用缓冲区大小(当前1860)小于TCP_MSS = 1460?如果是,我是否应该尝试将缓冲区
作为动态数组,大小等于packetsize
?
I am trying to send TCP packets to a remote server, using the Wemos D1 Mini Pro (ESP8266), configured in lwIP v2 high bandwidth mode (TCP_MSS = 1460
, LWIP_ FEATURES = 1
).
I set a maximum buffer size of 1810 bytes :
#define MAX_BUFFER_SIZE 1810
I declare the buffer as a global static variable :
static uint8_t buffer[MAX_BUFFER_SIZE];
and I am continually sending packetSize
(user-definable size) packets using TCP_write :
uint16_t sent = TCP.write((uint8_t*)buffer,packetSize);
most of the times I get sent
equal to packetSize, however, once a while the function returns a smaller value. For instance, if packetSize = 1135, I usually get the first bad value equal to 650 and a few zero values after that. Normal operation restores after a few failed sends.
I am looking for the reasons behind this fragmentation issue.
Thoughts : should I use a buffer size (currently 1860) smaller than TCP_MSS = 1460, no matter if packetSize
is actually smaller than TCP_MSS
? If yes, should I try to declare buffer
as a dynamic array with size equal to packetSize
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论