Error_Control_and_Detection
Error_Control_and_Detection
Error Control:
When data is transmitted over a cable or channel, there is always a chance that some of the bits will be changed
(corrupted) due to noise, signal distortion or attenuation. If errors do occur, then some of the bits will either
change from 0 to 1 or from 1 to 0.
Error Control allows the receiver to inform the sender of any frames lost or damaged in transmission and
coordinates the retransmission of those frames by the sender. Error control is divided in two main categories:
Error Detection It allows a receiver to check whether received data has been corrupted during transmission. It
can, for example, request a retransmission.
Error Correction This type of error control allows a receiver to reconstruct the original information when it has
been corrupted during transmission.
In the data link layer, the term error control refers primarily to methods of error detection and retransmission.
Error control in the data link layer is often implemented simply: Any time an error is detected in an exchange,
specified frames are retransmitted. This process is called automatic repeat request (ARQ).
Error control in the data link layer is based on automatic repeat request, which is the retransmission of data.
Hamming distance:
One of the central concepts in coding for error control is the idea of the Hamming distance. The Hamming
distance between two words (of the same size) is the number of differences between the corresponding bits. We
show the Hamming distance between two words x and y as d(x, y). The Hamming distance can easily be found if
we apply the XOR operation on the two words and count the number of 1s in the result. Note that the Hamming
distance is a value greater than zero.
Error Detection:
There are three ways to detect errors.
1. Parity check
2. CRC
3. Checksum
CRC codes operate as follows. Consider the d-bit piece of data, D, that the sending node wants to send to the
receiving node. The sender and receiver must first agree on a r+1 bit pattern, known as a generator, which we
will denote as G. We will require that the high and low order bits of G must be 1 (e.g., 10111 is acceptable, but
0101 and 10110 are not) . The key idea behind CRC codes is shown in Figure. For a given piece of data, D, the
sender will choose r additional bits, R, and append them to D such that the resulting d+r bit pattern (interpreted
as a binary number) is exactly divisible by G using modulo 2 arithmetic. The process of error checking with
CRC's is thus simple: the receiver divides the d+r received bits by G. If the remainder is non-zero, the receiver
knows that an error has occurred; otherwise the data is accepted as being correct.
All CRC calculations are done in modulo 2 arithmetic without carries in addition or borrows in subtraction. This
means that addition and subtraction are identical, and both are equivalent to the bitwise exclusive-or (XOR) of
the operands. Thus, for example,
Multiplication and division are the same as in base 2 arithmetic, except that any required addition or
subtraction is done without carries or borrows. As in regular binary arithmetic, multiplication by 2 k left shifts a
bit pattern by k places. Thus, given D and R, the quantity D*2 r XOR R yields the d+r bit pattern shown in Figure
above.
International standards have been defined for 8-, 12-, 16- and 32-bit generators, G. An 8-bit CRC is used to
protect the 5-byte header in ATM cells.
Figure below illustrates this calculation for the case of D = 101110, d = 6 and G = 1001, r=3. The nine bits
transmitted in this case are 101110 011. You should check these calculations for yourself and also check that
indeed D2r = 101011 * G XOR R.
A second way to viewing the CRC process is to express all values as polynomials in a dummy variable X, with
binary coefficients. The coefficients corresponds to the bits in the binary number. Thus for D=110011 we have,
D(X)=X5+X4+X+1 for P=11001 we have P(X)=X4+X3+1. Arithmetic operations are again modulo 2.
Example1:
Suppose our data is a list of five 4-bit numbers that we want to send to a destination. In addition to sending these
numbers, we send the sum of the numbers. For example, if the set of numbers is (7, 11, 12, 0, 6), we send (7, 11,
12,0,6,36), where 36 is the sum of the original numbers. The receiver adds the five numbers and compares the
result with the sum. If the two are the same, the receiver assumes no error, accepts the five numbers, and
discards the sum. Otherwise, there is an error somewhere and the data are not accepted.
Example2:
We can make the job of the receiver easier if we send the negative (complement) of the sum, called the
checksum. In this case, we send (7, 11, 12,0,6, -36). The receiver can add all the numbers received (including the
checksum). If the result is 0, it assumes no error; otherwise, there is an error
Internet Checksum
Traditionally, the Internet has been using a 16-bit checksum. The sender calculates the checksum by following
these steps.
Sender site:
1. The message is divided into 16-bit words.
2. The value of the checksum word is set to O.
3. All words including the checksum are added ushtg one's complement addition.
4. The sum is complemented and becomes the checksum.
5. The checksum is sent with the data.
Receiver site:
1. The message (including checksum) is divided into 16-bit words.
2. All words are added using one's complement addition.
3.The sum is complemented and becomes the new checksum.
4.If the value of checksum is 0, the message is accepted; otherwise, it is rejected.
Source : http://dayaramb.files.wordpress.com/2011/03/computer-
network-notes-pu.pdf