lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] TCP Raw API questions about efficiency and threads


From: Pîrvu Mihai
Subject: [lwip-users] TCP Raw API questions about efficiency and threads
Date: Fri, 3 Jun 2016 00:15:57 +0300

Hello guys, I've just ported my application to tcp raw API and I was wondering a few things. 

I've noticed that the performance is a bit too bad (300-500 ms for pings, between local clients) and I was wondering if I'm doing some things wrong.

Firstly,  I'm doing all my packet processing + sending of replies in tcp_recv callback. Is this normal, or shall I save the data somehow and process it later. My idea is that this blocks the main thread and the next packets are delayed. But I don't know this for sure.

I don't understand how I can use multiple threads using this API. It's callback based, so where do I create the threads? Let's say I want to process the entire callback saved using tcp_recv on a separate thread. Is that possible or do I have to create a new thread inside the callback?

The application I'm using is a vpn server that has to inspect the packets (so I do that in tcp_recv), see where to forward one packet (from a list of connected clients to the server) and send that data to the client. I saw that each tcp_pcb has a unique memory address (obv.), so I save that in an array and if the client IP/MAC is the same as on in the array, I send my data to that pcb from the array. I can also send broadcasts (if mac is FF:FF:FF:FF:FF:FF). This is the "processing" that is done. 

One bad thing is that I copy the entire pbuf into a local buffer and free it (I saw that there's some idea to save it for later use, would love to see some examples on that).


reply via email to

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