Upload
dhaval-doshi
View
23
Download
1
Tags:
Embed Size (px)
DESCRIPTION
It is a Ppt for communication networks
Citation preview
5/20/2018 Data Link Layer
1/51
5/20/2018 Data Link Layer
2/51
Functions of Data Link Layer Providing a well-defined service interface to the network layer.
Dealing with transmission errors.
Regulating the flow of data so that slow receivers are not swamped
by fast senders
DLL takes the packets it gets from the network layer and
encapsulatesthem into frames for transmission
Each frame contains a frame header, a payload field for
holding the packet, and a frame trailer
Data Link Layer
5/20/2018 Data Link Layer
3/51
Design Issues
Reliable Delivery
Flow control
Acknowledged delivery
Error detection and correction
Services provided to the Network Layer Unacknowledged connectionless service
Suitable for applications with low error rate and for real timetraffic such as voice
Acknowledged connectionless service Suitable for applications that needs assurance of delivery
Acknowledged connection-oriented service
Data Link Layer
5/20/2018 Data Link Layer
4/51
Transmission of the data link layer starts with
breaking up the bit stream into discrete frames
Computation of a checksum for each frame, and
Include the checksum into the frame before it is
transmitted.
Receiver computes its checksum error for a receiving
frame and if it is different from the checksum that is
being transmitted will have to deal with the error.
Framing is more difficult than one could think!
DLC functions
5/20/2018 Data Link Layer
5/51
To provide service to the network layer, the datalink layer must use the service provided to it bythe physical layer
Physical layer accept a raw bit stream andattempt to deliver it to the destination.
Bit stream is not guaranteed to be error freeNumber of bits received may be less than, equalto, or more than the number of bits transmitted,and they may have different values.
It is up to the data link layer to detect and, ifnecessary, correct errors
Framing
5/20/2018 Data Link Layer
6/51
1.Byte count
2.Flag bytes with byte stuffing
3.Flag bits with bit stuffing
Framing Methods
5/20/2018 Data Link Layer
7/51
It uses a field in the header to specify the number ofbytes in the frame.
Once the header information is being received it will be
used to determine end of the frame.
Byte/Character Count Framing
Method
A byte stream. (a)Without errors
5/20/2018 Data Link Layer
8/51
DisadvantagesTrouble with this algorithm is that when the count is
incorrectly received the destination will get out of synch
with transmission.
Destination may be able to detect that the frame is in error but it doesnot have a means (in this algorithm) how to correct it
Byte/Character Count Framing
Method
A byte stream (b)With one error.
5/20/2018 Data Link Layer
9/51
Flag Bytes with Byte Stuffing
Framing Method
This methods gets around the boundary detection of theframe by having each appended by the frame start and
frame end special bytes.
If they are the same (beginning and ending byte in the
frame) they are called flag byte.
A frame delimited by flag bytes.
5/20/2018 Data Link Layer
10/51
If the actual data contains a byte that is identicalto the FLAG byte (e.g., picture, data stream, etc.)
the convention that can be used is to have
escape character(ESC) inserted just before the
FLAG character
Flag Bytes with Byte Stuffing
Framing Method
5/20/2018 Data Link Layer
11/51
It may also appears that escape byte appears inthe data.
To prevent escape byte from being mixed with
the data, each escape byte appearing in data is
stuffed with another escape byte
Flag Bytes with Byte Stuffing
Framing Method
5/20/2018 Data Link Layer
12/51
Bit Stuffing Framing Method
This methods achieves the same thing as Byte Stuffing
method by using Bits (1) instead of Bytes (8 Bits).
It was developed for High-level Data Link Control (HDLC)
protocol.
Each frames begins and ends with a special bit pattern:
01111110or 0x7E
5/20/2018 Data Link Layer
13/51
Bit Stuffing Framing Method
5/20/2018 Data Link Layer
14/51
During data transmission, one or more bits of
data being transmitted may get corrupted Depending on the number of bits in data that
have been corrupted, there exist two types of
error:1. Single bit error
2. Burst error
Types of Error
5/20/2018 Data Link Layer
15/51
Single-bit error means that only 1 bit of a
given data unit (such as a byte, character, orpacket) is changed from 1 to 0 or from 0 to 1
Singlebit error
5/20/2018 Data Link Layer
16/51
Burst error means that 2 or more bits in the
data unit have changed from 1 to 0 or from 0to 1
Burst error
5/20/2018 Data Link Layer
17/51
During data transmission, errors may occur becauseof certain transmission impairments such as
attenuation and electromagnetic noiseTo detect or correct errors, we need to send someextra bits with our dataError detection uses the concept of redundancy, which
means adding extra bits for detecting errors at thedestination
These extra bits are called Redundant bits
These redundant bits are added by the sender andremoved by the receiver
Their presence allows the receiver to detect orcorrect corrupted bits
The central concept in detecting or correcting errorsis redundancy
Redudancy
5/20/2018 Data Link Layer
18/51
Error Detection:
In error detection, we are only looking to see ifany error has occurred
The answer is a simple yes or no
We are not even interested in the number of
corrupted bits
A single-bit error is the same for us as a bursterror
Some of the commonly error-detecting codes are:1.Simple parity check
2.Two dimensional(2D) parity check
3.Checksum
4.Cyclic Redundancy Check(CRC)
Error detection v/s Correction
5/20/2018 Data Link Layer
19/51
Error Correction:
Emphasis is on not only to detect the errors butalso to correct them
For this, it is important to know the exact
number of bits that are corrupted and, moreimportantly, their locationin the message
The correction of errors is more difficult than
the detection The most commonly used error correcting
code is Hamming code
Error detection v/s Correction
5/20/2018 Data Link Layer
20/51
An extra bit known as parity bit is added to eachdata word that is being transmitted
A k-bit data word is changed to n-bit codewordi.e. n = k+1
Value of parity bit (i.e. 0 or 1) is such thatcharacter has even (even parity) or odd (oddparity) number of onesGenerally, the MSB is parity bit
Example:
Simple Parity check
Even Parity
P Dataword
0 1 0 1 0 0 1 1
1 1 1 1 0 1 1 0
Odd Parity
P Dataword
1 1 0 1 0 0 1 1
0 1 1 1 0 1 1 0
5/20/2018 Data Link Layer
21/51
Simple parity-check code C(5, 4)
10.21
5/20/2018 Data Link Layer
22/51
10.22
Encoder and decoder for simple parity-check code
Si l P i h k
5/20/2018 Data Link Layer
23/51
What happens if the character 10010101 is
sent and the first two 0s accidentally becometwo 1s?
Thus, the following character is received:
11110101
Will there be a parity error?
Problem: Simple parity only detects odd numbers of
bits in error
Simple Parity check
T di i l i h k
5/20/2018 Data Link Layer
24/51
There are two types of 2D parity check
Longitudinal Redundancy Check (LRC)
Vertical Redundancy Check (VRC)
Longitudinal Redundancy Check (LRC)
Longitudinal parity adds a parity bit to each character
then adds a row of parity bits after a block of characters.
The row of parity bits is actually a parity bit for each
columnof characters
Two dimensional parity check
5/20/2018 Data Link Layer
25/51
T di i l it h k
5/20/2018 Data Link Layer
26/51
LRC and VRC
LRC and VRC are calculated using simple paritycheck method
The binary words being transmitted or received
organized in the form of rows and columns
VRC Parity bits are computed for each column
LRC Parity bits are computed for each row
Parity bits along with the data are sent to thereceiver
Two dimensional parity check
T di i l it h k
5/20/2018 Data Link Layer
27/51
If the data to be transmitted are 1100001, 1111001,1011001, 0000101, 0010101, 0010101, 1010001. find the
VRC, LRC and bytes to be transmitted
Coded Bytes: 11000011, 11110011, 10110010, 00001010, 00101011,00101011, 10100011, 00101011
Two dimensional parity check
BytesLRC
Bits
BIts
VRC Bits
1 1 1 0 0 0 1
1 1 0 0 0 0 0
0 1 1 0 1 1 1
0 1 1 0 0 0 0
0 0 0 1 1 1 0
0 0 0 0 0 0 01 1 1 1 1 1 1
0
0
1
0
1
01
1 1 0 0 1 1 1 1
T di i l it h k
5/20/2018 Data Link Layer
28/51
Both simple parity and 2D parity do not catchall errors.
Simple parity only catches odd numbers of biterrors (50% of all errors)
2D parity is better at catching errors butrequires too many check bits added to a blockof data.
As such, these methods are not that oftenused. However, a parity bit exists in 1 byte ofdata.
Two dimensional parity check
Additi Ch k
5/20/2018 Data Link Layer
29/51
It can be applied to a message of any length
It can be used to detect multiple errors
At the source, message is divided into m-bit units
At the sender, Generator creates an extra m-bit unitcalled checksum by adding the bits of data to betransmitted, which is sent with the message
At the receiver, checksum is again computed byadding the bits of received bytes
If the newly computed checksum is same as onetransmitted, then it implies no error
It is calculated by adding all the bytes bit-by-bit byneglecting the final carry (i.e out of MSB)
It can detect all odd numbers of errors and most ofthe even number of errors.
Additive Checksum
Additi Ch k
5/20/2018 Data Link Layer
30/51
Find the checksum byte for the fallowing
datawords: 10110011, 10101011, 01011010,11010101
Check sum byte: 10001101
Additive Checksum
1 0 1 1 0 0 1 1
1 0 1 0 1 0 1 1
0 1 0 1 1 0 1 0
Neglect Final
Carry1 1 0 1 0 1 0 1
1 1 0 0 0 1 1 0 1
C li R d d Ch k (CRC)
5/20/2018 Data Link Layer
31/51
Most widely and powerful error-detectingtechniques developed by IBM
Also referred to as Polynomial code, as it treatsthe bit stream to be transmitted as a polynomial
The coefficients are the 0 and 1 values in the bit
stringThe transmitter takes the Message polynomialM(x)
Using polynomial arithmetic, divides it by agiven Generator polynomial G(x)
MSB and LSB of the Generator polynomialshould be always 1
Cyclic Redundancy Check (CRC)
C li R d d Ch k (CRC)
5/20/2018 Data Link Layer
32/51
A m-bit frame is regarded as the coefficient list for apolynomial with mterms ranging from xm-1 to x0
The degree of the polynomial is m-1
Polynomial arithmetic is done in modulo-2
In modulo-2, there are no carries for addition or borrowsfor subtraction
Both addition and subtraction are identical to exclusiveOR operation
Sender and receiver must agree upon a generatorpolynomial, G(x), in advance
Degree of M(x) must be greater than degree of G(x)
Cyclic Redundancy Check (CRC)
C li R d d Ch k (CRC)
5/20/2018 Data Link Layer
33/51
mis the number of bits in the frame i.e.in M(x)
kis the degree of G(x)Algorithm for computing the checksum at the
sender
1. Append kbits to the LSB side of the data frame, so
it now contains m+k bits i.e xkM(x)
2. Divide the resultant polynomial xkM(x) by the
generator G(x) in modulo-2 arithmetic
3. After division, the remainder bits (i.e r-bits) calledredundant bits or CRCare added to the dividend to
form the code word (m+r bits)
4. Finally, this code word is transmitted
Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check (CRC)
5/20/2018 Data Link Layer
34/51
At the receivers end, the received codeword
of m+r bits is again divided by the samegenerator as used by the sender
If the remainder is non-zero, the receiver
know that the error has occurred and rejectthe data word
If the remainder is zero, the receiver knows
that there is no error and accept the data
word
Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check (CRC)
5/20/2018 Data Link Layer
35/51
Generate the CRC code for the message x3+1 using the
generator polynomial x3+x+1
M(x) = x3+1 in Binary =1001
G(x) = x3+x+1 in Binary = 1011
x3M(x) = x3(x3+1) = x6+x3= 1001000
Cyclic Redundancy Check (CRC)
1 0 1 1 1 0 0 1
1 0 1 1
0 1 0 0
0 0 0 0
1 0 0 01 0 1 1
0 1 1 0
0 0 0 0
1 1 0
1 0 1 0
DatawordCRC
(Remainder)
1 0 0 1 1 1 0
Codeword
1 0 0 1 1 1 0
Cyclic Redundancy Check (CRC)
5/20/2018 Data Link Layer
36/51
CRC computation at receiver
Cyclic Redundancy Check (CRC)
Cyclic Redundancy Check (CRC)
5/20/2018 Data Link Layer
37/51
Generate the CRC code for the dataword
1101011011 using generator 10011. Also write
both in the polynomial form.
Answer: CRC= 1110 codeword= 11010110111110
Cyclic Redundancy Check (CRC)
Standard polynomials
5/20/2018 Data Link Layer
38/51
Standard polynomials
10.38
Performance of CRC
5/20/2018 Data Link Layer
39/51
Performance of CRC
Error Correcting codes
5/20/2018 Data Link Layer
40/51
Once an error is detected, what is the receiver
going to do? Do nothing (simply toss the frame or packet)
Return an error message for retransmission
Fix the error with no further help from thetransmitter
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
41/51
Correct the errors
For a receiver to correct the error with nofurther help from the transmitter requires a
large amount of redundant information to
accompany the original data This redundant information allows the receiver to
determine the error and make corrections
This type of error control is often called
forward error correction(FEC) and involves
codes called Hamming codes
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
42/51
Hamming distance
Hamming distancebetween two codewords of equal length is
the number of positions at which the corresponding
codewords are different
Hamming distance between two codewords X and Y is
denoted as d(X, y)
Example:
It can be calculated by performing the XOR operation on the
codewords
The number of 1 in the result will give you Hamming distance
Error Correcting codes
X= 1 0 0 1 0 0 1 0
Y= 1 1 0 1 1 0 0 1
d X, Y) = 4
X= 1 0 0 1 0 0 1 0
Y= 1 1 0 1 1 0 0 1
XOR
0 1 0 0 1 0 1 1
d X, Y) = 4
Error Correcting codes
5/20/2018 Data Link Layer
43/51
Minimum hamming distance (dmin
)
It is the smallest of the hamming distances
calculated between each possible pair of codes
Possible to detect errors if the total number of
errors in the received codeword is less than dmin,
otherwise errors can not be corrected
Error detection and correction capabilities of any
coding technique largely depend on the dmin
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
44/51
mis the number of data bits in a frame
ris the number of redudant bitsNumber of bits in Codeword: n=m+r
In most data communication, all 2m possible data
messages are legal, but not all 2n code words are
used
Selection of r
2r>=m+r+1
For example: if m=7, the smallest value of r=424>=7+4+1
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
45/51
Hamming code
The basic idea is to insert parity bits in between the data bits
to be transmitted
Parity bits are placed at each 2t bit positions where
t=0,1,2,3,,,,,
20= 1 at first position
21= 2 at second position 22= 4 at fourth position and so on
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
46/51
Number of redundancy bits needed
Let data bits = m
Redundancy bits =r
Total message sent =m+r
The value of r must satisfy the following relation:
2r m+r+1
Example: if m=4, 3 parity bits are required to
satisfy the condition
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
47/51
Value of r bits set to 1 or 0 to make an even parity
r1= 1, 3, 5, 7, 9, 11, , , , , ,
r2=2,3, 6, 7, 10, 11, , , , , r4 = 4, 5, 6, 7, 12, 13, 14, 15, , , , ,
r8 = 8,9,10,11,12,13,14,15, , , , ,
and so on
Ex-OR the bits to get redundancy bits/ parity bits
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
48/51
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
49/51
Single bit errors
Error Correcting codes
Error Correcting codes
5/20/2018 Data Link Layer
50/51
Error Detection
The code being received is 10010100101. find the error bit
Error Correcting codes
5/20/2018 Data Link Layer
51/51
Note :Error correcting capability
To detect d errors in the codeword
dmin d+1
To correct d errors in the code word
dmin 2d+1