[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] raw api tcp_write()ing small chunks fills snd_queue
From: |
Simon Goldschmidt |
Subject: |
Re: [lwip-users] raw api tcp_write()ing small chunks fills snd_queue |
Date: |
Thu, 10 Apr 2014 11:03:13 +0200 |
Sergio R. Caprile wrote:
> I have this raw api application which tcp_write()s 5 small (~20 bytes)
> messages and then checks tcp_sndbuf() to send the biggest possible
> chunk, but it ends up having to send a smaller chunk because an internal
> queue gets full.
Actually, you have to understand TCP_SND_QUEUELEN to know what this limitation
means:
the snd_queuelen limitation is only a safety check that one pcb does not
consume too
many pbufs when you have multiple pcbs but only a limited number of pbufs.
This limitation is somewhat overridden by the "new" TCP_OVERSIZE code which
tries
to only create one pbuf per tcp segment *when copying the data*.
When not copying, data, the stack has no choice but to create one pbuf per
tcp_write call. However, this is rather a different amount of memory consumed
(PBUF_RAM or PBUF_POOL vs. PBUF_REF): e.g. you have enough RAM to create 30
PBUF_RAM,
but the PBUF_REF pool holds x100 pbufs.
So in applications where you mix these pbuf types, you might be better off to
just
set TCP_SND_QUEUELEN to a really high value that you never reach and implement
the
check to not enqueue too many pbufs on one connection yourself.
Simon