CN-m3c
CN-m3c
Example 1
41
Checksum - Example
▪ Add two 16-bit integers word
Sender Receiver
1 1110011001100110 1 1110011001100110
1 1101010101010101 1 1101010101010101
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1011101110111011
+ +
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 1011101110111100
sum
checksum 0100010001000011 1 0100010001000011
1111111111111111
If one of the bits is a 0, then we can
say that error introduced into packet
42
Internet Checksum
Performance
• It is not as strong as the CRC in error-checking
capability.
• For example, if the value of one word is
incremented and the value of another word is
decremented by the same amount, the two
errors cannot be detected because the sum and
checksum remain the same.
Error Correction
• Error Correction codes are used to detect and
correct the errors when data is transmitted
from the sender to the receiver.
• Error Correction can be handled in two ways:
• Backward error correction: Once the error is
discovered, the receiver requests the sender to
retransmit the entire data unit.
• Forward error correction: In this case, the
receiver uses the error-correcting code which
automatically corrects the errors.
Single-bit error correction
To correct an error, the receiver reverses the value of the
altered bit. To do so, it must know which bit is in error.
Number of redundancy bits needed
• Let data bits = m Redundancy bits = r
Total message sent = m+r
The value of r must satisfy the following relation:
2r ≥ m+r+1
Suppose the number of data bits is 7, then the number of
redundant bits can be calculated using:
= 24 ≥ 7 + 4 + 1
Thus, the number of redundant bits= 4
Hamming Code
• Parity bits: The bit which is appended to the original
data of binary bits so that the total number of 1s is
even or odd.
• Even parity: To check for even parity, if the total
number of 1s is even, then the value of the parity bit
is 0. If the total number of 1s occurrences is odd, then
the value of the parity bit is 1.
• Odd Parity: To check for odd parity, if the total
number of 1s is even, then the value of parity bit is 1.
If the total number of 1s is odd, then the value of
parity bit is 0.
Algorithm of Hamming code:
o An information of 'd' bits are added to the
redundant bits 'r' to form d+r.
o The location of each of the (d+r) digits is
assigned a decimal value.
o The 'r' bits are placed in the positions
1,2,.....2k-1.
o At the receiving end, the parity bits are
recalculated. The decimal value of the parity
bits determines the position of an error.
Error Correction
Relationship b/w Error position &
binary number.
Example
• Let's understand the concept of Hamming code
through an example:
• Suppose the original data is 1010 which is to
be sent.
Determining the position of
the redundant bits
• The number of redundant bits is 3. The three
bits are represented by r1, r2, r4. The position
of the redundant bits is calculated with
corresponds to the raised power of 2.
Therefore, their corresponding positions are 1,
21, 22.
• Representation of Data on the addition of
parity bits:
Determining the Parity Bits
Determining the r1 bit
• The r1 bit is calculated by performing a parity check on the
bit positions whose binary representation includes 1 in the
first position.