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.

TI-RTOS TM4C client / server UDP socket waiting to recvfrom, lost data packets.

Other Parts Discussed in Thread: TM4C129ENCPDT

Characteristics:
microcontroller: TM4C129ENCPDT.
TI-RTOS: 2.10.1.38

I have an interface with a TM4C129ENC server communicate via UDP with another TM4C129ENC interface as UDP client.

In the network there is a loss of data packets (sockets), and sometimes it locks the tool "recvfrom" set to "MSG_WAITALL".

When not receiving the data packet, does not leave exit "recvfrom" , some way out of "recvfrom"?

If by "MSG_DONTWAIT" it becomes non-blocking, but this way there is always the error "35".

I implemented a mechanism to reset the watchdog, but it takes too long to restart the interface.

What is the best "strategy" to ignore the lost packets?

Why you are constantly losing data packets?

Analyzing with wireshark, there is no communication error, only the server or the client fails to communicate, do not send more data packets.

The network is a router with a hub connected between interfaces and compudador to analyze data packets with wireshark. 

Regards

Patricio

  • Still unresolved.
  • Hi Patricio,

    With UDP, there is no guarantee the packet reaches the destination. The packet may be lost in the network or there may be too many packets received than that can be handled by client/server.

    When you are using recvfrom() with MSG_WAITALL, I would suggest that you set a socket timeout value for recv which would ensure the application doesn't hang in the recvfrom() if some packets are lost.

    You can use setsocketopt() to set the timeout value:

    struct timeval tv;
    tv.tv_sec = 3; /* Update timeout value here */
    tv.tv_usec = 0;
    if (setsockopt(skt, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
    //error processing
    }

    Vikram
  • Vikram ok, thanks for your response. I think it works in my case!

    Regards
    Patricio