lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Help! why send the same segment twice?


From: SAM
Subject: [lwip-users] Help! why send the same segment twice?
Date: Thu, 21 Jul 2022 17:11:52 +0800

Hi ,I need help!
When send >3 segments ,it's easy cause the following error.
HW: stm32H750+freertos+lwip_V2.1.2+lwip mqtt ;  stm32cubemx create project;
TCP_INPUT_DEBUG and TCP_OUTPUT_DEBUG set  ON , the following is debug log( "//" is my comment):
===========================debug log====================================
[15:22:00.452] Tmpx=push/full 
[15:22:00.452] ###push_all=1492  mqtt_publish: Publish with payload length 1492 to topic "push/full"      //push need send 1492+14=1506 bytes
[15:22:00.488]
[15:22:00.492] @@MQOSD4 mqtt_output_send: tcp_sndbuf: 4096 bytes, ringbuf_linear_available: 304, get 2196, put 1202
[15:22:00.492] tcp_write(pcb=20011664, data="" len=304, apiflags=3)
[15:22:00.512]
[15:22:00.512]
[15:22:00.512] @@@TWC=4,304,4096,0  // 304 bytes;
[15:22:00.512]
[15:22:00.512] tcp_write: queuelen: 0
[15:22:00.528]
[15:22:00.532] tcp_write: queueing 83706:84010  //segment 1 is 304 bytes
[15:22:00.532] tcp_write: 1 (after enqueued)
[15:22:00.552] tcp_write(pcb=20011664, data="">[15:22:00.561] tcp_output_segment: 83706:84010  //send segment1 (304 Bytes);
[15:22:00.569] , len=1202, apiflags=1)
[15:22:00.572]
[15:22:00.572]
[15:22:00.572] @@@TWC=4,1202,3792,1  //need send 1202 bytes; the following  two segment 1024+178;
[15:22:00.572]
[15:22:00.572] tcp_write: queuelen: 1
[15:22:00.572] tcp_write: queueing 84010:85034  //segment 2 is 1024 bytes
[15:22:00.590] tcp_write: queueing 85034:85212  //segment 3 is  178 bytes; the totle bytes is 304+1024+178=1506bytes;
[15:22:00.592] tcp_write: 3 (after enqueued)
[15:22:00.592]
[15:22:00.592] tcp_output_segment: 84010:85034 //send segment2 (1024 Bytes);
[15:22:00.600]
[15:22:00.602] ---tcp_input---
[15:22:00.602] tcp_output: sending ACK for 2995636869
[15:22:00.602]
[15:22:00.602] tcp_output_segment: 84010:85034 // why send segment2 twice???  This action create error following, segment2 is one segment,send twice ,the server ACK twice,
                                                                           //free segment2 twice, when queuelen=0, free segment,queuelen=0-1=65535; please see[15:22:00.662] and[15:22:00.672] log
[15:22:00.602]
[15:22:00.602] ---tcp_input---
[15:22:00.602] tcp_receive: ACK for 85034, unacked->seqno 83706:84010  //receive segment1 ACK
[15:22:00.602] tcp_receive: removing 83706:84010 from pcb->unacked
[15:22:00.602] tcp_receive: queuelen 3 ... 2 (after freeing unacked)     //queuelen=3-1=2
[15:22:00.602] tcp_receive: removing 84010:85034 from pcb->unacked  //receive segment2 ACK
[15:22:00.602] tcp_receive: queuelen 2 ... 1 (after freeing unacked)     //queuelen=1-1=1
[15:22:00.602]
[15:22:00.602] mqtt_tcp_sent_cb: Calling QoS 0 publish complete callback
[15:22:00.612]
[15:22:00.612]
[15:22:00.612] **pub_cb=1
[15:22:00.612]
[15:22:00.612] ***Publish ok=0
[15:22:00.612]
[15:22:00.612]
[15:22:00.612] @@MQOSD1
[15:22:00.612] tcp_output_segment: 85034:85212 //send segment3 (178 bytes)
[15:22:00.612]
[15:22:00.612] ---tcp_input---
[15:22:00.650]
[15:22:00.653] ---tcp_input---
[15:22:00.653] tcp_receive: ACK for 85212, unacked->seqno 85034:85212  //receive segment3 ACK
[15:22:00.653] tcp_receive: removing 85034:85212 from pcb->unacked
[15:22:00.653] tcp_receive: queuelen 1 ... 0 (after freeing unacked)             //queuelen=1-1=0 , no segment.
[15:22:00.662] tcp_receive: removing 3232235551:3232235855 from pcb->unsent                                         // How to understand this?? 3232235551:3232235855 is error segment
[15:22:00.662] tcp_receive: queuelen 0 ... Assertion "pcb->snd_queuelen >= pbuf_clen(next->p)" failed at line 1112 in ../Middlewares/Third_Party/LwIP/src/core/tcp_in.c
[15:22:00.662] Assertion "pbuf_free: p->ref > 0" failed at line 753 in ../Middlewares/Third_Party/LwIP/src/core/pbuf.c
[15:22:00.672] 65535 (after freeing unsent)
[15:22:00.672] tcp_receive: removing 84010:85034 from pcb->unsent
[15:22:00.672] tcp_receive: queuelen 65535 ... Assertion "pbuf_free: p->ref > 0" failed at line 753 in ../Middlewares/Third_Party/LwIP/src/core/pbuf.c    //65535=0-1
[15:22:00.672] 65534 (after freeing unsent)
[15:22:00.672] Assertion "tcp_receive: valid queue length" failed at line 1122 in ../Middlewares/Third_Party/LwIP/src/core/tcp_in.c
[15:22:00.672]
[15:22:00.672] @@MQOSD1
[15:22:01.102] MQT=0x0B
========================end of debug log============================
MEM_SIZE=16360;TCP_MSS=1024; TCP_SND_BUF=4*TCP_MSS; TCP_SND_QUEUELEN=((2 * (TCP_SND_BUF) + (TCP_MSS - 1))/(TCP_MSS))=8;MEMP_NUM_PBUF=16;

In my understand ,send the same segment twice, receive twice ACK, free/removing  the segments twice ,when queuelen=0 and receive ACK free valid addr(3232235551:3232235855),and error queuelen=0-1=65535;  what cause send the same segment twice??

I need help,  now lwip MQTT lost connection and work deault.
Thanks a lot!

reply via email to

[Prev in Thread] Current Thread [Next in Thread]