You are on page 1of 47

Data Link Layer

Data Link Layer


 They are two types
1. Logical link control layer
2. Medium access sub layer

In this you will learned about the logical link control layer they are
• Design issues
• Error detection and correction
• Elementary data link protocols
• Sliding window protocols
• Flow control
• Error control
• Framing
Data Link Layer Design Issue

• 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
Relationship between packets and frames

• It takes the packets it gets from the network layer and encapsulate them into
frames for transmission.
Services Provided to the Network Layer
• (a) Virtual communication. (b) Actual communication
Services Provided to the Network Layer
• Unacknowledged connectionless service.
• Acknowledged connectionless service.
• Acknowledged connection-oriented service.
Framing
• Character count.
• Flag bytes with byte stuffing.
• Starting and ending flags, with bit stuffing.
• Physical layer coding violations.
Framing
• A character stream
(a) Without errors. (b) With one error
Framing
• (a)A frame delimited by flag bytes.
• (b)Four examples of byte sequences before and after stuffing.
Framing
• Bit stuffing
• (a) The original data.
• (b) The data as they appear on the line.
• (c) The data as they are stored in receiver’s memory after de stuffing
Framing
• Physical Layer Coding Violations
• Used only when physical medium contains some redundancy
• 10: high-low
• 01: low-high
Error Control
• Acknowledged
• Error free data
Types Of Errors
• Error means (01 ,10)
• Single Bit Error (10100--->11100)
• Multiple Bit Error (10100--->11101)
• Burst Error(10100---> 11011)
Error Detection and Correction
• Error-Correcting Codes
• Error-Detecting Codes
Error Detection and Correction
• Error-Correcting Codes: Include enough redundant information along with each
block of data sent, to enable the receiver to deduce what the transmitted data
must have been.
• The use of error-correcting code is often referred to as forward-error-correction.
• Error-Detecting Codes: include only enough redundancy to allow the receiver to
deduce that an error has occurred, but not which error, and have it request a
retransmission.
Error Detection and Correction
• On channels that are highly reliable such as Fiber, it is cheaper to use an error
detecting code.
• On channels such as wireless links that make many errors it is better to use Error
correcting Codes. Because retransmission may be an error .
• A frame consists of m-bits data (message) and r-bits redundant or check bits.
• Total length is m+r=n.
• n-bit containing data and check bits is often referred to as an n-bit Code word
Error Detecting Methods
1. Parity (even parity, odd parity) (Single Bit Error)
2. CRC (Burst Error)
3. Checksum
Parity Checking
• Parity One additional bit added to original data.
• Count the no’s of 1’s Should be even - Even Parity (0)
• If the no’s of 1’s is odd - Odd Parity(1)

Ex :10100 -> 101000 ---> 101000 Even Parity


---> 111000 Odd Parity
Ex:10101->101011 ---> 101011 Even Parity
---> 100011 Odd Parity
Parity Checking
Ex:101011->100111 Even Parity
Error Detecting Methods
• Code word (n=m+r)
• ExclusiveOR
• The number of bit positions in which two code words differ is called the
Hamming distance.
• If two code words are at a Hamming distance d apart, it will require d single bit
errors to convert one into the other.
Error Detecting Methods
• CRC (Cyclic Redundancy Check) : Polynomial Codes are based upon treating bit
strings as representations of polynomials with coefficients of 0 and 1 only.
• A k-bit frame is represented as the coefficient list for a polynomial with k-terms
ranging from xk-1 to x0 .
• Such a polynomial is said to be of degree k-1.
• The high order (left most) bit is the coefficient of xk-1.
• The next bit is the coefficient of xk-2, and so on..
• For ex: the polynomial x5 + x4 + 1 , results to the polynomial x5 + x4 + x0
• And the bits generated are : 110001.
Error Detecting Methods
• When the polynomial code method is employed, the sender and receiver must
agree upon a generator polynomial, G(X) in advance.
• Both the high and low order bits of the generator must be 1.
• To compute the checksum for some frame with m-bits, corresponding to the
polynomial M(x), the frame must be longer than the generator polynomial.
CRC (Cyclic Redundancy Check)
• According to the rules of algebraic field theory , there are no carries for addition
or borrows for subtraction. Both addition and subtraction are identical to
exclusive OR.
• The idea is to append a checksum to the end of the frame in such a way that the
polynomial represented by the checksummed frame is divisible by G(x).
• When the receiver gets the checksummed frame , it tries dividing it by G(x).
• If there is a remainder, there has been a transmission error.
CRC (Cyclic Redundancy Check)
• The algorithm for computing the checksum is as follows:
1. Let r be the degree of G(x). Append r zero bits to the low-order end of the frame
so that it contains m+r bits and corresponds to the polynomial xr .M(x)
2. divide the bit string corresponding to G(x) into the bit string corresponding to
xr .M(x) , using modulo 2 division.
3. Append the remainder (which is always r or fewer bits) from the bit string
corresponding to xr .M(x) using modulo 2 subtraction. The result is the
checksummed frame to be transmitted. Call its polynomial T(x).
• Calculation for a frame 1101011011 using the generator G(x)= x4 + x + 1
Error-Detecting Codes
Calculation of the polynomial code checksum
CRC (Cyclic Redundancy Check)
• Upon receiving the checksummed T(x) frame,
• The receiver divides it by G(x).
• If T(x)/G(x) is “0” there is no errors in the transmission.
• If there is any remainder it indicates that there is an error.
Error Correcting Method
• Hamming Code Method
• If we want to design a code with m message bits & r check bits that will allow
• All single bit errors to be corrected.
• Each of the 2m legal messages has n illegal codewords at a distance 1 from it.
• These are formed by systematically inverting each of the n bits in the n-bit
codeword formed from it.
Error Correcting Method
• Thus each of the 2m legal messages requires n+1 bit patterns dedicated to it.
• Since the total number of bit patterns is 2m , we must have (n+1) 2m <= 2n .
• Using n=m+r,
• This requirement becomes (m+r+1) <= 2r.
• Given m, this r puts a lower limit on the number of check bits needed to correct
single errors.
Protocols

Protocols

Noiseless
Noisy

1.Simplex Stop and wait ARQ 1.Go Back N ARQ


2.Stop and Wait 2.Selective Repeat Request ARQ
3.Onre Bit Sliding Window Protocol
Elementary Data Link Protocols
• An Unrestricted Simplex Protocol
• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
An Unrestricted Simplex Protocol
• Data are transmitted in one direction only
• The transmitting and receiving hosts are always ready.
• Processing time can be ignored
• No errors occur; i.e. no damaged frames and no lost frames (perfect channel)
An Unrestricted Simplex Protocol
A Simplex Stop-and-Wait Protocol
• In this protocol we assume that Data are transmitted in one direction only
• No errors occur (perfect channel) .
• These assumptions imply that the transmitter cannot send frames at a rate faster than the
receiver can process them.
• Sender
• The sender sends one frame
• Waits for feedback from the receiver.
• When the ACK arrives, the sender sends the next frame.
• Receiver
• Receive frame
• After receiving frame send ACK to sender.
A Simplex Stop-and-Wait Protocol
Stop-and-Wait Protocol
Disadvantages
1.Lost Data
• Sender waits for ACK
• Receiver waits for data
2.Lost ACK
• Sender waits for ACK
A Simplex Protocol for a Noisy Channel
• Sender put a sequence number in the header of each frame it sends.
• The receiver then can check the sequence number of each arriving frame to see if
it is a new frame or a duplicate to be discarded.
• The receiver needs to distinguish only 2 possibilities: a new frame or a duplicate;
a 1-bit sequence number is sufficient. At any instant the receiver expects a
particular sequence number. Any wrong sequence numbered frame arriving at
the receiver is rejected as a duplicate. A correctly numbered frame arriving at the
receiver is accepted, passed to the host.
A Simplex Protocol for a Noisy Channel
• After transmitting a frame and starting the timer, the sender waits for something
exciting to happen.
• Only three possibilities exist: an acknowledgement frame arrives undamaged, a
damaged acknowledgement frame staggers in, or the timer expires.
• If a valid acknowledgement comes in, the sender fetches the next packet from its
network layer and puts it in the buffer, overwriting the previous packet. It also advances
the sequence number. If a damaged frame arrives or no frame at all arrives, neither the
buffer nor the sequence number is changed so that a duplicate can be sent.
• When a valid frame arrives at the receiver, its sequence number is checked to see if it is
a duplicate. If not, it is accepted, passed to the network layer, and an acknowledgement
is generated. Duplicates and damaged frames are not passed to the network layer.
A Simplex Protocol for a Noisy Channel
Stop and Wait ARQ
1.After transmitting one frame sender waits for an ACK.
2.If ACK not received after certain period of time ,sender retransmits
the frame.
3.Stop and wait +Time out Timer +Sequences number
4.Only one frame at a time
5.Bandwidth usage is less
Stop and Wait ARQ
• Case (i) ACK Lost
• Case(ii) Data Lost
• Case(iii) TimeOut
Sliding Window Protocol
• Sender can send multiple frames at a time
• The number of frames to be send depends upon size of the window.
• Frames are numbered in sequences
Sliding Window Protocol
Go Back N ARQ
• Sender Window Size is ‘n’.
• Receiver Window Size is 1.
• Sender can send multiple frames before receiving the acknowledgement for the
first frame.
• The number of frames to be send depends upon size of the window.
• Frames are numbered in sequences
• If acknowledgement of a frame not received with in an agreed upon time, all the
frames in the current window are retransmitted.
Go Back N ARQ
Selective Repeat ARQ
• In this ,only the erroneous or lost frames are retransmitted , while correct frames
are received.
• Receiver while keeping track of sequence numbers, and send NACK for only
frame which is missing or damaged.
• Sender will retransmits the frames for which NACK is received.
Selective Repeat ARQ

You might also like