lwIP stops receiving packet with high workloads

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by tjoAG on Thu Nov 08 07:29:32 MST 2012
Hi All

I'm using the lwIP on me device running LPC1788. It works very well unless I start sending packet very fast from my PC.

This the domain it is used in:

I'm using FreeRTOS.
It is a simple server-client application, where the PC is the server. There is only 1 TCP connection. Data packet send is always 14 bytes in size and is always initiated from the server (PC).
The device then send back a respond every time it receive a request from the server.
The server never sends a new request unless it has received a reply or it has timed on on the missing responds. (Timeout is 500 ms)

If the server do send the next request as fast as it can (just after receiving a responds) it is just matter of time ( few seconds/+4000 packets), before the communication stops. The packet send from the server never is received by the netconn API!!

The packet is send (verified by wireshark) and a TCP syn packet is send back to the servers TCP/IP stack.
But the packet is not received by the RX task with the Netconn API.
Also, further send packets are never received on the connection any more. No TCP disconnect is present in either ends.

It also seems that the lwIP still running with all it tasks. When DEBUG is enabled, the receive task still receives data from the EMAC and handle the data. But no further packets received are send to the application (Netconn receive).

When putting a delay (5 ms) in the server, before a new packet is send after the responds is received, there is no problems at all... Just keeps running and running. Using a 1 ms makes the communication run longer, but suddenly it stops.

So it seems that something happen somewhere in the lwIP when a packet is received to short after one is send with the Netconn API.. May bee it is the netconn API that stops working? Timing issue between TCP and netconn?

It is a bit difficult to debug.. Ege serial debug view is flooded with data when debug is enabled!

Any suggestion how to debug further or what could be wrong?

Client code RX task

nReceiveErr = netconn_recv(xNetConn, &buf);

if(nReceiveErr  == ERR_OK)
  nBufferOffset = 0;
do // while still data in buffer
    if(m_byEthDrvReceiveState == NORMAL)
      // Copy all until no more room inbuffer
      nTotal = netbuf_copy_partial(buf, &byRXData[0], 14, nBufferOffset);

      nBufferOffset += nTotal;

      // need 14 bytes
      if(nTotal >= 14)
        // Put the first 14 bytes in the queue
        ProtocolPutInRXQueue(&byRXData[1], ETH_TYPE);
        nTotal = 0;
}while( nBufferOffset < netbuf_len(buf));

Regards Thomas