This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1294KCPDT: Insufficent performance of LwIP stack - any suggestions?

Part Number: TM4C1294KCPDT


Hello!

I got an external device connected to my custom TM4C1294KCPDT-based board via TCP/IP. There are software on a PC connecting to this board.

The device sends some data to my board, the throughput is:

100 times per second - a packet of 78 bytes plus a packet of 2428 bytes, and some small packets once per second, thus about 256kbytes per second. I can receive and process all this data.

So I need to send processed data to PC, this is about 120bytes + 2418bytes 100 times per second.

The problem is, I can succesfully send small data ,120bytes @ 100Hz, plus lagre data, 2418bytes @ 20Hz, but then I increase the lagre data rate to 50Hz and more, I see LwIP reports TCP send buffer overflows, so I need to wait until it goes out and I have some data lost.

Is there any lwip tuning or any other workarounds possible? Thank you!

  • Hi,

      The LwIP provides various parameters to fine tune the configuration. You should find them in the lwipopts.h file. Below is just a snippet of the parameters related to the internal memory management.  Note the below parameter values are just what we use for the enet_io.c example. You may have already optimized them to suit your application. There are also parameters under the TCP section. I think if you post your question to the LwIP forum, their experts supporting the software will have the best knowledge as to which parameter(s) and by how much to change to best resolve your overflow issue. From my side, I can only tell you to increase these parameters until you see a difference that resolves your issue, it is more trial and error. If you do find which parameter(s) resolve the overflow issue, please do post back that it may benefit the community who faces the same issue. 

    //*****************************************************************************
    //
    // ---------- Internal Memory Pool Sizes ----------
    //
    //*****************************************************************************
    #define MEMP_NUM_PBUF 48 // Default 16
    //#define MEMP_NUM_RAW_PCB 4
    //#define MEMP_NUM_UDP_PCB 4
    #define MEMP_NUM_TCP_PCB 16 // Default 5
    //#define MEMP_NUM_TCP_PCB_LISTEN 8
    //#define MEMP_NUM_TCP_SEG 16
    //#define MEMP_NUM_REASSDATA 5
    //#define MEMP_NUM_ARP_QUEUE 30
    //#define MEMP_NUM_IGMP_GROUP 8
    #define MEMP_NUM_SYS_TIMEOUT 8
    //#define MEMP_NUM_NETBUF 2
    //#define MEMP_NUM_NETCONN 4
    //#define MEMP_NUM_TCPIP_MSG_API 8
    //#define MEMP_NUM_TCPIP_MSG_INPKT 8
    #define PBUF_POOL_SIZE 48 // Default 16

    //*****************************************************************************
    //
    // ---------- TCP options ----------
    //
    //*****************************************************************************
    #define LWIP_TCP 1
    //#define TCP_TTL (IP_DEFAULT_TTL)
    #define TCP_WND 4096 // default is 2048
    //#define TCP_MAXRTX 12
    //#define TCP_SYNMAXRTX 6
    //#define TCP_QUEUE_OOSEQ 1
    #define TCP_MSS 1500 // default is 128
    //#define TCP_CALCULATE_EFF_SEND_MSS 1
    #define TCP_SND_BUF (4 * TCP_MSS)  
    //#define TCP_SND_QUEUELEN (4 * (TCP_SND_BUF/TCP_MSS))
    //#define TCP_SNDLOWAT (TCP_SND_BUF/2)
    //#define TCP_LISTEN_BACKLOG 0
    //#define TCP_DEFAULT_LISTEN_BACKLOG 0xff

    Here is the link the LwIP for explanation on some of the parameters. https://lwip.fandom.com/wiki/Tuning_TCP. You might want to first try increasing the the TCP_SND_BUF. Again, the LwIP forum is the best place to help you here as this is a third-party software that we are not expert of on all the parameters. 

  • Here is mine:

    //*****************************************************************************
    //
    // ---------- Internal Memory Pool Sizes ----------
    //
    //*****************************************************************************
    #define MEMP_NUM_PBUF                     48    // Default 16
    //#define MEMP_NUM_RAW_PCB                4
    //#define MEMP_NUM_UDP_PCB                4
    #define MEMP_NUM_TCP_PCB                  16    // Default 5
    //#define MEMP_NUM_TCP_PCB_LISTEN         8
    //#define MEMP_NUM_TCP_SEG                16
    //#define MEMP_NUM_REASSDATA              5
    //#define MEMP_NUM_ARP_QUEUE              30
    //#define MEMP_NUM_IGMP_GROUP             8
    #define MEMP_NUM_SYS_TIMEOUT              8
    //#define MEMP_NUM_NETBUF                 2
    //#define MEMP_NUM_NETCONN                4
    //#define MEMP_NUM_TCPIP_MSG_API          8
    //#define MEMP_NUM_TCPIP_MSG_INPKT        8
    #define PBUF_POOL_SIZE                    48    // Default 16
    
    //*****************************************************************************
    //
    // ---------- TCP options ----------
    //
    //*****************************************************************************
    #define LWIP_TCP                        1
    //#define TCP_TTL                         (IP_DEFAULT_TTL)
    #define TCP_WND                         4096   // default is 2048
    //#define TCP_MAXRTX                      12
    //#define TCP_SYNMAXRTX                   6
    //#define TCP_QUEUE_OOSEQ                 1
    #define TCP_MSS                        1500        // default is 128
    //#define TCP_CALCULATE_EFF_SEND_MSS      1
    #define TCP_SND_BUF                     (16 * TCP_MSS)
                                                        // default is 256, was 6 *
    #define MEMP_NUM_TCP_SEG                64
    //#define TCP_SND_QUEUELEN                (4 * (TCP_SND_BUF/TCP_MSS))
    //#define TCP_SNDLOWAT                    (TCP_SND_BUF/2)
    //#define TCP_LISTEN_BACKLOG              0
    //#define TCP_DEFAULT_LISTEN_BACKLOG      0xff
    

    The problem is, I can pass the static buffer for message payload (not all packet, through), but pcb->snd_buf decreasing is this case too.

    Increasing TCP_SND_BUF does not solve the problem.

  • Hi,

      Did you have a chance to contact the LwIP support at lwip.100.n7.nabble.com/lwip-users-f3.html

  • Oleg Kobrin said:
    100 times per second - a packet of 78 bytes plus a packet of 2428 bytes, and some small packets once per second

    Hi Oleg,

    What is your link speed - 10 MBPS or 100 MBPS? Also is your MOSC clock rate 25 MHz?