Title: CEN 4500 Data Communications
1CEN 4500 Data Communications
Chapter 3 The Data Link Layer
Instructor S. Masoud Sadjadi http//www.cs.fiu.ed
u/sadjadi/Teaching/ sadjadi At cs Dot fiu Dot
edu
2Recap Data Link Layer
- Data link layer is the second layer in the
hierarchy of the hybrid reference model - Is to transform a raw transmission facility into
a line that appears free of undetected
transmission errors.
3Recap Data Link Layer
- We will study algorithms for achieving reliable,
efficient communication between two adjacent
machines at the data link layer. - Adjacent machines are two machines that are
connected by a communication channel that acts
conceptually like a wire (e.g., coaxial cable,
telephone line, or point-to-point wireless
channel) - A channel is called wire-like if the bits are
delivered in exactly the same order in which they
are sent. - What makes this layer essential is the fact that
- communication channels make errors occasionally,
- they have only a finite data rate, and
- there is a non-zero propagation delay
4Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
5Data Link Layer Design Issues
- Functions of the Data Link Layer
- Providing a well-defined service to the network
layer - Dealing with transmission errors
- Regulating the flow of data so that slow
receivers are not swamped by fast senders - Solution
- Data link layer takes the packets from the
network layer and encapsulates them into frames
for transmission. - A frame contains header, payload (packet), and
trailer. - Frame management is what data link layer is all
about.
6Functions of the Data Link Layer
- Relationship between packets and frames.
7Services Provided to Network Layer
- The principle service is transferring data from
the network layer on the source machine to the
network layer on the destination machine.
(a) Virtual communication. (b) Actual
communication.
8Reasonable Service Possibilities
- Unacknowledged connectionless service
- When error-rate is very low, so that the recovery
is left to the higher layers - Also for real-time traffic, such as voice
- Most LANs use this on the data link layer
- Acknowledged connectionless service
- Useful over unreliable channels, such as wireless
- Acknowledged connection-oriented service
- Each frame is numbered to guarantee exactly once
and in-order delivery of frames - A reliable bit stream
9Services Provided to Network Layer
- Placement of the data link protocol.
10Framing
- Physical layer accepts a raw bit stream and
attempt to deliver it to the destination. - It is up to the data link layer to detect and, if
necessary, correct errors. - The usual approach is for data link layer to
break the bit stream up into discrete frames and
compute the checksum for each frame. - Framing Methods
- Character count count can be garbled
- Flag bytes with byte stuffing starting and
ending delimiters - Starting and ending flags, with bit stuffing
- Physical layer coding violations
11Framing Character Count
- A character stream.
- (a) Without errors.
- (b) With one error.
12Framing Flag Bytes w/ Byte Stuffing
- What if the flag bytes bit pattern happens
occurs in the date? Insert a escape byte (ESC)
(a) A frame delimited by flag bytes. (b) Four
examples of byte sequences before and after
stuffing.
13Framing Bit Stuffing
- Each frame starts and ends with a special bit
pattern, 01111110 (in fact, a flag byte). - Whenever the senders data link layer encounters
five consecutive 1s in the data, it automatically
stuffs a 0 bit into the outgoing bit stream
Bit 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.
14Framing Physical Layer Coding Violation
- This method is only applicable to networks in
which the encoding on the physical medium
contains some redundancy. - For example, some LANs encode 1 bit of data by
using 2 physical bits - A 1 bit is a high-low pair
- A 0 bit is a low-high pair
- So, every data bit has a transition in the
middle easy for the receiver to locate the bit
boundaries. - High-high and low-low are not used for data!
15Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
16Error Background
- Transmission errors will be with us for a while
- The local loops are still twisted copper pairs
- Wireless communication is becoming more common
- Error Property
- As a result of the physical process that
generates them, errors on some media (e.g.,
radio) tend to come in bursts rather than singly. - A burst error does not imply that all the bits
are wrong it just implies that at least the
first and last are wrong - If errors were independent, most block would
contain errors - However, they are much harder to correct than are
isolated errors
17Error Handling
- Error Detection
- On channels that are highly reliable, such as
fiber, it is cheaper to detect errors and
retransmit data - Error-detecting codes add enough redundant
information to detect errors. - Error Correction
- On channels such as wireless links that make many
errors, retransmission does not make much sense - Error-correcting codes need to include enough
redundant information not only to detect the
error but also to correct it
18Error-Detecting Codes CRC
- Cyclic Redundancy Check (CRC)
- Also known as polynomial code
- Based on treating bit strings as representations
of polynomials with coefficients of 0 and 1 only - A k-bit frame is regarded as the coefficient list
for a polynomial with k terms, ranging from xk-1
to x0. - For example, 110001 represents x5 x4 x0
- Polynomial arithmetic is done modulo 2
- There are no carries for addition or borrows for
subtractions, both are identical to exclusive OR
19CRC
- The sender and receiver agree upon a generator
polynomial, G(x), both of its high and low bits
are 1 - To compute the checksum for some frame with m
bits, corresponding to the polynomial M(x), the
frame must be longer than the generator
polynomial - We append a checksum to the end of the frame,
so that the resulting polynomial is dividable by
G(x)
Calculation of the polynomial code checksum.
20Error-Correcting Code Hamming Code
- A frame consists of m data bits and r redundant,
or check, bits. - n m r called n-bit codeword.
- Hamming Distance
- The number of bit positions in which two
codewords differ - If two codewords are a Hamming distance d apart,
it will require d single-bit errors to convert
one into the other. - Given the algorithm to compute the check bits,
that are 2m legal codewords out of 2n codewords - The Hamming distance of the complete code (the
list of legal codewords) is the minimun distance
of any two codewords in the list.
21Error-Correcting Code Hamming Code
- To detect d errors
- you need a distance d 1 code
- If you receive a frame with d error, it will have
an illegal codeword - To correct d errors
- you need a distance 2d 1 code
- The closer legal codeword is the one to pick
- Example, Parity Bit
- The number of 1s are either even or odd
- A code with single parity has distance 2
22Error-Correcting Code Hamming Code
- How many check bit do we need to be able to
correct a 1 bit error? - For each 2m legal codewords, we need to have n
illegal ones, so n 1 codewords should be
reserved - 2m(n 1) lt 2n
- OR
- (m r 1) lt 2r
Hamming code to correct burst errors.
23Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
24Elementary Data Link Protocols
- An Unrestricted Simplex Protocol
- Protocol 1
- A Simplex Stop-and-Wait Protocol
- Protocol 2
- A Simplex Protocol for a Noisy Channel
- Protocol 3
- Try the simulator on your own and discuss it in
your study group!
25Assumptions for the Protocols
- The physical, data link, and network layers are
independent processes that communicate by passing
messages back and forth. - Machine A is trying to send a long message to
machine B, using a reliable, connection-oriented
service. - Later, we will consider the case where B will try
to send a message to A simultaneously. - A has an infinite supply of data ready to be sent
to B. - In a realistic situation, the data link layer
will not sit in a tight loop waiting for an
event, but it will be implemented using
interrupts - Machines do not crash
- As far as the data link layer is concerned, the
packet passed across the interface to data link
is pure data.
26Protocol Definitions
Continued ?
Some definitions needed in the protocols to
follow. These are located in the file protocol.h.
27Protocol Definitions(ctd.)
Some definitions needed in the protocols to
follow. These are located in the file
protocol.h.
28Unrestricted Simplex ProtocolProtocol 1
29Simplex Stop-and-Wait ProtocolProtocol 2
30A Simplex Protocol for a Noisy Channel Protocol 3
A positive acknowledgement with retransmission
protocol.
Continued ?
31A Simplex Protocol for a Noisy Channel Protocol
3 (ctd.)
A positive acknowledgement with retransmission
protocol.
32Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
33Sliding Window Protocols
- Need for both way transmission of data
- Using two simplex channels two expensive
- Using one channel in both directions
(intermixed), with temporarily delaying the ack
(piggybacking) - A One-Bit Sliding Window Protocol
- Protocol 4
- A Protocol Using Go Back N
- Protocol 5
- A Protocol Using Selective Repeat
- Protocol 6
34Sliding Window Protocols (2)
- On the sender side the frames that are sent or
can be sent (no ack yet). - On the receiver side the frames that it may
accept (discards other frames).
- 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.
35A One-Bit Sliding Window Protocol Protocol 4
Continued ?
36A One-Bit Sliding Window Protocol Protocol 4
(ctd.)
37A One-Bit Sliding Window Protocol Protocol 4 (2)
- Two scenarios for protocol 4. (a) Normal
case. (b) Abnormal case, if both sides starts
sending simultaneously (similar situation can
occur as a result of premature timeouts). The
notation is (seq, ack, packet number). An
asterisk indicates where a network layer accepts
a packet.
38A Protocol Using Go Back N Protocol 5
- Pipelining and error recovery. Effect on an
error when - (a) Receivers window size is 1.
- (b) Receivers window size is large.
39Sliding Window Protocol Using Go Back N
Protocol 5
Continued ?
40Sliding Window Protocol Using Go Back N Protocol
5
Continued ?
41Sliding Window Protocol Using Go Back N Protocol
5
Continued ?
42Sliding Window Protocol Using Go Back N
Protocol 5
43Sliding Window Protocol Using Go Back N Protocol
5
- Simulation of multiple timers in software.
44A Sliding Window Protocol Using Selective Repeat
Protocol 6
Continued ?
45A Sliding Window Protocol Using Selective Repeat
Protocol 6 (2)
Continued ?
46A Sliding Window Protocol Using Selective Repeat
Protocol 6 (3)
Continued ?
47A Sliding Window Protocol Using Selective Repeat
Protocol 6 (4)
48A Sliding Window Protocol Using Selective Repeat
Protocol 6 (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.
49Problem with non-sequential receive
- Suppose that we have a 3-bit seq. number
- The sender is permitted to send up to 7 frames
before it is required to wait for an ACK - Initially, we have (a)
- The sender transmits 0, 1, 2, 3, 4, 5, and 6
- The receiver accepts any frame between 0 to 6
(inclusive) - All seven frames arrive correctly, so the
receiver acknowledges them and advances its
window (b) - Suppose that all the ACKs are lost
- The sender times out and retransmits frame 0
- The receiver accepts this frame as it is within
7, 0, , 5 - The receiver sends a piggybacked ACK for frame 6,
since 0, , 6 have been received previously. - The sender is happy that all its transmission are
through and advances its window, and send 7, 0,
, 5. - Receiver then sends from 7 and the old frame 0 to
the network!!! - Therefore, the network gets an incorrect frame
and the protocol fails!!
50Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
51Protocol Verification
- Finite State Machined Models
- Petri Net Models
52Finite State Machined Models
- (a) State diagram for protocol 3. (b)
Transmissions.
53Petri Net Models
- A Petri net with two places and two transitions.
54Petri Net Models (2)
- A Petri net model for protocol 3.
55Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
56Example Data Link Protocols
- HDLC High-Level Data Link Control
- The Data Link Layer in the Internet
57High-Level Data Link Control
- Frame format for bit-oriented protocols.
58High-Level Data Link Control (2)
- Control field of
- (a) An information frame.
- (b) A supervisory frame.
- (c) An unnumbered frame.
59The Data Link Layer in the Internet
- A home personal computer acting as an internet
host.
60PPP Point to Point Protocol
- The PPP full frame format for unnumbered mode
operation.
61PPP Point to Point Protocol (2)
- A simplified phase diagram for bring a line up
and down.
62PPP Point to Point Protocol (3)
63Agenda
- Design Issues
- Error Detection and Correction
- Elementary Data Link Protocols
- Sliding Window Protocols
- Protocol Verification
- Example Data Link Protocols
- Summary
64Summary
- Data Link Layer
- The task of data link layer is to convert the raw
bit stream offered by the physical layer into a
stream of frames for use by the network layer. - Framing methods character count, byte and bit
stuffing. - It provides error control, flow control
- Protocols
- Protocols 1 to 6
- Sliding window protocols
- Protocol Verification FSMs Petri Nets
- Examples SDLC, HDLC, and PPP.