MinecraftShamrock
MinecraftShamrock

Reputation: 3574

Is the UDP checksum allowed to be calculated from a truncated payload?

UDP sockets only accept incoming datagrams if they have the right checksum. But I've heard that sometimes UDP packets are truncated because of the Maximum Transmission Unit (MTU).

(1) How are datagrams handled that are truncated purposely? Is it allowed that the checksum is calculated over a truncated payload? Or is it required that the checksum is always calculated over the whole data the application intended to send in one datagram?

(2) Also, is it allowed that a datagram is fragmented and then de-fragmented in another or incomplete order? Would that corrupt the checksum?

The main question is: Is it guaranteed that when a UDP datagram is received with the right checksum and passed to the application, that the payload is exactly the data that the sender application passed to the OS?

Upvotes: 1

Views: 190

Answers (1)

user207421
user207421

Reputation: 310875

I've heard that sometimes UDP packets are truncated because of the Maximum Transmission Unit (MTU).

You misheard. They can be fragmented for that reason.

(1) How are datagrams handled that are truncated purposely?

They aren't truncated, they are fragmented. If all the fragments arrive, the datagram can be reconstituted and its checksum verified. Otherwise nothing happens.

Is it allowed that the checksum is calculated over a truncated payload?

Impossible, see above.

Or is it required that the checksum is always calculated over the whole data the application intended to send in one datagram?

Yes.

(2) Also, is it allowed that a datagram is fragmented and then de-fragmented in another or incomplete order?

No.

Would that corrupt the checksum?

It wouldn't even happen.

The main question is: Is it guaranteed that when a UDP datagram is received with the right checksum and passed to the application, that the payload is exactly the data that the sender application passed to the OS?

Yes.

Upvotes: 1

Related Questions