lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Memory tune on different tcp_pcb applications


From: Dániel Velez
Subject: [lwip-users] Memory tune on different tcp_pcb applications
Date: Mon, 10 Mar 2014 13:22:07 +0000

Hi,

I have been using LwIP (raw API) for 2 years and I am very satisfied with the wide range of usability. So on the same controller (STM32F207) I open lots of tcp ports for different communications (http, some own protocols over TCP, and some kind of RS232 “converters”).

Up to now all options were set to match the requirements of http, but it use too much memory for other connections. Now I tried to tune somehow the memory usage of these connections, but it raised some questions.

For example all the protocols have own buffer, and task, so when pbuf received, the task wakes up and get the data from LwIP (free the pbuf), put in own buffer then process the data. I always know the free space in the buffer, so it would be expedient to set receive window for these pcbs independently (because if the protocol task is busy, it can’t get the data from LwIP, and every connection can fill the receive window, which is too big because of http). Same on RS232 pcbs: I need to limit the incoming bandwidth depending on the baudrate.

The complement problem is the TCP_SND_BUF buffer and TCP_SND_QUEUELEN. On http I need as big packets as can, but on RS232 I call frequently write, with small amount of data. So on http I need big TCP_SND_BUF with smaller TCP_SND_QUEUELEN, on RS232 pcbs smaller TCP_SND_BUF, but longer TCP_SND_QUEUELEN. (TCP_OVERSIZE is not option for me)

The question: is it possible to adjust these options on port listen, or on accept, and use different values on different pcbs? Maybe change the receive window manually, and disable the refresh automation?

 

Other question is about tcp_write: RS232 app is listening on one tcp port, and accept more connections. Every connection can send to RS232 and every received RS232 byte is transmitted to all connected connections. So I’m wondering if it’s possible to send the same data through more pcbs, without copy it multiple to the LwIP’s heap. This data is stored in buffer at app, and I thought to write it multiple to all pcbs, but without the TCP_WRITE_FLAG_COPY flag. The problem is that I don’t know when can I free this memory area (I tried to calculate something on tcp_sent callback, but it didn’t work). Is there any way to check if the specified data is acked or not, or on tcp_write created PBUF_ROM is freed or not?

 

Thanks and regards

Dani


reply via email to

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