Hi simon:

I use following code to send file to server by FlashFxp
static err_t ftpd_datarecv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, 
err_t err)
{
         struct ftpd_datastate *fsd = arg;
         if (err == ERR_OK && p != NULL)
         {
                   struct pbuf *q;
                   u16_t tot_len = 0;

                   for (q = p; q != NULL; q = q->next)
                   {
                            UINT len;

                            f_write(fsd->fil, q->payload, q->len, &len);
                            tot_len += len;
                            if (len != q->len)
                                     break;
                   }

                   tcp_recved(pcb, tot_len);
                   pbuf_free(p);
                   ftpdatarecv_flag = 1;
         }
         if (err == ERR_OK && p == NULL)
         {
                   struct ftpd_msgstate *fsm;
                   struct tcp_pcb *msgpcb;

                   fsm = fsd->msgfs;
                   msgpcb = fsd->msgpcb;
                   f_close(fsd->fil);
                   fsd->fil = NULL;
                   ftpd_dataclose(pcb, fsd);
                   fsm->datapcb = NULL;
                   fsm->datafs = NULL;
                   fsm->state = FTPD_IDLE;
                   send_msg(msgpcb, fsm, msg226);
                   ftpdatarecv_flag = 0;
         }
         return ERR_OK;
}


After send a while , the tcp_recv(pcb, ftpd_datarecv); is trigged slowed, so 
the speed is down …. It seems LWIP1.3.2 bug .

Vincent Cui
Software Engineer Leader
Mobile: +8613255150315
Tel: +86 21 34612525x6104
Fax: +86 21 34619770
E-Mail: [email protected]<mailto:[email protected]>
Shanghai EnLogic Electric Technology Co., Ltd.
Address: 1104-1106, Building A, No.391, Guiping Road, Xuhui District, Shanghai, 
200233


From: [email protected] 
[mailto:[email protected]] On Behalf Of 
[email protected]
Sent: 2012年4月13日 2:05
To: Mailing list for lwIP users
Subject: Re: [lwip-users] tcp_sndbuf return 0 when sending file

vincent cui wrote:
All

I develop a FTP server with lwIP 1.3.2 in Cortex M3 platform, when I use 
FlashFXP to get file from the server, the tcp_sndbuf always return 0 after work 
a while .
I capture it with wireshark, the file is attached file. The server ip: 
192.168.1.51. it seems that transfer error and need retransmission.

From the wireshark capture, I cannot see why the segment is retransmitted. 
Also, at which point do you get tcp_sndbuf==0, and what's the size of 
tcp_sndbuf initially?

I'm afraid that doesn't really help on your problem, though :-(
If I were you, I'd first have a look at lwip_stats to see if there are dropped 
segments or memory (allocation) failures and then monitor the value of 
tcp_sndbuf() (maybe it keeps getting smaller and never grows again?).


My sendcode in server is below:
[..]
            err = tcp_write(pcb, fsd->fifo.buffer + i, (u16_t)(fsd->fifo.size - 
i), 1);
Yikes! Using numbers instead of constants is really a thing people should learn 
(I'm speaking of TCP_WRITE_FLAG_COPY vs. '1')!

We provide the constants for people to use them so we are free to modify what 
they are defined to. By using '1' instead of TCP_WRITE_FLAG_COPY, you have 
successfully made your code susceptible to problems with future versions of 
lwIP (once we decide to change the value of TCP_WRITE_FLAG_COPY) :-)

Simon
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to