0% found this document useful (0 votes)
9 views77 pages

2.2 Framing & Error Control

The document discusses the data link layer's role in framing, flow control, and error control. It explains how data is packed into frames for transmission, the importance of delimiters, and various methods of error detection and correction, including character-oriented and bit-oriented framing. Additionally, it covers techniques such as checksums and cyclic redundancy checks (CRC) for ensuring data integrity during transmission.

Uploaded by

manviarora910
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)
9 views77 pages

2.2 Framing & Error Control

The document discusses the data link layer's role in framing, flow control, and error control. It explains how data is packed into frames for transmission, the importance of delimiters, and various methods of error detection and correction, including character-oriented and bit-oriented framing. Additionally, it covers techniques such as checksums and cyclic redundancy checks (CRC) for ensuring data integrity during transmission.

Uploaded by

manviarora910
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/ 77

Data Link Layer

11.4
11.4
FRAMING

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

A delimiter is a character or symbol that separates pieces of data. Ex- comma (,), full stop (.), colon (:), semicolon (;) & e
Co NTD…
 Framing in the data-link layer separates a message from one
source to a destination by adding a sender address and a
destination address.
 The destination address defines where the packet is to go;
the sender address helps the recipient acknowledge the
receipt.
 Although the whole message could be packed in one frame,
that is not normally done.
Co NTD…
 One reason is that a frame can be very large, making flow
and error control very inefficient.
 When a message is carried in one very large frame, even a
single-bit error would require the retransmission of the
whole frame.
 When a message is divided into smaller frames, a single-bit
error affects only that small frame.
F RAME SIZE
 Frames can be of fixed or variable size.
 In fixed-size framing, there is no need for defining the
boundaries of the frames; the size itself can be used as a
delimiter.
 Twoapproaches
 Character-oriented approach
 Bit-oriented approach
C HARACTER -ORIENTED FRAMING
 In character-oriented (or byte-oriented) framing, data to be
carried are 8-bit characters from a coding system such asASCII.
 The header - carries the source and destination addresses and
other control information, and the trailer, which carries error
detection redundant bits, are also multiples of 8 bits.
 To separate one frame from the next, an 8-bit (1-byte) flag is
added at the beginning and the end of a frame.

11.9
CoNTD…
 The flag, composed of protocol-dependent special characters,
signals the start or end of a frame.
 The flag could be selected to be any character not used for text
communication.
 Other types of information such as graphs, audio, and video; any
character used for the flag could also be part of the information.
 The receiver, when it encounters this pattern in the middle of the
data, thinks it has reached the end of the frame.
A frame in a character-oriented protocol
BYTE s TUFFING AND UNs TUFFING
 A byte-stuffing strategy was added to character-oriented framing.
 In byte stuffing (or character stuffing), a special byte is added to the data
section of the frame when there is a character with the same pattern as the
flag.
 The data section is stuffed with an extra byte. This byte is usually called the
escape character (ESC) and has a predefined bit pattern.
 Whenever the receiver encounters the ESC character, it removes it from
the data section and treats the next character as data, not as a delimiting
flag.

11.12
Byte stuffing and unstuffing

11.13
Note

Byte stuffing is the process of adding 1 extra


byte whenever there is a flag or escape
character in the text.
BIT-ORIENTED FRAMING
 In bit-oriented framing, the data section of a frame is a sequence
of bits to be interpreted by the upper layer as text, graphic, audio,
video, and so on
 Most protocols use a special 8-bit pattern flag, 01111110, as the
delimiter to define the beginning and the end of the frame.

11.15
A frame in a bit-oriented protocol
Note

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.
Bit stuffing and unstuffing
F Lo W AND E RR o R Co NTR o L

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

Flow control refers to a set of procedures used to


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

Error control in the data link layer is based on automatic


repeat request, which is the retransmission of data.
FLo W C o NTR o L AT THE DATA-LINK LAYER

11.23
E RRo R Co NTR o L
 Physical layer is not fully reliable - error control is implemented at
data- link layer to prevent the receiving node from delivering corrupted
packets to its network layer.
 Error control at the data-link layer is normally very simple
and implemented using one of the following two methods.
 In both methods, a CRC is added to the frame header by the sender
and checked by the receiver.

11.25
CoNTD…
 In the first method, if the frame is corrupted, it is silently discarded; if it
is not corrupted, the packet is delivered to the network layer. This
method is used mostly in wired LANs such as Ethernet.
 In the second method, if the frame is corrupted, it is silently discarded; if
it is not corrupted, an acknowledgment is sent (for the purpose of both
flow and error control) to the sender.

11.26
E RR o R D ETECTI o N AND
Co RRECTI o N
Note

Data can be corrupted during transmission.


Some applications require that errors be
detected and corrected.
T YPE s o F E RRo Rs
 Whenever bits flow from one point to another, they are
subject to unpredictable changes because of interference.
 This interference can change the shape of the signal.
 The term single-bit error means that only 1 bit of a given data
unit (such as a byte, character, or packet) is changed from 1 to
0 or from 0 to 1.
 The term burst error means that 2 or more bits in the data
unit have changed from 1 to 0 or from 0 to 1.
Note

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


changed.
Single-bit error

10.33
Note

Aburst error means that 2 or more bits in the data unit have
changed.
Burst error of length 8

10.35
Note

To detect or correct errors, we need to send extra


(redundant) bits with data.
The structure of encoder and decoder

10.37
E RRo R DETECTIoN

 Enough redundancy is added to detect an error.


 The receiver knows an error occurred but does not know
which bit(s) is(are) in error.
 Has less overhead than error correction.
Process of error detection in block coding
Error detection
 LRC – Linear Block Codes
 CRC – Cyclic Redundancy
Contents Check
 CHECKSUM
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 XOR
(addition modulo-2) of two valid codewords creates
another valid codeword.
Contd…

Ina linear block code, the exclusive OR (XOR) of


any two valid codewords creates another valid
codeword.
Contd…

In a linear block code, the minimum


Hamming distance is the number of 1s in the
nonzero valid codeword with the smallest
number of 1s.

For code 000, 011, 110, 101 the numbers of 1s in


the nonzero codewords are 2, 2, and 2. So the
minimum Hamming distance is dmin =2.
Contd…

A simple parity-check code is a


single-bit error-detecting
code in which
n =k +1 with dmin =2.
Simple parity-check code
Encoder and decoder for simple parity-check code
Parity-check code

▶ r0 =a3 +a2 +a1 +a0 (modulo-2)


▶ Syndrome (calculated by the receiver)
▶ s0 =b3 +b2 +b1 +b0 +q0 (modulo-2)
Contd…

A simple parity-check code can detect


an odd number of errors.
Two-dimensional parity-check code
Contd…
Contd…

Two-dimensional parity-check can detect up to 3-bit errors


Hamming code C(7, 4) C(n,k) dmin=3
The structure of the encoder and decoder for a Hamming code
Hamming Code

▶ Parity checks are created as follow (using modulo-2)


▶ r0 =a2 +a1 +a0
▶ r1 =a3 +a2 +a1
▶ r2 =a1 +a0 +a3
10.17
Contd…

▶ The checker in the decoder creates a 3-bit syndrome (s2s1s0).


▶ In which each bit is the parity check for 4 out of the 7 bits in the received
codeword:
▶ s0 =b2 +b1 +b0 +q0
▶ s1 =b3 +b2 +b1 +q1
▶ s2 =b1 +b0 +b3 +q2
▶ The equations used by the checker are the same as those used by the
generator with the parity-check bits added to the right-hand side of the
equation.
Logical decision made by the correction logic analyzer

Hamming code C(7, 4) can :


• detect up to 2-bit error
can correct up to 1 bit error
Burst error correction using Hamming code

Split burst error


between multiple
codewords
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.
A CRC code with C(7, 4)
CRC encoder and decoder
Division in CRC encoder
Division in the CRC decoder for two cases
CRC Polynomials
General design of encoder and decoder of a CRC code
CRC - Polynomials

▶ A pattern of 0s and 1s can be represented as a polynomial with


coefficients of 0 and 1.
▶ The power of each term shows the position of the bit; the
coefficient shows the value of the bit.
▶ Degree of a Polynomial: The degree of a polynomial is the
highest power in the polynomial. For example, the degree of
the polynomial x6 +x +1 is 6. The degree of a polynomial is 1 less
than the number of bits in the pattern. The bit pattern in this
case has 7 bits.
Contd…

▶ Adding and Subtracting Polynomials: Adding and


subtracting polynomials in mathematics are done by
adding or subtracting the coefficients of terms with the
same power.
▶ For example, adding x5 + x4 + x2 and x6 + x4 + x2 gives just
x6 +x5 . The terms x4 and x2 are deleted
Contd…

▶ Multiplying Two Polynomials : Multiplying a polynomial


by another is done term by term. Each term of the first
polynomial must be multiplied by all terms of the
second.
▶ The result is pairs of equal terms are deleted
Cyclic Code Encoder Using Polynomials
Contd…

The divisor in a cyclic code is normally


called the generator polynomial
or simply the generator.
Polynomial to represent a binary word
Standard polynomials
Advantages

▶ cyclic codes have a very good performance in detecting single-


bit errors, double errors, an odd number of errors, and burst errors.
▶ They can easily be implemented in hardware and software.
▶ They are especially fast when implemented in hardware.
CHECKSUM

 The last error detection method iscalled the checksum.


 Checksum is an error-detecting technique that can be applied to a
message of any length.
 In the Internet, the checksum technique is mostly used at the network
and transport layer rather than the data-link layer
Contd…

▶ At the source, the message is first divided into m-bit units.


▶ The generator then creates an extra m-bit unit called the
checksum, which is sent with the message.
▶ At the destination, the checker creates a new checksum
from the combination of the message and sent checksum.
▶ If the new checksum is all 1s (Compliment of checksum is
all 0s), the message is accepted; otherwise, the message is
discarded
Example

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

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

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).
In one’s complement arithmetic, the complement of a
number is found by completing all bits (changing all 1s to
0s and all 0s to 1s).
Internet Checksum Example

▶ Note
▶ When adding numbers, a carryout from the most significant bit
needs to be added to the result
▶ Example: add two 16-bit integers

1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

sum 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1

You might also like