Showing results for 
Show  only  | Search instead for 
Did you mean: 
Registered: ‎09-05-2019

LWIP TX stops after sending some data

Hi everyone,

I modified the FreeRTOS lwIP TCP Perf Client example for sending repeated transfers of 2048 bytes to a minimalistic windows client I made, but after sending exactly 31 of  them it stops in lwip_send(), in the 32nd (thus getting stuck at 64kB).

64kB is the exact size of the TCP send buffer I have configured, so I guess that there is probably some problem with lwip_send() filling up the buffer and freezing when asked to send data before space is freed up (from the data being sent on the wire), am I correct?
If that is the case, how can I go about solving this issue? From what I had understood, I didn't need to handle the send buffer when using the sockets API, so I'm very confused.

The client (Zynq) executes a loop similar to the following:

while(1) {
    // code that triggers and waits for a DMA transfer
    bytes_sent = 0;
    total_bytes = 0;
    while (total_bytes < TRANSFER_LENGTH) {
        if((bytes_sent = lwip_send(*sock, BufferPtr+total_bytes, TRANSFER_LENGTH-total_bytes), apiflags))<0) {
            // code that handles error, never reached in this test
        total_bytes += bytes_sent;
// some prints omitted } }

Also, the server on the other side always only receives the first two groups of 2048 bytes, before it gets stuck waiting forever for the next transfer. It's executing (python, on a Windows machine) something whose receive loop is similar to:

while True:            
    while (len(data_list)<TRANSFER_LENGTH) :
        data = conn.recv(TRANSFER_LENGTH)
        if not data:
        data_list += list(data)
    # further processing

I'm using lwip211 and FreeRTOS on a Zynq device, with the Vitis IDE.

The DMA transfer mentioned in the pseudocode is a S2MM transfer from a custom peripheral I made, and it's working (in the sense that if I print the values of the buffer before calling lwip_send, it shows the exact values I expect). In any case, I though there could be a chance that this issue is caused by some interaction between lwip and my DMA code, which is why I decided to mention it.

I have already looked at, which does sound like the problem I'm facing, but the solution proposed doesn't apply to me (I'm already using a more recent version o lwip).

I'm quite new to this types of applications, and know very little of sockets programming in special, so please forgive any rookie mistakes, or wrong terminology.

(Moved this post here from, since I figured that was probably not the best forum to post)

Thank you.

0 Kudos
2 Replies
Registered: ‎08-25-2009

Hi @lb_fiber ,

Without modifying the example code,  do you have the issue that it stopped sending after a while?

Are you freeing the pbuf after it has been filled up? As you know, lwip is an open source library, have you posted the question on LWIP forum for any advise?


"Don't forget to reply, kudo and accept as solution."
0 Kudos
Registered: ‎09-05-2019

Hi @nanz,

When using the example code unmodified, the problem does not manifest (or at least it's not visible during the execution of the perf test).

I don't free the pbuff in my code, but neither does the example code (unless I'm missing it somehow, in which case I apologise). In fact, I thought that when using the socket-style API there was no need to explicitly take care of the pbuffs.

As for the suggestion of posting in the LWIP forum: great idea, I will be posting there too, I actually didn't know there was a dedicated forum for LWIP users. I had decided to post here first since it could be an issue related to the interaction with my AXI peripherals, or DMA code, or the Xilinx LWIP implementation.

I'm sorry for taking so long to answer, this month has been a little busy for the project I'm in.
Again, please excuse me for any begginer mistakes I may have made.

Thank you for your help.

0 Kudos