Reputation: 3574
I am new to UDP and Java's UDP API and I know that packets might arrive corrupted, splitted by IP or wrong in any other way. Of course, if such a packet arrives splitted, the checksum in the UDP header won't be right.
When reading a UDP packet in Java like DatagramSocket.receive(DatagramPacket)
, is it guaranteed, that the content of the received packet is correct (meaning that the calculated checksum is right)? Or will Java also pass corrupted UDP packets to the application?
Upvotes: 2
Views: 916
Reputation: 4563
From IETF RFC 5405 section 3.4, I quote:
[...] application developers SHOULD implement additional checks where data integrity is important [...]
Now, how important data integrity is to your application and how you value the 'SHOULD' in capital letters, that's up to you.
In other words:
Therefore, by implementation in the network layer the integrity of received UDP packet data remains unclear in the application layer.
Upvotes: 0
Reputation: 6058
Short answer:
Yes, unless configured otherwise.
Long answer:
Udp packets includes CHECKSUM that is used by your OS is verifying the packets for you. When a packet with the wrong checksum is received is discarded by the OS stack (before reaching the application layer).
I've never tried it but in Ubuntu is possible to disable the checksum with
ethtool --offload eth0 rx off
Upvotes: 1