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 _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
