lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] TCP data exchange quickly stalls


From: R. Diez
Subject: Re: [lwip-users] TCP data exchange quickly stalls
Date: Tue, 7 Jan 2014 13:15:16 +0000 (GMT)

Hallo again:


> [...]

> When the single TCP connection is established, both connection ends send 
> every 
> now and them a few bytes of known data. After both ends have sent 2 packets 
> of 
> data, each side receives just 1 packet with the right data inside. Then no 
> packet is ever received again,
> [...]


I have dug a little deeper, and I know more now. The problem only triggers if I 
set LWIP_LOOPBACK_MAX_PBUFS to a non-zero value. This is the documentation for 
that symbol:

/**
 * LWIP_LOOPBACK_MAX_PBUFS: Maximum number of pbufs on queue for loopback
 * sending for each netif (0 = disabled)
 */

When I read about that maximum value, I didn't expect that 0 would disable it. 
What feature is exactly disabled? Or does 0 mean that there is no check, and 
therefore there is no limit? Would that mean those loopback buffers could eat 
up the whole RAM then?

In the mean time, I have switched lwIP from version 1.4.1 to git head. When I 
enable LWIP_LOOPBACK_MAX_PBUFS and that problem triggers, I have seen variable 
netif->loop_cnt_current overflowing and landing at 65535 (-1), at which point 
the TCP connection traffic stops. I still do not know why it overflows, but the 
following assert in src/core/netif.c, function netif_poll(), line 773, looks 
like it was designed to catch this case, but it does not work properly:

#if LWIP_LOOPBACK_MAX_PBUFS
      u8_t clen = pbuf_clen(in);
      /* adjust the number of pbufs on queue */
      LWIP_ASSERT("netif->loop_cnt_current underflow",
        ((netif->loop_cnt_current - clen) < netif->loop_cnt_current));
      netif->loop_cnt_current -= clen;
#endif /* LWIP_LOOPBACK_MAX_PBUFS */

I have changed it locally to the following expression, and it does work then 
(it triggers before wrapping around):

  LWIP_ASSERT("netif->loop_cnt_current underflow", netif->loop_cnt_current >= 
clen );

Or is there something I haven't quite understood?

Thanks,
  rdiez



reply via email to

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