Unit 3
Unit 3
the network layer. This layer converts the raw transmission facility provided by the physical layer to a
reliable and error-free link.
The main functions and the design issues of this layer are
Frame Header
Payload field that contains the data packet from network layer
Trailer
Error Control
The data link layer ensures error free link for data transmission. The issues it caters to with respect to error
control are −
FRAMING
Problems in Framing –
Detecting start of the frame: When a frame is transmitted, every station must be able to detect it.
Station detect frames by looking out for special sequence of bits that marks the beginning of the frame
i.e. SFD (Starting Frame Delimeter).
How do station detect a frame: Every station listen to link for SFD pattern through a sequential
circuit. If SFD is detected, sequential circuit alerts station. Station checks destination address to accept
or reject frame.
Detecting end of frame: When to stop reading the frame.
Types of framing – There are two types of framing:
1. Fixed size – The frame is of fixed size and there is no need to provide boundaries to the frame, length of
the frame itself acts as delimiter.
Drawback: It suffers from internal fragmentation if data size is less than frame size
Solution: Padding
2. Variable size – In this there is need to define end of frame as well as beginning of next frame to
distinguish. This can be done in two ways:
1. Length field – We can introduce a length field in the frame to indicate the length of the frame. Used
in Ethernet(802.3). The problem with this is that sometimes the length field might get corrupted.
2. End Delimeter (ED) – We can introduce an ED(pattern) to indicate the end of the frame. Used
in Token Ring. The problem with this is that ED can occur in the data. This can be solved by:
1. Character/Byte Stuffing: Used when frames consist of character. If data contains ED then, byte is
stuffed into data to diffentiate it from ED.
Let ED = “$” –> if data contains ‘$’ anywhere, it can be escaped using ‘\O’ character.
–> if data contains ‘\O$’ then, use ‘\O\O\O$'($ is escaped using \O and \O is escaped using \O).
Disadvantage – It is very costly and obsolete method.
2. Bit Stuffing: Let ED = 01111 and if data = 01111
–> Sender stuffs a bit to break the pattern i.e. here appends a 0 in data = 011101.
–> Receiver receives the frame.
–> If data contains 011101, receiver removes the 0 and reads the data.
Examples –
If Data –> 011100011110 and ED –> 0111 then, find data after bit stuffing ?
Sol: 0 1110 0 0 1 1 1 1 0
0 1 1 0 1 0 0 0 1 1 0 1 1 0
If Data –> 110001001 and ED –> 1000 then, find data after bit stuffing ?
ERROR DETECTION AND CORRECTION METHODS
Because of Attenuation, distortion, noise and interferences, errors during transmission are inevitable, leading to
corruption transmitted bits.
Longer the frame size and higher the probability of single bit error, lower is the probability receiving a
frame without error.
ERROR
When data is being transmitted from one machine to another, it may possible that data become corrupted
on its way. Some of the bits may be altered, damaged or lost during transmission. Such a condition is
known as error.
TYPES OF ERRORS
Single bit error: Only one bit gets corrupted. Common in Parallel transmission.
Burst error: More than one bit gets corrupted very common in serial transmission of data occurs when
the duration of noise is longer than the duration of one bit.
The term single-bit error means that only one bit of given data unit (such as a byte, character, or data
unit) is changed from 1 to 0 or from 0 to 1 as shown in Fig. 3.2.1.
Single bit errors are least likely type of errors in serial data transmission.
For example, if 16 wires are used to send all 16 bits of a word at the same time and one of the wires is
noisy, one bit is corrupted in each word.
Burst error:
More than one bit gets corrupted very common in serial transmission of data occurs when the
duration of noise is longer than the duration of one bit.
The noise affects data; it affects a set of bits.
The number of bits affected depends on the data rate and duration of noise.
ERROR DETECTION TECHNIQUES
Basic approach used for error detection is the use of redundancy, where additional bits are
added to facilitate detection and correction of errors. Popular techniques are
Redundancy is the method in which some extra bits are added to the data so as to check whether the
data contain error or not.
m - data bits (i.e., message
bits) r - redundant bits (or
check bits). n - total number
of bits
n= (m + r).
An n-bit unit containing data and check-bits is often referred to as an n-bit codeword.
The simplest and most popular error detection scheme. Appends a Parity bit to the end of the data.
Even Parity: 01000001 – Number of ones in the group of bits is even Odd Parity: 11000001 - Number
of ones in the group of bits is odd
A parity of 1 is added to the block if it conta an even numberAtthereceivingof end1’stheparity. bit is computed
from the received data bits and compared with the received parity bit.
This scheme makes the total number of 1’seven, that is why it is called even parity checking.
Considering a 4-bit word, different combinations of the data words and the corresponding code words
are given in Table.
Example:
Performance can be improved by using two dimensional parity check, which organizes the block of
bits in the form of table.
Parity check bits are calculated from each row, which is equivalent to a simple parity check.
Parity check bits are also calculated for all columns.
Both are sent along with the data.
At the receiving end these are compared with the parity bits calculated on the received data.
Performance:
If two bits in one data unit are damaged and two bits in exactly same position in another data unit are
also damaged, The 2-D Parity check checker will not detect an error.
For example, if two data units: 11001100 and 10101100.
If first and second from last bits in each of them is changed, making the data units as 01001110 and
00101110, the error cannot be detected by 2-D Parity check.
CHECKSUM
In checksum error detection scheme, the data is divided into k segments each of m bits.
In the sender’s end 1’sthe complementsegmentsarearithmetiaddedu
The sum is complemented to get the checksum. The checksum segment is sent along with the data
segments
Example 1:
Sender Reciever:
Data checksum
• One of the most powerful and commonly used error detecting codes.
Basic approach:
• Given a m-bit block of bit sequence, the sender generates an n-bit sequence known as frame
sequence check(FCS), so that the resulting frame, consisting of m+n bits exactly divisible by same
predetermined number.
• The receiver divides the incoming frame by that number and, if there is no reminder, assumes
there was no error.
Fig. by dividing a sample 4- bit number by the coefficient of the generator polynomial x 3+x+1, which is
1011, using the modulo-2 arithmetic.
Modulo-2 arithmetic is a binary addition process without any carry over, which is just the Exclusive-OR
operation.
Consider the case where k=1101. Hence we have to divide 1101000 (i.e. k appended by 3 zeros) by 1011,
which produces the remainder r=001, so that the bit frame (k+r) =1101001 is actually being transmitted
through the communication channel.
At the receiving end, if the received number, i.e.,1101001 is divided by the same generator polynomial
1011 to get the remainder as 000, it can be assumed that the data is free of errors.
Performance of CRC
Concept of error-correction can be easily understood by examining the simplest case of single-bit
errors. As we have already seen that a single-bit error can be detected by addition of a parity bit with the
data, which needed to be send.
A single additional bit can detect error, but it’s not sufficient enough to correct that error too. For
correcting an error one has to know the exact position of error, i.e. exactly which bit is in error (to locate
the invalid bits).
For example, to correct a single-bit error ermine which one of the seven bits is in error.
bits.
An ASCII character, the error correction must To this, we have to add some additional redundant
To calculate the numbers of redundant bits (r) required to correct d data bits, let us find out the
relationship between the two. So we have (d+r) as the total number of bits, which are to be transmitted;
then r must be able to indicate at least d+r+1 different values. Of these, one value means no error, and
remaining d+r values indicate error location of error in each of d+r locations. So, d+r+1 states must be
distinguishable by r bits, and r bits can indicates 2r states. Hence, 2r must be greater than d+r+1.
2r >= d+r+1
The value of r must be determined by putting in the value of d in the relation. For example, if d is 7,
then the smallest value of r that satisfies the above relation is 4. So the total bits, which are to be transmitted
is 11 bits (d+r = 7+4 =11).
Now let us examine how we can manipulate these bits to discover which bit is in error. A technique
developed by R.W. Hamming provides a practical solution. The solution or coding scheme he developed is
commonly known as Hamming Code.
Hamming code can be applied to data units of any length and uses the relationship between the data bits
and redundant bits as discussed.
11 10 9 8 7 6 5 4 3 2 1
D D D R d d d r d r r
Redundant bits
Figure Positions of redundancy bits in hamming code Basic approach for error
detection by using Hamming code is as follows:
• To each group of m information bits k parity bits are added to form (m+k) bit code as shown in Fig.
3.2.8.
• Location of each of the (m+k) digits is assigned a decimal value.
• The k parity bits are placed in positions 1, 2,k-1 positions…,2.–K parity checks are performed on
selected digits of each codeword.
• At the receiving end the parity bits are recalculated. The decimal value of the k parity bits provides the
bit-position in error, if any.
Figure:Use of Hamming code for error correction for a 4-bit data
Figure shows how hamming code is used for correction for 4-bit numbers (d4d3d2d1)
with the help of three redundant bits (r3r2r1).
For the example data 1010, first r1 (0) is calculated considering the parity of the bit
positions, 1, 3, 5 and 7. Then the parity bits r2 is calculated considering bit positions 2,
3, 6 and 7.
Finally, the parity bits r4 is calculated considering bit positions 4, 5, 6 and 7 as shown.
If any corruption occurs in any of the transmitted code 1010010, the bit position in error
can be found out by calculating r3r2r1 at the receiving end.
For example, if the received code word is 1110010, the recalculated value of r3r2r1 is
110, which indicates that bit position in error is 6, the decimal value of 110