You are on page 1of 7

Communication and Computer Networks Asst. Prof. Dr.

Ali Kadhum Idrees

Error Detection and Correction:


There are two methods for transmission error control in computer networks:
 Error correcting codes:
The ability of the receiver for detecting and correcting the errors is called
forward error correcting. The error control bits that added to the transmitted
message help the receiver for correcting the corrupted data packet. This
method preferred, if the probability of bits error is high or when the
retransmission is not support. Codeword
M bits r bits
Codeword (n) = message (M) + redundant (r)
If two codewords are a Hamming distance d apart, it will require d single bit
error to convert one into the other. To detect d errors, you need a distance of
d+1 code. To correct d errors, you need a distance 2d+1 code.
Examples: parity bit (even or odd)
Hamming method: (m+r+1) <= 2 r
 Parity checking: Detect single bit errors.
Even parity:
 Add a ‘1’ bit to the end of codeword, if the number of ‘1’ bit is odd.
 Add a ‘0’ bit to the end of codeword, if the number of ‘1’ bit is even.
Odd parity:
 Add a ‘1’ bit to the end of codeword, if the number of ‘1’ bit is even.
 Add a ‘0’ bit to the end of codeword, if the number of ‘1’ bit is odd.
Example: 10110101 want to be sent
101101011 with even parity
While 10110001 become 101100010 with even parity
Two Dimensional Bit Parity: Detect and correct single bit errors.

Department of Computer Science 1 University of Babylon


Communication and Computer Networks Asst. Prof. Dr. Ali Kadhum Idrees

Sender Receiver
Drop parity bit and accept
data Yes

Reject
1100001 Data Even?
No
Data

Calculate
parity bit Count bits

1100001 1
Bits

Transmission media

Figure (26): error detection and correction using parity checking.


 Hamming method: for m data bits, we needs r additional bits add to the
packet for error detecting where (m+r+1) <= 2 r
Example: computer A want to send a massage m of 7 bits to computer B.
assume that the received m at B has an error in the 7th bit position in the
bit stream of m. using hamming method how A can calculate the r
additional bits before transmitting m and how B can detect the error in the
received m, where m = 1011001.
Sol: r=4

Department of Computer Science 2 University of Babylon


Communication and Computer Networks Asst. Prof. Dr. Ali Kadhum Idrees

r1 r2 d r4 d d d r8 d d d
Calculating the additional bits:
r1 deals with the following bits
1 3 5 7 9 11
r1 r2 d r4 d d d r8 d d d
r2 deals with the following bits
2 3 6 7 10 11
r1 r2 d r4 d d d r8 d d d
r4 deals with the following bits
4 5 6 7
r1 r2 d r4 d d d r8 d d d
r8 deals with the following bits
8 9 10 11
r1 r2 d r4 d d d r8 d d d

m = 1011001
r1 r2 1 r4 0 1 1 r8 0 0 1
insert r1
1 r2 1 r4 0 1 1 r8 0 0 1

insert r2
1 0 1 r4 0 1 1 r8 0 0 1

insert r4
1 0 1 0 0 1 1 r8 0 0 1

insert r8
1 0 1 0 0 1 1 1 0 0 1

Department of Computer Science 3 University of Babylon


Communication and Computer Networks Asst. Prof. Dr. Ali Kadhum Idrees

1 0 1 0 0 1 0 1 0 0 1

1 0 1 0 0 1 0 1 0 0 1

1 0 1 0 0 1 0 1 0 0 1

1 0 1 0 0 1 0 1 0 0 1

The bit in the 7th position is error. 0111

 Error Detection:
Error correcting codes are sometimes used for data transmission, for
example, when the channel is simplex, so retransmission cannot be
requested, but most error detection followed by retransmission is preferred
because it is more efficient. Error detection codes are an error control method
that currently used by all computer networks, where the codeword is the
packet add to it the error detecting bits. There are two methods:
1. Checksum method:
Checksum is the sum of the segment contents as sequence of 16-bit
integers, and then take the 1’s complements of the sum. It is called 1’s
complement checksum and used intensively in Internet protocols (used at
transport layer only). The algorithm divide the bit stream into a sequence
of words each of which 16-bit, and then sum the words with each other. In
each once, if the sum of two words give redundancy, it will add ‘1’ to the
summation result. Finally, it takes the 1’s complements for the final
summation that represent the value of checksum. the sender puts
checksum value into UDP (User Data Protocol) checksum field and then
transmit it. when the receiver receive the codeword (bit stream +
checksum value), computes checksum of received codeword. If the
Department of Computer Science 4 University of Babylon
Communication and Computer Networks Asst. Prof. Dr. Ali Kadhum Idrees

summation result is zero, then the codeword is correct. Otherwise, the


codeword is corrupted.
Example: the computer A want to transmit a message M to computer B.
by using a 4-bits words, what is the transmitted codeword from A to B and
how can B sure that the received codeword from A is correct, where
M = 1000101111001101
Sol: Sender calculation: Receiver calculation
1000
+ 1011 1000
+ 1011
0011
+ 0011
1 +
1
0100
+ 0100
1100 +
1100
0000
+ 0000
1 +
1
0001
+ 0001
1101 +
1101
1110
1110
1’s comp is 0001 +
0001
transmitted codeworde
1000101111001101 0001 1111
M r 1’s comp is 0000, then the
codeword is correct

2. Cyclic Redundancy Check codes (CRC codes):


It is a polynomial codes that are based upon treating bit strings as
representations of polynomials with coefficients of 0 and 1 only.
Definitions:
G(x): represent the generator polynomial, where both the high and low
order bits of the generators must be 1. G(x) must be available at the
sender and receiver.
M(x): the frame with m bits, and must be longer than the generator
polynomial.
r: the degree of generator, and when the generator is x 5  1 , i.e., it’s degree
is 5 (r = 5).
Department of Computer Science 5 University of Babylon
Communication and Computer Networks Asst. Prof. Dr. Ali Kadhum Idrees

x r M (x) : Represent the polynomial frame after performs the first step of

algorithm on the transmitted frame (i.e., represent the frame that required
to be sent after adding zero r bit to its end).
T(x): represent the final transmitted frame.
NOTE: the addition and subtraction corresponding to XOR.
The following algorithm for computing the CRC:
1. Append r zero bits to the low-order end of the frame, so it now contains
m+r bits and corresponds to the polynomial x r M (x) .
2. Divide the bit string corresponding to G(x) into the bit string
corresponding to x r M (x) using modulo 2 divisions.
x r M ( x)
remainder  , where the remainder is the division remainder in bits.
G ( x)

3. Subtract the remainder (which is always r or fewer bits) from the bit
string corresponding to x r M (x) using modulo 2 subtractions. The result
is the checksummed frame to be transmitted that called T(x).
T(x) = x r M (x) - remainder.

Upon receiving the checksummed frame, the receiver divides it by G(x)


as follow: E = T(x) / G(x). If there is a remainder (E<> 0), this mean an error
is available. If E = 0 the checksummed frame is correct.
Example: suppose you have a computer network in which computer X want to
send the following bit frame M = 110101 to computer Y. explain how can
calculate the CRC bits by X and add to the end of M, then explain the
calculations that performed by Y to detect the error in the received frame. by
considering G = 1001 at either sender and receiver.
Sol: | G | = | r | + 1 , r=3
M r
110101 000

Department of Computer Science 6 University of Babylon


Communication and Computer Networks Asst. Prof. Dr. Ali Kadhum Idrees

Sender calculation: Receiver calculation:


E = T(x) / G(x)

110011 110011
1001 110101000 1001 110101011
1001 1001
1000 1000
1001 1001
0011 0011
0000 0000
0110 0110
0000 0000
1100 1101
1001 1001
1010 1001
1001 1001
remainder 011 E= 0000
T(x) = x r M (x) - remainder
The received frame is correct.
110101000
-
011
T(x) = 110101011

the transmitted frame is :


M r
110101 011

Department of Computer Science 7 University of Babylon

You might also like