4

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

  • If you want to confirm that the data is correct, then also send a checksum (e.g. SHA1). Of course, there's no system that's 100% foolproof... – Oliver Charlesworth Mar 02 '13 at 20:25
  • "how many packets were actually lost and re-transmitted" - there's no way with the posix socket interface... I guess it's doable with tcpdump/wireshark. – Karoly Horvath Mar 02 '13 at 20:30
  • Well, Thanks Oli Charlesworth and Karoly Horvath. There might be some way in my opinion, since wireshark tool, in its implementation must have used some API's to check the number of re-transmitted packets. I shall check the details of tcpdump. Thanks again. – Harry_Potter Mar 02 '13 at 20:45
  • both are using http://en.wikipedia.org/wiki/Pcap – Karoly Horvath Mar 02 '13 at 21:05

1 Answers1

6

/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.

Community
  • 1
  • 1
nemo
  • 55,207
  • 13
  • 135
  • 135
  • Wow, That's really cool stuff.. Thank you nemo and Karoly Horvath. I need to figure out the way to use it. Will update you guys after successfully completing it. Thanks! – Harry_Potter Mar 02 '13 at 21:15
  • Don't forget upvoting/accepting the answer if it worked for you so it's not dangling around as unanswered :) – nemo Mar 02 '13 at 21:16
  • @nemo , I am sorry, can u please let me know how to up-vote the answer if you don't mind ? Actually, white votingup, it says about the minimum reputation needed to vote up. Will surely do when my reputation goes up, I joined today :) – Harry_Potter Mar 02 '13 at 21:21
  • @RahulkumarThakkar You can vote answers up as soon as you've gained 15 reputation. See http://stackoverflow.com/faq#reputation for further reading. Welcome to SO btw. ;) – nemo Mar 02 '13 at 22:51