E-mail: kalansari1@georgebrown.ca
1
Reminder!
2
Chapter 10: Outline
10.1 INTRODUCTION
3
10-1 INTRODUCTION
4
• The data link layer is responsible for node-to-node (hope-to-hope) delivery of
data. Responsibilities of the data link layer include framing, flow control, error
control and media access control.
• The data link layer adds reliability to the physical layer through a mechanism to
detect and retransmit damaged, duplicate or lost frames.
• Some other applications require that errors be detected and corrected, such as in
text transmission.
5
• When transmitting a given data unit (such as a byte) a single-bit transmission
error means that only one bit in the data unit is inverted.
6
• A burst of noise can cause a burst of errors in the transmitted data.
• As an example, a noise burst of 0.01 s can affect 10 bits if the data rate was 1
kbps. Whereas, the same noise burst can affect 10000 bits if the data rate
was 1 Mbps.
7
• A burst of noise is more likely to occur than a single-bit error.
8
Error Control
Error detection:
Error correction:
9
• Error correction can be classified into two categories:
The receiver uses the redundant bits to allocate the corrupted bits and
correct them.
Retransmission:
10
Block Coding
• At the receiver redundant bits are added such that to create a relationship
between the data bits and the redundant bits. The receiver checks the
relationship between the received redundant bits and the received data bits to
detect transmission errors and correct them.
• In block coding, the message is divided into blocks called data-words. Each
data-word has “k” bits. A number of “r” redundant bits are added to each
data-word to make a code-word with length “n = k + r”.
11
• With “k” bits there is a combination of 2 k data-words.
Example
In the 4B/5B block coding, k = 4 and n = 5. Therefore, there are:
2k 2 4 16 data - words
2n 25 32 code - words
Only 16 out of 32 code-words are used for message transfer and the rest are
either used for other purposes or unused.
12
Error Detection In Block Coding
• The sender creates code-words out of data-words. At the receiver, if the
received code-word matches one of the valid code-words, the data-word is
extracted from the code-word. Otherwise, if the received code-word is invalid, it
is discarded.
13
Example
Assume k = 2 and n = 3 for a block coding scheme with the data-words to code-
words conversion table given below.
• In error correction, the receiver needs to detect the correct code-word sent.
15
Example
Assume k = 2 and n = 5 for a block coding scheme with the data-words to code-
words conversion table given below.
Assume a transmission error happens in the second bit from right. That is,
“01001 is received.
The receiver compares the received code-word with the valid code-words in the
above table and decides that it matches the second code-word because there
is a difference in only one bit between them. Whereas, there is a difference in
more than one bit between the received code-word and any other valid cod-
word.
16
Hamming Distance
• The Hamming distance “d” between two words w1 and w2 is the number of
differences between their corresponding bits.
Example
Find the minimum Hamming distance for the coding scheme in table below.
Minimum Hamming
distance : d min 2
• To allow the detection for up to “s” transmission errors per unit of data, the
minimum Hamming distance between the valid code-words must be:
d min s 1
• To allow the correction for up to “t” transmission errors per unit of data, the
minimum Hamming distance between the valid code-words must be:
d min 2t 1
20
Geometric concept for finding dmin in error detection
21
Geometric concept for finding dmin in error correction
22
Example
Find the error detection and correction capability for the coding scheme in table
below.
d min s 1 3 s2
d min 2t 1 3 t 1
24
Example 10.1
Let us assume that k = 2 and n = 3. Table 10.1 shows the list
of datawords and codewords. Later, we will see how to
derive a codeword from a dataword.
Table 10.1: A code for error detection in Example 10.1
25
Example 10.2
Let us find the Hamming distance between two pairs of
words.
26
Example 10.3
The minimum Hamming distance for our first code scheme
(Table 10.1) is 2. This code guarantees detection of only a
single error. For example, if the third codeword (101) is sent
and one error occurs, the received codeword does not match
any valid codeword. If two errors occur, however, the
received codeword may match a valid codeword and the
errors are not detected.
27
Example 10.4
A code scheme has a Hamming distance dmin = 4. This code
guarantees the detection of up to three errors (d = s + 1 or
s = 3).
28
Example 10.5
The code in Table 10.1 is a linear block code because the
result of XORing any codeword with any other codeword is
a valid codeword. For example, the XORing of the second
and third codewords creates the fourth one.
29
Example 10.6
In our first code (Table 10.1), the numbers of 1s in the
nonzero codewords are 2, 2, and 2. So the minimum
Hamming distance is dmin = 2.
30
Table 10.2: Simple parity-check code C(5, 4)
The extra bit is called parity bit, is selected to make the total
number of 1s in the codeword even.
31
Figure 10.4: Encoder and decoder for simple parity-check code
32
Example 10.7
Let us look at some transmission scenarios. Assume the
sender sends the dataword 10110. The codeword created
from this dataword is 10111, which is sent to the receiver.
We examine five cases:
33
10-3 CYCLIC CODES
34
10.3.1 Cyclic Redundancy Check
35
Table 10.3: A CRC code with C(7, 4)
36
Cyclic Redundancy Check (CRC):
37
Figure A Decimal CRC example.
38
Figure 10.5: CRC encoder and decoder
39
Figure 10.6: Division in CRC encoder
40
Figure 10.7: Division in the CRC decoder for two cases
41
The CRC is a mathematical technique that is used in synchronous data
transmission.
In this technique, each string of bits is represented by a polynomial function.
The technique is done by division. It is illustrated as follows:
M ( x)
Q ( x) R ( x)
G ( x)
where M(x) is the binary data, called the message function, and G(x) is a special
code for which the message function is divided, called the generating function.
The process yields a quotient function, Q(x), and a remainder function, R(x).
The quotient is not used, and the remainder, which is the CRC block check code
(BCC), is attached to the end of the message.
At the receiver, the message and CRC check character pass through its block
check register (checker). If the register’s content is zero, then the message
contains no errors.
CRC codes are easy to implement, requiring only the use of shift registers, XOR
gates, and feedback paths.
42
Hardware implementation of the CRC technique:
44
5. Connect the message polynomial M(x) to the first Ex-OR gate on the right
and connect the output of the first EX-OR gate on the right to the 2nd
inputs of all EX-OR gate as well as to the input of first FF on the left, i.e.,
FF # 1.
The number of clock pulses required to generate the remainder in the shift
register is equal to the number of message bits. In our case, it will take 8 clock
pulses (because the message is 11001101, 8 bits) to generate the R(x) in the
shift register. Four additional clock pulses will piggyback R(x) on the M(x).
The complete T(x) will be shifted out of the first Ex-OR gate (on the right) at
the end of the 12th clock pulse. Figure 10 shows the generation of R(x) in the
shift register step by step after each clock pulse is applied for a G(x) = x3 + x +
1 and M(x) = 101001. 45
Figure 10