The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
THE DATA LINK LAYER 
Muhammad Adil Raja 
Roaming Researchers, Inc. 
August 25, 2014
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
OUTLINE 
1 INTRODUCTION 
2 DATA LINK LAYER DESIGN ISSUES 
3 ERROR DETECTION AND CORRECTION 
4 ELEMENTARY DATA LINK PROTOCOLS 
5 SLIDING WINDOW PROTOCOLS 
6 EXAMPLE DATA LINK PROTOCOLS 
7 CONCLUSIONS
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
INTRODUCTION I 
The goal is to study the design principles for the data 
link layer. 
To study the algorithms for achieving reliable, efficient 
communication of whole units of information. 
To understand communication with frames as opposed 
to bits.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
DATA LINK LAYER DESIGN ISSUES I 
The data link layer uses the services of the physical layer to 
send and receive bits over communication channels. It has 
a number of functions, including: 
1 Providing a well-defined service interface to the 
network layer. 
2 Dealing with transmission errors. 
3 Regulating the flow of data so that slow receivers are 
not swamped by fast senders. 
To accomplish these goals, the data link layer takes the 
packets it gets from the network layer and encapsulates 
them into frames for transmission. 
Each frame contains a frame header. 
And a payload field for holding the packet.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
2. Dealing with transmission errors. 
3. Regulating the flow of data so that slow receivers are not swamped 
DATA LINK LAYER DESIGN ISSUES II 
by fast senders. 
To accomplish these goals, the data link layer takes the packets it gets from the 
network layer And and a frame encapsulates trailer. 
them into frames for transmission. Each frame 
contains a frame header, a payload field for holding the packet, and a frame 
trailer, as Frame illustrated management in Fig. 3-1. Frame forms management the heart forms of the the functionality 
heart of what the 
data link of layer the does. data In link the layer. 
following sections we will examine all the above-mentioned 
issues in detail. 
Header Payload field Trailer 
Frame 
Sending machine 
Receiving machine 
Packet Packet 
Header Payload field Trailer 
Figure 3-1. Relationship between packets and frames. 
FIGURE: Relationship between packets and frames. 
Although this chapter is explicitly about the data link layer and its protocols, 
many of the principles we will study here, such as error control and flow control, 
are found in transport and other protocols as well. That is because reliability is an
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER I 
The function of the data link layer is to provide services 
to the network layer. 
The rincipal service is transfering data from the network 
layer on the source machine to the network layer on the 
destination machine. 
On the source machine is an entity, call it a process or 
a program, in the network layer that hands some bits to 
the data link layer for transmission to the destination. 
The job of the data link layer is to transmit the bits to 
the destination machine so they can be handed over to 
the network layer (of the destination machine).
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
transmit the bits to the destination machine so they can be handed over to the net-work 
layer there, as shown in Fig. 3-2(a). The actual transmission follows the 
SERVICES PROVIDED TO THE NETWORK LAYER 
II 
path of Fig. 3-2(b), but it is easier to think in terms of two data link layer proc-esses 
communicating using a data link protocol. For this reason, we will impli-citly 
use the model of Fig. 3-2(a) throughout this chapter. 
4 
3 
2 
1 
4 
3 
2 
1 
4 
3 
2 
1 
4 
3 
2 
1 
Host 1 Host 2 Host 1 Host 2 
Virtual 
data path 
Actual 
data path 
(a) (b) 
Figure 3-2. (a) Virtual communication. (b) Actual communication. 
FIGURE: (a) Virtual Communication. (b) Actual communication. 
The data link layer can be designed to offer various services. The actual ser-vices
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER 
III 
The data link layer can be designed to offer various 
services. 
The actual services that are offered vary from protocol 
to protocol. 
The reasonable possibilities are: 
1 Unacknowledged connectionless service. 
2 Acknowledged connectionless service. 
3 Acknowledged connection-oriented service. 
Unacknowledged connectionless service consists of 
having the source machine send independent frames to 
the destination machine without having the destination 
machine acknowledge them. 
Ethernet is a good example that provides this service. 
No logical connection is established beforehand or 
released afterward.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER 
IV 
If a frame is lost due to noise on the line, no attempt is 
made to detect the loss or recover from it in the data 
link layer. 
This class of service is appropriate when the error rate 
is low. 
The recovery is left to the higher layers. 
It is also appropriate for real-time traffic, such as voice. 
Or for other service in late data is worse than bad data. 
In an acknowledged connectionless service there 
are still no logical connections. 
However, each frame sent is individually acknowledged. 
The sender knows that whether a frame has been 
arrived correctly or has been lost.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER 
V 
If it does not arrive within a certain time interval, it can 
be sent again. 
The service is useful over unreliable channels, such as 
wireless systems. 
IEEE 802.11 is a good example of this class of service. 
Providing acknowledgements in the data link layer is a 
good thing, but not a requirement. 
The network layer can always send a packet and wait 
for it to be acknowledged by its peer on the remote 
machine. 
If the acknowledgement does not arrive within a certain 
interval of time, the sender can send the message 
again. 
This strategy can be inefficient.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER 
VI 
Links usually have a strict maximum frame length 
imposed by the hardware, and known propagation 
delays. 
The network layer does not know these things. 
The network layer might send a large packet that is 
broken up into, say, 10 frames, of which 2 are lost on 
average. 
It would then take a very long time for the packet to get 
through. 
On the other hand, if individual frames are 
acknowledged and retransmitted, then errors can be 
corrected more directly and more quickly. 
On reliable channels, such as fiber, the overhead of a 
heavyweight data link protocol may be unnecessary.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER 
VII 
However, it might be very useful on wireless channels 
which are inherently unreliable. 
Providing a connection oriented service is the most 
reliable thing the data link layer can do. 
The source and destination machines establish a 
connection before any data are transferred. 
Each frame sent over the connection is numbered. 
Moreover, the data link layer ensures that each frame 
sent is indeed received. 
Moreover, it guarantees that each frame is received 
exactly once. 
And that all the frames are received in the right order. 
Transfers go through three phases in a connection 
oriented scheme:
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SERVICES PROVIDED TO THE NETWORK LAYER 
VIII 
1 Connection establishment. 
2 Frame transmission. 
3 Connection release.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
FRAMING I 
The data link layer uses the services of the physical 
layer. 
The physical layer accepts a raw bitstream and tries to 
deliver it to the destination. 
Physical layer tries to handle noise and transmission 
errors. 
There is no guarantee for error-free deliveries. 
The data link layer has to correct the errors. 
The usual way is to break up the bit stream into frames. 
The data link layer computes the checksums. 
Upon arrival of a frame the checksum is recomputed.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
FRAMING II 
A few strategies for framing: 
1 Byte count. 
2 Flag bytes with byte stuffing. 
3 Flag bits with bit stuffing. 
4 Physical layer coding violations.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
FRAMING III 
198 THE DATA LINK LAYER CHAP. 3 
Byte count One byte 
5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3 
(a) 
5 1 2 3 4 7 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3 
(b) 
Error 
Frame 1 
5 bytes 
Frame 1 
Frame 2 
5 bytes 
Frame 2 
(Wrong) 
Frame 3 
8 bytes 
Frame 4 
8 bytes 
Now a byte 
count 
Figure 3-3. A byte stream. (a)Without errors. (b)With one error. 
FIGURE: A byte stream. (a) Without errors. (b) With one error. 
The second framing method gets around the problem of resynchronization 
after an error by having each frame start and end with special bytes. Often the 
same byte, called a flag byte, is used as both the starting and ending delimiter. 
This byte is shown in Fig. 3-4(a) as FLAG. Two consecutive flag bytes indicate 
the end of one frame and the start of the next. Thus, if the receiver ever loses syn-chronization
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
FRAMING IV 
SEC. 3.1 DATA LINK LAYER DESIGN ISSUES 199 
FLAG Header Payload field Trailer FLAG 
Original bytes After stuffing 
A ESC FLAG B 
A ESC ESC B 
A ESC ESC ESC FLAG B 
A ESC ESC ESC ESC B 
A FLAG B 
A ESC B 
A ESC FLAG B 
A ESC ESC B 
(a) 
(b) 
Figure 3-4. (a) A frame delimited by flag bytes. (b) Four examples of byte se-quences 
before and after byte stuffing. 
The third method of delimiting the bit stream gets around a disadvantage of 
byte stuffing, which is that it is tied to the use of 8-bit bytes. Framing can be also 
be done at the bit level, so frames can contain an arbitrary number of bits made up 
of units of any size. It was developed for the once very popular HDLC (High-level 
Data Link Control) protocol. Each frame begins and ends with a special 
bit pattern, 01111110 or 0x7E in hexadecimal. This pattern is a flag byte. When-ever 
the sender’s data link layer encounters five consecutive 1s in the data, it 
FIGURE: (a) A frame delimited by flag bytes. (b) Four examples of 
byte sequences before and after byte stuffing.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
FRAMING V 
200 THE DATA LINK LAYER CHAP. 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 
0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 0 
Stuffed bits 
(a) 
(b) 
(c) 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 
Figure 3-5. Bit stuffing. (a) The original data. (b) The data as they appear on 
the line. (c) The data as they are stored in the receiver’s memory after destuf-fing. 
FIGURE: (Bit stuffing. (a) The original data. (b) The data as they 
appear on the line. (c) The data as they are stored in the 
receiver’s memory after destuffing. 
With both bit and byte stuffing, a side effect is that the length of a frame depends on the contents of the data it carries. For instance, if there are no bytes in the data, 100 bytes might be carried in a frame of roughly 100 bytes. however, the data consists solely of flag bytes, each flag byte will be escaped the frame will become roughly 200 bytes long. With bit stuffing, the increase
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ERROR CONTROL I 
How to make sure all frames are eventually delivered to 
the network layer at the destination and in the proper 
order. 
Use of acknowledgements, retransmissions, timers and 
sequence numbers.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
FLOW CONTROL I 
Sender transmitting faster than the receiver accepting. 
Feedback based flow control. 
Rate based flow control.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ERROR DETECTION AND CORRECTION I 
For wireless and very old networks error rates can be 
high. 
Network designers add redundant data to deal with 
errors. 
Error Correcting Codes: Help in figuring out the 
specific error that has occurred. 
Error Detecting Codes: Help in figuring out if some 
error has occurred or not. 
The use of error correcting codes is often referred to as 
FEC (Forward Error Correction). 
For reliable channels error detecting codes are 
normally employed. 
For noisy channels, error correcting codes are used.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ERROR DETECTION AND CORRECTION II 
Error correcting codes are also implemented in physical 
layer. 
Applied mathematics: Galois fields, properties of 
sparse matrices.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ERROR-CORRECTING CODES I 
Four different error-correcting codes: 
1 Hamming codes. 
2 Binary convolutional codes. 
3 Reed-Solomon codes. 
4 Low-Density Parity Check codes. 
All of these codes add redundancy to the information 
that is sent. 
A frame consists of m data (i.e. message) bits and r 
redundant (i.e. check) bits. 
In a block code, the r check bits are computed solely 
as a function of the m data bits with which they are 
associated.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ERROR-CORRECTING CODES II 
It is as if the m bits were looked up in a large table to 
find their corresponding r check bits. 
In a systematic code, the m bits are sent directly, 
along with the check bits, rather than being encoded 
themselves before they are sent. 
In a linear code. the r check bits are computed as a 
linear function of the m data bits. 
XOR or modulo 2 addition is a popular choice. 
This means that encoding can be done with operations 
such as matrix multiplications or simple logic circuits.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ERROR-DETECTING CODES I 
They are used for reliable channels. 
Linear systematic block codes: 
1 Parity. 
2 Checksums. 
3 Cyclic redundancy checks (CRCs). 
Fletcher’s checksum. 
CRC (Cyclic redundancy check). 
Polynomial code.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
ELEMENTARY DATA LINK PROTOCOLS I 
A Utopian Simplex Protocol. 
A Simplex Stop-and-Wait Protocol for an Error-Free 
Channel. 
A Simplex Stop-and-Wait Protocol for a Noisy Channel.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
SLIDING WINDOW PROTOCOLS I 
A One-Bit Sliding Window Protocol. 
A Protocol Using Go-Back-N. 
A Protocol Using Selective Repeat.
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
EXAMPLE DATA LINK PROTOCOLS I 
Packet over SONET. 
ADSL (Assymetric Digital Subscriber Loop).
The Data 
Link Layer 
Muhammad 
Adil Raja 
Introduction 
Data Link 
Layer Design 
Issues 
Error 
Detection 
and 
Correction 
Elementary 
Data Link 
Protocols 
Sliding 
Window 
Protocols 
Example 
Data Link 
Protocols 
Conclusions 
REFERENCES 
The inspiration and figures for these slides have been taken 
from, Computer Networks, Andrew S. Tanenbaum, 5th 
Edition.

The Data Link Layer

  • 1.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions THE DATA LINK LAYER Muhammad Adil Raja Roaming Researchers, Inc. August 25, 2014
  • 2.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 3.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 4.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 5.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 6.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 7.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 8.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions OUTLINE 1 INTRODUCTION 2 DATA LINK LAYER DESIGN ISSUES 3 ERROR DETECTION AND CORRECTION 4 ELEMENTARY DATA LINK PROTOCOLS 5 SLIDING WINDOW PROTOCOLS 6 EXAMPLE DATA LINK PROTOCOLS 7 CONCLUSIONS
  • 9.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions INTRODUCTION I The goal is to study the design principles for the data link layer. To study the algorithms for achieving reliable, efficient communication of whole units of information. To understand communication with frames as opposed to bits.
  • 10.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions DATA LINK LAYER DESIGN ISSUES I The data link layer uses the services of the physical layer to send and receive bits over communication channels. It has a number of functions, including: 1 Providing a well-defined service interface to the network layer. 2 Dealing with transmission errors. 3 Regulating the flow of data so that slow receivers are not swamped by fast senders. To accomplish these goals, the data link layer takes the packets it gets from the network layer and encapsulates them into frames for transmission. Each frame contains a frame header. And a payload field for holding the packet.
  • 11.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions 2. Dealing with transmission errors. 3. Regulating the flow of data so that slow receivers are not swamped DATA LINK LAYER DESIGN ISSUES II by fast senders. To accomplish these goals, the data link layer takes the packets it gets from the network layer And and a frame encapsulates trailer. them into frames for transmission. Each frame contains a frame header, a payload field for holding the packet, and a frame trailer, as Frame illustrated management in Fig. 3-1. Frame forms management the heart forms of the the functionality heart of what the data link of layer the does. data In link the layer. following sections we will examine all the above-mentioned issues in detail. Header Payload field Trailer Frame Sending machine Receiving machine Packet Packet Header Payload field Trailer Figure 3-1. Relationship between packets and frames. FIGURE: Relationship between packets and frames. Although this chapter is explicitly about the data link layer and its protocols, many of the principles we will study here, such as error control and flow control, are found in transport and other protocols as well. That is because reliability is an
  • 12.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER I The function of the data link layer is to provide services to the network layer. The rincipal service is transfering data from the network layer on the source machine to the network layer on the destination machine. On the source machine is an entity, call it a process or a program, in the network layer that hands some bits to the data link layer for transmission to the destination. The job of the data link layer is to transmit the bits to the destination machine so they can be handed over to the network layer (of the destination machine).
  • 13.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions transmit the bits to the destination machine so they can be handed over to the net-work layer there, as shown in Fig. 3-2(a). The actual transmission follows the SERVICES PROVIDED TO THE NETWORK LAYER II path of Fig. 3-2(b), but it is easier to think in terms of two data link layer proc-esses communicating using a data link protocol. For this reason, we will impli-citly use the model of Fig. 3-2(a) throughout this chapter. 4 3 2 1 4 3 2 1 4 3 2 1 4 3 2 1 Host 1 Host 2 Host 1 Host 2 Virtual data path Actual data path (a) (b) Figure 3-2. (a) Virtual communication. (b) Actual communication. FIGURE: (a) Virtual Communication. (b) Actual communication. The data link layer can be designed to offer various services. The actual ser-vices
  • 14.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER III The data link layer can be designed to offer various services. The actual services that are offered vary from protocol to protocol. The reasonable possibilities are: 1 Unacknowledged connectionless service. 2 Acknowledged connectionless service. 3 Acknowledged connection-oriented service. Unacknowledged connectionless service consists of having the source machine send independent frames to the destination machine without having the destination machine acknowledge them. Ethernet is a good example that provides this service. No logical connection is established beforehand or released afterward.
  • 15.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER IV If a frame is lost due to noise on the line, no attempt is made to detect the loss or recover from it in the data link layer. This class of service is appropriate when the error rate is low. The recovery is left to the higher layers. It is also appropriate for real-time traffic, such as voice. Or for other service in late data is worse than bad data. In an acknowledged connectionless service there are still no logical connections. However, each frame sent is individually acknowledged. The sender knows that whether a frame has been arrived correctly or has been lost.
  • 16.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER V If it does not arrive within a certain time interval, it can be sent again. The service is useful over unreliable channels, such as wireless systems. IEEE 802.11 is a good example of this class of service. Providing acknowledgements in the data link layer is a good thing, but not a requirement. The network layer can always send a packet and wait for it to be acknowledged by its peer on the remote machine. If the acknowledgement does not arrive within a certain interval of time, the sender can send the message again. This strategy can be inefficient.
  • 17.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER VI Links usually have a strict maximum frame length imposed by the hardware, and known propagation delays. The network layer does not know these things. The network layer might send a large packet that is broken up into, say, 10 frames, of which 2 are lost on average. It would then take a very long time for the packet to get through. On the other hand, if individual frames are acknowledged and retransmitted, then errors can be corrected more directly and more quickly. On reliable channels, such as fiber, the overhead of a heavyweight data link protocol may be unnecessary.
  • 18.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER VII However, it might be very useful on wireless channels which are inherently unreliable. Providing a connection oriented service is the most reliable thing the data link layer can do. The source and destination machines establish a connection before any data are transferred. Each frame sent over the connection is numbered. Moreover, the data link layer ensures that each frame sent is indeed received. Moreover, it guarantees that each frame is received exactly once. And that all the frames are received in the right order. Transfers go through three phases in a connection oriented scheme:
  • 19.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SERVICES PROVIDED TO THE NETWORK LAYER VIII 1 Connection establishment. 2 Frame transmission. 3 Connection release.
  • 20.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions FRAMING I The data link layer uses the services of the physical layer. The physical layer accepts a raw bitstream and tries to deliver it to the destination. Physical layer tries to handle noise and transmission errors. There is no guarantee for error-free deliveries. The data link layer has to correct the errors. The usual way is to break up the bit stream into frames. The data link layer computes the checksums. Upon arrival of a frame the checksum is recomputed.
  • 21.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions FRAMING II A few strategies for framing: 1 Byte count. 2 Flag bytes with byte stuffing. 3 Flag bits with bit stuffing. 4 Physical layer coding violations.
  • 22.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions FRAMING III 198 THE DATA LINK LAYER CHAP. 3 Byte count One byte 5 1 2 3 4 5 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3 (a) 5 1 2 3 4 7 6 7 8 9 8 0 1 2 3 4 5 6 8 7 8 9 0 1 2 3 (b) Error Frame 1 5 bytes Frame 1 Frame 2 5 bytes Frame 2 (Wrong) Frame 3 8 bytes Frame 4 8 bytes Now a byte count Figure 3-3. A byte stream. (a)Without errors. (b)With one error. FIGURE: A byte stream. (a) Without errors. (b) With one error. The second framing method gets around the problem of resynchronization after an error by having each frame start and end with special bytes. Often the same byte, called a flag byte, is used as both the starting and ending delimiter. This byte is shown in Fig. 3-4(a) as FLAG. Two consecutive flag bytes indicate the end of one frame and the start of the next. Thus, if the receiver ever loses syn-chronization
  • 23.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions FRAMING IV SEC. 3.1 DATA LINK LAYER DESIGN ISSUES 199 FLAG Header Payload field Trailer FLAG Original bytes After stuffing A ESC FLAG B A ESC ESC B A ESC ESC ESC FLAG B A ESC ESC ESC ESC B A FLAG B A ESC B A ESC FLAG B A ESC ESC B (a) (b) Figure 3-4. (a) A frame delimited by flag bytes. (b) Four examples of byte se-quences before and after byte stuffing. The third method of delimiting the bit stream gets around a disadvantage of byte stuffing, which is that it is tied to the use of 8-bit bytes. Framing can be also be done at the bit level, so frames can contain an arbitrary number of bits made up of units of any size. It was developed for the once very popular HDLC (High-level Data Link Control) protocol. Each frame begins and ends with a special bit pattern, 01111110 or 0x7E in hexadecimal. This pattern is a flag byte. When-ever the sender’s data link layer encounters five consecutive 1s in the data, it FIGURE: (a) A frame delimited by flag bytes. (b) Four examples of byte sequences before and after byte stuffing.
  • 24.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions FRAMING V 200 THE DATA LINK LAYER CHAP. 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 0 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 0 1 0 Stuffed bits (a) (b) (c) 0 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 0 Figure 3-5. Bit stuffing. (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in the receiver’s memory after destuf-fing. FIGURE: (Bit stuffing. (a) The original data. (b) The data as they appear on the line. (c) The data as they are stored in the receiver’s memory after destuffing. With both bit and byte stuffing, a side effect is that the length of a frame depends on the contents of the data it carries. For instance, if there are no bytes in the data, 100 bytes might be carried in a frame of roughly 100 bytes. however, the data consists solely of flag bytes, each flag byte will be escaped the frame will become roughly 200 bytes long. With bit stuffing, the increase
  • 25.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ERROR CONTROL I How to make sure all frames are eventually delivered to the network layer at the destination and in the proper order. Use of acknowledgements, retransmissions, timers and sequence numbers.
  • 26.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions FLOW CONTROL I Sender transmitting faster than the receiver accepting. Feedback based flow control. Rate based flow control.
  • 27.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ERROR DETECTION AND CORRECTION I For wireless and very old networks error rates can be high. Network designers add redundant data to deal with errors. Error Correcting Codes: Help in figuring out the specific error that has occurred. Error Detecting Codes: Help in figuring out if some error has occurred or not. The use of error correcting codes is often referred to as FEC (Forward Error Correction). For reliable channels error detecting codes are normally employed. For noisy channels, error correcting codes are used.
  • 28.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ERROR DETECTION AND CORRECTION II Error correcting codes are also implemented in physical layer. Applied mathematics: Galois fields, properties of sparse matrices.
  • 29.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ERROR-CORRECTING CODES I Four different error-correcting codes: 1 Hamming codes. 2 Binary convolutional codes. 3 Reed-Solomon codes. 4 Low-Density Parity Check codes. All of these codes add redundancy to the information that is sent. A frame consists of m data (i.e. message) bits and r redundant (i.e. check) bits. In a block code, the r check bits are computed solely as a function of the m data bits with which they are associated.
  • 30.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ERROR-CORRECTING CODES II It is as if the m bits were looked up in a large table to find their corresponding r check bits. In a systematic code, the m bits are sent directly, along with the check bits, rather than being encoded themselves before they are sent. In a linear code. the r check bits are computed as a linear function of the m data bits. XOR or modulo 2 addition is a popular choice. This means that encoding can be done with operations such as matrix multiplications or simple logic circuits.
  • 31.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ERROR-DETECTING CODES I They are used for reliable channels. Linear systematic block codes: 1 Parity. 2 Checksums. 3 Cyclic redundancy checks (CRCs). Fletcher’s checksum. CRC (Cyclic redundancy check). Polynomial code.
  • 32.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions ELEMENTARY DATA LINK PROTOCOLS I A Utopian Simplex Protocol. A Simplex Stop-and-Wait Protocol for an Error-Free Channel. A Simplex Stop-and-Wait Protocol for a Noisy Channel.
  • 33.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions SLIDING WINDOW PROTOCOLS I A One-Bit Sliding Window Protocol. A Protocol Using Go-Back-N. A Protocol Using Selective Repeat.
  • 34.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions EXAMPLE DATA LINK PROTOCOLS I Packet over SONET. ADSL (Assymetric Digital Subscriber Loop).
  • 35.
    The Data LinkLayer Muhammad Adil Raja Introduction Data Link Layer Design Issues Error Detection and Correction Elementary Data Link Protocols Sliding Window Protocols Example Data Link Protocols Conclusions REFERENCES The inspiration and figures for these slides have been taken from, Computer Networks, Andrew S. Tanenbaum, 5th Edition.