Theme 3 Error Detection and Correction
Theme 3 Error Detection and Correction
and correction
Objectives
• Overview
• Parity check
• Check sum
• CRC (Cyclic Redundancy Check)
• Hamming codes
Overview
• A WAN is said to operate at the physical layer and at the data link
layer.
• characteristics that separate a WAN from a LAN are typically found at the
physical layer and the data link layer
• But routing occurs at layer 3?
• If a WAN operate at layer 1 and 2, is a router LAN or WAN device?
• Difference comes when a router uses the physical and data link layer
standards and protocols that are associated with WANs
• The primary WAN roles of a router are therefore not routing, but
providing connections to and between the various WAN physical and
data-link standards
Error detection and correction
• It is a link-layer service.
• Where is link layer implemented?
• Sending side
• Encapsulate datagram from higher layers in a link-layer frame
• Receiving side
• Receives the entire frame and de-capsulates the network layer datagram
• Sending controller sets the error detection
Parity Check – 1-dimensional
• Parity checking can be one-dimensional or two dimensional
• In a single parity-check, an extra bit is added to every data unit
• The objective of adding the parity bit (a 0 or a 1) is to make the total
number of 1s in the data unit (including the parity bit) to become
even.
• Some systems may use odd-parity checking, where the total number
of 1s should then be odd.
• Even parity is typically used for synchronous transmission and odd
parity for asynchronous transmission.
Parity Check – 1-dimensional
• The MSB of an 8-bits word is used as the parity bit and the remaining
7 bits are used as data or message bits.
Parity Check – 1-dimensional
• The parity bit can be set to 0 and 1 depending on the type of the parity required.
• For even parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is even. Shown in
fig. (a).
• For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is odd. Shown in
fig. (b).
Parity Check – 1-dimensional
• Example
• The data 1010100 is given the even parity bit of 1, resulting in the bit sequence 10101001.
• This data is transferred to another computer. In transit, the data is corrupted, and the
computer receives the incorrect data 10000101. (but computer does not know it)
• The receiving computer computes the parity: 1+0+0+0+0+1+0+1 = 3.
• It then performs 3 modulo 2 (the remainder of 3 divided by 2), expecting the result 0 which
would indicate that the number is even.
• Instead, it receives the result 3 modulo 2 = 1, indicating that the number is odd.
• Because it is looking for numbers with even parity, it asks the original computer to send the
data again.
• This time, the data comes through with no errors: 10101001. The receiving computer
calculates 1+0+1+0+1+0+0+1 = 4.
• 4 modulo 2 = 0, indicating even parity.
• The parity bit is stripped from the end of the sequence, and the data 1010100 is accepted.
Parity check – 2 dimensional
• Generalization of the one-dimensional parity scheme.
• Form an MxN matrix of bits, then
• Add a (even or odd) parity bit to each row and to each column
• Example:
• Transmitted data (unprotected): 1111000 1010101 1111111
• Two dimensional (even) parity:
11110000
10101010
11111111
10100101
Parity check – 2 dimensional
• Received one bit in error:
11110000
10101010
11011111 odd parity (should be even)
10100101
odd parity
Checksum
• In CRC, at source:
– a sequence of redundant bits, called CRC check bits, are appended to the end of data unit so that the
resulting data unit becomes exactly divisible by a second, predetermined binary number.
– The predetermined binary number is called a generator value
• At the destination:
– the incoming data unit is divided by the generator value.
– If at this step there is no remainder, the data unit is assumed to be correct and is therefore accepted.
– A remainder indicates that the data unit has been damaged in transit and therefore must be rejected.
Cyclic Redundancy
Check (CRC)
• Example
Hamming Code
• Error correcting code
• A block code that is capable of;
• detecting up to two simultaneous bit errors, and
• correcting single-bit errors
• The source encodes the message by inserting redundant bits within the
message.
• The redundant bits are the extra bits that are generated and inserted at
specific positions in the message itself to enable error detection and
correction.
• When the destination receives this message, it performs recalculations to
detect errors and find the bit position that has error.
Hamming Code
• The number of redundant bits can be calculated using the following
formula:
• 2^r ≥ m + r + 1
• where, r = redundant bit, m = data bit
• Put check bits in positions p that are powers of 2, starting with
position 1
• Check bit in position p is parity of data bits in positions with a p term
in their values
• Plus an easy way to correct [soon]
Hamming Code
• Example: data=0101, 3 check bits
– 7 bit code, check bit positions 1, 2, 4
– Check 1 covers positions 1, 3, 5, 7
– Check 2 covers positions 2, 3, 6, 7
– Check 4 covers positions 4, 5, 6, 7
1 2 3 4 5 6 7
Hamming Code
• Example: data=0101, 3 check bits
– 7 bit code, check bit positions 1, 2, 4
– Check 1 covers positions 1, 3, 5, 7
– Check 2 covers positions 2, 3, 6, 7
– Check 4 covers positions 4, 5, 6, 7
0 1 0 0 1 0 1
1 2 3 4 5 6 7
0 1 0 0 1 0 1
1 2 3 4 5 6 7