You are on page 1of 57

The Data Link Layer

Md Iftekhar Hussain
Assoc. Prof., Dept. of Information Technology
North-Eastern Hill University

Data Link Layer Design Issues

Services Provided to the Network Layer


Framing
Error Control
Flow Control

Functions of the Data Link Layer

Provide service interface to the network layer


Dealing with transmission errors
Regulating data flow

Slow receivers not swamped by fast senders

Functions of the Data Link Layer (2)

Relationship between packets and frames.

Services Provided to Network Layer

(a) Virtual communication.


(b) Actual communication.

Types of DLL Services


Unacknowledged Connectionless Service
Acknowledged Connection-oriented Service
Acknowledged Connectionless Service

Services Provided to Network Layer


(2)

Placement of the data link protocol.

Framing

A character stream. (a) Without errors. (b) With one error.

Framing (2)

(a) A frame delimited by flag bytes.


(b) Four examples of byte sequences before and after stuffing.

Framing (3)

Bit stuffing
(a) The original data.
(b) The data as they appear on the line.
(c) The data as they are stored in receivers memory after destuffing.

Error Detection and Correction


Error-Correcting Codes
Error-Detecting Codes
Detect and correct errors if there is
any.
Use of ACK and timers.

Fundamentals
A frame consists of m data bits and r redundant or check bits
Total size, n = m + r
This is referred to as n-bit codeword

Error-Correcting Codes
Include enough redundant information along with the block of data sent ,
to
enable the receiver to deduce what the transmitted data must have been.

Hamming Distance
Given two codewords, 10001001 and 10110001
It is possible to determine how many corresponding bits differ.
10001001
10110001
--The Hamming Distance, d= 3(The no. of bit position in which the codewords differ)
Method:
Just EX-OR the two codewords
Count the no. of 1s in the result

Error-Correcting Codes

Use of a Hamming code to correct burst errors.

Error-Detecting Codes
Include enough redundancy to allow the receiver to deduce that an error
occurred, not which error.
widely used in error prone links like wireless networks
Parity bit checking can detect only 50% of the errors

Cyclic Redundancy Check(CRC) or polynomial code


Bit strings are represented by polynomials with coefficients of 0 & 1 only.
A k-bit frame is regarded as the coefficient list for a polynomials with k terms,
ranging from xk-1 to x0
Ex. A bit string 110001 is represented by a polynomial

X5+x4+x0

Polynomial arithmetic is done in modulo 2 operation(No borrow or carry so like EXOR)


The sender and the receiver must agree upon a generator polynomial, G(x) in
advance.
Both the high and low order bit of the generator must be 1

Cyclic Redundancy Check(CRC) or polynomial code


Let r be the degree of G(x). Append r zero bits to the lower-order end of the
frame so it now contains m + r bits and corresponds t the polynomial xr M(x)
Divide the bit string corresponding to xrM(x) by the bit string corresponding to
G(x), using modulo 2 division
Subtract the remainder from the bit string corresponding to xr M(x) using modulo
2 subtraction. The result is the check summed frame to be transmitted. Call its
polynomial T(x)

Error-Detecting Codes

Calculation of the polynomial code checksum.

Analysis
Say the transmitted stream is T(x)
the Error introduced is E(x)
So, the received frame is T(x) + E(x)
The receiver will divide the received frame by G(x)
[T(x) + E(x)] / G(x) = 0 if no error or not detected
else detected
After occurring error if the transmitted frame is divisible by G(x), such errors are
not detectable

Flow Control
Feed back based flow control
The receiver gives permisson to sender for sending
Rate based flow control

Elementary Data Link Protocols

An Unrestricted Simplex Protocol


A Simplex Stop-and-Wait Protocol
A Simplex Protocol for a Noisy Channel

Protocol Definitions

Continued

Some definitions needed in the protocols to follow.


These are located in the file protocol.h.

Protocol
Definitions
(ctd.)

Some definitions
needed in the
protocols to follow.
These are located in
the file protocol.h.

Unrestricted
Simplex
Protocol

Simplex
Stop-andWait
Protocol

A Simplex Protocol for a Noisy Channel

A positive
acknowledgement
with retransmission
protocol.
Continued

A Simplex Protocol for a Noisy Channel (ctd.)

A positive acknowledgement with retransmission protocol.

Sliding Window Protocols


A One-Bit Sliding Window Protocol
A Protocol Using Go Back N
A Protocol Using Selective Repeat

Sliding Window Protocols (2)

A sliding window of size 1, with a 3-bit sequence number.


(a) Initially.
(b) After the first frame has been sent.
(c) After the first frame has been received.
(d) After the first acknowledgement has been received.

A One-Bit Sliding Window Protocol

Continued

A One-Bit Sliding Window Protocol (ctd.)

A One-Bit Sliding Window Protocol (2)

Two scenarios for protocol 4. (a) Normal case. (b) Abnormal


case. The notation is (seq, ack, packet number). An asterisk
indicates where a network layer accepts a packet.

A Protocol Using Go Back N

Pipelining and error recovery. Effect on an error when


(a) Receivers window size is 1.
(b) Receivers window size is large.

Sliding
Window
Protocol
Using Go
Back N

Continued

Sliding Window Protocol Using Go Back N

Continued

Sliding Window Protocol Using Go Back N

Continued

Sliding Window Protocol Using Go Back N

A Sliding Window Protocol Using Selective Repeat

Continued

A Sliding Window Protocol Using Selective Repeat (2)

Continued

A Sliding Window Protocol Using Selective Repeat (3)

Continued

A Sliding Window Protocol Using Selective Repeat (4)

A Sliding Window Protocol Using Selective Repeat (5)

(a) Initial situation with a window size seven.


(b) After seven frames sent and received, but not acknowledged.
(c) Initial situation with a window size of four.
(d) After four frames sent and received, but not acknowledged.

Protocol Verification
Finite State Machined Models
Petri Net Models

Finite State Machined Models

(a) State diagram for protocol 3. (b) Transmissions.

Petri Net Models

A Petri net with two places and two transitions.

Petri Net Models (2)

A Petri net model for protocol 3.

Example Data Link Protocols


HDLC High-Level Data Link Control
The Data Link Layer in the Internet

High-Level Data Link Control


Bit Oriented Protocol and use bit staffing for data transparency

Frame format for bit-oriented protocols.


The Control field is used for sequence no., Ack etc.
Data field may contain any information and may be arbitrarily long.
The Checksum field is a cyclic redundancy code
The frame is delimited with a flag sequence 01111110.
The minimum frame contains three fields (Add, Control, Checksum) and is of
32 bits

High-Level Data Link Control (2)


There are three kinds of frames: Information, Supervisory and Unnumbered
The protocol uses a sliding window with a 3-bit sequence no.
The next field is a piggyback acknowledgement
The Poll/Final bit is used when a computer is polling a group of terminals. When
used as P, the computer is inviting the terminal to send data. All the frames sent by
the terminal, except the final one, have the P/F bit set to P. The final one is set to F.
The various kinds of supervisory frames are distinguished by the Type field.
Type 0--------- Ack frame(indicates next frame expected)[ This is used when
no piggybacking is possible]
Type 1--------- is a negative Ack frame[ used to indicate that a transmission
error has been detected.] The seq. no. gives the first frame no. not received
correctly.

Type 2---- Receive not Ready( It acknowledges all frames up to but not including
next ). It tells the sender to stop sending.
Type 3------ Selective Reject( It calls for retransmission of only the frame specified.
Unnumbered Frame:
It is sometimes used for control purposes but also carry data when unreliable
connectionless service is called for.

High-Level Data Link Control (3)

Control field of
(a) An information frame.
(b) A supervisory frame.
(c) An unnumbered frame.

High-Level Data Link Control (4)


Some Additional Commands:
Command

Description

DISC(DISConnect)

It allows a machine to announce


that it is going down

SNRM(Set Normal
Response Mode)

Allows a machine to announce that


it has just come back online and is
present

Forces all seq. nos. back to


0.

FRMR(FRaMe
Reject)

Used to indicate that a frame with a


correct checksum but impossible
semantics arrived.

Ex. A frame outside the


window

UA(Unnumbered
Ack)

Acknowledges control frames

The Data Link Layer in the Internet

A home personal computer acting as an internet host.

PPP Point to Point Protocol


Deals with Router-Router and home user-to-ISP traffic.
PPP features:
1. Frame format (start and end delimiter, also handles error detection)
2. A link control protocol for bringing lines up, testing them, negotiating
options and bringing them down again gracefully when they are no
longer needed.
3. A way to negotiate network layer options in a way that is independent of
the network layer protocol to be used.

Indicates that all stations


are to accept the frame

Indicates an unnumbered
frame; unreliable , Unack
frame

What Packet is there in


the payload field. Ex.
NCP, IP,IPX, AppleTalk etc

The PPP full frame format for unnumbered mode operation.

PPP Point to Point Protocol (2)

A simplified phase diagram for bring a line up and down.

PPP Point to Point Protocol (3)

The LCP frame types.

You might also like