SlideShare a Scribd company logo
1 of 103
Download to read offline
10.1
Chapter 10
Error Detection
and
Correction
Copyright Ā© The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
10.2
Position of the data-link layer
10.3
Data link layer duties
ā—¼ Packetizing: move data packets or frames from one hop to the next within the
same LAN or WAN
ā—¼ Addressing: uses physical addresses (MAC Addresses) that are assigned for
and used to find the next hop in the hop-to-hop delivery
ā—¼ Error Control: uses error detection and correction to reduce the severity of
error occurrence
ā—¼ Flow Control: controls how much data a sender can transmit before it must
wait for an acknowledgement from the receiver in order not to overwhelm it
ā—¼ Medium Access Control (MAC): controls how the nodes should access a
shared media in a way to prevent packet collisions
10.4
Data can be corrupted
during transmission.
Some applications require that
errors be detected and corrected.
Note
10.5
10-1 INTRODUCTION
Let us first discuss some issues related, directly or
indirectly, to error detection and correction.
ā€¢ Types of Errors
ā€¢ Redundancy
ā€¢ Detection Versus Correction
ā€¢ Forward Error Correction Versus Retransmission
ā€¢ Coding
ā€¢ Modular Arithmetic
Topics discussed in this section:
10.6
In a single-bit error, only 1 bit in the data
unit has changed.
Note
10.7
Figure 10.1 Single-bit error
10.8
A burst error means that 2 or more bits
in the data unit have changed.
Note
10.9
Figure 10.2 Burst error of length 8
ā—¼ The length of the burst is measured from the 1st to the last corrupted bits
ā—¼ The burst error doesnā€™t necessarily mean that errors occur in consecutive bits
ā—¼ Burst errors are most likely to occur in serial transmission
ā—¼ The noise duration is usually longer than the duration of one bit
ā—¼ The severity of burst errors are dependent on the data rate & the noise duration
ā—¼ For example: a noise duration of 0.01 sec would corrupt 10 bits of a 1Kbps
transmission and 10,000 bits of a 1Mbps source
10.10
Error Detection & Correction Concepts
ā—¼ Error detection: find out whether an errors has occurred
ā—¼ Error correction: find the exact number of corrupted bits
and their exact location within the message
ā—¼ Error detection is the first step towards error correction
ā—¼ Error detection and correction use the concept of
redundancy, which is adding extra bits to the data unit
ā—¼ The extra bits carry information about the data unit that
help find out whether any change may have happened to
the data unit at the receiver side
ā—¼ The extra bits are discarded as soon as the accuracy of
the transmission has been determined
10.11
To detect or correct errors, we need to
send extra (redundant) bits with data.
Note
10.12
Forward Error Correction vs. Retransmission
ā—¼ Error correction by retransmission
ā—¼ If error is detected, the sender is asked to retransmit
ā—¼ Forward Error Correction (FEC):
ā—¼ The receiver uses an error correcting code, which automatically
corrects certain types of errors
ā—¼ Theoretically, any error can be automatically corrected
ā—¼ Error correction is harder than error detection and needs more
redundant bits
ā—¼ The secret of error correction is to locate the invalid bits
ā—¼ To locate a single-bit error in a data unit, you need enough
redundant bits to cover all states of change in the data bits as
well as the redundant bits and the no-change case
10.13
Coding
ā—¼ Redundancy is achieved via coding schemes as follows:
ā—¼ Sender adds extra bits to the data bits based on a certain relationship (e.g.
CRC circuit)
ā—¼ Receiver checks the relationship in order to detect and/or correct errors
ā—¼ Two factors of coding schemes to observe:
ā—¼ The ratio of the redundant (r) bits to the data bits (d)ā†’ (r/d)
ā—¼ The robustness of the whole process (does not give false info)
ā—¼ Categories of coding schemes:
1. Block coding ( we cover it in this chapter)
2. Convolution coding (not covered here)
10.14
Modular Arithmetic (X mod-N)
ā—¼ Use a limited number of integers
ā—¼ Define an upper limit called modulus, N
ā—¼ Use only the integers from 0 to N-1, inclusive
ā—¼ This is called modulo-N arithmetic
ā—¼ If a number is greater than N, it is divided by N and
the remainder is the result
ā—¼ If a number is negative, add as many Nā€™s as needed to
make it positive
ā—¼ There is no carry out when numbers are added or
subtracted
ā—¼ In modulo-2 arithmetic, the addition and subtraction
are similar and are performed using the bit-wise XOR
function
10.15
Figure 10.4 XORing of two single bits or two words
10.16
10-2 BLOCK CODING
In block coding,
ā€¢ we divide our message into blocks, each of k bits,
called datawords.
ā€¢ Then, we add r redundant bits to each block to
make the length n:
ā€¢ n = k + r. The resulting n-bit blocks are called
codewords.
ā€¢ Error Detection
ā€¢ Error Correction
ā€¢ Hamming Distance
ā€¢ Minimum Hamming Distance
Topics discussed in this section:
k: dataword;
r: redundant bits
n: codeword
10.17
Figure 10.5 Datawords and codewords in block coding
10.18
The 4B/5B block coding discussed in Chapter 4 is a good
example of this type of coding.
In this coding scheme, k = 4 and n = 5,
ā€¢ No. of datawords=2k = 16
ā€¢ No. of codewords= 2n = 32.
We saw that 16 out of 32 codewords are used for message
transfer and the rest are either used for other purposes or unused.
Example 10.1
10.19
Figure 10.6 Process of error detection in block coding
e.g. X2+X+1
10.20
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.
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.
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.
Example 10.2
Table 10.1 A code for error detection (Example 10.2)
10.21
ā€¢ An error-detecting code can detect
only the types of errors for which it is
designed;
ā€¢ other types of errors may remain
undetected.
Note
10.22
Figure 10.6 Process of error detection in block coding
e.g. X2+X+1
10.23
ā€¢ Let us add more redundant bits to Example 10.2 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 10.2 shows the datawords and codewords.
ā€¢ So, k=2, r=3,ā†’n=2+3=5 bits
Example 10.3
10.24
ā€¢ Assume the dataword is d= 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.
Example 10.3
10.25
ā—¼ Codeword sent = 01011, Codeword received = 01001
ā—¼ 01001 vs. 00000 āž” 2 bit difference ļŒ
ā—¼ 01001 vs. 10101 āž” 3 bit difference ļŒ
ā—¼ 01001 vs. 11110 āž” 4 bit difference ļŒ
ā—¼ 01001 vs. 01011 āž” 1 bit difference ā˜ŗ
1. The receiver will compare received code word with all the valid
codewords looking number of difference in bits.
2. It will choose the least difference
Compare 01001
with all
codewords
difference=
Hamming
distance
10.26
The Hamming distance between two
words is the number of differences
between the corresponding bits.
Note
d=Hamming
distance
10.27
Let us find the Hamming distance between two pairs of
words.
1. The Hamming distance d(000, 011) is 2 because
Example 10.4
2. The Hamming distance d(10101, 11110) is 3 because
d=Hamming
distance
10.28
The minimum Hamming distance (dmin) is
the smallest Hamming distance between
all possible pairs in a set of words.
Note
10.29
Find the minimum Hamming distance of the coding
scheme in Table 10.1.
Solution
We first find all Hamming distances.
Example 10.5
The dmin in this case is 2.
10.30
Find the minimum Hamming distance of the coding
scheme in Table 10.2.
Solution
We first find all the Hamming distances.
The dmin in this case is 3.
Example 10.6
10.31
To guarantee the detection of up to s
errors in all cases, the minimum
Hamming distance in a block
code must be dmin = s + 1.
Note
10.32
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.
ā€¢ e.g. send 101ā†’received 111 (detected ā†’because not a valid
code),
ā€¢ If two errors occur, however, the received codeword may match a
valid codeword and the errors are not detected.
ā†’e.g: send 101ā†’received 000 (considered validā†’ not detetcted)
Example 10.7
dmin = s + 1.
s=1
10.33
Our second block code scheme (Table 10.2) has dmin = 3. This code
can detect up to two errors. Again, we see that 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 combinations of three errors change a valid
codeword to another valid codeword. The receiver accepts the
received codeword and the errors are undetected.
Example 10.8
dmin = s + 1.
s=2
10.34
To guarantee correction of up to t errors
in all cases, the minimum Hamming
distance in a block code
must be dmin = 2t + 1.
Note
10.35
A code scheme has a Hamming distance dmin = 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, . . . ).
Example 10.9
dmin = s + 1.
s=3
dmin = 2t + 1.
t=?
10.36
10-3 LINEAR BLOCK CODES
ā€¢ Almost all block codes used today belong to a
subset called linear block codes.
ā€¢ A linear block code is a code in which the
exclusive OR (addition modulo-2) of two valid
codewords creates another valid codeword.
ā€¢ Codeword1 (xor) codeword2āž”codeword3
1. Minimum Distance for Linear Block Code
2. Example of Linear Block Codes
Topics discussed in this section:
10.37
In a linear block code, the exclusive OR
(XOR) of any two valid codewords
creates another valid codeword.
Note
10.38
1. The scheme 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.
ā€¢ 101 + 011 = 110 (cod #4 in the table)
2. The scheme in Table 10.2 is also a linear block code. We can
create all four codewords by XORing two other codewords.
Example 10.10
10.39
Note: The minimum Hamming distance for a linear block code is the
smallest number of 1ā€™s in the nonzero codewords
In (Table 10.1), the numbers of 1s in the nonzero codewords are 2, 2,
and 2. So the minimum Hamming distance is dmin = 2.
In (Table 10.2), the numbers of 1s in the nonzero codewords are 3, 3,
and 4. So in this code we have dmin = 3.
Example 10.11
10.40
A simple parity-check code is a single-bit
error-detecting code in which n = k + 1
with dmin = 2.
ā†’i.e. #. of r bits= 1 bit extra
ā†’ Even parityā†’ add 1ā€™s so total numbers of 1ā€™s is even
parity-check code
10.41
Table 10.3 Simple even parity-check code C(5, 4) parity bit
10.42
Figure 10.10 Encoder and decoder for simple parity-check code
10.43
How it works?
To send (a3 a2 a1 a0 : 1011)ā†’ p=1ā†’codeword = (a3 a2 a1 a0 r0 10111)-----> sent to
the receiver. We examine five cases:
1. No error occurs;
ā†’the received codeword is (b3 b2 b1 b0 q0: 10111. ā†’syndrome S= 0 (no
error) ā†’extracted dataword 1011.
2. One error a1 is changed.
ā†’ received codeword is 10011 ā†’ S= 1 (error)ā†’ discard data.
3. One error: r0 is changed:
ā†’received codeword is 10110ā†’S=1 (error)ā†’ discard data.
4. Two errors: r0 & a3 are changed:
ā†’received codeword is 00110ā†’ S=0 (no error: false!) ā†’ dataword 0011 is
created at the receiver.
ā†’Note that here the dataword is wrongly created due to the syndrome
value.
5. Three errors: a3, a2, a1 are changed ā†’The received codeword is 01011.
ā†’S=1 (error) ā†’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.
Example 10.12
10.44
A simple parity-check code can detect
an odd number of errors.
Note
10.45
Figure 10.11 Two-dimensional parity-check code
ā—¼ Data words are organized in a table (rows & columns)
ā—¼ For each row and each column, a parity-check bit is
added
Parity bits
10.46
Figure 10.11 Two-dimensional parity-check code
Original
data
10.47
Performance of the Two-Dimensional
Parity Check
Two-Dimensional Parity Check can do the following
ā—¼ Guarantee to detect single error
ā—¼ Increases the likelihood of detecting burst errors
ā—¼ It fails if the error bits are in exactly the same positions
in two different data units
ā†’because the changes will cancel each other in this case
10.48
The Hamming Error Correction Codes
Hamming codes can be used in Error Detection and correction
ā—¼ The category of Hamming codes discussed here is with
dmin= 3:
ā†’2-bit detection & 1-bit correction
ā—¼ We need to choose an integer mā‰„3 such that:
ā—¼ n=2m-1 & k=n-m (i.e. n=k+m)
ā—¼ The number of check bits r=m
ā—¼ For example:
ā—¼ If m=3, then n=7 & k=4
ā—¼ This is Hamming Code C(7,4) with dmin= 3
ā—¼ Each code word = a3 a2 a1 a0 r2 r1 r0
10.49
Table 10.4 Hamming code C(7, 4)
10.50
Figure 10.12 The structure of the encoder and decoder for a Hamming code
generator creates 3-bit even-parity check
ā—¼ r0 = a2 + a1 + a0 (modulo-2)
ā—¼ r1 = a3 + a2 + a1 (modulo-2)
ā—¼ r2 = a1 + a0 + a3 (modulo-2)
checker creates 3-bit syndrome
ā—¼ s0 = b2 + b1 + b0 + q0 (modulo-2)
ā—¼ s1 = b3 + b2 + b1 + q1 (modulo-2)
ā—¼ s2 = b1 + b0 + b3 + q2 (modulo-2)
10.51
Table 10.5 Logical decision made by the correction logic analyzer
ā—¼ The 3-bit syndrome represent 1 out 8 different error conditions
as shown in the table
ā—¼ The decoder is only concerned with the conditions in the table
that are not shaded (i.e. data:b3b2b1b0), in which a data bit has
been flipped
s2 s1 s0
s2 s1 s0 =001ā†’q0
q0 in 1st equation
s2 s1 s0 =111ā†’b1
b1 in all equations
10.52
Let us check some cases:
1. No error: d=dataword 0100 ā†’ c=codeword= 0100011.
ā†’received: b=0100011. S=000 (no error)ā†’ dataword = 0100.
2. One error: d=0111 ā†’ c=0111001
ā†’received b=0011001, S=011 (error in b2)ā†’correct(flip b2)
ā†’the final dataword is 0111 (correct).
3. Two errors: d=1101ā†’ c= 1101000.
ā†’received b= 0001000, S=101 (error b0), correct(flip b0)
ā†’the final dataword is 0000 (false data)
ā†’This shows that our code detects 2 errors, but cannot correct
Example 10.13
10.53
We need a dataword of at least k>=7 bits. Calculate values
of k and n that satisfy this requirement.
Solution
We need to make k = n āˆ’ m >=7, or (2m āˆ’ 1) āˆ’ m ā‰„ 7.
1. If we set m = 3, ā†’n = 23 āˆ’ 1, and k = 7 āˆ’ 3=4, which is
not acceptable.
2. If we set m = 4,ā†’n = 24 āˆ’ 1 = 15 and k = 15 āˆ’ 4 = 11,
which satisfies the condition. So the code is
Example 10.14
C(15, 11)
C(n, k)
10.54
Performance of the Hamming Code
ā—¼ It can detect a 2-bit error
ā—¼ It can correct a 1-bit error
ā—¼ It can be modified in order to detect burst
errors of size N:
ā—¼ It is based on splitting the burst error between N
codewords
ā—¼ Convert the frame into N codewords
ā—¼ Rearrange the codewords in the frame from row-wise
to column-wise (see the example)
10.55
Figure 10.13 Burst error correction using Hamming code
10.56
10-4 CYCLIC CODES
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.
ā€¢ Cyclic Redundancy Check (CRC)
ā€¢ Hardware Implementation
ā€¢ Polynomials
ā€¢ Cyclic Code Analysis
ā€¢ Advantages of Cyclic Codes
ā€¢ Other Cyclic Codes
Topics discussed in this section:
10.57
Table 10.6 A CRC (Cyclic Redundancy Check) code with C(7, 4)
10.58
Figure 10.14 CRC encoder and decoder
10.59
Figure 10.14 CRC encoder and decoder
10.60
Cyclic Redundancy Check (CRC)
ā—¼ At the encoder of the sender:
ā—¼ The k-bit dataword is augmented by
appending (n-k) zeros to the right
hand side of it
ā—¼ The n-bit result is fed into the
generator
ā—¼ The generator uses an agreed-upon
divisor (checker) of size (n-k+1)
ā—¼ The generator divides the
augmented dataword by the divisor
using modulo-2 division
ā—¼ The quotient of the division is
discarded
ā—¼ The remainder is appended to the
dataword to create the codeword
10.61
Cyclic Redundancy Check (CRC)
ā—¼ At the decoder of the receiver:
ā—¼ The received codeword is divided by the same divisor to create the
syndrome, which has a size of (n-k) bits
ā—¼ If all the syndrome bits are zeros, then no error is detected
ā—¼ Otherwise, an error is detected and the received dataword is
discarded
10.62
Figure 10.21 A polynomial to represent a binary word
ā—¼ The 1ā€™s and 0ā€™s represent the coefficients of the polynomial
ā—¼ The power of each term represents the position of the bit
ā—¼ The degree of the polynomial is the highest power of it
ā—¼ Adding and subtracting the polynomials are done by adding
and subtracting the coefficients of the same-power terms
10.63
10.64
10.65
Figure 10.22 CRC division using polynomials
10.66
The divisor in a cyclic code is normally
called the generator polynomial
or simply the generator.
Note
10.67
10.68
Figure 10.15 Division in CRC encoder
sender
10.69
Figure 10.16 Division in the CRC decoder for two cases
receiver
10.70
examples
10.71
examples
10.72
Cyclic Code Analysis
ā—¼ Define the following cyclic code parameters as
polynomials:
ā—¼ Dataword: d(x)
ā—¼ Codeword: c(x)
ā—¼ Generator: g(x)
ā—¼ Syndrome: s(x)
ā—¼ Error: e(x)
ā—¼ Received codeword = c(x) + e(x)
ā—¼ Received codeword/g(x) = c(x)/g(x) + e(x)/g(x)
ā—¼ c(x)/g(x) does not have a remainder by definition
ā—¼ s(x) is the remainder of e(x)/g(x)
ā—¼ If s(x)ā‰ 0, then an error is detected
ā—¼ If s(x)=0, then either no error has occurred or the error has not
been detected
ā—¼ If e(x) is divisible by g(x), then e(x) canā€™t be detected
10.73
In a cyclic code,
If s(x) ā‰  0, one or more bits is corrupted.
If s(x) = 0, either
a. No bit is corrupted. or
b. Some bits are corrupted, but the
decoder failed to detect them.
Note
10.74
In a cyclic code, those e(x) errors that
are divisible by g(x) are not caught.
Note
10.75
Single-Bit Error
ā—¼ A single-bit error is e(x)=xi, where i is the
position of the bit
ā—¼ If a single-bit error is caught, then xi is not
divisible by g(x) (i.e.; there is a
remainder)
ā—¼ If g(x) has, at least, two terms and the
coefficient of x0 is not zero, then e(x) canā€™t
be divided by g(x). That is, all single-bit
errors will be caught
10.76
If the generator has more than one term
and the coefficient of x0 is 1,
all single errors can be caught.
Note
10.77
Which of the following g(x) values guarantees that a
single-bit error is caught? For each case, what is the error
that cannot be caught?
a. x + 1 b. x3 c. 1
Solution
a. No xi can be divisible by x + 1. Any single-bit error can
be caught.
b. If i is equal to or greater than 3, xi is divisible by g(x).
All single-bit errors in positions 1 to 3 are caught.
c. All values of i make xi divisible by g(x). No single-bit
error can be caught. This g(x) is useless.
Example 10.15
10.78
Figure 10.23 Representation of two isolated single-bit errors using polynomials
ā—¼ Two isolated single-bit errors are represented as
ā—¼ e(x)= xj + xi = xi (xj-i + 1) = xi (xt + 1)
ā—¼ If g(x) has, at least, two terms and the coefficient of x0 is
not zero, then xi canā€™t be divided by g(x)
ā—¼ Therefore, if g(x) is to detect e(x), it must not divide (xt + 1)
where t is the distance between the two error bits and t
should be between 2 and n-1 (n is the degree of g(x))
10.79
If a generator cannot divide xt + 1
(t between 2 and n ā€“ 1),
then all isolated double errors
can be detected.
Note
10.80
Find the status of the following generators related to two
isolated, single-bit errors.
a. x + 1 b. x4 + 1 c. x7 + x6 + 1 d. x15 + x14 + 1
Solution
a. This is a very poor choice for a generator. Any two
errors next to each other cannot be detected.
b. This generator cannot detect two errors that are four
positions apart.
c. This is a good choice for this purpose.
d. This polynomial cannot divide (xt + 1) if t is less than
32,768]
15. A codeword with two isolated errors up to
32,768 15 bits apart can be detected by this generator.
Example 10.16
10.81
A generator that contains a factor of
(x + 1) can detect all odd-numbered
errors.
Note
10.82
ā All burst errors with L ā‰¤ r will be
detected. (r is the degree of g(x))
ā All burst errors with L = r + 1 will be
detected with probability 1 ā€“ (1/2)rā€“1.
ā All burst errors with L > r + 1 will be
detected with probability 1 ā€“ (1/2)r.
Note
10.83
Find the suitability of the following generators in relation
to burst errors of different lengths.
a. x6 + 1 b. x18 + x7 + x + 1 c. x32 + x23 + x7 + 1
Solution
a. This generator can detect all burst errors with a length
less than or equal to 6 bits;
3 out of 100 burst errors with length 7 will slip by;
1 ā€“ (1/2)6ā€“1 = 1 - 1/32 = 0.97
16 out of 1000 burst errors of length 8 or more will slip by. 1 ā€“
(1/2)6 = 1 ā€“ 1/64 = 0.984
Example 10.17
10.84
b. This generator can detect all burst errors with a length
less than or equal to 18 bits;
8 out of 1 million burst errors with length 19 will slip by;
4 out of 1 million burst errors of length 20 or more will
slip by.
c. This generator can detect all burst errors with a length
less than or equal to 32 bits;
5 out of 10 billion burst errors with length 33 will slip by;
3 out of 10 billion burst errors of length 34 or more will
slip by.
Example 10.17 (continued) Reading
only
10.85
A good polynomial generator needs to
have the following characteristics:
1. It should have at least two terms.
2. The coefficient of the term x0 should
be 1.
3. It should not divide xt + 1, for t
between 2 and n āˆ’ 1.
4. It should have the factor x + 1.
Note
10.86
Performance of Cyclic Codes
ā—¼ Detect single-bit errors
ā—¼ Detect double-bit isolated errors
ā—¼ Detect odd number of errors
ā—¼ Detect burst errors of length less than or
equal to the degree of the generator
ā—¼ Detect, with a very high probability, burst
errors of length greater than the degree of
the generator
ā—¼ Can be implemented in either SW or HW
10.87
Table 10.7 Standard polynomials
10.88
10-5 CHECKSUM
ā€¢ The last error detection method we discuss here is
called the checksum.
ā€¢ The checksum is used in the Internet by several
protocols although
ā€¢ not used at the data link layer.
ā€¢ we briefly discuss it .
ā€¢ Idea
ā€¢ Oneā€™s Complement
ā€¢ Internet Checksum
Topics discussed in this section:
10.89
Examples : protocols uses CheckSum:
UDP & TCP
TCP
UDP
10.90
The concept of check sum as follows:
ā€¢ 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.
ā€¢ Send : We want to sedn : (7, 11, 12, 0, 6),
ā†’send (7, 11, 12, 0, 6, -36),
note : -36= -Sum (7, 11, 12, 0, 6), . T
ā€¢ The receiver adds (7, 11, 12, 0, 6, -36)=result,
ā†’ If result=0, No errorā†’ accept data
ā†’ else if result ā‰  0 ā†’ error occurs
ā†’data are not accepted.
Example 10.18: Concept
10.91
If we we use 4-bit numbers, 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.
Example 10.20
10.92
How can we represent the number āˆ’6 in oneā€™s
complement arithmetic using only four bits?
Solution
ā€¢ oneā€™s complement (x)= inverting all bits(x).
ā€¢ 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 n=4).
Example 10.21
Checksum = INV (data 1 āŠ• data 2 āŠ• ... āŠ• data n)
10.93
0 1 1 0 6
1 0 0 1 9
1 1 1 1 15
0 0 0 0 0
Figure 10.24 Example 10.22
10.94
1ā€™s complement example:
10.95
10.96
The Internet Checksum
ā—¼ The checksum generator subdivides the data unit into
equal-length data units of 16-bit each
ā—¼ The data units are added using the 1ā€™s complement
arithmetic such that the total is always n-bit long
ā—¼ The data units are binary added normally to give the partial sum
ā—¼ The outer carry out is added to the partial sum to give the sum
ā—¼ The result is 1ā€™s complemented to give the checksum
ā—¼ The checksum is appended to the data unit
ā—¼ The checksum checker performs the same operation
including the checksum:
ā—¼ If the result is zero, then the data unit has not been altered
10.97
Sender site: (Internet Checksum)
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.
Note
10.98
Receiver site: (Internet Checksum)
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.
Note
10.99
C+1=Dā€”>
D+1=Eā†’
E+C (mod 16) =Aā†’
A+5=Fā†’
F+6 (mod 16)ā†’5
5+9=E
1sr column
addition
10.100
10.101
āœ“ Let us calculate the checksum for a text of 8 characters
(ā€œForouzanā€).
āœ“ The text needs to be divided into 2-byte (16-bit) words. We use
ASCII (see Appendix A) to change each byte to a 2-digit
hexadecimal number.
āœ“ E.g. F = 0x46 ASCII, o= 0x6F.
āœ“ Figure 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 0x36.
āœ“ We keep the rightmost digit (6) and insert the leftmost digit (3) as
the carry in the second column.
āœ“ The process is repeated for each column.
Example 10.23
10.102
Figure 10.25 Example 10.23
F F F F
F F
10.103
Performance of the Checksum
ā—¼ Detect all odd number of errors
ā—¼ Detect most even number of errors
ā—¼ If corresponding bits in different data units of
opposite values are affected, the error will not
be detected
ā—¼ Generally weaker than the CRC

More Related Content

Similar to Computer Networks/Computer Engineering.pdf

4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdfkenilpatel65
Ā 
Error_Detection_and_correction.ppt
Error_Detection_and_correction.pptError_Detection_and_correction.ppt
Error_Detection_and_correction.pptKashfUlHuda1
Ā 
DCN Slides ch10 Error Detection and Correction.ppt
DCN Slides ch10 Error Detection and Correction.pptDCN Slides ch10 Error Detection and Correction.ppt
DCN Slides ch10 Error Detection and Correction.pptBilal Munir Mughal
Ā 
Error Detection and Correction
Error Detection and CorrectionError Detection and Correction
Error Detection and CorrectionTechiNerd
Ā 
ch10.ppt
ch10.pptch10.ppt
ch10.pptSibiSanta
Ā 
Error Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networksError Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networksNt Arvind
Ā 
5(1)crc-chechsum-hamming.ppt
5(1)crc-chechsum-hamming.ppt5(1)crc-chechsum-hamming.ppt
5(1)crc-chechsum-hamming.pptprashant513130
Ā 
hamming code detailed
hamming code detailedhamming code detailed
hamming code detailedIKhait
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.pptdlakmlkfma
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.pptdlakmlkfma
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.pptdlakmlkfma
Ā 
Data Communication And Networking - ERROR DETECTION AND CORRECTION
Data Communication And Networking - ERROR DETECTION AND CORRECTIONData Communication And Networking - ERROR DETECTION AND CORRECTION
Data Communication And Networking - ERROR DETECTION AND CORRECTIONAvijeet Negel
Ā 

Similar to Computer Networks/Computer Engineering.pdf (20)

Ch10
Ch10Ch10
Ch10
Ā 
4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf4_Datalink__Error_Detection_and Correction.pdf
4_Datalink__Error_Detection_and Correction.pdf
Ā 
LECTURE-10 (Data Communication) ~www.fida.com.bd
LECTURE-10 (Data Communication) ~www.fida.com.bdLECTURE-10 (Data Communication) ~www.fida.com.bd
LECTURE-10 (Data Communication) ~www.fida.com.bd
Ā 
Error_Detection_and_correction.ppt
Error_Detection_and_correction.pptError_Detection_and_correction.ppt
Error_Detection_and_correction.ppt
Ā 
DCN Slides ch10 Error Detection and Correction.ppt
DCN Slides ch10 Error Detection and Correction.pptDCN Slides ch10 Error Detection and Correction.ppt
DCN Slides ch10 Error Detection and Correction.ppt
Ā 
Error Detection and Correction
Error Detection and CorrectionError Detection and Correction
Error Detection and Correction
Ā 
ch10.ppt
ch10.pptch10.ppt
ch10.ppt
Ā 
Ch10 2 v1
Ch10 2 v1Ch10 2 v1
Ch10 2 v1
Ā 
ch10.pdf
ch10.pdfch10.pdf
ch10.pdf
Ā 
Error Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networksError Detection and correction concepts in Data communication and networks
Error Detection and correction concepts in Data communication and networks
Ā 
5(1)crc-chechsum-hamming.ppt
5(1)crc-chechsum-hamming.ppt5(1)crc-chechsum-hamming.ppt
5(1)crc-chechsum-hamming.ppt
Ā 
hamming code detailed
hamming code detailedhamming code detailed
hamming code detailed
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.ppt
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.ppt
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.ppt
Ā 
ch10_2_v1.ppt
ch10_2_v1.pptch10_2_v1.ppt
ch10_2_v1.ppt
Ā 
Ch10 2 v1
Ch10 2 v1Ch10 2 v1
Ch10 2 v1
Ā 
Ch10 1 v1
Ch10 1 v1Ch10 1 v1
Ch10 1 v1
Ā 
Data Communication And Networking - ERROR DETECTION AND CORRECTION
Data Communication And Networking - ERROR DETECTION AND CORRECTIONData Communication And Networking - ERROR DETECTION AND CORRECTION
Data Communication And Networking - ERROR DETECTION AND CORRECTION
Ā 
Ch10 1 v1
Ch10 1 v1Ch10 1 v1
Ch10 1 v1
Ā 

More from abdnazar2003

laplace transform 2 .pdf
laplace transform 2                  .pdflaplace transform 2                  .pdf
laplace transform 2 .pdfabdnazar2003
Ā 
laplace transform 1 .pdf
laplace transform 1                 .pdflaplace transform 1                 .pdf
laplace transform 1 .pdfabdnazar2003
Ā 
Lecture 4 .pdf
Lecture 4                              .pdfLecture 4                              .pdf
Lecture 4 .pdfabdnazar2003
Ā 
Lecture 3 .pdf
Lecture   3                         .pdfLecture   3                         .pdf
Lecture 3 .pdfabdnazar2003
Ā 
Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptxabdnazar2003
Ā 
Lecture 2 .pdf
Lecture 2                           .pdfLecture 2                           .pdf
Lecture 2 .pdfabdnazar2003
Ā 
Lecture 1 .pptx
Lecture 1                            .pptxLecture 1                            .pptx
Lecture 1 .pptxabdnazar2003
Ā 
C. N. II Lec.4.pdf h
C. N. II Lec.4.pdf                      hC. N. II Lec.4.pdf                      h
C. N. II Lec.4.pdf habdnazar2003
Ā 
Lecture 2 Connecting LANs, Backbone Networks, and Virtual LANs.ppt
Lecture 2   Connecting LANs, Backbone Networks, and Virtual LANs.pptLecture 2   Connecting LANs, Backbone Networks, and Virtual LANs.ppt
Lecture 2 Connecting LANs, Backbone Networks, and Virtual LANs.pptabdnazar2003
Ā 
Forouzan6e_ch06_PPTs_Accessible 2024.pptx
Forouzan6e_ch06_PPTs_Accessible 2024.pptxForouzan6e_ch06_PPTs_Accessible 2024.pptx
Forouzan6e_ch06_PPTs_Accessible 2024.pptxabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfabdnazar2003
Ā 

More from abdnazar2003 (20)

laplace transform 2 .pdf
laplace transform 2                  .pdflaplace transform 2                  .pdf
laplace transform 2 .pdf
Ā 
laplace transform 1 .pdf
laplace transform 1                 .pdflaplace transform 1                 .pdf
laplace transform 1 .pdf
Ā 
Lecture 4 .pdf
Lecture 4                              .pdfLecture 4                              .pdf
Lecture 4 .pdf
Ā 
Lecture 3 .pdf
Lecture   3                         .pdfLecture   3                         .pdf
Lecture 3 .pdf
Ā 
Lecture 2 .pptx
Lecture 2                            .pptxLecture 2                            .pptx
Lecture 2 .pptx
Ā 
Lecture 2 .pdf
Lecture 2                           .pdfLecture 2                           .pdf
Lecture 2 .pdf
Ā 
Lecture 1 .pptx
Lecture 1                            .pptxLecture 1                            .pptx
Lecture 1 .pptx
Ā 
LEC3 t.pdf
LEC3                               t.pdfLEC3                               t.pdf
LEC3 t.pdf
Ā 
LEC2 j.pdf
LEC2                               j.pdfLEC2                               j.pdf
LEC2 j.pdf
Ā 
LEC1 h.pdf
LEC1                               h.pdfLEC1                               h.pdf
LEC1 h.pdf
Ā 
C. N. II Lec.4.pdf h
C. N. II Lec.4.pdf                      hC. N. II Lec.4.pdf                      h
C. N. II Lec.4.pdf h
Ā 
Lecture 2 Connecting LANs, Backbone Networks, and Virtual LANs.ppt
Lecture 2   Connecting LANs, Backbone Networks, and Virtual LANs.pptLecture 2   Connecting LANs, Backbone Networks, and Virtual LANs.ppt
Lecture 2 Connecting LANs, Backbone Networks, and Virtual LANs.ppt
Ā 
Forouzan6e_ch06_PPTs_Accessible 2024.pptx
Forouzan6e_ch06_PPTs_Accessible 2024.pptxForouzan6e_ch06_PPTs_Accessible 2024.pptx
Forouzan6e_ch06_PPTs_Accessible 2024.pptx
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 
Computer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdfComputer Networks/Computer Engineering.pdf
Computer Networks/Computer Engineering.pdf
Ā 

Recently uploaded

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
Ā 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
Ā 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
Ā 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
Ā 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
Ā 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
Ā 
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerAnamika Sarkar
Ā 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
Ā 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
Ā 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
Ā 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
Ā 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
Ā 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
Ā 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
Ā 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
Ā 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
Ā 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
Ā 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
Ā 

Recently uploaded (20)

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
Ā 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
Ā 
young call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Serviceyoung call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Service
young call girls in Rajiv ChowkšŸ” 9953056974 šŸ” Delhi escort Service
Ā 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
Ā 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
Ā 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
Ā 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
Ā 
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned ļ»æTube Exchanger
Ā 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
Ā 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
Ā 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
Ā 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
Ā 
ā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
ā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCRā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
ā˜… CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
Ā 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
Ā 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
Ā 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
Ā 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
Ā 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
Ā 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
Ā 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
Ā 

Computer Networks/Computer Engineering.pdf

  • 1. 10.1 Chapter 10 Error Detection and Correction Copyright Ā© The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
  • 2. 10.2 Position of the data-link layer
  • 3. 10.3 Data link layer duties ā—¼ Packetizing: move data packets or frames from one hop to the next within the same LAN or WAN ā—¼ Addressing: uses physical addresses (MAC Addresses) that are assigned for and used to find the next hop in the hop-to-hop delivery ā—¼ Error Control: uses error detection and correction to reduce the severity of error occurrence ā—¼ Flow Control: controls how much data a sender can transmit before it must wait for an acknowledgement from the receiver in order not to overwhelm it ā—¼ Medium Access Control (MAC): controls how the nodes should access a shared media in a way to prevent packet collisions
  • 4. 10.4 Data can be corrupted during transmission. Some applications require that errors be detected and corrected. Note
  • 5. 10.5 10-1 INTRODUCTION Let us first discuss some issues related, directly or indirectly, to error detection and correction. ā€¢ Types of Errors ā€¢ Redundancy ā€¢ Detection Versus Correction ā€¢ Forward Error Correction Versus Retransmission ā€¢ Coding ā€¢ Modular Arithmetic Topics discussed in this section:
  • 6. 10.6 In a single-bit error, only 1 bit in the data unit has changed. Note
  • 8. 10.8 A burst error means that 2 or more bits in the data unit have changed. Note
  • 9. 10.9 Figure 10.2 Burst error of length 8 ā—¼ The length of the burst is measured from the 1st to the last corrupted bits ā—¼ The burst error doesnā€™t necessarily mean that errors occur in consecutive bits ā—¼ Burst errors are most likely to occur in serial transmission ā—¼ The noise duration is usually longer than the duration of one bit ā—¼ The severity of burst errors are dependent on the data rate & the noise duration ā—¼ For example: a noise duration of 0.01 sec would corrupt 10 bits of a 1Kbps transmission and 10,000 bits of a 1Mbps source
  • 10. 10.10 Error Detection & Correction Concepts ā—¼ Error detection: find out whether an errors has occurred ā—¼ Error correction: find the exact number of corrupted bits and their exact location within the message ā—¼ Error detection is the first step towards error correction ā—¼ Error detection and correction use the concept of redundancy, which is adding extra bits to the data unit ā—¼ The extra bits carry information about the data unit that help find out whether any change may have happened to the data unit at the receiver side ā—¼ The extra bits are discarded as soon as the accuracy of the transmission has been determined
  • 11. 10.11 To detect or correct errors, we need to send extra (redundant) bits with data. Note
  • 12. 10.12 Forward Error Correction vs. Retransmission ā—¼ Error correction by retransmission ā—¼ If error is detected, the sender is asked to retransmit ā—¼ Forward Error Correction (FEC): ā—¼ The receiver uses an error correcting code, which automatically corrects certain types of errors ā—¼ Theoretically, any error can be automatically corrected ā—¼ Error correction is harder than error detection and needs more redundant bits ā—¼ The secret of error correction is to locate the invalid bits ā—¼ To locate a single-bit error in a data unit, you need enough redundant bits to cover all states of change in the data bits as well as the redundant bits and the no-change case
  • 13. 10.13 Coding ā—¼ Redundancy is achieved via coding schemes as follows: ā—¼ Sender adds extra bits to the data bits based on a certain relationship (e.g. CRC circuit) ā—¼ Receiver checks the relationship in order to detect and/or correct errors ā—¼ Two factors of coding schemes to observe: ā—¼ The ratio of the redundant (r) bits to the data bits (d)ā†’ (r/d) ā—¼ The robustness of the whole process (does not give false info) ā—¼ Categories of coding schemes: 1. Block coding ( we cover it in this chapter) 2. Convolution coding (not covered here)
  • 14. 10.14 Modular Arithmetic (X mod-N) ā—¼ Use a limited number of integers ā—¼ Define an upper limit called modulus, N ā—¼ Use only the integers from 0 to N-1, inclusive ā—¼ This is called modulo-N arithmetic ā—¼ If a number is greater than N, it is divided by N and the remainder is the result ā—¼ If a number is negative, add as many Nā€™s as needed to make it positive ā—¼ There is no carry out when numbers are added or subtracted ā—¼ In modulo-2 arithmetic, the addition and subtraction are similar and are performed using the bit-wise XOR function
  • 15. 10.15 Figure 10.4 XORing of two single bits or two words
  • 16. 10.16 10-2 BLOCK CODING In block coding, ā€¢ we divide our message into blocks, each of k bits, called datawords. ā€¢ Then, we add r redundant bits to each block to make the length n: ā€¢ n = k + r. The resulting n-bit blocks are called codewords. ā€¢ Error Detection ā€¢ Error Correction ā€¢ Hamming Distance ā€¢ Minimum Hamming Distance Topics discussed in this section: k: dataword; r: redundant bits n: codeword
  • 17. 10.17 Figure 10.5 Datawords and codewords in block coding
  • 18. 10.18 The 4B/5B block coding discussed in Chapter 4 is a good example of this type of coding. In this coding scheme, k = 4 and n = 5, ā€¢ No. of datawords=2k = 16 ā€¢ No. of codewords= 2n = 32. We saw that 16 out of 32 codewords are used for message transfer and the rest are either used for other purposes or unused. Example 10.1
  • 19. 10.19 Figure 10.6 Process of error detection in block coding e.g. X2+X+1
  • 20. 10.20 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. 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. 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. Example 10.2 Table 10.1 A code for error detection (Example 10.2)
  • 21. 10.21 ā€¢ An error-detecting code can detect only the types of errors for which it is designed; ā€¢ other types of errors may remain undetected. Note
  • 22. 10.22 Figure 10.6 Process of error detection in block coding e.g. X2+X+1
  • 23. 10.23 ā€¢ Let us add more redundant bits to Example 10.2 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 10.2 shows the datawords and codewords. ā€¢ So, k=2, r=3,ā†’n=2+3=5 bits Example 10.3
  • 24. 10.24 ā€¢ Assume the dataword is d= 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. Example 10.3
  • 25. 10.25 ā—¼ Codeword sent = 01011, Codeword received = 01001 ā—¼ 01001 vs. 00000 āž” 2 bit difference ļŒ ā—¼ 01001 vs. 10101 āž” 3 bit difference ļŒ ā—¼ 01001 vs. 11110 āž” 4 bit difference ļŒ ā—¼ 01001 vs. 01011 āž” 1 bit difference ā˜ŗ 1. The receiver will compare received code word with all the valid codewords looking number of difference in bits. 2. It will choose the least difference Compare 01001 with all codewords difference= Hamming distance
  • 26. 10.26 The Hamming distance between two words is the number of differences between the corresponding bits. Note d=Hamming distance
  • 27. 10.27 Let us find the Hamming distance between two pairs of words. 1. The Hamming distance d(000, 011) is 2 because Example 10.4 2. The Hamming distance d(10101, 11110) is 3 because d=Hamming distance
  • 28. 10.28 The minimum Hamming distance (dmin) is the smallest Hamming distance between all possible pairs in a set of words. Note
  • 29. 10.29 Find the minimum Hamming distance of the coding scheme in Table 10.1. Solution We first find all Hamming distances. Example 10.5 The dmin in this case is 2.
  • 30. 10.30 Find the minimum Hamming distance of the coding scheme in Table 10.2. Solution We first find all the Hamming distances. The dmin in this case is 3. Example 10.6
  • 31. 10.31 To guarantee the detection of up to s errors in all cases, the minimum Hamming distance in a block code must be dmin = s + 1. Note
  • 32. 10.32 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. ā€¢ e.g. send 101ā†’received 111 (detected ā†’because not a valid code), ā€¢ If two errors occur, however, the received codeword may match a valid codeword and the errors are not detected. ā†’e.g: send 101ā†’received 000 (considered validā†’ not detetcted) Example 10.7 dmin = s + 1. s=1
  • 33. 10.33 Our second block code scheme (Table 10.2) has dmin = 3. This code can detect up to two errors. Again, we see that 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 combinations of three errors change a valid codeword to another valid codeword. The receiver accepts the received codeword and the errors are undetected. Example 10.8 dmin = s + 1. s=2
  • 34. 10.34 To guarantee correction of up to t errors in all cases, the minimum Hamming distance in a block code must be dmin = 2t + 1. Note
  • 35. 10.35 A code scheme has a Hamming distance dmin = 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, . . . ). Example 10.9 dmin = s + 1. s=3 dmin = 2t + 1. t=?
  • 36. 10.36 10-3 LINEAR BLOCK CODES ā€¢ Almost all block codes used today belong to a subset called linear block codes. ā€¢ A linear block code is a code in which the exclusive OR (addition modulo-2) of two valid codewords creates another valid codeword. ā€¢ Codeword1 (xor) codeword2āž”codeword3 1. Minimum Distance for Linear Block Code 2. Example of Linear Block Codes Topics discussed in this section:
  • 37. 10.37 In a linear block code, the exclusive OR (XOR) of any two valid codewords creates another valid codeword. Note
  • 38. 10.38 1. The scheme 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. ā€¢ 101 + 011 = 110 (cod #4 in the table) 2. The scheme in Table 10.2 is also a linear block code. We can create all four codewords by XORing two other codewords. Example 10.10
  • 39. 10.39 Note: The minimum Hamming distance for a linear block code is the smallest number of 1ā€™s in the nonzero codewords In (Table 10.1), the numbers of 1s in the nonzero codewords are 2, 2, and 2. So the minimum Hamming distance is dmin = 2. In (Table 10.2), the numbers of 1s in the nonzero codewords are 3, 3, and 4. So in this code we have dmin = 3. Example 10.11
  • 40. 10.40 A simple parity-check code is a single-bit error-detecting code in which n = k + 1 with dmin = 2. ā†’i.e. #. of r bits= 1 bit extra ā†’ Even parityā†’ add 1ā€™s so total numbers of 1ā€™s is even parity-check code
  • 41. 10.41 Table 10.3 Simple even parity-check code C(5, 4) parity bit
  • 42. 10.42 Figure 10.10 Encoder and decoder for simple parity-check code
  • 43. 10.43 How it works? To send (a3 a2 a1 a0 : 1011)ā†’ p=1ā†’codeword = (a3 a2 a1 a0 r0 10111)-----> sent to the receiver. We examine five cases: 1. No error occurs; ā†’the received codeword is (b3 b2 b1 b0 q0: 10111. ā†’syndrome S= 0 (no error) ā†’extracted dataword 1011. 2. One error a1 is changed. ā†’ received codeword is 10011 ā†’ S= 1 (error)ā†’ discard data. 3. One error: r0 is changed: ā†’received codeword is 10110ā†’S=1 (error)ā†’ discard data. 4. Two errors: r0 & a3 are changed: ā†’received codeword is 00110ā†’ S=0 (no error: false!) ā†’ dataword 0011 is created at the receiver. ā†’Note that here the dataword is wrongly created due to the syndrome value. 5. Three errors: a3, a2, a1 are changed ā†’The received codeword is 01011. ā†’S=1 (error) ā†’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. Example 10.12
  • 44. 10.44 A simple parity-check code can detect an odd number of errors. Note
  • 45. 10.45 Figure 10.11 Two-dimensional parity-check code ā—¼ Data words are organized in a table (rows & columns) ā—¼ For each row and each column, a parity-check bit is added Parity bits
  • 46. 10.46 Figure 10.11 Two-dimensional parity-check code Original data
  • 47. 10.47 Performance of the Two-Dimensional Parity Check Two-Dimensional Parity Check can do the following ā—¼ Guarantee to detect single error ā—¼ Increases the likelihood of detecting burst errors ā—¼ It fails if the error bits are in exactly the same positions in two different data units ā†’because the changes will cancel each other in this case
  • 48. 10.48 The Hamming Error Correction Codes Hamming codes can be used in Error Detection and correction ā—¼ The category of Hamming codes discussed here is with dmin= 3: ā†’2-bit detection & 1-bit correction ā—¼ We need to choose an integer mā‰„3 such that: ā—¼ n=2m-1 & k=n-m (i.e. n=k+m) ā—¼ The number of check bits r=m ā—¼ For example: ā—¼ If m=3, then n=7 & k=4 ā—¼ This is Hamming Code C(7,4) with dmin= 3 ā—¼ Each code word = a3 a2 a1 a0 r2 r1 r0
  • 49. 10.49 Table 10.4 Hamming code C(7, 4)
  • 50. 10.50 Figure 10.12 The structure of the encoder and decoder for a Hamming code generator creates 3-bit even-parity check ā—¼ r0 = a2 + a1 + a0 (modulo-2) ā—¼ r1 = a3 + a2 + a1 (modulo-2) ā—¼ r2 = a1 + a0 + a3 (modulo-2) checker creates 3-bit syndrome ā—¼ s0 = b2 + b1 + b0 + q0 (modulo-2) ā—¼ s1 = b3 + b2 + b1 + q1 (modulo-2) ā—¼ s2 = b1 + b0 + b3 + q2 (modulo-2)
  • 51. 10.51 Table 10.5 Logical decision made by the correction logic analyzer ā—¼ The 3-bit syndrome represent 1 out 8 different error conditions as shown in the table ā—¼ The decoder is only concerned with the conditions in the table that are not shaded (i.e. data:b3b2b1b0), in which a data bit has been flipped s2 s1 s0 s2 s1 s0 =001ā†’q0 q0 in 1st equation s2 s1 s0 =111ā†’b1 b1 in all equations
  • 52. 10.52 Let us check some cases: 1. No error: d=dataword 0100 ā†’ c=codeword= 0100011. ā†’received: b=0100011. S=000 (no error)ā†’ dataword = 0100. 2. One error: d=0111 ā†’ c=0111001 ā†’received b=0011001, S=011 (error in b2)ā†’correct(flip b2) ā†’the final dataword is 0111 (correct). 3. Two errors: d=1101ā†’ c= 1101000. ā†’received b= 0001000, S=101 (error b0), correct(flip b0) ā†’the final dataword is 0000 (false data) ā†’This shows that our code detects 2 errors, but cannot correct Example 10.13
  • 53. 10.53 We need a dataword of at least k>=7 bits. Calculate values of k and n that satisfy this requirement. Solution We need to make k = n āˆ’ m >=7, or (2m āˆ’ 1) āˆ’ m ā‰„ 7. 1. If we set m = 3, ā†’n = 23 āˆ’ 1, and k = 7 āˆ’ 3=4, which is not acceptable. 2. If we set m = 4,ā†’n = 24 āˆ’ 1 = 15 and k = 15 āˆ’ 4 = 11, which satisfies the condition. So the code is Example 10.14 C(15, 11) C(n, k)
  • 54. 10.54 Performance of the Hamming Code ā—¼ It can detect a 2-bit error ā—¼ It can correct a 1-bit error ā—¼ It can be modified in order to detect burst errors of size N: ā—¼ It is based on splitting the burst error between N codewords ā—¼ Convert the frame into N codewords ā—¼ Rearrange the codewords in the frame from row-wise to column-wise (see the example)
  • 55. 10.55 Figure 10.13 Burst error correction using Hamming code
  • 56. 10.56 10-4 CYCLIC CODES 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. ā€¢ Cyclic Redundancy Check (CRC) ā€¢ Hardware Implementation ā€¢ Polynomials ā€¢ Cyclic Code Analysis ā€¢ Advantages of Cyclic Codes ā€¢ Other Cyclic Codes Topics discussed in this section:
  • 57. 10.57 Table 10.6 A CRC (Cyclic Redundancy Check) code with C(7, 4)
  • 58. 10.58 Figure 10.14 CRC encoder and decoder
  • 59. 10.59 Figure 10.14 CRC encoder and decoder
  • 60. 10.60 Cyclic Redundancy Check (CRC) ā—¼ At the encoder of the sender: ā—¼ The k-bit dataword is augmented by appending (n-k) zeros to the right hand side of it ā—¼ The n-bit result is fed into the generator ā—¼ The generator uses an agreed-upon divisor (checker) of size (n-k+1) ā—¼ The generator divides the augmented dataword by the divisor using modulo-2 division ā—¼ The quotient of the division is discarded ā—¼ The remainder is appended to the dataword to create the codeword
  • 61. 10.61 Cyclic Redundancy Check (CRC) ā—¼ At the decoder of the receiver: ā—¼ The received codeword is divided by the same divisor to create the syndrome, which has a size of (n-k) bits ā—¼ If all the syndrome bits are zeros, then no error is detected ā—¼ Otherwise, an error is detected and the received dataword is discarded
  • 62. 10.62 Figure 10.21 A polynomial to represent a binary word ā—¼ The 1ā€™s and 0ā€™s represent the coefficients of the polynomial ā—¼ The power of each term represents the position of the bit ā—¼ The degree of the polynomial is the highest power of it ā—¼ Adding and subtracting the polynomials are done by adding and subtracting the coefficients of the same-power terms
  • 63. 10.63
  • 64. 10.64
  • 65. 10.65 Figure 10.22 CRC division using polynomials
  • 66. 10.66 The divisor in a cyclic code is normally called the generator polynomial or simply the generator. Note
  • 67. 10.67
  • 68. 10.68 Figure 10.15 Division in CRC encoder sender
  • 69. 10.69 Figure 10.16 Division in the CRC decoder for two cases receiver
  • 72. 10.72 Cyclic Code Analysis ā—¼ Define the following cyclic code parameters as polynomials: ā—¼ Dataword: d(x) ā—¼ Codeword: c(x) ā—¼ Generator: g(x) ā—¼ Syndrome: s(x) ā—¼ Error: e(x) ā—¼ Received codeword = c(x) + e(x) ā—¼ Received codeword/g(x) = c(x)/g(x) + e(x)/g(x) ā—¼ c(x)/g(x) does not have a remainder by definition ā—¼ s(x) is the remainder of e(x)/g(x) ā—¼ If s(x)ā‰ 0, then an error is detected ā—¼ If s(x)=0, then either no error has occurred or the error has not been detected ā—¼ If e(x) is divisible by g(x), then e(x) canā€™t be detected
  • 73. 10.73 In a cyclic code, If s(x) ā‰  0, one or more bits is corrupted. If s(x) = 0, either a. No bit is corrupted. or b. Some bits are corrupted, but the decoder failed to detect them. Note
  • 74. 10.74 In a cyclic code, those e(x) errors that are divisible by g(x) are not caught. Note
  • 75. 10.75 Single-Bit Error ā—¼ A single-bit error is e(x)=xi, where i is the position of the bit ā—¼ If a single-bit error is caught, then xi is not divisible by g(x) (i.e.; there is a remainder) ā—¼ If g(x) has, at least, two terms and the coefficient of x0 is not zero, then e(x) canā€™t be divided by g(x). That is, all single-bit errors will be caught
  • 76. 10.76 If the generator has more than one term and the coefficient of x0 is 1, all single errors can be caught. Note
  • 77. 10.77 Which of the following g(x) values guarantees that a single-bit error is caught? For each case, what is the error that cannot be caught? a. x + 1 b. x3 c. 1 Solution a. No xi can be divisible by x + 1. Any single-bit error can be caught. b. If i is equal to or greater than 3, xi is divisible by g(x). All single-bit errors in positions 1 to 3 are caught. c. All values of i make xi divisible by g(x). No single-bit error can be caught. This g(x) is useless. Example 10.15
  • 78. 10.78 Figure 10.23 Representation of two isolated single-bit errors using polynomials ā—¼ Two isolated single-bit errors are represented as ā—¼ e(x)= xj + xi = xi (xj-i + 1) = xi (xt + 1) ā—¼ If g(x) has, at least, two terms and the coefficient of x0 is not zero, then xi canā€™t be divided by g(x) ā—¼ Therefore, if g(x) is to detect e(x), it must not divide (xt + 1) where t is the distance between the two error bits and t should be between 2 and n-1 (n is the degree of g(x))
  • 79. 10.79 If a generator cannot divide xt + 1 (t between 2 and n ā€“ 1), then all isolated double errors can be detected. Note
  • 80. 10.80 Find the status of the following generators related to two isolated, single-bit errors. a. x + 1 b. x4 + 1 c. x7 + x6 + 1 d. x15 + x14 + 1 Solution a. This is a very poor choice for a generator. Any two errors next to each other cannot be detected. b. This generator cannot detect two errors that are four positions apart. c. This is a good choice for this purpose. d. This polynomial cannot divide (xt + 1) if t is less than 32,768] 15. A codeword with two isolated errors up to 32,768 15 bits apart can be detected by this generator. Example 10.16
  • 81. 10.81 A generator that contains a factor of (x + 1) can detect all odd-numbered errors. Note
  • 82. 10.82 ā All burst errors with L ā‰¤ r will be detected. (r is the degree of g(x)) ā All burst errors with L = r + 1 will be detected with probability 1 ā€“ (1/2)rā€“1. ā All burst errors with L > r + 1 will be detected with probability 1 ā€“ (1/2)r. Note
  • 83. 10.83 Find the suitability of the following generators in relation to burst errors of different lengths. a. x6 + 1 b. x18 + x7 + x + 1 c. x32 + x23 + x7 + 1 Solution a. This generator can detect all burst errors with a length less than or equal to 6 bits; 3 out of 100 burst errors with length 7 will slip by; 1 ā€“ (1/2)6ā€“1 = 1 - 1/32 = 0.97 16 out of 1000 burst errors of length 8 or more will slip by. 1 ā€“ (1/2)6 = 1 ā€“ 1/64 = 0.984 Example 10.17
  • 84. 10.84 b. This generator can detect all burst errors with a length less than or equal to 18 bits; 8 out of 1 million burst errors with length 19 will slip by; 4 out of 1 million burst errors of length 20 or more will slip by. c. This generator can detect all burst errors with a length less than or equal to 32 bits; 5 out of 10 billion burst errors with length 33 will slip by; 3 out of 10 billion burst errors of length 34 or more will slip by. Example 10.17 (continued) Reading only
  • 85. 10.85 A good polynomial generator needs to have the following characteristics: 1. It should have at least two terms. 2. The coefficient of the term x0 should be 1. 3. It should not divide xt + 1, for t between 2 and n āˆ’ 1. 4. It should have the factor x + 1. Note
  • 86. 10.86 Performance of Cyclic Codes ā—¼ Detect single-bit errors ā—¼ Detect double-bit isolated errors ā—¼ Detect odd number of errors ā—¼ Detect burst errors of length less than or equal to the degree of the generator ā—¼ Detect, with a very high probability, burst errors of length greater than the degree of the generator ā—¼ Can be implemented in either SW or HW
  • 88. 10.88 10-5 CHECKSUM ā€¢ The last error detection method we discuss here is called the checksum. ā€¢ The checksum is used in the Internet by several protocols although ā€¢ not used at the data link layer. ā€¢ we briefly discuss it . ā€¢ Idea ā€¢ Oneā€™s Complement ā€¢ Internet Checksum Topics discussed in this section:
  • 89. 10.89 Examples : protocols uses CheckSum: UDP & TCP TCP UDP
  • 90. 10.90 The concept of check sum as follows: ā€¢ 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. ā€¢ Send : We want to sedn : (7, 11, 12, 0, 6), ā†’send (7, 11, 12, 0, 6, -36), note : -36= -Sum (7, 11, 12, 0, 6), . T ā€¢ The receiver adds (7, 11, 12, 0, 6, -36)=result, ā†’ If result=0, No errorā†’ accept data ā†’ else if result ā‰  0 ā†’ error occurs ā†’data are not accepted. Example 10.18: Concept
  • 91. 10.91 If we we use 4-bit numbers, 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. Example 10.20
  • 92. 10.92 How can we represent the number āˆ’6 in oneā€™s complement arithmetic using only four bits? Solution ā€¢ oneā€™s complement (x)= inverting all bits(x). ā€¢ 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 n=4). Example 10.21 Checksum = INV (data 1 āŠ• data 2 āŠ• ... āŠ• data n)
  • 93. 10.93 0 1 1 0 6 1 0 0 1 9 1 1 1 1 15 0 0 0 0 0 Figure 10.24 Example 10.22
  • 95. 10.95
  • 96. 10.96 The Internet Checksum ā—¼ The checksum generator subdivides the data unit into equal-length data units of 16-bit each ā—¼ The data units are added using the 1ā€™s complement arithmetic such that the total is always n-bit long ā—¼ The data units are binary added normally to give the partial sum ā—¼ The outer carry out is added to the partial sum to give the sum ā—¼ The result is 1ā€™s complemented to give the checksum ā—¼ The checksum is appended to the data unit ā—¼ The checksum checker performs the same operation including the checksum: ā—¼ If the result is zero, then the data unit has not been altered
  • 97. 10.97 Sender site: (Internet Checksum) 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. Note
  • 98. 10.98 Receiver site: (Internet Checksum) 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. Note
  • 99. 10.99 C+1=Dā€”> D+1=Eā†’ E+C (mod 16) =Aā†’ A+5=Fā†’ F+6 (mod 16)ā†’5 5+9=E 1sr column addition
  • 100. 10.100
  • 101. 10.101 āœ“ Let us calculate the checksum for a text of 8 characters (ā€œForouzanā€). āœ“ The text needs to be divided into 2-byte (16-bit) words. We use ASCII (see Appendix A) to change each byte to a 2-digit hexadecimal number. āœ“ E.g. F = 0x46 ASCII, o= 0x6F. āœ“ Figure 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 0x36. āœ“ We keep the rightmost digit (6) and insert the leftmost digit (3) as the carry in the second column. āœ“ The process is repeated for each column. Example 10.23
  • 102. 10.102 Figure 10.25 Example 10.23 F F F F F F
  • 103. 10.103 Performance of the Checksum ā—¼ Detect all odd number of errors ā—¼ Detect most even number of errors ā—¼ If corresponding bits in different data units of opposite values are affected, the error will not be detected ā—¼ Generally weaker than the CRC