7/31/2019 EC-356 Data Link Layer
1/49
7/31/2019 EC-356 Data Link Layer
2/49
7/31/2019 EC-356 Data Link Layer
3/49
7/31/2019 EC-356 Data Link Layer
4/49
7/31/2019 EC-356 Data Link Layer
5/49
7/31/2019 EC-356 Data Link Layer
6/49
7/31/2019 EC-356 Data Link Layer
7/49
7/31/2019 EC-356 Data Link Layer
8/49
7/31/2019 EC-356 Data Link Layer
9/49
7/31/2019 EC-356 Data Link Layer
10/49
7/31/2019 EC-356 Data Link Layer
11/49
7/31/2019 EC-356 Data Link Layer
12/49
7/31/2019 EC-356 Data Link Layer
13/49
Error Control
Feedback: Using special control frames. To ensure reliable delivery
is to provide the sender with some feedback.
Sender
Data Frame
ReceiverAcknowledgement (ACK)
Or negative Acknowledgement (NAK)
Timers : Hardware troubles may cause special control frames tovanish completely and the receiver will not react at all.
Sequence Numbers : To outgoing frames, to prevent receiver from
accepting the same frame two or more times, and pass it to thenetwork layer more than once.
To help receiver distinguish retransmissions from originals.
7/31/2019 EC-356 Data Link Layer
14/49
7/31/2019 EC-356 Data Link Layer
15/49
EDC= Error Detection and Correction bits (redundancy)D = Data protected by error checking, may include header fields
Error detection not 100% reliable! protocol may miss some errors, but rarely larger EDC field yields better detection and correction
7/31/2019 EC-356 Data Link Layer
16/49
Isolated Errors : every packet would be in error
Advantage:
Transmission errors : generated by physical processes, errors
on some media tend to come inbursts rather than singly.
Disadvantage: They are much harder to detect and correct than
isolated errors.
bursty error: only one packet is incorrect
7/31/2019 EC-356 Data Link Layer
17/49
7/31/2019 EC-356 Data Link Layer
18/49
Error-Correcting Codes
m data bits rcheck bits
What is a codeword ?
n=m+r
There are 2npossible codewords and 2mpossible data messages.
Hamming distancebetween codewords:
min d(C1,C2)=number of (same bit position) bits which differ
d(10010010,00010001)=3
If two codewords are a hamming distance dapart, it will require d
single-bit errors to convert one into the other.
7/31/2019 EC-356 Data Link Layer
19/49
In most data transmission applications, all 2m
possible datamessages are legal, but due to the way the check bits are
computed, not all 2npossible codewords are used.
Given the algorithm for computing the check bits, it ispossible to construct a complete list of codewords, and from
this list find the two codewords whose Hamming distance is
minimum. This distance is the Hamming distance of the
complete code.
7/31/2019 EC-356 Data Link Layer
20/49
To detect derrors, you need a distance d+1 code.
d+1
radius=dbits
distance
7/31/2019 EC-356 Data Link Layer
21/49
To correct derrors, you need a distance 2d+1 code.
7/31/2019 EC-356 Data Link Layer
22/49
Parity check is a code with distance 2. Therefore, it can detect
single-bit error.
Consider a code with only 4 valid codewords:0000000000, 0000011111, 1111100000, 1111111111
,
bit errors and correct double errors.
If the codeword 0000000111 arrives and we know at most two
bits are in error, the receiver knows that the original must havebeen 0000011111. If, however, a triple error changes
0000000000 into 0000000111, the error will not be corrected
properly.
7/31/2019 EC-356 Data Link Layer
23/49
A 1-bit error correcting code (Hamming code)
m data bits rcheck bits
n=m+r
distance 1 from it.
Thus each of the 2m legal messages requires n+1 bit patterns
dedicated to it.
r
rmm
nm
rm
rm
n
2)1(
22)1(
22)1(
++
++
++
Therefore,
7/31/2019 EC-356 Data Link Layer
24/49
Single Bit Parity:Detect single bit errors
Two Dimensional Bit Parity:Detect and correctsingle bit errors
0 0
7/31/2019 EC-356 Data Link Layer
25/49
There is a lower limit on the number of check bits needed to
correct single errors.
In practice, it can be achieved using a method due to Hamming.
The bits of codewords are numbered consecutively, starting with
bit 1 at the left end. The bits that are power of 2 (1, 2, 4, 8, )
r h k i
The rest are filled up with the data bits. Each check bit forces
the parity of some collection of bits, including itself, to be even
(or odd).
7/31/2019 EC-356 Data Link Layer
26/49
Error-Correcting Codes
A 1-bit error
correcting code
(Hamming code)
Correct 12-bit burst
errors by transmitting
vertically.
7/31/2019 EC-356 Data Link Layer
27/49
7/31/2019 EC-356 Data Link Layer
28/49
Error-detecting Codes
error control: error detection or error correction?
assume error rate=1/106 data=1000 bits
error detecting check bits: 1 bit (e.g. parity check)
. .
In 103packets:
error detecting overhead=103+1001=2001 bits
error correcting overhead=10*103bits=10000 bits
retransmission
7/31/2019 EC-356 Data Link Layer
29/49
The Data Link Layer
Error-detecting Codes
CRC (Cyclic Redundancy Code)
Treat bit strings as polynomials with coefficient 0 and 1.
(E.g. 10001001:x7+x3+1, 01010111=x6+x4+x2+x+1)
. .
(the generating polynomial, G(x))2.
Assume with remainder
Then transmit
M x x
G xA x R x
T x M x x R x
r
r
( )
( )( ) ( ).
( ) ( ) ( ).
=
=
3. When receiver receives T(x), it divides it by G(x). If there
is a remainder, then an error has occurred.
(All the above operations are done in modulo 2.)
7/31/2019 EC-356 Data Link Layer
30/49
7/31/2019 EC-356 Data Link Layer
31/49
7/31/2019 EC-356 Data Link Layer
32/49
Elementary Data Link Protocols
7/31/2019 EC-356 Data Link Layer
33/49
Elementary Data Link Protocols
7/31/2019 EC-356 Data Link Layer
34/49
Elementary Data Link Protocols
7/31/2019 EC-356 Data Link Layer
35/49
7/31/2019 EC-356 Data Link Layer
36/49
7/31/2019 EC-356 Data Link Layer
37/49
7/31/2019 EC-356 Data Link Layer
38/49
1. An Unrestricted Simplex Protocol
7/31/2019 EC-356 Data Link Layer
39/49
7/31/2019 EC-356 Data Link Layer
40/49
7/31/2019 EC-356 Data Link Layer
41/49
2. A Simplex Stop-and-Wait Protocol
7/31/2019 EC-356 Data Link Layer
42/49
7/31/2019 EC-356 Data Link Layer
43/49
7/31/2019 EC-356 Data Link Layer
44/49
3. A Simplex Protocol for Noisy Channel
sequence numbers (to number packets and ACKs)
senderP(1) P(2)
senderP(1) P(1)
time-out
receiverACK
receiverACK
error
If there is no sequence number for packets, the receiver
can not distinguish between these two cases.
new old
7/31/2019 EC-356 Data Link Layer
45/49
The sender cannot tell whether this
ACK is for P(1) or P(2) if not
um ered.
A potential failure
ACKs must also be numbered.
sender
receiver
P(1) P(1) P(2)
error
ACK ACK
time-out
7/31/2019 EC-356 Data Link Layer
46/49
7/31/2019 EC-356 Data Link Layer
47/49
3. A Simplex Protocol for Noisy Channel
7/31/2019 EC-356 Data Link Layer
48/49
7/31/2019 EC-356 Data Link Layer
49/49