Mus
Mus

Reputation: 7530

Checksum Explanation?

I am currently looking at checksums but am having trouble fully understanding how they work.

FYI, I have been looking at UDP checksums and Internet checksums. I have learned that UDP at the sender side performs 1s complement, however I am unclear as to what 1s complement is.

I have a rough idea of 1s complement being something to do with 'reversing' the values of all 1s and 0s, so that a 1 becomes a 0 and a 0 becomes a 1, but I do not know why this is done in the first place.

Could somebody kindly provide some information about checksums in general?

Thank you.

Upvotes: 7

Views: 5490

Answers (2)

Tony The Lion
Tony The Lion

Reputation: 63190

Checksum is mostly the hash (a one way encryption function) of some value to make sure that the data is consistent when it gets to the other end. The checksum is taken before the data is sent, then when the data is received at the other, the checksum of the same value is taken again, and matched with the checksum from the sender, if they are the same, then the data is in good state, else we know something is wrong.

Fairly simplified explanation.

Upvotes: 14

brunoais
brunoais

Reputation: 6836

A checksum is just an integer which is calculated by these rules: Sum everything in the packet except the checksum (I call it sum). Save in the checksum: -sum.

When the packet is arriving, sum everything that is in the packet. If the sum gives 0, then the packet is valid.

Upvotes: 0

Related Questions