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 Answers
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.
-
Can i disable UDP header checksum validation while opening the socket??– innosamAug 26, 2013 at 20:59
-
1Yes, 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
-
-
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
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.
-
1you can force it to ignore, at least in ipv4. In ipv6 this is no longer the case. Aug 26, 2013 at 21:10