lwip-users
[Top][All Lists]
Advanced

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

RE: [lwip-users] tcp_write() errors on snd_queuelen


From: Kieran Mansley
Subject: RE: [lwip-users] tcp_write() errors on snd_queuelen
Date: Thu, 17 Mar 2011 09:48:27 +0000

On Wed, 2011-03-16 at 18:27 +0000, Tim Lambrix wrote:

> What is actually getting put into that TCP window memory?  Is that the
> ack for each tcp packet?  Is that memory coming out of the MEM_SIZE
> define?

It doesn't refer to real memory as such; the receive window is how much
space the receiver is advertising to the sender.  The sender is allowed
to send this much data before it has to wait for an acknowledgement that
provides a further tranche of receive window.  It refers to memory
indirectly in that the receiver has to commit to receiving the data it
has advertised space for, so it needs to have sufficient buffers
available.  (Strictly speaking it is allowed to drop received packets
even if they are in the advertised receive window, but that should be
avoided) 

> 
> > TCP_SND_BUF and TCP_SND_QUEUELEN seem OK. Those settings allow you
> to make 64 or 128
> > calls to tcp_write() (one pbuf per call when copying data, 2 per
> call when not 
> > copying) and to enqueue 8400 bytes of data in these pbufs.
> 
> I am copying the data into the tcp_write.  So I can then hold 128 * my
> 50 byte packets in the TCP_SND_BUF of ~8K?  However, when I have
> viewed the buffer size debug output, I see pcb->snd_queuelen get up to
> 100 or more but pcb->snd_buf only has a couple hundred bytes removed.
> Where is the rest of the queues (pbufs, I assume) stored in memory?

There are two lengths for the send queue: the byte length and the
segment length.  It is considered full when either limit is reached.
Metadata structures like pbufs can be stored in a variety of places
depending on how you've configured lwIP.  It's possible to take them
from a fixed pool for example, or it can just use malloc.  

> > The other memory settings seem OK, too. However, that depends on the
> number of
> > parallel connections.
> 
> I only support 1 connection at a time.  If I support 2, does it double
> the memory requirements and does it happen automatically or is the
> TCP_SND_QUEUELEN shared between the connections?

TCP_SND_QUEUELEN is the length of each socket's send queue, not shared
between connections, so the memory requirement is proportional to the
number of sockets.

> Lastly, how big is a pbuf and is there a relationship between the
> MEMP_NUM_TCP_SEG and a pbuf? 

I can't remember exactly what its size is - take a look at the
definition.  It's deliberately pretty small though, I think about 32
bytes.

There is a many-to-one mapping between pbufs and segments (i.e. each
segment can be split across multiple pbufs by chaining them together).

> If there is a way to set a pbuf, should it be set to a typical call
> into tcp_write for optimum memory usage?

I don't understand that bit.

Kieran




reply via email to

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