0% found this document useful (0 votes)
8 views

Data Communication - 8th Lecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Data Communication - 8th Lecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

11/20/2023

DATA COMMUNICATION DATA COMMUNICATION


✓ Types of Errors (occurred during transmission): Whenever bits flow from
▰ Course Title: Data Communication one point to another, they are subject to unpredictable changes because of
▰ Course Code: CSE-3525 interference. This interference can change the shape of the signal. Types of errors
are:
▰ Credit Hours: 3
▰ Textbooks: 1. Data Communications AND Networking - 5th Edition a) Single-Bit Error:
The term single-bit error means that only 1 bit of a given data unit (such as a byte,
by Behrouz A. Forouzan character, or packet) is changed from 1 to 0 or from 0 to 1.
2. Computer Networks - 5th Edition by A. Tanenbaum
For a single-bit error to occur, the noise must have a duration of only 1 )ls, which
is very rare; noise normally lasts much longer than this.

Conducted by: Engr. Muinul Islam

Fig. Single-bit error

1 2

DATA COMMUNICATION DATA COMMUNICATION

✓ Types of Errors (Contd.): ✓ Redundancy:


The central concept in detecting or correcting errors is redundancy. To be able to detect or
b) Burst Error: correct errors, we need to send some extra bits with our data. These redundant bits are added by
The term burst error means that 2 or more bits in the data unit have changed from the sender and removed by the receiver. Their presence allows the receiver to detect or correct
1 to 0 or from 0 to 1. corrupted bits.
A burst error is more likely to occur than a single-bit error because the duration of ✓ Detection Vs Correction
the noise signal is normally longer than the duration of 1 bit, which means that
when noise affects data, it affects a set of bits. ❑ In error correction, we need to know the exact number of bits that are corrupted and more
importantly, their location in the message. The number of the errors and the size of the
message are important factors.

❑ If we need to correct one single error in an 8-bit data unit, we need to consider eight
possible error locations; if we need to correct two errors in a data unit of the same size,
we need to consider 28 possibilities.

Fig. Burst error

3 4

1
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

✓ Methods of Error Correction ✓ Coding (Contd.)


❑ Forward error correction: The ratio of redundant bits to the data bits and the robustness of the process are important
In Forward error correction is the process in which the receiver tries to guess the factors in any coding scheme.
message by using redundant bits. This is possible, if the number of errors is small. We can divide coding schemes into two broad categories: a) Block coding and b) Convolution
coding.
❑ Correction by retransmission
A technique in which the receiver detects the occurrence of an error and asks the sender
to resend the message. Resending is repeated until a message arrives that the receiver
believes is error-free.

✓ Coding
Redundancy is achieved through various coding schemes.
The sender adds redundant bits through a process that creates a relationship between the
redundant bits and the actual data bits.
The receiver checks the relationships between the two sets of bits to detect or correct the errors. Figure shows the general idea of coding.

5 6

DATA COMMUNICATION DATA COMMUNICATION

✓ Block Coding ✓ Error Detection (Contd.)


In block coding, we divide our message into blocks, each of k bits, called datawords. We add r
redundant bits to each block to make the length n = k + r. The resulting n-bit blocks are called
codewords.
The block coding process is one-to-one; the same data word is always encoded as the same
codeword. This means that we have 2n − 2k codewords that are not used. We call these
codewords invalid or illegal.

✓ Error Detection
Figure. Process of error detection in block coding
To detect error, the following two conditions are needed to be met:

1. The receiver has (or can find) a list of valid codewords. ✓ Hamming Distance
2. The original codeword has changed to an invalid one. 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).
An error-detecting code can detect only the types of errors for which it is designed; other types of
errors may remain undetected. Hamming distance is a value greater than zero. Hamming distance between the received codeword
and the sent codeword is the number of bits that are corrupted during transmission.

7 8

2
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

✓ Hamming Distance (Contd.) ✓ Hamming Distance and Error


For example, if the codeword 00000 is sent and 01101 is received, 3 bits are in error and the When a codeword is corrupted during transmission, the Hamming distance between the sent and
Hamming distance between the two is d(00000, 01101) = 3. received codewords is the number of bits affected by the error. In other words, the Hamming
distance between the received codeword and the sent codeword is the number of bits that are
If the Hamming distance between the sent and the received codeword is not zero, the codeword corrupted during transmission.
has been corrupted during transmission. 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 For example, if the codeword 00000 is sent and 01101 is received, 3 bits are in error and the
Hamming distance is a value greater than or equal to zero. Hamming distance between the two is d(00000, 01101) =3.

✓ Minimum Hamming Distance


✓ Minimum Distance for Error Detection
Now let us find the minimum Hamming distance in a code if we want to be able to detect up to s
The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a
errors. If s errors occur during transmission, the Hamming distance between the sent codeword and
set of words. We use dmin to define the minimum Hamming distance in a coding scheme.
received codeword is s. If our code is to detect up to s errors, the minimum distance between the
To find this value, we find the Hamming distances between all words and select the smallest one. valid codes must be s + 1, so that the received codeword does not match a valid codeword.

If the minimum distance between all valid codewords is s + 1, the received codeword cannot be
erroneously mistaken for another codeword.

9 10

DATA COMMUNICATION DATA COMMUNICATION

✓ Minimum Distance for Error Detection (Contd.)


The distances are not enough (s + 1) for the receiver to accept it as valid. The error will be ✓ Minimum Distance for Error Correction
detected. We need to clarify a point here: Although a code with dmin =s + 1 may be able to detect When a received codeword is not a valid codeword, the receiver needs to decide
more than s errors in some special cases, only s or fewer errors are guaranteed to be detected. which valid codeword was sent. The decision is based on the concept of territory, an
We can look at this criteria geometrically. Let us assume that the sent codeword x is at the center exclusive area surrounding the codeword. Each valid codeword has its own territory.
of a circle with radius s. All received codewords that are created by 0 to s errors are points inside
the circle or on the perimeter of the circle. All other valid codewords must be outside the circle, as For example, suppose a codeword x is corrupted by t bits or less. Then this corrupted
shown in Figure. This means that dmin must be an integer greater than s or dmin = s + 1. codeword is located either inside or on the perimeter of this circle. If the receiver
receives a codeword that belongs to this territory, it decides that the original codeword
is the one at the center. We assume that only up to t errors have occurred; otherwise,
the decision is wrong.

11 12

3
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

✓ Linear Block Codes ✓ Few Linear Block Codes (Contd.)


A linear block code is a code in which the exclusive OR (addition modulo-2) of two
valid codewords creates another valid codeword. ❑ Simple Parity-Check Code (Contd.)
The minimum Hamming distance for this category is dmin =2, which means that
✓ Minimum Distance for Linear Block Codes
the code is a single-bit error-detecting code; it cannot correct any error.
It is simple to find the minimum Hamming distance for a linear block code. The
minimum Hamming distance is the number of 1s in the nonzero valid codeword with
Example: Let us assume that k = 2 and n = 3. Fig-1 shows the list of datawords
the smallest number of 1s.
and codewords.
✓ Few Linear Block Codes
Parity-Check Code Perhaps the most familiar error-detecting code is the simple parity-
check code.
❑ Simple Parity-Check Code
In this code, a k-bit dataword is changed to an n-bit codeword where n = k + 1. Fig-1 A code for error detection
The extra bit, called the parity bit, is selected to make the total number of Is in Assume the sender encodes the dataword 01 as 011 and sends it to the
the codeword even. receiver.

13 14

DATA COMMUNICATION DATA COMMUNICATION

✓ Few Linear Block Codes (Contd.) ✓ Few Linear Block Codes (Contd.)
❑ Simple Parity-Check Code (Contd.) ❑ Simple Parity-Check Code (Contd.)
Example (Contd.): Let us assume that k = 2 and n = 3. Fig-1 shows the list of Example (Contd.): The code in Fig-2 is also a parity-check code with k = 4 and n
datawords and codewords. We can assume, the sender encodes the dataword = 5.
01 as 011 and sends it to the receiver. We also can consider the following cases:
1. The receiver receives 011. It is a valid codeword. The receiver extracts the
dataword 01 from it.
2. The codeword is corrupted during transmission, and 111 is received (the
leftmost bit is corrupted). This is not a valid codeword and is discarded. 3. 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.
Fig-2 Simple parity-check code C(5, 4)

15 16

4
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION


✓ Few Linear Block Codes (Contd.)
✓ Few Linear Block Codes (Contd.)
❑ Simple Parity-Check Code (Contd.)
Example (Contd.):
❑ Simple Parity-Check Code (Contd.)
Example (Contd.):
If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is
1. In both cases, the total number of 1s in the codeword is even. The sender
sends the codeword, which may be corrupted during transmission. The receiver
receives a 5-bit word.
The checker at the receiver does the same thing as the generator in the sender
with one exception: The addition is done over all 5 bits. The result, which is called
Fig-3 Encoder and decoder for simple parity-check code the syndrome, is just 1 bit. The syndrome is 0 when the number of 1s in the
Fig-3 shows a possible structure of an encoder (at the sender) and a decoder (at received codeword is even; otherwise, it is 1.
the receiver). This is normally done by adding the 4 bits of the dataword (modulo- s0 = b3 + b2 + b1 + b0 + q0 (modulo-2)
2); the result is the parity bit. In other words, r0 = a3 + a2 + a1 + a0

17 18

DATA COMMUNICATION DATA COMMUNICATION

✓ Few Linear Block Codes (Contd.) ✓ Few Linear Block Codes (Contd.)

❑ Simple Parity-Check Code (Contd.)


❑ Two-dimensional parity check code
In this method, the dataword is organized in a table (rows and columns).
Example (Contd.):
The syndrome is passed to the decision logic analyzer.
If the syndrome is 0, there is no detectable error in the received codeword; the
data portion of the received codeword is accepted as the dataword; if the
syndrome is 1, the data portion of the received codeword is discarded. The
dataword is not created.
A simple parity-check code can detect an odd number of errors.

Fig. Two-dimensional parity-check code

19 20

5
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

✓ Few Linear Block Codes (Contd.)


✓ Few Linear Block Codes (Contd.)
❑ Two-dimensional parity check code (Contd.)
❑ Two-dimensional parity check code
In Fig, the data to be sent, five 7-bit bytes, are put in separate rows. For each row
and each column, 1 parity-check bit is calculated. The whole table is then sent to
the receiver, which finds the syndrome for each row and each column.
As Fig shows, the two-dimensional parity check can detect up to three errors that
occur anywhere in the table (arrows point to the locations of the created nonzero
syndromes). However, errors affecting 4 bits may not be detected.
❑ Hamming Codes
Fig. Two-dimensional parity-check code These codes were originally designed with dmin = 3, which means that they can
detect up to two errors or correct one single error.

21 22

DATA COMMUNICATION DATA COMMUNICATION

✓ Few Linear Block Codes (Contd.) ✓ Few Linear Block Codes (Contd.)

❑ Hamming Codes (Contd.) ❑ Hamming Codes (Contd.)


Although there are some Hamming codes that can correct more than one error,
our discussion focuses on the single-bit error-correcting code.

First let us find the relationship between n and k in a Hamming code. We need to
choose an integer m >= 3. The values of n and k are then calculated from m as
n = 2m - 1 and k ::: n - m. The number of check bits r =m.

For example, if m =3, then n ::: 7 and k::: 4. This is a Hamming code C(7, 4) with
dmin =3. Table shows the datawords and codewords for this code.

Table: Hamming code C(7, 4)

23 24

6
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

✓ Few Linear Block Codes (Contd.) ✓ Few Linear Block Codes (Contd.)
❑ Cyclic Codes ❑ Cyclic Codes
Cyclic codes are special linear block codes with one extra property. In a cyclic Cyclic codes are special linear block codes with one extra property. In a cyclic
code, if a codeword is cyclically shifted (rotated), the result is another codeword. code, if a codeword is cyclically shifted (rotated), the result is another codeword.
For example, if 1011000 is a codeword and we cyclically left-shift, then 0110001 For example, if 1011000 is a codeword and we cyclically left-shift, then 0110001
is also a codeword. In this case, if we call the bits in the first word a0 to a6, and the is also a codeword. In this case, if we call the bits in the first word a0 to a6, and the
bits in the second word b0 to b6, we can shift the bits by using the following: In bits in the second word b0 to b6, we can shift the bits by using the following: In
the rightmost equation, the last bit of the first word is wrapped around and the rightmost equation, the last bit of the first word is wrapped around and
becomes the first bit of the second word b0 to b6, we can shift the bits by using the becomes the first bit of the second word b0 to b6, we can shift the bits by using the
following: following:
b1 = a0 b2 = a1 b3 = a2 b4 = a3 b5 = a4 b6 = a5 b0 = a6 b1 = a0 b2 = a1 b3 = a2 b4 = a3 b5 = a4 b6 = a5 b0 = a6

In the rightmost equation, the last bit of the first word is wrapped around and In the rightmost equation, the last bit of the first word is wrapped around and
becomes the first bit of the second word. becomes the first bit of the second word.

25 26

DATA COMMUNICATION DATA COMMUNICATION

❑ CHECKSUM ❑ Checksum (Contd.)


The checksum is used in the Internet by several protocols although not at the At the source, the message is first divided into m-bit units. The generator then
data link layer. Like linear and cyclic codes, the checksum is based on the creates an extra m-bit unit called the checksum, which is sent with the message.
concept of redundancy. Several protocols still use the checksum for error At the destination, the checker creates a new checksum from the combination of
detection. This means that the CRC is also used in layers other than the data link the message and sent checksum.
layer.
If the new checksum is all 0s, the message is accepted; otherwise, the message
Example 1. Suppose our data is a list of five 4-bit numbers that we want to send is discarded (Figure).
to a destination. In addition to sending these numbers, we send the sum of the Note that in the real implementation, the checksum unit is not necessarily added
numbers. For example, if the set of numbers is (7, 11, 12, 0, 6), we send (7, 11, at the end of the message; it can be inserted in the middle of the message.
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.

27 28

7
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

❑ Checksum (Contd.) ❑ 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 using one's complement
addition.
4. The sum is complemented and becomes the checksum.
5. The checksum is sent with the data.

Fig: Checksum

29 30

DATA COMMUNICATION DATA COMMUNICATION

❑ Internet Checksum (Contd.) ❑ Internet Checksum (Contd.)


The receiver uses the following steps for error detection.
For example, F is represented as Ox46 and 0 is represented as Ox6F. Figure
➢ Receiver site: 10.25 shows how the checksum is calculated at the sender and receiver sites. In
part a of the figure, the value of partial sum for the first column is Ox36. We keep
1. The message and the checksum are received.
the rightmost digit (6) and insert the leftmost dight (3) as the carry in the second
2. The message (including checksum) is divided into 16-bit words.
column.
3. All words are added using one's complement addition.
4. The sum is complemented and becomes the new checksum. The process is repeated for each column.
5. If the value of checksum is 0, the message is accepted; otherwise, it is
rejected.
Example. Let us calculate the checksum for a text of 8 characters ("Forouzan").
The text needs to be divided into 2-byte (l6-bit) words. We use ASCII (see
Appendix A) to change each byte to a 2-digit hexadecimal number.

31 32

8
11/20/2023

DATA COMMUNICATION DATA COMMUNICATION

❑ Internet Checksum (Contd.)


❑ Internet Checksum (Contd.)

Figure. Checksum
Algorithm to calculate a traditional checksum

33 34

COMPUTER ARCHITECTURE

Thanks
35

You might also like