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

Uni2 Ppt Reference Ke Liye of Remianing Topicx

The document covers key concepts in data link control, focusing on error detection and correction methods. It discusses various types of errors, redundancy techniques, coding schemes, and specific codes like Hamming and cyclic codes. Additionally, it explains the checksum method for error detection, emphasizing the importance of Hamming distance in ensuring reliable communication.

Uploaded by

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

Uni2 Ppt Reference Ke Liye of Remianing Topicx

The document covers key concepts in data link control, focusing on error detection and correction methods. It discusses various types of errors, redundancy techniques, coding schemes, and specific codes like Hamming and cyclic codes. Additionally, it explains the checksum method for error detection, emphasizing the importance of Hamming distance in ensuring reliable communication.

Uploaded by

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

Computer Networks

Day- 4

1
Recap
• Day-1 : Concept of Layering
• Day-2 : LAN Technologies (Ethernet)
• Day-3: Basic Wifi

2
Data Link Control

3
Error Detecting & Correction

Note

Data can be corrupted


during transmission.

Some applications require that


errors be detected and corrected.

4
Error Detecting & Correction

• Error: A condition when the receiver’s information does not


match with the sender’s information
• Error Detection
• Simple Parity check
• Two-dimensional Parity check
• Checksum
• Cyclic Redundancy Code
• Error Correction
• Hamming code

5
INTRODUCTION

Error: A condition when the receiver’s information


does not match with the sender’s information.

Types of Errors:
Redundancy
Detection Versus Correction
Forward Error Correction Versus Retransmission
Coding
Modular Arithmetic

6
Types of Errors

Note

In a single-bit error, only 1 bit in the data unit has


changed.

7
Single-bit error

8
Note

A burst error means that 2 or more bits in the


data unit have changed.

9
Burst error of length 8

10
Redundancy
Note

To detect or correct errors, we need to send


extra (redundant) bits with data.

Detection Vs Correction
•Detection: Checking whether error occurred
•Correction: Identifying the position of the errors : no. of errors, size

Forward Error Correction Vs Retransmission


•FEC: Receiver tries to guess the correct message using redundant bits
•Retransmission: detect the error and retransmit
11
Coding

Redundancy is achieved through various coding


schemes
block codes and convolution codes

12
Note

In modulo-N arithmetic, we use only the


integers in the range 0 to N −1, inclusive.

13
XORing of two single bits or two words

14
BLOCK CODING

In block coding, we divide our message into blocks,


each of k bits, called datawords.
We add r redundant bits to each block to make the
length n = k + r.
The resulting n-bit blocks are called codewords.

15
The structure of encoder and decoder

16
Datawords and codewords in block coding

17
4B/5B block coding:
In this coding scheme,
k = 4 and n = 5.
2k = 16 datawords and 2n = 32 codewords.
16 out of 32 codewords are used for message transfer and
the rest are either used for other purposes or unused.

18
Process of error detection in block coding

19
Let us assume that k = 2 and n = 3.
Table shows the list of datawords and codewords.

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.
20
Note

An error-detecting code can detect


only the types of errors for which it is designed;
other types of errors may remain undetected.

21
Structure of encoder and decoder in error correction

22
Let us add more redundant bits to Previous Example 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 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.
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. 23
Note

The Hamming distance between two words is


the number of differences between
corresponding bits.

24
Let us find the Hamming distance between two pairs of
words.

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

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

25
Note

The minimum Hamming distance is the


smallest Hamming distance between
all possible pairs in a set of words.

26
Find the minimum Hamming distance of the coding scheme

Solution
We first find all Hamming distances.

The dmin in this case is 2.


27
Find the minimum Hamming distance of the coding scheme
C(5,2) with dmin = 3

Solution
We first find all the Hamming distances.

The dmin in this case is 3.


28
Note

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.

29
Example 10.7

The minimum Hamming distance for C(3,2)code scheme 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.
30
Our second block code scheme C(5,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.
31
Note

To guarantee correction of up to t errors in all


cases, the minimum Hamming distance in a
block code
must be dmin = 2t + 1.

32
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, . . . ).

33
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.

34
Note

In a linear block code, the exclusive OR (XOR) of


any two valid codewords creates another valid
codeword.

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

36
Note

A simple parity-check code is a


single-bit error-detecting
code in which
n = k + 1 with dmin = 2.

37
Simple parity-check code C(5, 4)

38
Encoder and decoder for simple parity-check code

39
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. The syndrome 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.
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.

40
Note

A simple parity-check code can detect an odd


number of errors.

41
Two-dimensional parity-check code

42
Two-dimensional parity-check code

43
Hamming Code
•The Hamming distance between two words is the number of
differences between corresponding bits.
•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.
•To guarantee correction of up to t errors in all cases, the
minimum Hamming distance in a block code must be dmin = 2t + 1.
• k – no. of data bits, r – no. of redundant bits, n – No. of code bits
•n=k+r
•2r ≥ k + r + 1 where, r = redundant bit, k = data bit
• Eg: k = 4; then r = 3

44
Hamming code C(7, 4)

45
r0 = a2+a1+a0 mod 2 s0 = b2+b1+b0+q0 mod 2
r1=a3+a2+a1 mod 2 s1 =b3+b2+11+q1 mod 2
r2=a1+a0+a3 mode 2 s2 =b1+b0+b3+q2 mod 2

46
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 codeword 0011001 is received. 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. 47
Burst error correction using Hamming code

48
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.

49
ACRC code with C(7, 4)

50
CRC encoder and decoder

51
Division in CRC encoder

52
Division in the CRC decoder for two cases

53
A polynomial to represent a binary word

54
CRC division using polynomials

55
Note

The divisor in a cyclic code is normally called


the generator polynomial
or simply the generator.

56
Note

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.

57
Note

In a cyclic code, those e(x) errors that are


divisible by g(x) are not caught.

58
Note

If the generator has more than one term and


the coefficient of x0 is 1,
all single errors can be caught.

59
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.
60
Note

A generator that contains a factor of


x + 1 can detect all odd-numbered errors.

61
Note

❏ All burst errors with L ≤ r will be


detected.
❏ 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.

62
Note

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.
63
Standard polynomials

64
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 at the data
link layer.

65
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.

66
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.

67
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.

68
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.

69
Checksum

70
Exercise

1 . Checksums use _________ arithmetic.


A) one’s complement arithmetic
B) two’s complement arithmetic
C) either (a) or (b)
D) none of the above

71
Exercise

1 . Checksums use _________ arithmetic.


A) one’s complement arithmetic
B) two’s complement arithmetic
C) either (a) or (b)
D) none of the above

72
Exercise

2. In modulo-11 arithmetic, we use only the integers in the range ______, inclusive.
A) 1 to 10
B) 0 to 10
C) 1 to 11
D) none of the above

73
Exercise

2. In modulo-11 arithmetic, we use only the integers in the range ______, inclusive.
A) 1 to 10
B) 0 to 10
C) 1 to 11
D) none of the above

74
Exercise

3. In cyclic redundancy checking, the divisor is _______ the CRC.


A) one bit less than
B) one bit more than
C) The same size as
D) none of the above

75
Exercise

3. In cyclic redundancy checking, the divisor is _______ the CRC.


A) one bit less than
B) one bit more than
C) The same size as
D) none of the above

76
Exercise

4. In modulo-2 arithmetic, __________ give the same results.


A) addition and subtraction
B) addition and multiplication
C) addition and division
D) none of the above

77
Exercise

4. In modulo-2 arithmetic, __________ give the same results.


A) addition and subtraction
B) addition and multiplication
C) addition and division
D) none of the above

78
Exercise

5. In cyclic redundancy checking, what is the CRC?


A) The quotient
B) The dividend
C) The divisor
D) The remainder

79
Exercise

5. In cyclic redundancy checking, what is the CRC?


A) The quotient
B) The dividend
C) The divisor
D) The remainder

80
Exercise

6. Which error detection method consists of just one redundant bit per data unit?
A) CRC
B) Checksum
C) Simple parity check
D) Two-dimensional parity check

81
Exercise

6. Which error detection method consists of just one redundant bit per data unit?
A) CRC
B) Checksum
C) Simple parity check
D) Two-dimensional parity check

82
Exercise

7. To guarantee correction of up to 5 errors in all cases, the minimum Hamming


distance in a block code must be ________.
A) 11
B) 6
C) 5
D) none of the above

83
Exercise

7. To guarantee correction of up to 5 errors in all cases, the minimum Hamming


distance in a block code must be ________.
A) 11
B) 6
C) 5
D) none of the above

84
Exercise

8. In block coding, if k = 2 and n = 3, we have _______ invalid codewords.


A) 4
B) 8
C) 2
D) none of the above

85
Exercise

8. In block coding, if k = 2 and n = 3, we have _______ invalid codewords.


A) 4
B) 8
C) 2
D) none of the above

86
Exercise

9. Let G(x) be the generator polynomial used for CRC checking. What is the condition
that should be satisfied by G(x) to detect odd number of bits in error?

(a) G(x) contains more than two terms

(b) G(x) does not divide 1+xk, for any k not exceeding the frame length

(c) 1+x is a factor of G(x)

(d) G(x) has an odd number of terms

87
Exercise

9. Let G(x) be the generator polynomial used for CRC checking. What is the condition
that should be satisfied by G(x) to detect odd number of bits in error?

(a) G(x) contains more than two terms

(b) G(x) does not divide 1+xk, for any k not exceeding the frame length

(c) 1+x is a factor of G(x)

(d) G(x) has an odd number of terms

88
Exercise
10. The message 11001001 is to be transmitted using the CRC polynomial x^3 + 1 to
protect it from errors. The message that should be transmitted is:

(a) 11001001000

(b) 11001001011

(c) 11001010

(d) 110010010011

89
Exercise
10. The message 11001001 is to be transmitted using the CRC polynomial x^3 + 1 to
protect it from errors. The message that should be transmitted is:

(a) 11001001000

(b) 11001001011
Sol : The polynomial x^3+1 corresponds to divisor
(c) 11001010 is 1001.
11001001 000 <--- input right padded by 3 bits
(d) 110010010011 1001 <--- divisor
01011001 000 <---- XOR of the above 2
1001 <--- divisor
00010001 000
1001
00000011 000
10 01
00000001 010
1 001
00000000 011 <------- remainder (3 bits) 90
Exercise
11. A computer network uses polynomials for error checking with 8 bits as
information bits and uses x3 + x + 1 as the generator polynomial to generate
the check bits. In this network, the message 01011011 is transmitted as

(a) 01011011010

(b) 01011011011

(c) 01011011101

(d) 01011011100

91
Exercise
11. A computer network uses polynomials for error checking with 8 bits as
information bits and uses x3 + x + 1 as the generator polynomial to generate
the check bits. In this network, the message 01011011 is transmitted as

(a) 01011011010

(b) 01011011011

(c) 01011011101

(d) 01011011100

92
Exercise
12. A code scheme has a Hamming distance dmin = 4. What is the error
detection and correction capability of this scheme?

(a) 3,1

(b) 4,2

(c) 4,1

(d) 3,2

93
Exercise
12. A code scheme has a Hamming distance dmin = 4. What is the error
detection and correction capability of this scheme?

(a) 3,1

(b) 4,2

(c) 4,1

(d) 3,2

94
Exercise

13. When 2 or more bits in a data unit has been changed during the

transmission, the error is called ____________

a) random error

b) burst error

c) inverted error

d) double error

95
Exercise

13. When 2 or more bits in a data unit has been changed during the

transmission, the error is called ____________

a) random error

b) burst error

c) inverted error

d) double error

96
Data Link Control: FRAMING

The data link layer needs to pack bits into frames, so


that each frame is distinguishable from another.
Our postal system practices a type of framing. The
simple act of inserting a letter into an envelope
separates one piece of information from another; the
envelope serves as the delimiter.

• Fixed-Size Framing

• Variable-Size Framing
97
A frame in a character-oriented protocol

98
Byte stuffing and unstuffing
(Point-to-Point Protocol (PPP) is a byte-oriented protocol).

Byte stuffing is the process of adding 1 extra byte


whenever there is a flag or escape character in the text.

99
A frame in a bit-oriented protocol (HDLC)

100
Bit stuffing and unstuffing

Bit stuffing is the process of adding one extra 0 whenever five consecutive
1s follow a 0 in the data, so that the receiver does not mistake the pattern
0111110 for a flag.

101
FLOW AND ERROR CONTROL

The most important responsibilities of the data link


layer are flow control and error control. Collectively,
these functions are known as data link control.

 Flow Control: set of procedures used to restrict the


amount of data that the sender can send before waiting for
acknowledgment.

 Error Control: data link layer is based on automatic repeat


request, which is the retransmission of data.

102
Data Link Layer Protocols
combine framing, flow control, and error control to
achieve the delivery of data from one node to another.

103
NOISELESS CHANNELS

Let us first assume we have an ideal channel in which


no frames are lost, duplicated, or corrupted.
Two protocols for this type of channel.

• Simplest Protocol

• Stop-and-Wait Protocol

104
The design of the simplest protocol with no flow or error control

105
Sender-side algorithm for the simplest protocol

Receiver-side algorithm for the simplest protocol

11.106
Design of Stop-and-Wait Protocol

107
Sender-site algorithm for Stop-and-Wait Protocol

Receiver-site algorithm for Stop-and-Wait Protocol

108

You might also like