Loading in 5 sec....

British Computer SocietyPowerPoint Presentation

British Computer Society

- By
**sukey** - Follow User

- 121 Views
- Uploaded on

Download Presentation
## PowerPoint Slideshow about ' British Computer Society' - sukey

**An Image/Link below is provided (as is) to download presentation**

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Error Detection & Correction

- Learning Objectives: By the end of the lesson, students will be able to:
- Explain the cause of errors on communication links
- Explain different mechanism to detect errors and correct the errors
- Explain the limitation of error correcting techniques
- Differentiate between actual data word and codeword , that is transmitted in communication channel

Error Detection & Correction

- Introduction:
- Data can be corrupted during transmission in the transmission media due to transmission impairments such as attenuation, distortion and noise
- For reliable communication, a mechanism for error detection and correction is required
- In audio or video data transmission, a small level of error may be tolerable, but digital data such as text is transmitted with a very high level of accuracy

Error Detection & Correction

- Type of Error
- Single Bit Error
- Burst Error

Error Detection & Correction

- Single-Bit Error:

Meaning of Single bit error

In a single-bit error, only one bit of a given data unit (such as a byte, character, or packet) is changed from 1 to 0 or from 0 to 1

Error Detection & Correction

- Example of Single –bit error:

Error Detection & Correction

- Burst Error:

Meaning of burst error

A burst error means that 2 or more bits in the data unit have changed from 1 to 0 or from 0 to1

Error Detection & Correction

- Error Detection
- Check if any error has occurred
- Don’t care the number of errors
- Don’t care the positions of errors

- Error Correction
- Need to know the number of errors
- Need to know the positions of errors
- More complex
- The number of errors and the size of the message are important factors in error correction

Error Detection & Correction

- Error Detection:
- Redundancy
- Parity check
- Cyclic redundancy check (CRC)
- Checksum
- Hamming Distance

Error Detection & Correction

Redundancy:

Redundancy

Error detection uses the concept of redundancy, which means adding extra bits for detecting errors at the destination.

Error Detection & Correction

Figure 1.1: The structure of encoder and decoder

Error Detection & Correction

- Redundancy is achieved through various coding schemes such as block coding or convolution coding
- 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
- The ratio of redundant bits to the data bits and the robustness of the process are important factors in any coding scheme
- The figure 1.1 above shows the general idea of coding

Error Detection & Correction

- Block Coding:
- In block coding, we divide 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
- With ‘k’ bits, we can create a combination of 2k datawords; with ‘n’ bits, we can create a combination of 2n codewords.

Error Detection & Correction

Figure 1.2 Datawords and codewords in block coding

Error Detection & Correction

- 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. This means that we have 2n – 2k codewords that are not used
- We call these codewords invalid or illegal
- The figure 1.2 shows the block coding scheme

Error Detection & Correction

- Error Detection:
- The receiver can detect a change in the original codeword if:
- The receiver has (or can find) a list of valid codewords
- The original codeword has changed to an invalid one

- The receiver can detect a change in the original codeword if:

Error Detection & Correction

Figure 1.3: Process of error detection in block coding

Error Detection & Correction

- Process of error detection in block coding:
- The sender creates codewords out of datawords by using a generator
- Each codeword sent to the receiver may change during transmission
- If the received codeword is the same as one of the valid codewords, the word is accepted; the corresponding dataword is extracted for use. If the received codeword is not valid, it is discarded.

Error Detection & Correction

- However, if the codeword is corrupted during transmission but the received word still matches a valid codeword, the error remains undetected.
- Block coding can detect only single errors. Two or more errors may remain undetected

Error Detection & Correction

Example 1.1:

Let us assume that k = 2 and n = 3. Table 1.1 shows the list of datawords and codewords. Later, we will see how to derive a codeword from a dataword.

Assume the sender encodes the dataword 01 as 011 and sends it to the receiver. Consider the following cases:

1. The receiver receives 011. It is a valid codeword. The receiver extracts the dataword 01 from it.

Error Detection & Correction

Table 1.1 A code for error detection (Example 1.1)

Error Detection & Correction

2. The codeword is corrupted during transmission, and 111 is received. This is not a valid codeword and is discarded.

3. The codeword is corrupted during transmission, and 000 is received. This is a valid codeword. The receiver incorrectly extracts the dataword 00. Two corrupted bits have made the error undetectable.

Error Detection & Correction

An error-detecting code can detect only the types of errors for which it is designed; other types of errors may remain undetected.

Error Detection & Correction

- Error Correction:
- Error correction is much more difficult than error detection
- In error detection, the receiver needs to know only that the received codeword is invalid; in error correction the receiver needs to find or guess the original codeword sent
- We need more redundant bits for error correction than for error detection
- Figure 1.4 shows the role of block coding in error correction. The concept is same as error detection but the checker functions are much more complex

Error Detection & Correction

Figure 1.4 Structure of encoder and decoder in error correction

Error Detection & Correction

Example 1.2

Let us add more redundant bits to Example 1.1 to see if the receiver can correct an error without knowing what was actually sent. We add 3 redundant bits to the 2-bit dataword to make 5-bit codewords. Table 1.2 shows the datawords and codewords. Assume the dataword is 01. The sender creates the codeword 01011. The codeword is corrupted during transmission, and 01001 is received. First, the receiver finds that the received codeword is not in the table. This means an error has occurred. The receiver, assuming that there is only 1 bit corrupted, uses the following strategy to guess the correct dataword.

Error Detection & Correction

Table 1.2 A code for error correction (Example 1.2)

Error Detection & Correction

1. Comparing the received codeword with the first codeword in the table (01001 versus 00000), the receiver decides that the first codeword is not the one that was sent because there are two different bits.

2. By the same reasoning, the original codeword cannot be the third or fourth one in the table.

3. The original codeword must be the second one in the table because this is the only one that differs from the received codeword by 1 bit. The receiver replaces 01001 with 01011 and consults the table to find the dataword 01.

Error Detection & Correction

- Simple Parity-Check Code:
- Simple parity check code is a linear block code.
- A linear block code is a code in which the exclusive OR of two valid codewords creates another valid codeword

Error Detection & Correction

- In simple parity check code, a k-bit dataword is changed to an n-nit codeword where n = k+1
- The extra bit, called a parity bit, is selected to make the total number of 1s in the codeword even case
- The minimum hamming distance for this category is
dmin = 2, which means that the code is a single bit error detecting code; it cannot correct any error

- A simple parity check code is a single bit error detecting code in which n = k+1 with d min = 2
- The code in table 1.3 is also a simple parity check code with k=4 and n=5

Error Detection & Correction

Table 1.3 Simple parity-check code C(5, 4)

Error Detection & Correction

Figure 1.5 Encoder and decoder for simple parity-check code

Error Detection & Correction

- The encoding and decoding for simple parity check is illustrated by figure 1.5
- The encoder uses a generator that takes a copy of a 4 bit dataword (a0, a1, a2 and a3) and generates a parity bit r0
- The dataword bits and the parity bit create the 5 bits codeword
- The parity bit that is added makes the number of 1s in the codeword even. This is done by adding the 4 bits of the dataword (modulo-2); the result is the parity. i.e.
r0 = a3 + a2 + a1 + a0 (modulo-2)

- If the number of 1s is even, the result is 0; if the number of 1s is odd, the result is 1

Error Detection & Correction

- 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 the syndrome, is just 1bits
- The syndrome is 0 when the number of 1s in the received codeword is even; otherwise, it is 1
s0 = b3 + b2 + b1 + b0 + q0 (modulo - 2)

- If the syndrome is 0, there is no 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

Error Detection & Correction

Example 1.3

Let us see if the two codes we defined in table 1.1 and Table 1.2 belong to the class of linear block codes.

1. The scheme in Table 1.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.

2. The scheme in Table 1.2 is also a linear block code. We can create all four codewords by XORing two other codewords.

Error Detection & Correction

Example 1.4

Let us look at some transmission scenarios. Assume the sender sends the dataword 1011. The codeword created from this dataword is 10111, which is sent to the receiver. We examine five cases:

1. No error occurs; the received codeword is 10111. Thesyndrome is 0. The dataword 1011 is created.

2. One single-bit error changes a1 . The received codeword is 10011. The syndrome is 1. No dataword is created.

3. One single-bit error changes r0 . The received codeword is 10110. The syndrome is 1. No dataword is created.

Error Detection & Correction

4. An error changes r0 and a second error changes a3 .The received codeword is 00110. The syndrome is 0. The dataword 0011 is created at the receiver. Note that here the dataword is wrongly created due to the syndrome value.

5. Three bits—a3, a2, and a1—are changed by errors.The received codeword is 01011. The syndrome is 1.The dataword is not created. This shows that the simple parity check, guaranteed to detect one single error, can also find any odd number of errors.

Error Detection & Correction

Example 1.5

Suppose the sender wants to send the word world. In ASCII the five characters are coded as

1110111 1101111 1110010 1101100 1100100

The following shows the actual bits sent

11101110 11011110 11100100 11011000 11001001

Error Detection & Correction

Example 1.6

Now suppose the word world in Example 1.5 is received by the receiver without being corrupted in transmission.

11101110 11011110 11100100 11011000 11001001

The receiver counts the 1s in each character and comes up with even numbers (6, 6, 4, 4, 4). The data are accepted.

Error Detection & Correction

Example 1.7

Now suppose the word world in Example 1.6 is corrupted during transmission.

11111110 11011110 11101100 11011000 11001001

The receiver counts the 1s in each character and comes up with even and odd numbers (7, 6, 5, 4, 4). The receiver knows that the data are corrupted, discards them, and asks for retransmission.

Error Detection & Correction

Note:

Simple parity check can detect all single-bit errors. It can detect burst errors only if the total number of errors in each data unit is odd.

Error Detection & Correction

- Cyclic Code:
- 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
- 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 bits in the second word b0 to b6 , we can shift the bits by suing the following:
b1 = a0 b2 = a1 b3 = a2 b4 = a3 b5 = a4 b6 = a5 b0 = a6

Error Detection & Correction

Table 1.4 A CRC code with C(7, 4)

Error Detection & Correction

Figure 1.6 CRC encoder and decoder

Error Detection & Correction

- Cyclic Redundancy Check:
- CRC Encoder:
- In the encoder, the dataword has k bits (figure 1.6 shows 4 bits); the codeword has n bits (7 here)
- The size of the dataword is augmented by adding n-k (3 here) 0s to the right-hand side of the word
- The n- bit result is fed into the generator. The generator uses a divisor of size n-k+1 (4 here), predefined value
- The generator divides the augmented codeword by the divisor using modulo – 2 arithmetic.

Error Detection & Correction

- Cyclic Redundancy Check:
- CRC Encoder:
- The quotient of the division is discarded and the remainder (r2 r1 r0) is appended to the dataword to create a codeword

- CRC Decoder:
- The decoder receives the possibly corrupted codeword. A copy of all n bits is fed to the checker which is a replica of the generator.

Error Detection & Correction

- Cyclic Redundancy Check:
- CRC Decoder:
- The remainder produced by the checker is a syndromes of (n-k) (3 here) bits, which is fed to the decision logic analyzer
- The analyzer has a simple function. If the syndrome bits are all 0s, the 4 leftmost bits of the codeword are accepted as the dataword (interpreted as no error); otherwise, the 4 bits are discarded (error)

Error Detection & Correction

Figure 1.7 Division in CRC encoder

Error Detection & Correction

Figure 1.8 Division in the CRC decoder for two cases

Error Detection & Correction

- Checksum:
- Checksum is one of the method used for error detection
- The checksum is used by the internet by several protocols although not at the data link layer
- Like linear and cyclic codes, the checksum is based on the concept of redundancy
- We introduce one’s complement arithmetic concept in checksum error detection process

Error Detection & Correction

- Example 1.5
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.

Error Detection & Correction

- Example 1.6:
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.

Error Detection & Correction

Example 1.7:

How can we represent the number 21 in one’s complement arithmetic using only four bits?

Solution:

The number 21 in binary is 10101 (it needs five bits). We can wrap the leftmost bit and add it to the four rightmost bits. We have (0101 + 1) = 0110 or 6.

Error Detection & Correction

Example 1.8:

How can we represent the number −6 in one’s complement arithmetic using only four bits?

Solution:

In one’s complement arithmetic, the negative or complement of a number is found by inverting all bits. Positive 6 is 0110; negative 6 is 1001. If we consider only unsigned numbers, this is 9. In other words, the complement of 6 is 9. Another way to find the complement of a number in one’s complement arithmetic is to subtract the number from 2n − 1 (16 − 1 in this case).

Error Detection & Correction

Note:

Sender site:

1. The message is divided into 16-bit words.

2. The value of the checksum word is set to 0.

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

Error Detection & Correction

Note:

Receiver site:

1.The message (including checksum) is divided into 16-bit words.

2. All words are added using one’s complement addition.

3. The sum is complemented and becomes the new checksum.

4. If the value of checksum is 0, the message is accepted; otherwise, it is rejected.

The Hamming distance between two words is the number of differences between corresponding bits.

The minimum Hamming distance is the smallest Hamming distance between all possible pairs in a set of words.

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

Error Detection & Correction Error Detection & Correction

Example 1.9:

Let us find the hamming distance between two pairs of word

1. The Hamming distance d(000, 011) is 2 because

2. The Hamming distance d(10101, 11110) is 3 because

Error Detection & Correction

Example 2.0:

Find the minimum Hamming distance of the coding scheme in the table below

Solution

We first find all Hamming distances.

The d min in this case is 2.

Error Detection & Correction

Example 2.1:

Find the minimum Hamming distance of the coding scheme in the table below

Solution

We first find all the Hamming distances.

The d min in this case is 3.

Error Detection & Correction

Minimum Hamming Distance for Error Detection

To guarantee the detection of up to s errors in all cases, the minimum Hamming distance in a block code must be d min = s + 1.

Error Detection & Correction

Example 2.2:

- The minimum Hamming distance for our first code scheme in the table above 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.

Error Detection & Correction

Example 2.3:

Table above has d min = 3. This code can detect up to two errors. When any of the valid codewords is sent, two errors create a codeword which is not in the table of valid codewords. The receiver cannot be fooled. However, some combination of three errors change a valid codeword to another valid codeword. The receiver accepts the received codeword and the errors are undetected

Error Detection & Correction

Geometric concept for finding d min in error detection:

Error Detection & Correction

Geometric concept for finding d min in error correction:

Error Detection & Correction

- Minimum Distance for Error Correction:
- To guarantee correction of up to t errors in all cases, the minimum Hamming distance in a block code must be dmin = 2t + 1.

Error Detection & Correction

Example 2.4:

A code scheme has a Hamming distance d min = 4. What is the error detection and correction capability of this scheme?

Solution

This code guarantees the detection of up to three errors(s = 3), but it can correct up to one error. In other words, if this code is used for error correction, part of its capability is wasted. Error correction codes need to have an odd minimum distance (3, 5, 7, . . . ).

Error Detection & Correction

- Hamming Codes:
- All Hamming code with dmin = 3 can detect up to two errors or correct one single error
- The relationship between n and k in a Hamming code for chosen integer m>=3 is calculated as
n = 2m – 1

k = n - m

- For example, if m = 3, then n = 7 and k = 4, this is a Hamming code C(7, 4), with dmin = 3

Error Detection & Correction

Table 1.5 Hamming code C(7, 4)

Error Detection & Correction

- Hamming Code Algorithm:
- The position of the parity bits are defined by the power of two to ease calculation of which bit was flipped upon detection of incorrect parity
- All bit positions that are powers of two are used as parity bits
- All other bit positions are for the data to be encoded. (Positions 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, etc.),
- Each parity bit calculates the parity for some of the bits in the code word. The position of the parity bit determines the sequence of bits that it alternately checks and skips.

Error Detection & Correction

- Position 1 (n=1): skip 0 bits (0=n−1), check 1 bit (n), skip 1 bit (n), check 1 bit (n), skip 1 bit (n), etc. (1,3,5,7,9,11,13,15,...)
- Position 2 (n=2): skip 1 bit (1=n−1), check 2 bits (n), skip 2 bits (n), check 2 bits (n), skip 2 bits (n), etc. (2,3,6,7,10,11,14,15,...)
- Position 4 (n=4): skip 3 bits (3=n−1), check 4 bits (n), skip 4 bits (n), check 4 bits (n), skip 4 bits (n), etc. (4,5,6,7,12,13,14,15,20,21,22,23,...)
- Position 8 (n=8): skip 7 bits (7=n−1), check 8 bits (n), skip 8 bits (n), check 8 bits (n), skip 8 bits (n), etc. (8-15,24-31,40-47,...)
- Position 16 (n=16): skip 15 bits (15=n−1), check 16 bits (n), skip 16 bits (n), check 16 bits (n), skip 16 bits (n), etc. (16-31,48-63,80-95,...)
- Position 32 (n=32): skip 31 bits (31=n−1), check 32 bits (n), skip 32 bits (n), check 32 bits (n), skip 32 bits (n), etc. (32-63,96-127,160-191,...)
- General rule for position n: skip n−1 bits, check n bits, skip n bits, check n bits...
- And so on.

Error Detection & Correction

This general rule can be shown visually:

Error Detection & Correction

Positions of redundancy bits in Hamming code

Error Detection & Correction

Redundancy bits calculation

Error Detection & Correction

Example of redundancy bit calculation

Error Detection & Correction

Error detection using Hamming code

Error Detection & Correction

Example 2.4

Let us trace the path of three datawords from the sender to the destination:

1. The dataword 0100 becomes the codeword 0100011. The codeword 0100011 is received. The syndrome is 000, the final dataword is 0100.

2. The dataword 0111 becomes the codeword 0111001. The syndrome is 011. After flipping b2 (changing the 1 to 0), the final dataword is 0111.

3. The dataword 1101 becomes the codeword 1101000. The syndrome is 101. After flipping b0, we get 0000, the wrong dataword. This shows that our code cannot correct two errors.

Error Detection & Correction

- References:
- Behrouz A. Forouzan, Data Communication and networking, Fourth Edition, McGraw Hill International Edition
- Stalling, William, Data and computer Communication, seventh Edition, Prentice Hall

Download Presentation

Connecting to Server..