tags:

views:

30

answers:

3

Hello,

This is going probably be a general question regarding checksum used for error detection. I got a lab assignment where we are going to recreate a protocol similar to how RDT2.0 works. And I'm stuck in how to use checksum to detect errors.

The functions are there already what I need is to implement the functionality. What I don't understand is how you can know that a pack is corrupted.

E.g. I'm going to send over a text file. So I have some function which will take a number of bytes and store it in an object where I'll also attach a header with the checksum.

So if this package will be corrupted now I have no where to tell it has happent since the checksum will also be changed right?

So can anyone tell me how I should use the checksum?

A: 

You're right that if your data gets corrupted, your checksum might be too - the hope is that they don't get corrupted in a way that's not apparent to you. A simple parity bit is the worst for this sort of transparent corruption - the larger your checksum field, the less likely it is that your data will be corrupted and you won't notice.

Carl Norum
+1  A: 

The checksum might have been changed, but the chances of it being changed to match the checksum of the changed content are slim.

So, when you read the package, you calculate a new checksum for the content and compare it to the checksum stored in the package. If they match, there is no corruption, if not, something was changed (either the content, the checksum, or both).

Epcylon
A: 

I think the missing bit is that the checksum is calculated before you send the data, then recalculated after the data is received. If the checksum of the received data matches the received checksum in the attached header, you can be fairly confident that neither was corrupted en route.

Nathon