请教:LWIP如何发送大于TCP_MSS(1460)的数据

发布于 2016-02-15 16:31:07    浏览:2478
RTT版本为1.2.1
在我的项目中调用lwip_send()函数发送数据。
当数据小于TCP_MSS时,一切正常;
当数据大于TCP_MSS时,lwip_send没有反馈错误信息,但是接受端始终没有数据。
我调试一直追踪到tcp_write函数都没有错误反馈,有没有找到问题出在哪?这个问题我已经调试好几天了还是无果。
打开TCP_OUTPUT_DEBUG调试后,在终端得到了以下信息

tcp_write(pcb=20004f34, data=20009aa4, len=1466, apiflags=1)
tcp_write: queueing 6517:7977
tcp_write: queueing 7977:7983
tcp_output_segment: 6517:7977
tcp_output: sending ACK for 333009266
tcp_output_segment: 6517:7977

请哪位大侠指点一下,是否我的配置哪里有问题?还是其他什么情况。
以下是rtconfig.h配置
/* RT-Thread config file */
#ifndef __RTTHREAD_CFG_H__
#define __RTTHREAD_CFG_H__
/* RT_NAME_MAX*/
#define RT_NAME_MAX 8

/* RT_ALIGN_SIZE*/
#define RT_ALIGN_SIZE 4

/* PRIORITY_MAX */
#define RT_THREAD_PRIORITY_MAX 32

/* Tick per Second */
#define RT_TICK_PER_SECOND 100

/* SECTION: RT_DEBUG */
/* Thread Debug */
#define RT_DEBUG
#define RT_THREAD_DEBUG

#define RT_USING_OVERFLOW_CHECK

/* Using Hook */
#define RT_USING_HOOK

/* Using Software Timer */
/* #define RT_USING_TIMER_SOFT */
#define RT_TIMER_THREAD_PRIO 4
#define RT_TIMER_THREAD_STACK_SIZE 512
#define RT_TIMER_TICK_PER_SECOND 10

/* SECTION: IPC */
/* Using Semaphore*/
#define RT_USING_SEMAPHORE

/* Using Mutex */
#define RT_USING_MUTEX

/* Using Event */
#define RT_USING_EVENT

/* Using MailBox */
#define RT_USING_MAILBOX

/* Using Message Queue */
#define RT_USING_MESSAGEQUEUE

/* SECTION: Memory Management */
/* Using Memory Pool Management*/
#define RT_USING_MEMPOOL

/* Using Dynamic Heap Management */
#define RT_USING_HEAP

/* Using Small MM */
#define RT_USING_SMALL_MEM

//
#define RT_USING_COMPONENTS_INIT

/* SECTION: Device System */
/* Using Device System */
#define RT_USING_DEVICE
//
#define RT_USING_DEVICE_IPC

//
#define RT_USING_SERIAL
#define RT_USING_UART1
#define RT_USING_UART2
#define RT_USING_UART3

#define RT_USING_RTC

/* SECTION: Console options */
#define RT_USING_CONSOLE
/* the buffer size of console*/
#define RT_CONSOLEBUF_SIZE 128
//
//#define RT_CONSOLE_DEVICE_NAME "uart1"

/* SECTION: finsh, a C-Express shell */
#define RT_USING_FINSH
/* Using symbol table */
#define FINSH_USING_SYMTAB
#define FINSH_USING_DESCRIPTION

/* SECTION: device filesystem */
#define RT_USING_DFS

#define RT_USING_DFS_ELMFAT
/* Reentrancy (thread safe) of the FatFs module. */
#define RT_DFS_ELM_REENTRANT
/* Number of volumes (logical drives) to be used. */
#define RT_DFS_ELM_DRIVES 2
/* #define RT_DFS_ELM_USE_LFN 1 */
/* #define RT_DFS_ELM_CODE_PAGE 936 */
#define RT_DFS_ELM_MAX_LFN 255
/* Maximum sector size to be handled. */
#define RT_DFS_ELM_MAX_SECTOR_SIZE 4096

/* the max number of mounted filesystem */
#define DFS_FILESYSTEMS_MAX 2
/* the max number of opened files */
#define DFS_FD_MAX 4

/* SECTION: lwip, a lighwight TCP/IP protocol stack */
#define RT_USING_LWIP
/* LwIP uses RT-Thread Memory Management */
#define RT_LWIP_USING_RT_MEM
/* Enable ICMP protocol*/
#define RT_LWIP_ICMP
/* Enable UDP protocol*/
#define RT_LWIP_UDP
/* Enable TCP protocol*/
#define RT_LWIP_TCP
/* Enable DNS */
#define RT_LWIP_DNS

/* the number of simulatenously active TCP connections*/
#define RT_LWIP_TCP_PCB_NUM 5

/* Using DHCP */
#define RT_LWIP_DHCP

/* ip address of target*/
#define RT_LWIP_IPADDR0 192
#define RT_LWIP_IPADDR1 168
#define RT_LWIP_IPADDR2 1
#define RT_LWIP_IPADDR3 30

/* gateway address of target*/
#define RT_LWIP_GWADDR0 192
#define RT_LWIP_GWADDR1 168
#define RT_LWIP_GWADDR2 1
#define RT_LWIP_GWADDR3 1

/* mask address of target*/
#define RT_LWIP_MSKADDR0 255
#define RT_LWIP_MSKADDR1 255
#define RT_LWIP_MSKADDR2 255
#define RT_LWIP_MSKADDR3 0

/* tcp thread options */
#define RT_LWIP_TCPTHREAD_PRIORITY 12
#define RT_LWIP_TCPTHREAD_MBOX_SIZE 10
#define RT_LWIP_TCPTHREAD_STACKSIZE 1024

/* ethernet if thread options */
#define RT_LWIP_ETHTHREAD_PRIORITY 15
#define RT_LWIP_ETHTHREAD_MBOX_SIZE 10
#define RT_LWIP_ETHTHREAD_STACKSIZE 512

/* TCP sender buffer space */
#define RT_LWIP_TCP_SND_BUF 8192
/* TCP receive window. */
#define RT_LWIP_TCP_WND 8192

/* SECTION: RT-Thread/GUI */
/* #define RT_USING_RTGUI */

/* name length of RTGUI object */
#define RTGUI_NAME_MAX 12
/* support 16 weight font */
#define RTGUI_USING_FONT16
/* support Chinese font */
#define RTGUI_USING_FONTHZ
/* use DFS as file interface */
#define RTGUI_USING_DFS_FILERW
/* use font file as Chinese font */
#define RTGUI_USING_HZ_FILE
/* use Chinese bitmap font */
#define RTGUI_USING_HZ_BMP
/* use small size in RTGUI */
#define RTGUI_USING_SMALL_SIZE
/* use mouse cursor */
/* #define RTGUI_USING_MOUSE_CURSOR */
/* default font size in RTGUI */
#define RTGUI_DEFAULT_FONT_SIZE 16

/* image support */
/* #define RTGUI_IMAGE_XPM */
/* #define RTGUI_IMAGE_BMP */

//
// #define RT_USING_CMSIS_OS
//
#define RT_USING_RTT_CMSIS
//
// #define RT_USING_BSP_CMSIS

#endif

查看更多

6 个回答
bernard
bernard 2016-02-15
This guy hasn't written anything yet
可以打开lwIP中的分段和包汇合功能。
lugang_2920213
lugang_2920213 2016-02-15
This guy hasn't written anything yet
可以打开lwIP中的分段和包汇合功能。

请教老大,这个功能使用哪个宏打开
我试过打开RT_LWIP_TCP_SEG_NUM宏,但是没有解决问题。
aozima
aozima 2016-02-16
拒绝白嫖,拒绝键盘侠!
#define RT_LWIP_REASSEMBLY_FRAG
lugang_2920213
lugang_2920213 2016-02-16
This guy hasn't written anything yet
#define RT_LWIP_REASSEMBLY_FRAG

测试了没有成功。
决定在应用程序中限制包必须小于TCP_MSS,等项目完成后再继续研究。
多谢aozima指导。

XNXH_6023
XNXH_6023 2021-04-28
This guy hasn't written anything yet

我这边问题解决了。
把tcp、mem的debug打开,发现是打包数据发送时,超过TCP_MSS(1460)的数据无法申请到内存造成的。
经查看,发现lwip协议栈依赖的内存对齐大小宏MEM_SIZE_ALIGNED 敌营的MEM_SIZE定义为默认值1600(太小)造成

撰写答案

请登录后再发布答案,点击登录
关注者
0
被浏览
2.5k

发布
问题

分享
好友

手机
浏览

扫码手机浏览