[Ns-developers] Infinite buffers == evil

Tom Henderson tomh at tomh.org
Fri Mar 5 07:10:45 PST 2010


On 3/5/10 6:42 AM, Gustavo Carneiro wrote:
>   Hello all.
>
> I recently submitted a couple of bug reports [1-2] regarding "receive
> queues" in PacketSocket and UdpSocket.  I was utterly convinced we had no
> such receive queues.  I have been for a long time plagued with "memory
> bloat" problems in my simulations.  I discovered that I had PacketSocket's
> unintentionally listening to packets (when they were supposed to be used
> only for sending), and on top of that they had unlimited receive queues.
>   This means that _every packet_ generated in the simulation was stored in
> memory, to be released only in the end of the simulation.
>
> First of all, I propose to BAN infinite buffers by default, everywhere in
> NS-3.  This includes:
>
> find . -type f -print0 | xargs -0 -e grep -nH -e "integerValue
> (0xffffffffl)"
> ./node/tcp-socket.cc:48:                   UintegerValue (0xffffffffl),
>   // RcvBufSize
> ./node/udp-socket.cc:42:                   UintegerValue (0xffffffffl),
> // RcvBufSize
> ./node/packet-socket.cc:46:                   UintegerValue (0xffffffffl),
>   // RcvBufSize
>
> Why?  Because infinite buffers are not realistic, and cause memory leaks of
> the worst kind, the kind that a memory leak detector cannot find.
>
> Also I don't understand why we need receive buffers at all?  Maybe we should
> remove them altogether?

We have them mainly because we have asynchronous sockets and also 
because real systems have them as a settable parameter.  If your 
receiver is slow and your buffer is small, you will lose datagrams.

I think the problem that should be corrected is the default infinite 
size, because you can inadvertently waste memory as you point out.  In 
general, we tend to default to Linux values for things so how about a 
default of 131071 (net.core.rmem_max)?

- Tom


More information about the Ns-developers mailing list