lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] TCP Window and Memory Allocation


From: Kieran Mansley
Subject: Re: [lwip-users] TCP Window and Memory Allocation
Date: Wed, 30 May 2007 09:22:41 +0100

On Wed, 2007-05-30 at 10:35 +0300, Caglar Akyuz wrote:
> Hi,
> 
> When I was playing with my lwipopts.h file, I realized that increasing
> TCP_WND size does not effect my memory allocation. Is this the case?
> 
> If it is, then what should I do to assure correct operation for the
> stack? I think I should adjust my memory allocation accordingly, but I
> don't know what should be the policy. How much memory should I allocate
> for a given size of TCP Window?

For each connection, if you're sending and receiving data, and you never
want to run out of memory for packets, you need at most the TCP_SND_BUF
and TCP_WND bytes of packet buffers (pbufs) available.  These values
don't affect how much memory is allocated directly because some users
may prefer to occasionally run out of memory for packets rather than
configure the theoretical maximum amount of memory.

Packet buffers can be allocated in a couple of different ways.  For
example, there is a fixed size pool of packet buffers whose size you can
modify using the PBUF_POOL options in lwipopts.h  Note that if a buffer
is taken from the pool the stack might not always use the full amount in
that buffer, so in general if memory is your main concern you're better
off having lots of little pool buffers rather than a few big ones.  It
can chain small ones together to make long ones if it needs to.

The stack can also allocate packet buffers dynamically from RAM, rather
than the pool, and depending on which API you're using this is perhaps
the most common method.  The amount of memory required is then not pre-
determined, but will grow and shrink as the stack's usage changes.  

Hope that helps,

Kieran





reply via email to

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