CS485 Sylabus

### Intro to check summing

• Check summing

• Interpret a binary pattern as numbers:

• Computer communication always transmit binary codes

• A binary code can represent some fact

Example:

 ``` ASCII code: 01000001 'A' Marital status code: 00000000 Single 00000001 Married 00000010 Divorced 00000011 Widowed ```

• Binary codes can always be interpreted as an integer:

 ``` Binary code meaning in ASCII code meaning as bin number ------------- --------------------------- ----------------------- 01000001 the letter 'A' decimal value 65 ```

• Check summing a (input) message:

• We interpret a binary code/pattern in the input data as:

 Integer value (in binary number representation)

• We can compute the sum of all value in the input data:

 We truncate the (running) sum to n bits to prevent "overflow"...

• Commonly used lengths for the summation:

 8 bits, 16 bits or 32 bits

• We append the (check) sum at the end of the input data

(So the receiver can verify the (check) sum of the original input)

• Example:

 ``` Message: ABC In Binary code: 01000001 01000010 01000011 Compute check sum: 01000001 01000010 + 01000011 ------------ 110000110 (truncated to 8 bits) Transmitted message: 01000001 01000010 01000011 10000110 ```

• Detecting bit errors with check sums

• Checking for errors with check sum:

• The receiver knows that the message contains a check sum (byte) at the end !!!

• Check sum verification:

 The receiver compute the check sum of the received message (excluding the last byte) Thereceiver compares the computed check sum against the received check sum

• Example 1: no bit errors

 ``` Original message: 01000001 01000010 01000011 Transmitted message: 01000001 01000010 01000011 10000110 Received message: 01000001 01000010 01000011 10000110 ^ Check sum: | 01000001 | 01000010 | 01000011 + | -------------- | 110000110 | ^ | | | +-------------------------------------+ Compare/verify Check sum is equal ==> assume no bit errors ```

• Example 2: some bit errors

 ``` Original message: 01000001 01000010 01000011 Transmitted message: 01000001 01000010 01000011 10000110 Received message: 01010001 01000110 01000011 10000110 ^ Check: 01010001 | 01000110 | 01000011 + | -------------- | 110011010 | ^ | | | +-------------------------------------+ Compare: 10011010 ≠ 10000110 Check sum is NOT equal ==> detects bit errors ```

• Example 3: the check sum method can miss detection of some 2 bit errors

 ``` Original message: 01000001 01000010 01000011 Transmitted message: 01000001 01000010 01000011 10000110 Received message: 01000011 01000010 01000001 10000110 ^ Check: 01000011 | 01000010 | 01000001 + | -------------- | 110000110 | ^ | | | +-------------------------------------+ Compare Check sum is equal ==> assume no bit errors ```

• Goal of the check sum:

• The check sum is used to protect the integrity of every (data) value in the entrie message

 The sum computed is meaningless (i.e., the sum is not a total of some useful value)

• A more efficient operation used to protect the integrity of serie of values is:

 XOR

Example:

 ``` Message: ABC In Binary: 01000001 01000010 01000011 Check "sum": 01000001 (XOR is computed per column) 01000010 XOR 01000011 -------------- 01000000 Transmitted message: 01000001 01000010 01000011 01000000 ```

Note:

• XOR applied to multiple input value works like this:

 If there are an even number of 1's, then XOR output is 0           If there are an odd number of 1's, then XOR output is 1

• Property of a message that uses an XOR sum

• Fact:

• Due to the property of the XOR operation:

 The number of 1 bits in every column of the XOR check sum computation is even

Example:

 ``` Message: ABC In Binary: 01000001 01000010 01000011 Check "sum": 01000001 (XOR is computed per column) 01000010 XOR 01000011 -------------- 01000000 ```

Reason:

• If a column has an odd number of 1 bits:

 XOR will result in 1;   making the total # 1 bits in the column even

• If a column has an even number of 1 bits:

 XOR will result in 0;   and the total # 1 bits in the column will remain even

• Detecting bit errors with "XOR check sums"

• Checking for errors with check sum:

• How to verify a received message:

 The receiver must compute the XOR check sum of the message and the check sum

• If the result = 000...00 (all bits are 0), then:

 The receiver will assume that the message contains no bit errors

Otherwise:

 The receiver will assume that the message contains some bit errors

• Example 1: no bit errors case

 ``` Original message: 01000001 01000010 01000011 Transmitted message: 01000001 01000010 01000011 01000000 Received message: 01000001 01000010 01000011 01000000 Check: 01000001 01000010 01000011 01000000 XOR ------------------- 00000000 "Xor sum" is equal to 00000000 ==> assume no bit errors ```

• Example 2: some bit errors case

 ``` Original message: 01000001 01000010 01000011 Transmitted message: 01000001 01000010 01000011 01000000 Received message: 01010001 01000110 01000011 01000000 Check: 01010001 01000110 01000011 01000000 XOR ------------------- 00010100 Check sum is NOT equal to 00000000 ==> assumes some bit errors ```

• Example 3: the XOR sum method can also miss detection of some 2 bit errors

 ``` Original message: 01000001 01000010 01000011 Transmitted message: 01000001 01000010 01000011 01000000 Received message: 01000011 01000010 01000001 01000000 Check: 01000011 01000010 01000001 01000000 XOR ------------------- 00000000 XOR sum is equal to 00000000 ==> assumes no bit errors ```