You are on page 1of 94

Chapter 3

The Data Link Layer


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.
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 receiver’s memory after destuffing.
Error Detection and Correction

• Error-Correcting Codes
• Error-Detecting Codes
Data can be corrupted
during transmission.

Some applications require that


errors be detected and corrected.
TYPES OF ERRORS
In a single-bit error, only 1 bit in the data
unit has changed.
Single-bit error
Multiple-bit error
A burst error means that 2 or more bits
in the data unit have changed.
Burst error of length 8
Redundancy

To detect or correct errors, we need to


send extra (redundant) bits with data.
Process of error detection in block coding
An error-detecting code can detect
only the types of errors for which it is
designed; other types of errors may
remain undetected.
Structure of encoder and decoder in error
correction
VRC
LRC
VRC and LRC
Two-dimensional parity-check code
Two-dimensional parity-check code
Two-dimensional parity-check code
CRC

A CRC code with


C(7, 4)
CRC
Division in CRC encoder
Error-Detecting Codes
Division in the CRC decoder for two cases
A polynomial to represent a binary word
CRC division using polynomials
a) The divisor in a cyclic code is normally called the
generator polynomial
b) or simply the generator.

A good polynomial generator needs to have


the following characteristics:
1. It should have at least two terms.
2. The coefficient of the term x0 should
be 1.
3. It should not divide xt + 1, for t
between 2 and n − 1.
4. It should have the factor x + 1.
Standard Polynomials
Checksum
a) Sender site:
Receiver site:
b) 1. The message is divided into 16-bit
words. 1. The message (including checksum)
c) 2. The value of the checksum word is is divided into 16-bit words.
set to 0.
d) 3. All words including the checksum 2. All words are added using one’s
are added using one’s complement complement addition.
addition.
e) 4. The sum is complemented and 3. The sum is complemented and
becomes the becomes the new checksum.
checksum.
f) 5. The checksum is sent with the data. 4. If the value of checksum is 0, the
message is accepted; otherwise, it is
rejected.
Checksum
Data Unit and Checksum
Error Correction
Hamming Code
Hamming Code
Hamming Code
Example of Hamming Code
Single-bit error
Error
Detection
Burst error correction using Hamming
code
Error-Correcting Codes

Use of a Hamming code to correct burst errors.


Elementary Data Link Protocols

• An Unrestricted Simplex Protocol


• A Simplex Stop-and-Wait Protocol
• A Simplex Protocol for a Noisy Channel
The design of the simplest protocol with
no flow or error control
Sender-site algorithm for the simplest
protocol
Receiver-site algorithm for the simplest
protocol
Flow diagram
Design of Stop-and-Wait Protocol
Sender-site algorithm for Stop-and-Wait
Protocol
Receiver-site algorithm for Stop-and-Wait
Protocol
Flow diagram
NOISY CHANNELS
Stop-and-Wait Automatic Repeat Request
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request
Stop-and-Wait ARQ
Error correction in Stop-and-Wait ARQ is done by keeping a
copy of the sent frame and retransmitting of the frame
when the timer expires.

In Stop-and-Wait ARQ, we use sequence numbers to number the


frames.
The sequence numbers are based on modulo-2 arithmetic.

In Stop-and-Wait ARQ, the acknowledgment number always


announces in modulo-2 arithmetic the sequence number of the
next frame expected.
Design of the Stop-and-Wait ARQ
Protocol
Sender-site algorithm for Stop-and-Wait
ARQ

(continued)
Sender-site algorithm for Stop-and-Wait
ARQ (continued)
Receiver-site algorithm for Stop-and-Wait
ARQ Protocol
Flow diagram
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 (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) In the Go-Back-N Protocol, the sequence numbers are modulo
2m,
b) where m is the size of the sequence number field in bits.
Send window for Go-Back-N ARQ
The send window is an abstract concept defining an imaginary box of size
2m − 1 with three variables: Sf, Sn, and S size.

The send window can slide one


or more slots when a valid acknowledgment arrives .
Receive window for Go-Back-N ARQ
a) The receive window is an abstract concept defining an
imaginary box of size 1 with one single variable Rn.
The window slides when a correct frame has arrived; sliding
occurs one slot at a time.
Design of Go-Back-N ARQ
Window size for Go-Back-N ARQ

In Go-Back-N ARQ, the size of the send window must be less


than 2m;
the size of the receiver window
is always 1.
Go-Back-N sender algorithm
Go-Back-N sender algorithm (Continued)
Go-Back-N receiver algorithm
Flow diagram
Flow diagram
Stop-and-Wait ARQ is a special case of Go-Back-N ARQ in which
the size of the send window is 1.
Send window for Selective Repeat ARQ
Receive window for Selective Repeat ARQ
Design of Selective Repeat ARQ
Selective Repeat ARQ, window size

In Selective Repeat ARQ, the size of the sender and


receiver window
must be at most one-half of 2m.
Sender-site Selective Repeat algorithm
Sender-site Selective Repeat algorithm
(Continued)
Sender-site Selective Repeat algorithm
(Continued)
Receiver-site Selective Repeat algorithm
Receiver-site Selective Repeat algorithm
(Continued)
Delivery of data in Selective Repeat ARQ
Flow diagram
Design of piggybacking in Go-Back-N
ARQ

You might also like