LWIP receive incomming packages multiple times

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LWIP receive incomming packages multiple times

Jump to solution
1,219 Views
michaelschuehle
Contributor II

Hello,

I'm running a LPC4357 on a OEM board from embeddedartists.com

I have a LWIP implementation based on LPCOpen where I receive commands from a client computer (LPC is server) and response some data to the client.

My Problem is now, that if my client send one command to the server, the server send the response two or more times.

The Wireshark screenshot shows the bevaviour: Client (@191) requenst some data (No. 86889) and the server (@10) responsed two times (No. 86890 and 86896).

pastedImage_2.png

The strange thing is: This behaviour only happens if I'm using the debug mode or if the client is far away. If I build a release programm and the client is my Computer next to the server I have a perfect communication (1 command -> 1 response).

On my main loop i call a function processNetwork() where all the network stuff is done (code below), this is part of the LPCOpen examples.

I tried different call intervalls for this processNetwork() function (as soon as possible, 10ms, 100ms, 250ms) but without any solutions to that problem.

I also call tcp_recved() at the end of my tcp_received() function after I processed the incomming data.

As a reason of the different behaviours between Debug and Release builds I think the problem is any kind of timing issue.

I would be happy if you have any idea what the problem could be or in which direction i have to search for.

Kind regards,

Michael

void processNetwork(void){
    /* Handle packets as part of this loop, not in the IRQ handler */
    lpc_enetif_input(&lpc_netif);

    /* lpc_rx_queue will re-qeueu receive buffers. This normally occurs
       automatically, but in systems were memory is constrained, pbufs
       may not always be able to get allocated, so this function can be
       optionally enabled to re-queue receive buffers. */
#if 0
    while (lpc_rx_queue(&lpc_netif)) {}
#endif

    /* Free TX buffers that are done sending */
    lpc_tx_reclaim(&lpc_netif);

    /* LWIP timers - ARP, DHCP, TCP, etc. */
    sys_check_timeouts();

    /* Call the PHY status update state machine once in a while
       to keep the link status up-to-date */
    physts = lpcPHYStsPoll();

    /* Only check for connection state when the PHY status has changed */
    if (physts & PHY_LINK_CHANGED)
        networkLinkChanged();

    /* Print IP address info */
    if (ipPrinted == false) {
        if (lpc_netif.ip_addr.addr) {
            static char tmp_buff[16];
            ETHERNETDEBUGOUT("IP_ADDR    : %s\n", ipaddr_ntoa_r((const ip_addr_t *) &lpc_netif.ip_addr, tmp_buff, 16));
            ETHERNETDEBUGOUT("NET_MASK   : %s\n", ipaddr_ntoa_r((const ip_addr_t *) &lpc_netif.netmask, tmp_buff, 16));
            ETHERNETDEBUGOUT("GATEWAY_IP : %s\n", ipaddr_ntoa_r((const ip_addr_t *) &lpc_netif.gw, tmp_buff, 16));
            ETHERNETDEBUGOUT("HOSTNAME   : %s\n\n",lpc_netif.hostname);
            ipPrinted = true;
        }
    }
}
Labels (2)
0 Kudos
Reply
1 Solution
1,049 Views
soledad
NXP Employee
NXP Employee

Hi, 

There is important to isolate the issue, could you try using only (without modifications) the webserver example from LPCOpen?

I want to know if there is a software or hardware issue. 

Regards 

Sol 

View solution in original post

0 Kudos
Reply
2 Replies
1,049 Views
michaelschuehle
Contributor II

Hi Sol,

the advice was good. I cross checked my code with the Echo example and found a memory leak.

I didn't free all received pbufs and thereby I received the package twice or more.

Thanks for the help / hint.

Best regards

Michael

0 Kudos
Reply
1,050 Views
soledad
NXP Employee
NXP Employee

Hi, 

There is important to isolate the issue, could you try using only (without modifications) the webserver example from LPCOpen?

I want to know if there is a software or hardware issue. 

Regards 

Sol 

0 Kudos
Reply