Search code examples
clinuxsocketstcpwireless

Check number of correctly received packets - Socket Programming


I am writing an application in C using socket programming. I wish to send the data from the server node to the client node. I use the read and write commands on the socket descriptor to get and send the data over the network respectively. Since, the underlying protocol used is TCP/IP, finally I receive the correct data. Is it possible to check on the client side that to receive the data correctly, how many packets were actually lost and re-transmitted? I am writing this application in Linux (debian) environment.

Any help is highly appreciated !

-Rahulkumar


Solution

  • /proc/net/tcp has a field retrnsmt, you simply need to find your socket in this list.

    An alternative would be to use the TCP_INFO sockopt. The current layout of struct tcp_info can be found in linux/tcp.h. The field you want to use is probably tcpi_retrans.