checksums

Discussion in 'Mac Programming' started by eddies1j2, May 20, 2008.

  1. eddies1j2 macrumors newbie

    Joined:
    Jul 3, 2007
    #1
    Hi everybody

    this isnt a programming question but it is related...

    i dont seem to understand the difference between checksums and parity bit/check

    i dont understand how if you have 7 bits and if you put the sum on the last bit how can the sum fit on only one bit... i dont know if this is right but can someone explain me checksum with binary or something like that

    i tried wikipedia and a lot of pages but they are too complex


    thanks in advance
     
  2. Catfish_Man macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #2
    1 bit of parity for 7 bits of data won't catch all errors. It just gives you a certain chance of catching them.
     
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    What you're talking about is parity. This isn't the same as a checksum, but we'll get to that in a minute.

    Parity has to be defined as even or odd. Normally you'd have a 9th bit to handle the parity for a byte of actual data, but we can work with 7 bits of data to 1 bit of parity.

    Say our system uses even parity... this means that the number of ones in our 8 bits (7 data, 1 parity) must be even. So if your data is:
    1011001
    Your parity bit would have to be:
    0

    to make the number of 1s even.

    This is used in systems like RAID level 5, but I think it uses odd parity. Essentially you must have 3 or more disks. One whole disk is reserved for parity. In the simplest example, you have two disks full of data. Each time a write is performed to either of these disks, the parity is calculated, so if the new values are 0 and 1, the parity bit written on the 3rd disk is 0. If it's 0 0, 1 is the parity bit, if it's 1 1, 1 is the parity bit. When one (and only one!) disk dies, you can rebuild its contents by calculating odd-parity on to a new disk you replace the failed disk with.

    A checksum normally means some algorithm that is applied to generate a very small value that will be representative of a much large amount of data. There are possibilities of collisions in the checksum which means that different sets of data would produce the same checksum, but this is rare in the circumstances that a checksum is normally applied. For example, if you download a large file from the internet, and you have a tool to generate a cehcksum on this file, and the "publisher" of the file used the same checksum tool, you can compare your results to see if they match. Generally transmission issues on your connection or malicious tampering will change the checksum, so you can see that the file is not the same as the one published.

    -Lee
     
  4. Sayer macrumors 6502a

    Sayer

    Joined:
    Jan 4, 2002
    Location:
    Austin, TX
    #4
    Why do you need to understand these concepts?

    Checksum is a value based on a large bucket of data that shouldn't change if two buckets are identical in contents.

    Parity is an even or odd value based on the 7 other bits. If the bits are added up and differ from parity bit, then you have a single-bit error somewhere. This is usually for hardware (RAM) or during transmission of small chunks of data.

    You can actually use both schemes, parity during transmission (drips and drabs) and a checksum after transmission to verify integrity of the whole bucket.
     
  5. eddies1j2 thread starter macrumors newbie

    Joined:
    Jul 3, 2007
    #5
    thanks! i need this for an exam of programming class (java) just basic concepts i should now
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    I'm pretty baffled as to why these concepts would be on an exam in a programming class. They are quite important but I would think they would be in a logic class, architecture class, networking class (this is where I dealt with most of these concepts), etc.

    Checksumming is similar to hashing, which might be applicable in a programming course, especially since java uses hashCode for objects to determine if things are sort of like each other for use in things like HashMaps. In that case you try to get as "unique" of a value as you can in 32-bits. If your object is simple enough that you can write a hash that will never collide, this is called a perfect hash. For anything that can store more than 32 unique bits of data, this isn't really possible, so normally you have to make your best go at it and hope there aren't too many collisions.

    -Lee
     

Share This Page