0

ICMP messages contain checksums: https://tools.ietf.org/html/rfc792

Does ping validate the checksums when receiving an echo reply message?

I don't see a note about it in the man page.

I'm using Fedora 27.

  • TBH the reason I'm asking is because I'm writing a program that needs to compute the checksum but I don't know how to check if I'm doing it right. – FGreg Feb 13 '18 at 8:14
1

Yes, it does.

From the source code:

csfailed = in_cksum((unsigned short *)icp, cc, 0);

Although it does not seem to check the csfailed when the icp->type == ICMP_ECHOREPLY.

If you just want to see the algorithm for the checksum, check the source code for unsigned short in_cksum and following.

  • so does that mean if the checksum is not valid, there is no indication? – FGreg Feb 13 '18 at 8:18
  • There is a part that checks whether the ICMP type is "Parameter Problems", but this looks like the incoming packet has this information in the header. You should just give it a try, with the source code you can simply forge a "wrong" checksum to be sent. – Stefan M Feb 13 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.