Title: The Data Link Layer
1The Data Link Layer
2Data Link Layer Design Issues
- Main topics the algorithms for achieving
reliable, efficient communication between two
adjacent machines at the data link layer. - By adjacent, we mean the two machines are
physically connected by a communication channel
(e.g., a coaxial cable or a phone line) that acts
conceptually like a wire. - The essential property of a channel that makes it
wire-like'' is that the bits are delivered in
exactly the same order in which they are sent. - Why need data link layer software ?
- Communication circuits make errors occasionally,
- they have a finite data rate,
- there is a nonzero propagation delay, and
- the adjacent machines have finite and maybe
different processing speeds.
3Functions 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
4Relationship between packets and frames
5Services Provided to Network Layer
The principal service transferring data from the
network layer on the source machine to the
network layer on the destination machine.
- Virtual communication. Actual
communication.
- Three possible services
- Unacknowledged connectionless service.
- Acknowledged connectionless service.
- Connection-oriented service.
6Placement of the data link protocol
- An example a subnet consisting of routers
connected by point-to-point lines. - When a frame arrives at a router, the hardware
verifies the checksum and passes the frame to the
data link layer software. - The data link layer software, which may be
embedded in a chip on the network adaptor board,
checks to see if this is the frame expected. and
if so, gives the packet in the payload field to
the (network layer) routing software. - The routing software chooses the appropriate
outgoing line and passes the packet back down to
the data link layer software. - The data link layer software transmits it over
the selected outgoing line. - Many of the principles at the data link layer,
such as error control and flow control, are also
found in transport and other layers and protocols
as well.
7Framing
- What is framing ?
- The process of breaking the bit stream offered by
the physical layer into discrete segments
(frames). - Why framing ?
- For computing the checksum for each frame.
- For acknowledging the lost frames.
- How to do framing ?
8A character stream
- Without errors. (b) With one error.
What happens if the count is garbled by an error
?
9Flag bytes
- A frame delimited by flag bytes. (b) Four
examples of byte sequences before and after
stuffing.
Disadvantages closely tied to 8-bit
characters and the ASCII character code.
10Bit 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.
11Physical layer coding violations
- The IEEE 802 standard LAN uses the following
(Differential Manchester) encoding scheme a 1
bit is encoded as HL, and a 0 bit as LH. - The invalid encodings - HH and LL - can be used
for framing. - Character count can be combined with others for
extra safety.
12Error control and flow control
- Error control the goal (of a reliable
connection-oriented service) to ensure each
frame is ultimately passed to the network layer
at the destination exactly once, no more and no
less. - The measures
- Acknowledgements from the receiver to the sender.
- Timers for preventing senders from hanging
forever. - Sequence numbers for dealing with duplicated
frames. - Flow control What to do with a sender that
systematically wants to transmit frames faster
than the receiver can accept them ? - Some kind of feedback mechanism is needed so that
the sender can be made aware of whether or not
the receiver is able to keep up. - This is frequently integrated with error handling
for convenience.
13Error Detection and Correction
- Transmission errors are a fact of life.
- Sources of errors (local loop and wireless
links) - Thermal noise and electromagnetic interference
broad-spectrum background noise level. - The frequency dependency of the amplitude,
propagation speed, and phase of signals
distortion. - Echoes, off-course birds, etc.
- Errors tend to come in burst rather than singly.
14Error-Correcting Codes
Basic idea Including redundant information along
with each block of data sent to enable the
receiver to deduce what the transmitted character
must have been. An unit containing m bits of
data and r bits of redundancy, or check bits, is
referred to as an m r bits codeword. The
number of bit positions in which two codewords
differ is called the Hamming distance. Two d
apart codewords require d single-bit errors to
convert one into the other. The minimum
Hamming distance between any two codewords from a
list of codewords is the distance of the complete
list. To detect d errors, a distance of d
1 is needed because with such a code there is no
way that d single-bit errors can change a valid
codeword into another valid codeword. To
correct d errors, a distance of 2d 1 is needed
because that way the legal codewords are so far
apart that even with d changes, the original
codeword is still closer than any other codeword,
so it can be uniquely determined.
15Hamming code
- At the sending side
- The bits of the codeword are numbered
consecutively, starting with bit 1 at the left
end. - The bits that are powers of 2 (1, 2, 4, 8, 16,
etc.) are check bits. The rest (3, 5, 6, 7, etc.)
are filled up with the data bits. - Check bit forces the parity of the following bits
to be even (or odd) - the check bit itself, and
- all data bits whose position number has an
element of 2i when it is expended into a sum of
powers of 2. E.g., for check bit 1, the following
data bits are checked 3 1 2, 5 1 4, 7
1 2 4, ... - One data bit is checked by all and just those
check bits occurring in its expansion.
16Hamming code
- At the receiver side
- A counter is initialized into zero.
- Each check bit k ( 1, 2, 4, ...) and its checked
data bits are examined to see if the parity is
correct. - If not, k is added into the counter.
- If the counter is zero at the end, the codeword
is accepted as valid. Otherwise, it contains the
number of the incorrect bit. - E.g., if the parities were wrong when examining
check bits 1, 2, 4, then the counter-value 7
1 2 4 , we can conclude that data bit 7 was
inverted since bit 7 is the only one checked by
bits 1, 2, and 4.
17Use of a Hamming code to correct burst errors
The following figure shows some 7-bit ASCII
characters encoded as 11-bit codewords using a
Hamming code. The data bits are found in bit
positions 3, 5, 6, 7, 9, 10, and 11.
- To correct burst errors by means of Hamming codes
- A sequence of codewords are arranged as a matrix,
one codeword per row. - The data is transmitted one column ( bits) at a
time, starting with the leftmost column. - The matrix is reconstructed at the receiving
side. - If a burst error of length occurs, at most 1 bit
in each codeword will be effected, which can be
corrected by the Hamming code.
18Error-detecting codes
- Error-correcting codes are suitable for simplex
channels where no retransmission can be
requested. - Error-detection plus retransmission is often
preferred because it is more efficient. - For comparison, consider a channel with error
rate of 10(-6) per bit. Let block size be 1000
bits. - To correct a single error (by Hamming code), 10
check bits per block are needed. To transmit 1000
blocks, 10,000 check bits (overhead) are
required. - To detect a single error, a single parity bit per
block will suffice. To transmit 1000 blocks, only
one extra block (due to the error rate of
10(-6) per bit) will have to be retransmitted,
giving the overhead of only 2001 ( 1000 1001)
bits. - Under what conditions is error-correction more
efficient ?
19Cyclic Redundancy Code (CRC) method
- A k-bit frame is regarded as the coefficient list
for a polynomial with k terms, ranging from
x(k-1) to x0. - Polynomial arithmetic is done modulo 2. Both
addition and subtraction are identical to
EXCLUSIVE OR - 10011011 01010101
- 11001010 - 10101111
- ---------------
--------------- - 01010001 11111010
- The basic idea of the CRC method
- The sender appends a checksum to the end of the
frame in such a way that the polynomial
represented by the checksummed frame is divisible
by a generator polynomial G(x). - When the receiver gets the frame, it tries
dividing it by the same G(x). If there is a
remainder, there must have been an error and a
retransmission will be requested. - How to compute the chechsum for a given frame ?
20Calculation of the CRC checksum
- In any division problem, if you diminish the
dividend by the remainder, what is left over is
divisible by the divisor. - Detectable errors by CRC
- All single errors are detectable if G(x)
contains two or more terms. - All double errors are detectable if G(x) does not
divide xk 1 for any k up to the maximum
frame length. - All odd number of errors if G(x) contains a
factor of x 1 . - All burst errors of length ? r (the degree of
G(x) ) or the number of check bits. - The probability of a burst error of length r 1
being accepted as valid is (0.5) (r 1). - The probability of a bad frame, garbled by a long
burst or multiple shorter bursts, getting through
unnoticed is (0.5)r. - Simple hardware has been built to compute and
verify the CRC checksum.
21Elementary Data Link Protocols
- Assumptions
- The physical layer, data link layer, and network
layer are independent processes. - The network layer contacts the data link layer by
generating proper events. There exist suitable
library procedures for the data link layer to
delivery a packet (To_network_layer), and to
fetch a packet (from_network_layer). - The data link layer provides a reliable,
connection-oriented service to the network layer.
- The physical layer computes/checks checksums in
outgoing/incoming frames, and contacts the data
link layer by generating proper events. There
exist suitable library procedures for the data
link layer to send a frame (to_physical_layer),
and to fetch a frame (from_physical_layer).
22Protocol Definitions
Continued ?
Some definitions needed in the protocols to
follow. These are located in the file protocol.h.
23Protocol Definitions(ctd.)
Some definitions needed in the protocols to
follow. These are located in the file
protocol.h.
24Unrestricted Simplex Protocol
25Simplex Stop-and-Wait Protocol
26A Simplex Protocol for a Noisy Channel
- A scheme using timer and acknowledgement
- The sender starts a timer after sending a frame.
- The receiver sends back an acknowledgement only
when the incoming frame were correctly received. - The sender will retransmit the frame if the timer
expired before receiving an acknowledgement. - What is the fatal flaw in the above scheme ?
- Loss of an acknowledgement duplicated frame.
- How to distinguish a frame being seen for the
first time from a retransmission ? - Use a sequence number in the header of each
frame.
Continued ?
27A Simplex Protocol for a Noisy Channel (ctd.)
A positive acknowledgement with retransmission
protocol.
28Sliding Window Protocols
- How to achieve full-duplex data transmission ?
- Two separate simplex data channels -- waste of
bandwidth. - One circuit for data in both directions and using
the field in the frame header to distinguish a
data from an acknowledgement. - Piggybacking temporarily delay outgoing
acknow-ledgements so that they can get a free
ride on the next outgoing data frame. Save
bandwidth, number of interrupts and buffers. - How long should the receiver wait for an outgoing
frame onto which to piggyback the
acknowledgement ? - An ad hoc scheme waiting a fixed number of msec
(timer).
29Basics of sliding window protocols
- A sequence number is assciated with each
transmitted frame. Sequence numbers range from 0
up to some maximum (2n - 1) circularly. - A window is a list of consecutive sequence
numbers. The size of a window is determined by
two pointers the lower edge and the higher edge.
The size can be fixed or dynamically extended and
shrunk. - The sender maintains a sending window with
consecutive sequence numbers corresponding to
frames sent but has yet not acknowledged. - Whenever a new packet arrives from the network
layer, it is given the next highest sequence
number, and the upper edge of the window is
advanced by one. - When an acknowledgement comes in, the lower edge
is advanced by one. - The size of the sender's window is a dynamical
one. - The receiver maintains a receiving window with
consecutive sequence numbers corresponding to
frames it is permitted to accept. - When a frame whose sequence number is equal to
the lower edge of the window is received, it is
passed to the network layer, an acknowledgement
is generated, and the window is rotated by one. - The receiver's window always remains at its
initial size.
30A 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.
31A One-Bit Sliding Window Protocol
- The maximum window size is 1.
- Stop-and-wait.
Continued ?
32A One-Bit Sliding Window Protocol (ctd.)
33A 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.
34A Protocol Using Go Back N
- A tacit assumption in previous protocols the
time in the following period is negligible - The transmission time for a frame to arrive at
the receiver. - The processing time for the receiver to handle
the incoming frame. - The transmission time for an acknowledgement to
come back at the sender. - Consequently, the sender is blocked during the
above period, which can be very large in channels
with long round-trip propagation delay. - How to solve this problem ?
- The pipelining solution Set the maximum
sender's window size (the number of outstanding
frames) so large that the sender is allowed to
transmit multiple frames until the
acknowledgement for the first frame comes back.
Thereafter, acknowledgements will arrive one
after another, so the sender always gets
permission to transmit. - What to do if a frame in the middle of a long
stream is damaged or lost ?
35Pipelining and error recovery
- (a) The go back n strategy
- The receiver discards all subsequent frames,
sending no acknowledgements. The receiver's
window size is 1. - After time out, the sender retransmits all
unacknowledged frames in order, starting with the
damaged or lost one.
- (b) The selective repeat strategy
- The receiver buffers correct subsequent frames,
but sending no acknowledgements (or Nak). The
receiver's window size is larger than 1. - After time out (or receiving Nak), the sender
retransmits the damaged or lost frame.
36Sliding Window Protocol Using Go Back N
Continued ?
37Sliding Window Protocol Using Go Back N
Continued ?
38Sliding Window Protocol Using Go Back N
Continued ?
39Sliding Window Protocol Using Go Back N
40Sliding Window Protocol Using Go Back N (2)
- Simulation of multiple timers in software.
41A Sliding Window Protocol Using Selective Repeat
Continued ?
42A Sliding Window Protocol Using Selective Repeat
(2)
Continued ?
43A Sliding Window Protocol Using Selective Repeat
(3)
Continued ?
44A Sliding Window Protocol Using Selective Repeat
(4)
45A 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.
46Protocol Verification
- Finite State Machined Models
- Petri Net Models
47Finite State Machined Models
- (a) State diagram for protocol 3. (b)
Transmissions.
48Petri Net Models
- A Petri net with two places and two transitions.
49Petri Net Models (2)
- A Petri net model for protocol 3.
50Example Data Link Protocols
- HDLC High-Level Data Link Control
- The Data Link Layer in the Internet
51High-Level Data Link Control
The nice thing about standards is that you have
so many to choose from. At the data link layer,
we have IBM SDLC (Synchronous Data Link Control),
ANSI ADCCP (Advanced Data Communication Control
Procedure), ISO HDLC (High-level Data Link
Control), CCITT LAP (Link Access Procedure), etc.
If you do not like any of them, you can just
wait for next year's model. All are bit-oriented
and using bit stuffing. All use the same frame
structure
- The frame is delimited with flag sequence
01111110. - Address can be used to identify a terminal on
multidrop lines or to distinguish commands from
responses for point-to-point lines. - Control is used for sequence numbers,
acknowledgements, and others. - Data can be arbitrarily long.
- Checksum uses CRC-CCITT.
52High-Level Data Link Control (2)
- Three kinds of frames distinguished by the
control field - (a) An information frame.
- (b) A supervisory frame.
- (c) An unnumbered frame.
53The Data Link Layer in the Internet
- There are two situations in which point-to-point
communication occurs in Internet - Router-router leased line connection between
Internet routers. - Host-router dial-up line connection between home
computers and the Internet service providers'
routers, as shown in the following Figure.
- A home personal computer acting as an internet
host.
54PPP Point to Point Protocol
- PPP provides three features
- A framing method that unambiguously delineates
the end of one frame and the start of the next
one. The frame format also handles error
detection. - A link control protocol for bringing lines up,
testing them, negotiating options, and bringing
them down again gracefully when they are no
longer needed. This protocol is called LCP (Link
Control Protocol). - A way to negotiate network-layer options in a way
that is independent of the network layer protocol
to be used. The method chosen is to have a
different NCP (Network Control Protocol) for each
network layer supported.
55A typical scenario of PPP
- A typical scenario of a home user calling up an
Internet service provider to make a home PC a
temporary Internet host - Physical connection setup phase
- The PC calls the provider's router via a modem.
- The router's modem answers the phone and
establishes a physical connection. - Data link layer options negotiation phase
- The PC sends the router a series of LCP packets
in the payload field of one or more PPP frames.
These packets and their responses select the PPP
parameters to be used. - Network layer options negotiation phase
- A series of NCP packets are sent to configure the
network layer and to assign an IP address for the
PC (if the PC wants to run a TCP/IP protocol
stack). - Data communication phase
- The PC sends and receives IP packets over the
established connection. - Connection release phase
- When the PC is finished, NCP is used to tear down
the network layer connection and free up the IP
address. - The LCP is used to shut down the data line layer
connection. - The computer tells the modem to hang up the
phone, releasing the physical connection.
56The PPP full frame format for unnumbered mode
operation
The PPP frame was chosen to closely resemble the
HDLC frame, as shown below
In summary, PPP is a multi-protocol framing
mechanism suitable for use over modems, HDLC
bit-serial lines, SONET, and other physical
layers. It supports error detection, option
negotiation, header compression, and optionally,
reliable transmission using HDLC framing.
57PPP Point to Point Protocol (2)
- A simplified phase diagram for bring a line up
and down.
58PPP Point to Point Protocol (3)