TCP communication freezes after a while on W7500P

Hi,

I established an TCP client-server communication with a WIZwiki-W7500P and PC, but the W7500P freezes after some time.

The WIZwiki is the client who connect on the server side (PC - Linux). The server sends 1000 bytes each 200 ms.
After transfer about 1 MB transferred the communication and the board freezes.

The client WIZwiki-W7500P code:

int main() {
    int phy_link;
    pc.printf("Wait a second...\r\n");
    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x00, 0x01, 0x02}; 
    
    EthernetInterface eth;
    eth.init(mac_addr); //Use DHCP
    eth.connect();
    
    do{
        phy_link = eth.ethernet_link();
        pc.printf("...");
        wait(2);
    }while(!phy_link);
        printf("\r\n");
     
    pc.printf("IP Address is %s\r\n", eth.getIPAddress());
    
    TCPSocketConnection sock;
    int ret = sock.connect("192.168.3.105", 8080);
 
    char buffer[1024];
    while (true) {
        ret = sock.receive(buffer, sizeof(buffer));          
        pc.printf("Received from server: %d\n\r", ret);
    }
 
    sock.close();
    
    eth.disconnect();
}

The server Linux:

while(1){ n = write(childfd, buf, 1000); if (n < 0) error("ERROR writing to socket"); usleep(1000*200); }

Any idea? Does the W7500P IOP implements congestion control?

Environment: mbed

Best regards

hello, joaopaulob

could you capture the packets through wireshark?

in tcp communication, it is easy way to check the packet flow.

[url]https://www.wireshark.org/download.html[/url]

if you do not know how to use wireshark, please ask any thing.

thank you

I have faced a similar issue and the error was happening because the MCU socket was closing due to a timeout. Wireshark should help a lot and if the problem is in the W7500P side, then I would suggest you to use a debug snippet like this one:

void debug_socketSN(uint8_t sn) {
		printf("WZTOE_Sn_RX_RSR: %d\r\n",(*(volatile uint32_t *)WZTOE_Sn_RX_RSR(sn)));
		printf("WZTOE_Sn_RXBUF_SIZE: %d\r\n",(*(volatile uint32_t *)WZTOE_Sn_RXBUF_SIZE(sn)));
		printf("WZTOE_Sn_RX_RD: %d\r\n",(*(volatile uint32_t *)WZTOE_Sn_RX_RD(sn)));
		printf("WZTOE_Sn_RX_WR: %d\r\n",(*(volatile uint32_t *)WZTOE_Sn_RX_WR(sn)));
		printf("WZTOE_Sn_SR: 0x%x\r\n",(*(volatile uint32_t *)WZTOE_Sn_SR(sn)));
}

hope this helps.

Thank you, pherig

It is right.

These codes are helpful to know the tcp data flow.

1 Like

Thank you very much