Chapter Four: Data Link Layer
Chapter Four: Data Link Layer
Chapter Four: Data Link Layer
2
Introduction
• The second layer in OSI reference model is called the data link layer
• The data link layer has a number of specific functions it can carry out.
• These functions include:
– Providing a well-defined service interface to the network layer.
– Regulating the flow of data so that slow receivers are not swamped
by fast senders.
– Dealing with transmission errors.
3
Introduction
• To accomplish these goals:
– Takes the packets it gets from the network layer and
encapsulates them into frames for transmission
– Each frame contains
• frame header,
• payload field for holding the packet,
• frame trailer
4
Services Provided to the Network Layer
• The principal service is transferring data from the network layer on
the source machine to the network layer on the destination
machine
• Three services that are commonly provided are:
– Unacknowledged connectionless service.
• The source machine send independent frames to the
destination machine without having the destination machine
acknowledge them
• 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
• Appropriate when:
– the error rate is very low so that recovery is left to higher
layers
– appropriate for real-time traffic, such as voice, in which
late data are worse than bad data
5
– Acknowledged connectionless service.
• Each frame sent is individually acknowledged
• The sender knows whether a frame has arrived correctly. If
it has not arrived within a specified time interval, it can be
sent again
• For wireless
– Acknowledged connection-oriented service.
• The source and destination machines establish a
connection before any data are transferred
• Each frame sent over the connection is numbered, and the
data link layer guarantees that each frame sent is indeed
received exactly once
• Three way handshake 6
Fragmentation
• One of the tasks of data link layer
• Why?
8
Framing
9
Framing (2)
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
11
memory after destuffing.
Flow control
• assuring that a transmitting entity does not overwhelm a
• Different methods
acknowledgement
• Efficient
15
Causes of Error
different frequencies
16
Types of error
Single bit error
only one bit in a data unit (byte, character, packet, ...) has
changed
Burst error
• Eliminate causes---Impossible!
errors
18
Error Detection (Cont…)
Two Methods
• Parity bit
• Cyclic Redundancy Check (CRC)
19
Parity Bit
• Parity
a redundant bit, called a parity bit, is added to
every data unit so that the total number of 1s in
the unit (including the parity bit) becomes even
(or odd for odd-parity); this method can detect all
single-bit errors; it can detect burst errors only if
the total number of errors in each data unit is odd
– Even number of bit errors goes undetected
20
Cyclic Redundancy Check (CRC)
based on binary division
21
CRC (Cont…)
• append a string of n 0s in to the data unit ( n = divisor bits # –1)
‾ If remainder ,ERROR
‾ Otherwise NO ERROR
22
23
24
Error Control
• Detection and correction of errors
– Lost frames
– Damaged frames
– Error detection
– Positive acknowledgment
packets
and Go-Back-N 26
Stop-and-wait ARQ (SWA)
Next packet is sent after previous packet acknowledgment
ACK
• Damaged packets
• Lost packets
• Lost acknowledgment 27
Normal operation
28
Lost frame
29
Lost ack
30
Delayed ack
31
Go-Back-N ARQ
Continuous packet transmission like SRA
32
Go-Back-4: 4 frames are outstanding; so go back 4
fr fr fr fr fr fr fr fr fr fr fr fr fr fr time
0 1 2 3 4 5 6 3 4 5 6 7 8 9
A
B
A A A Out-of-sequence frames A A A A A A
C C C C C C C C C
K K K K K K K K K
1 2 3 error 4 5 6 7 8 9
33
Selective Repeat ARQ (SRA)
Continuously transmission packets
Retransmission for
• Damaged packets
• Lost packets
34
• Lost acknowledgments
fr fr fr fr fr fr fr fr fr fr fr fr fr fr time
0 1 2 3 4 5 6 2 7 8 9 10 11 12
A
B A A N A A A A A A A A A
C C A C C C C C C C C C
K K K K K K K K K K K K
1 2 2 2 2 2 7 8 9 1 1 1
error 0 1 2
35