wunihaoo 发表于 2011-2-25 10:47:03

LWIP+enc28j60发送问题

我的程序功能是这样的,板子向上位机每次发送8K字节左右的数据,上位机收到数据后会回复一包45字节的数据。现在板子的程序是这样设计的:发送和接收数据分别是在两个线程里面处理,都加了互斥锁的,但是发送数据发了一会儿就会卡死,卡在发送函数里面,有时候发的时间会长点,和发送速度快慢也有关系。抓包发现貌似是重发引起的,如下图(上位机IP:10.10.10.11 板子IP:10.10.10.63):
http://cache.amobbs.com/bbs_upload782111/files_36/ourdev_618322ZSB34M.jpg
(原文件名:未命名.jpg)

感觉这个重发有点问题呢,重发的数据是还没有发送过的数据。请大侠们帮我看看,感激不尽!

又重新试了几次,卡死也不单单是重发引起,有时抓包都正常

ffxz 发表于 2011-2-26 09:19:52

两个线程分别做收发在LwIP中是比较困难的,不知道你这部分是如何设计的

重发也许是你那个dup ack引起的,这个你也可以把cap文件也贴上来。

wunihaoo 发表于 2011-2-26 13:16:18

回复【1楼】ffxz
-----------------------------------------------------------------------

抓包感觉看不出什么问题来每次卡死的时候 抓包的情况都可能不同,有时候看不出问题。

我用DM9000都没得问题呢,用enc28j60就这样了,是不是驱动问题? 开始用的DM9000驱动也是这种状况,后来换了一个就好了。

wunihaoo 发表于 2011-2-26 20:16:48

回复【2楼】wunihaoo
-----------------------------------------------------------------------
现在把程序修改了下,接收线程是用select判断是否有接收的数据。

打开LWIP的TCP_OUTPUT_DEBUG调试发现每次卡死的时候,是这种情况,是说发送队列太长了:
tcp_write(pcb=200071fc, data=20008aac, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=20008aac, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1061250:1062274 (0x0)
tcp_enqueue: queueing 1062274:1063298 (0x0)
tcp_output_segment: 1061250:1062274
tcp_output_segment: 1062274:1063298
tcp_write(pcb=200071fc, data=200092ac, len=44, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=200092ac, len=44, flags=0, apiflags=0)
tcp_enqueue: queueing 1063298:1063342 (0x0)
tcp_output_segment: 1063298:1063342
tcp_output: nothing to send (00000000)
tcp_output: sending ACK for 426865333
tcp_write(pcb=200071fc, data=200092e4, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=200092e4, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1063342:1064366 (0x0)
tcp_enqueue: queueing 1064366:1065390 (0x0)
tcp_output_segment: 1063342:1064366
tcp_output_segment: 1064366:1065390
tcp_write(pcb=200071fc, data=20009ae4, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=20009ae4, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1065390:1066414 (0x0)
tcp_enqueue: queueing 1066414:1067438 (0x0)
tcp_output_segment: 1065390:1066414
tcp_output_segment: 1066414:1067438
tcp_write(pcb=200071fc, data=2000a2e4, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000a2e4, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1067438:1068462 (0x0)
tcp_enqueue: queueing 1068462:1069486 (0x0)
tcp_output_segment: 1067438:1068462
tcp_output_segment: 1068462:1069486
tcp_write(pcb=200071fc, data=2000aae4, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000aae4, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1069486:1070510 (0x0)
tcp_enqueue: queueing 1070510:1071534 (0x0)
tcp_output_segment: 1069486:1070510
tcp_output_segment: 1070510:1071534
tcp_write(pcb=200071fc, data=2000b2e4, len=44, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000b2e4, len=44, flags=0, apiflags=0)
tcp_enqueue: queueing 1071534:1071578 (0x0)
tcp_output_segment: 1071534:1071578
tcp_output: nothing to send (00000000)
tcp_write(pcb=200071fc, data=2000b31c, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000b31c, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1071578:1072602 (0x0)
tcp_enqueue: queueing 1072602:1073626 (0x0)
tcp_output_segment: 1071578:1072602
tcp_output_segment: 1072602:1073626
tcp_write(pcb=200071fc, data=2000bb1c, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000bb1c, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1073626:1074650 (0x0)
tcp_enqueue: queueing 1074650:1075674 (0x0)
tcp_output_segment: 1073626:1074650
tcp_output_segment: 1074650:1075674
tcp_write(pcb=200071fc, data=2000c31c, len=1024, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000c31c, len=1024, flags=0, apiflags=0)
tcp_enqueue: queueing 1075674:1076698 (0x0)
tcp_output_segment: 1075674:1076698
tcp_output: nothing to send (00000000)
tcp_output_segment: 1074650:1075674
tcp_write(pcb=200071fc, data=2000c71c, len=0, apiflags=0)
tcp_write(pcb=200071fc, data=2000c71c, len=2048, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000c71c, len=2048, flags=0, apiflags=0)
tcp_enqueue: queueing 1076698:1077722 (0x0)
tcp_enqueue: queueing 1077722:1078746 (0x0)
tcp_output_segment: 1076698:1077722
tcp_output_segment: 1077722:1078746
tcp_write(pcb=200071fc, data=2000cf1c, len=1068, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000cf1c, len=1068, flags=0, apiflags=0)
tcp_enqueue: queueing 1078746:1079770 (0x0)
tcp_enqueue: queueing 1079770:1079814 (0x0)
tcp_output_segment: 1078746:1079770
tcp_output_segment: 1079770:1079814
TCP thread miss segnumb: 13031. Time: 201210
tcp_write(pcb=200071fc, data=2000b31c, len=980, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000b31c, len=980, flags=0, apiflags=0)
tcp_enqueue: too long queue 4 (max 4)
tcp_output: nothing to send (00000000)
tcp_write(pcb=200071fc, data=2000b31c, len=2004, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000b31c, len=2004, flags=0, apiflags=0)
tcp_enqueue: queueing 1079814:1080838 (0x0)
tcp_enqueue: queue too long 6 (4)
tcp_output: nothing to send (00000000)
tcp_output_segment: 1079770:1079814
tcp_write(pcb=200071fc, data=2000b31c, len=2004, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000b31c, len=2004, flags=0, apiflags=0)
tcp_enqueue: queueing 1079814:1080838 (0x0)
tcp_enqueue: queue too long 6 (4)
tcp_output: nothing to send (00000000)
tcp_output: nothing to send (00000000)
tcp_write(pcb=200071fc, data=2000b31c, len=2004, apiflags=0)
tcp_enqueue(pcb=200071fc, arg=2000b31c, len=2004, flags=0, apiflags=0)
tcp_enqueue: queueing 1079814:1080838 (0x0)
tcp_enqueue: queue too long 6 (4)

zhangdawei 发表于 2011-8-24 15:15:23

mark

xsx127 发表于 2012-7-28 16:50:40

能共享下么,最近在搞这个
页: [1]
查看完整版本: LWIP+enc28j60发送问题