Data Link Layer 1
Data Link Layer 1
Data Link Layer 1
BY:
MITUL PATEL
Figure 3-5
WCB/McGraw-Hill
Figure 3-6
WCB/McGraw-Hill
Error Control
Types of Errors
Single-bit error
Burst error
Error detection
Error detection means to decide whether the
received data is correct or not without having
a copy of the original message.
Error detection uses the concept of
redundancy, which means adding extra bits
for detecting errors at the destination.
Redundancy
Error Correction
Need to know exact number of bits that are
corrupted and their location in the message
The number of the errors and the size of the
message are important factors
Correct one single error in an 8-bit data
unit, how many possibilities??
Two errors in 8-bit data unit?
10 errors in 1000 bits??
BLOCK CODING
Divide the message into blocks each of kbits called datawords.
Add r redundant bits to each block to make
length n=k+r. The resulting n-bit blocks are
called codewords.
K bits
N bits
K bits
N bits
K bits
N bits
k=2
n=3
Datawords
Codewords
00
000
01
011
10
101
11
110
k=2
n=5
Dataword
Codeword
00
00000
01
01011
10
10101
11
11110
Hamming Distance
The Hamming distance between two words
is the number of differences between
corresponding bits.
Hamming distance of two words x and y is
d(x,y)
Can be found by applying XOR operation on
the two words and count the number of 1s
in the result.
Minimum Hamming
Distance
Codewords
00
000
01
011
10
101
11
110
d(000,011)=2
d(000,101)=2
d(000,110)=2
d(011,101)=2 d(011,110)= 2
d(101,110)=2
The dmin in this case is 2.
Minimum Hamming
Distance
Codewords
00
00000
01
01011
10
10101
11
11110
Our
Example
C(3,2) with dmin = 2
Codewords
Datawords
Codewords
00
000
00
00000
01
011
01
01011
10
101
10
10101
11
110
11
11110
Parity Check
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
Example
Assume the sender sends the dataword
1011.The codeword was created from this
dataword is 10111,which is sent to the receiver.
1. No error occurs
2. One single-bit error changes a1.
3. One single-bit error changes r0.
4. An error changes r0 and a second error
changes a3.
5. Three bits-a3,a2 and a1- are changed by
errors.
Performance
It
Performance
LRC increases the likelihood of
detecting burst errors.
If two bits in one data units are
damaged and two bits in exactly
the same positions in another data
unit are also damaged, the LRC
checker will not detect an error.
2D Parity Check:
Performance
46
2D Parity Check:
Performance
47
Hamming Codes
dmin=3
Hamming code C(7,4)
Dataword
s
Codeword
s
Dataword
s
Codeword
s
0000
0000000
1000
1000110
0001
0001101
1001
1001011
0010
0010111
1010
1010001
0011
0011010
1011
1011100
0100
0100011
1100
1100101
0101
0101110
1101
1101000
0110
0110100
1110
1110010
0111
0111001
1111
1111111
Syndrome
000
001
010 011
100
101
110
111
Error
None
q0
q1
q2
b0
b3
b1
b2
CYCLIC CODES
Cyclic codes are special linear block codes
with one extra property.
If a codeword is cyclically shifted, the result
is another codeword.
1011000
0110001
Codeword
Dataword
Codeword
0000
0000000
1000
1000101
0001
0001011
1001
1001110
0010
0010110
1010
1010011
0011
0011101
1011
1011000
0100
0100111
1100
1100010
0101
0101100
1101
1101001
0110
0110001
1110
1110100
0111
0111010
1111
1111111
Binary Division
Divisor 1011
Data sequence 1010011110
Polynomial
Standard Polynomials
Single-bit error
What should be the structure of g(x) to
guarantee the detection of a single-bit error?
A single-bit error is e(x) =x i where i is the
position of the bit. If a single-bit error is caught,
then xi is not divisible by g(x).
If g(x) has at least two terms and the
coefficient of x0is not zero, then e(x) cannot be
divided by g(x).
If the generator has more than one term and
the coefficient of x0 is 1,all single errors can be
caught.
Burst error
A burst error is of the form e(x) =(xj+ ... + xi)
We can factor out xi and write the error as
xi(xj-i + ... + 1).
If our generator can detect a single error
(minimum condition for a generator), then it
cannot divide xi.
In other words, the remainder of (xj-i + ... +
1)/(xr + ... + 1) must not be zero.
Note that the denominator is the generator
polynomial. We can have three cases:
1.
2.
3.
length of error L
r degree of generator
L <= r the remainder can never be zero.
Checksum
Internet Checksum
Traditionally, the Internet has been using a
16-bit checksum.
The sender calculates the checksum by
following these steps.
Sender site:
At sender side
The first step is to form 16-bit words.
0100 F203 F4F5 F6F7
The second step is to calculate the sum using
32-bits.
0100 + F203 + F4F5 + F6F7 = 0002 DEEF
The third step is to add the carries (0002) to
the 16-bit sum.
DEEF + 002 = DEF1
The fourth step is to take the complement.
~DEF1 = 210E checksum is 21 0E
The packet header is sent as :
01 00 F2 03 F4 F5 F6 F7 21 0E
Receiver Side
The first step is to form 16-bit words.
0100 F203 F4F5 F6F7 210E
The second step is to calculate the sum
using 32-bits.
0100 + F203 + F4F5 + F6F7 + 210E=
0002 FFFD
The third step is to add the carries (0002)
to the 16-bit sum.
FFFD+ 0002 = FFFF which means that no
error was detected.(In 1s complement,
zero is 0000 or FFFF.)
FRAMING
FRAMING
The data link layer needs to pack bits into frames, so
that each frame is distinguishable from another. Our
postal system practices a type of framing. The simple
act of inserting a letter into an envelope separates one
piece of information from another; the envelope serves
as the delimiter.
Topics discussed in this section:
Fixed-Size Framing
Variable-Size Framing
11.82
11.83
11.84
Note
11.85
11.86
Note
Bit stuffing is the process of adding
one extra 0 whenever five consecutive
1s follow a 0 in the data, so that the
receiver does not mistake
the pattern 0111110 for a flag.
11.87
11.88