Data Link Layer
Data Link Layer
Data Link Layer
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Data Link Layer
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Services Provided to the Network Layer
• Principal Service Function of the data link layer is to transfer the
data from the network layer on the source machine to the network
layer on the destination machine.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Possible Services Offered
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Unacknowledged Connectionless
Service
• It consists of having the source machine send independent
frames to the destination machine without having the destination
machine acknowledge them. No logical connections.
• Each frame send by the Data Link layer is acknowledged and the
sender knows if a specific frame has been received or lost.
• If the ack has not arrived within a specific time interval, it can be
sent again.
• Network layer does not know frame size of the packets and other
restriction of the data link layer. Hence it becomes necessary for
data link layer to have some mechanism to optimize the
transmission.
Acknowledged Connection Oriented
Service
• Source and Destination establish a connection first.
• Examples:
– Satellite channel communication,
– Long-distance telephone communication, etc.
Acknowledged Connection Oriented
Service
• Three distinct phases:
• To provide service to the network layer the data link layer must
use the service provided to it by physical layer.
i.e discard the bad frame and sending back the error report.
Framing Methods
1. Character count.
2. Flag bytes with byte stuffing.
3. Flag bits with bit stuffing.
4. Physical layer coding violations.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Character Count Framing Method
• It uses a field in the header to specify the number of
characters in the frame.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Flag Bytes with Byte Stuffing
• This methods gets around the boundary detection of the frame by
having each appended by the frame start and frame end special
bytes.
• The problem with this method is that when binary data such as
object program or floating point numbers are being transmitted,
there is the chance that the transmitted data may contain the flag
bit pattern.
• Here to solve this a special escape byte (ESC)is added just before
each FLAG in the data.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Flag Bits with Bit Stuffing Framing
Method
• The drawback of byte stuffing method is that it is closely tied to
the use of 8-bit characters.
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.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Bit Stuffing
• The sender will wait for ack until the timer expires.
• Two approaches:
1. Feedback-based flow control
2. Rate-based flow control
Feedback-based Flow Control
• Receiver sends back information to the sender giving it
permission to send more data, or
1. Hamming codes.
2. Binary convolutional codes.
3. Reed-Solomon codes.
4. Low-Density Parity Check codes.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Error Detection & Correction Code
• A frame consists of
– m data bits (message) and
– r redundant bits (check bits).
– Let the total length be n i.e n=m+r
Example:
• 4 valid codes:
– 0000000000
– 0000011111
– 1111100000
– 1111111111
• Minimal Distance of this code is 5 => can correct and double
errors and it detect quadruple errors.
• 0000000111 => single or double – bit error. Hence the
receiving end must assume the original transmission was
0000011111.
• 0000000000 => had triple error that was received as
0000000111 it would be detected in error.
Error Detection & Correction Code
• One cannot perform double errors and at the same time detect
quadruple errors.
• Error correction requires evaluation of each candidate
codeword which may be time consuming search.
• Through design this search time can be minimized.
• In theory if n = m + r, this requirement becomes:
– (m + r + 1) ≤ 2r
Hamming Code
• Codeword: b1 b2 b3 b4 ….
• Check bits: The bits that are powers of 2
(p1, p2, p4, p8, p16, …).
• The rest of bits (m3, m5, m6, m7, m9, …)
are filled with m data bits.
• Example of the Hamming code with m = 7
data bits and r = 4 check bits is given in the
next slide.
The Hamming Code
7 6 5 4 3 2 1
D D D P D P P 7-BIT CODEWORD
D - D - D - P (EVEN PARITY)
D D - - D P - (EVEN PARITY)
D D D P - - - (EVEN PARITY)
Hamming Code
• Why Those Bits? - The three parity bits (1,2,4) are related to
the data bits (3,5,6,7) as shown at right. In this diagram, each
overlapping circle corresponds to one parity bit and defines
the four bits contributing to that parity computation. For
example, data bit 3 contributes to parity bits 1 and 2. Each
circle (parity bit) encompasses a total of four bits, and each
circle must have EVEN parity. Given four data bits, the three
parity bits can easily be chosen to ensure this condition.
• It can be observed that changing any one bit numbered 1..7
uniquely affects the three parity bits. Changing bit 7 affects all
three parity bits, while an error in bit 6 affects only parity bits 2
and 4, and an error in a parity bit affects only that bit. The
location of any single bit error is determined directly upon
checking the three parity circles.
Hamming Code
Hamming Code
7 6 5 4 3 2 1
1 1 1 0 1 1 0 7-BIT CODEWORD
1 - 1 - 1 - 0 (EVEN PARITY) NOT! 1
1 1 - - 1 1 - (EVEN PARITY) OK! 0
1 1 1 0 - - - (EVEN PARITY) NOT! 1
Hamming Code
• In fact, the bad parity bits labeled 101 point directly to the bad
bit since 101 binary equals 5. Examination of the 'parity
circles' confirms that any single bit error could be corrected in
this way.
• The value of the Hamming code can be summarized:
1. Detection of 2 bit errors (assuming no correction is
attempted);
2. Correction of single bit errors;
3. Cost of 3 bits added to a 4-bit message.
• The ability to correct single bit errors comes at a cost which is
less than sending the entire message twice. (Recall that
simply sending a message twice accomplishes no error
correction.)
Error Detection Codes (2)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Convolutional Codes
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Convolutional Encoders
• Like any error-correcting code, a convolutional code works by
adding some structured redundant information to the user's
data and then correcting errors using this information.
• A convolutional encoder is a linear system.
• A binary convolutional encoder can be represented as a shift
register. The outputs of the encoder are modulo 2 sums of the
values in the certain register's cells. The input to the encoder
is either the unencoded sequence (for non-recursive codes) or
the unencoded sequence added with the values of some
register's cells (for recursive codes).
• Convolutional codes can be systematic and non-systematic.
Systematic codes are those where an unencoded sequence is
a part of the output sequence. Systematic codes are almost
always recursive, conversely, non-recursive codes are almost
always non-systematic.
Convolutional Encoders
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Error-Detecting Codes (2)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Error-Detecting Codes (3)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (2)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (3)
...
...
Some definitions needed in the protocols to follow. These
definitions are located in the file protocol.h.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Elementary Data Link Protocols (5)
...
A utopian simplex protocol.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Utopian Simplex Protocol (2)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Simplex Stop-and-Wait Protocol
for a Noisy Channel (1)
...
A simplex stop-and-wait protocol.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Simplex Stop-and-Wait Protocol
for a Noisy Channel (2)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (1)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (2)
...
A positive acknowledgement with retransmission protocol.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (3)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Sliding Window Protocols (4)
...
...
...
A sliding window protocol using go-back-n.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (4)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (5)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (6)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (7)
...
A sliding window protocol using go-back-n.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (8)
...
A sliding window protocol using go-back-n.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (9)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Go-Back-N (10)
...
A sliding window protocol using selective repeat.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (2)
...
A sliding window protocol using selective repeat.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (3)
...
A sliding window protocol using selective repeat.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (4)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (5)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (6)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (7)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (8)
...
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (9)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol Using Selective Repeat (10)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Example Data Link Protocols
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Packet over SONET (1)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Packet over SONET (2)
PPP Features
1. Separate packets, error detection
2. Link Control Protocol
3. Network Control Protocol
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Packet over SONET (3)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Packet over SONET (4)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
ADSL (Asymmetric Digital
Subscriber Loop) (1)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
ADSL (Asymmetric Digital
Subscriber Loop) (1)
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
End
Chapter 3
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011