Sei sulla pagina 1di 41

Data Link Layer

Error Detection and Correction


Responsibilities of Data Link Layer
• Responsibilities : framing, addressing, flow control, error control,
and media access control.
• Framing : The data link layer divides the stream of bits received
from the network layer into manageable data units called frames.
• Addressing : The data link layer adds a header to the frame to
define the addresses of the sender and receiver of the frame.
• Flow Control : If the rate at which the data are absorbed by the
receiver is less than the rate at which data are produced in the
sender, the data link layer imposes a flow control mechanism to
avoid overwhelming the receiver.
• Error Control : The data link layer also adds reliability to the
physical layer by adding mechanisms to detect and retransmit
damaged, duplicate, or lost frames.
• Media Access Control : When two or more devices are connected
to the same link, data link layer protocols are necessary to
determine which device has control over the link at any given time.
Single Bit Error
Burst Error
Terms
• Redundancy
• Forward Error Correction : or channel coding[ is a
technique used for controlling errors in data transmission over unreliable or noisy communication
channels. The redundancy allows the receiver to detect a limited number of errors that may occur
anywhere in the message, and often to correct these errors without retransmission. FEC gives the
receiver the ability to correct errors without needing a reverse channel to request retransmission of
data, but at the cost of a fixed, higher forward channel bandwidth. FEC is therefore applied in situations
where retransmissions are costly or impossible, such as one-way communication links and when
transmitting to multiple receivers in multicast.

• Retransmission
• Error Detection
• Error Correction
• Block Coding
• Modulo 2 arithmetic – XOR operation
Error Control – Block Coding
• Divide message into blocks,
– each of k bits, called datawords
– add r redundant bits to each block to make the
length n = k + r.
– The resulting n-bit blocks are called codewords.
– Since n > k, the number of possible codewords is
larger than the number of possible datawords.
– The block coding process is one-to-one; the same
dataword is always encoded as the same
codeword.
Block Coding(without Error)

Source Encoder
00 001

Decoder
00
Block Coding(with Error)

Source Encoder
00 001

Decoder
01 010
Error Detection
Steps
Datawords Codewords • The receiver receives 011. It is a
00 000 valid codeword. The receiver
01 011 extracts the dataword 01 from it.
10 101
11 110 • The codeword is corrupted during
transmission, and 111 is received
(the leftmost bit is corrupted).
• This is not a valid codeword and is
discarded.
• The codeword is corrupted during
transmission, and 000 is received
(the right two bits are corrupted).
This is a valid codeword. The
receiver incorrectly extracts the
dataword 00. Two corrupted bits
have made the error undetectable.
Hamming Distance(XOR)
• Find the minimum Hamming distance of the coding scheme
– d(OOO, 011) =2
Why cant apply Hamming distance?
– d(O11,110)=2 How will u decide r bits?
– dmin is 2. Why XOR instead of AND (or) OR
operation?
• d(OOO, 101) =2 d(101, 110) =2 How will u know the location of error
in Hamming code algorithm?
• d(O0O, 110) =2 d(011, 101) =2 How rearranging the data makes u to
detect burst error
• Find the minimum Hamming distance of the coding scheme
– d(OOOOO, 01011) = 3 d(01011, 10101) =4
• The dmin is 3.
– d(OOOOO, 10101) =3 d(OlO11, 11110) = 3
– d(OOOOO, 11110) = 4 d(10101, 11110) =3
• Dmin is 3
Linear Block Codes
• Simple Parity Check Code:
– k-bit dataword
– n-bit codeword where n = k + 1(codeword even)
– dmin =2
– Can detect single bit error
Simple Parity check C(5,4)
Datawords Codewords Datawords Codewords
0000 00000 1000 10001
0001 00011 1001 10010
0010 00101 1010 10100
0011 00110 1011 10111
0100 01001 1100 11000
0101 01010 1101 11011
0110 01100 1110 11101
0111 01111 1111 11110
Encoder and Decoder for single Parity Check
Syndrome Bit
• Sender Side --------------- modulo 2 arithmetic
– r0 = a0+a1+a2+a3
• Receiver Side
– s0 = b0+b1+b2+b3+r0
• If Syndrome bit is 0 – no error else error
Example - LRC
• S = 1011 G = 10111
R = 10111 S0= 0 - no error
• S = 1011 G = 10111R = 10011 S0 = 1 – Error
• S = 1011 G = 10111
R = 10110 S0 = 1 - Error
• S = 1011 G = 10111
R = 10001 S0 = 0 – No error
(data is modified)
• Two Dimensional Parity Check Code - Vertical
Redundancy Check?
https://www.geeksforgeeks.org/gate-gate-it-2008-question-64/
Encoder and Decoder for Hamming
Code
Hamming Code Error detection and correction
• Sender Source ----------------------
– r0 = a0+a1+a2 modulo 2 arithmetic
– r1 = a1+a2+a3
– r2 = a1+a3+a0
• Receiver - Destination
– s0 = b0+b1+b2 + q0 modulo 2 arithmetic
– s1 = b1+b2+b3 + q1
– s2 = b1+b3+b0 + q2
• Error detection and Correction
Error Detection and Correction
(Single Bit)

Error Detection and Correction


(Burst Error)
How?
Why cant apply Hamming distance?
How will u decide r bits?
Why XOR instead of AND (or) OR operation?
How will u know the location of error in Hamming code algorithm?
How rearranging the data makes u to detect burst error
Question - 1
• D.W 0100 C.W : 0100011 Syndrome = 000
– C.W at receiver ?
• D.W 0111 C.W : 0111001 Syndrome = 011
– C.W at Receiver
• D.W 1101 C.W :1101000 Syndrome : 101
– C.W at receiver ?
Cyclic Encoder and Decoder(CRC)
Algorithm
• K = 4, n = 7, r=3
• Divisor = n-k+1
• The generator divides the dataword by the
divisor(modulo 2 division).
• Check leftmost bit
– leftmost bit 0 – 0000
– Leftmost bit 1 – dataword
• Copy of the divisor is XORed with the dividend.
• Next bit is pulled from dividend for next step
• The reminder r2r1r0 is appended to the dataword
Division – CRC Encoder
Division – CRC Encoder
Polynomials
• 1000011 = x6+x+1
• Addition : (x3+x)+(x+1) = x3+1 (mod2)
• (x5+x4+x2)+(x6+x4+x2) = x6+x5
• Multiplication
Polynomial Division
• Divide the first term of the dividend by the
first term of the divisor to get the quotient.
• Multiply the term in the quotient by the
divisor and subtract the result from the
dividend
• Repeat steps until the dividend degree is less
than the divisor degree.
CRC Division using Polynomials
SENDER 1001=x3+1

1011
Augment by
3
Divide the first term of the
dividend by the first term
of the divisor to get the
quotient.
Multiply the term in the
quotient by the divisor
and subtract the result
from the dividend 1001110
Repeat steps until the
dividend degree is less
than the divisor degree. Receiver?
Checksum
Problems
• 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. –
• Make rcvr side operation in single step
Problem - Checksum
• 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. – Use 1’s
Complement arithmetic
Error
CRC generator properties(research)
• It should have at least two terms.
• The coefficient of the term x0 should be 1.
• It should not be divisible by x.
• It should be divisible by x+ 1.
• http://research.ijcaonline.org/volume35/num
ber2/pxc3976032.pdf
Direct questions
• Calculate single parity, VRC for set of data
• Hamming distance, minimum hamming
distance
• Calculate CRC, CRC using polynomial
expression, Hamming Code, Checksum
Problems
• Assume Single Bit Parity Generator,
• Dataword = 1011 codeword = 10111(sender)
– If C.W = 10111, S=?
– If C.W = 10110, S=?
– If C.W = 10001, S=?
– If C.W = 10000, S=?
– If C.W = 01001, S=?
– If C.W = 01000, S=?
– Conclude your interpretation.
Problems
• Imagine a communication link that is
experiencing interference so every 18th bit is
changed from 0 to 1 or from 1 to 0. Does
parity check detect all the errors?
Problem
• How can we represent the number −6 in one’s
complement arithmetic using only four bits?
– Solution 1
• 6 – 0110
• -6 = 1001 = 9
– Solution 2
• 2n-1-no = 16-1-6 = 9
Problem
• calculate the checksum for a text of 8
characters of your name.
• Solution
– Find Ascii value for letters
– Do hex addition
– Calculate Wrapped Sum
– Find Checksum
– Send Receiver side and Do repeat
• Eight bit messages are transmitted using a
Hamming code. How many check bits are
needed to ensure that receiver can detect
and correct single bit errors? Show the bit
• pattern transmitted for the message
1001010. Assume that odd parity is used in
the
• Hamming code.
• ANS:
• m+r+1≤2r , m=8
• 8+r+1≤2r, r=4
• n=m+r=8+4=12
Problem
A bit stream 10101010 is transmitted using the standard CRC method. The
generator polynomial is x3+x2+1. Show the actual bit string transmitted

What is the remainder obtained by dividing X7 + X5 + 1by the generator


polynomial X3 +1 ?.
Problem link
• http://web.mit.edu/6.02/www/f2012/handou
ts/tutprobs/ecc.html

Potrebbero piacerti anche