7

If i open a raw socket, and send udp packets with a wrong checksum, would the packets be dropped other side by the tcp/ip stack?

2
  • you may be able to sniff them on the remote host though, this would enable to you to differentiate pkts that never arrived vs ones that were dropped due to malformed data
    – Paul Rubel
    Aug 26, 2013 at 21:00
  • 1
    That's what the checksum is for.
    – user207421
    Aug 26, 2013 at 23:24

2 Answers 2

6

Yes they would be dropped. If you need more reliable communication you're much better off using TCP.

for more information, take a look at this: http://www.diffen.com/difference/TCP_vs_UDP

UDP there's no guarantee that the packets will even be sent, let alone received. If they are in fact received though, they are checked. If they fail checksum they are dropped.

EDIT: also to add to that, udp does not by default order the packets as they are sent, that has to be done at the application level. Bear this in mind if you still intend on using UDP.

5
  • Can i disable UDP header checksum validation while opening the socket??
    – innosam
    Aug 26, 2013 at 20:59
  • 1
    Yes, the UDP header checksum is optional. Just set it to 0 (means unused) Aug 26, 2013 at 21:02
  • Be careful with this, because according to the wikipedia article ( en.wikipedia.org/wiki/User_Datagram_Protocol ) it states that in ipv6 it's no longer able to send the packet without checksum. Here's the ipv6 spec from which the wikipedia stuff was sourced from... tools.ietf.org/html/rfc2460 Aug 26, 2013 at 21:04
  • @user2366842 how can i force it to ignore the UDP header checksum?
    – innosam
    Aug 26, 2013 at 21:31
  • binarytides.com/raw-udp-sockets-c-linux have a look at this, and where it's calculating out the checksum, just set it equal to 0.... Once again, note, both sending and receiving machines MUST be ipv4 or else this will fail. Specifically the function from lines 28 to 51 Aug 26, 2013 at 21:37
5

If comes packet with wrong checksum, OS will drop it before passing it to the socket.

Destination application cannot determine if packet was lost or comes with wrong checksum. I think that it also cannot force else behavior.

1
  • 1
    you can force it to ignore, at least in ipv4. In ipv6 this is no longer the case. Aug 26, 2013 at 21:10

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.