Data Link Layer - Winona State University

advertisement
CS 313 Introduction to
Computer Networking &
Telecommunication
Data Link Layer Part I –
Designing Issues and
Elementary Protocols
Chi-Cheng Lin, Winona State University
Topics
Introduction
 Framing
 Error Control
 Flow Control
 Elementary Data Link Protocols

2
Introduction

Algorithms to achieve reliable, efficient
communication between two adjacent
machines at the layer
Adjacent:
Physically connected by a communication
channel
3
Introduction

Issues
Providing well-defined services to network
layer
Framing
Determining how bits are grouped into frames
Error control
Flow control
4
Functions of the Data Link Layer

Relationship between packets and
frames.
5
Services to Network Layer

Transferring data between network
layers of machines
6
Services

Unacknowledged connectionless service
Appropriate for
Low error rate
 Let higher layer(s) recover errors
Real-time traffic, e.g., speech, video
Most LANs, such as Ethernet

Acknowledged connectionless service
Useful over unreliable channels
Each frame sent individually acknowledged
e.g., wireless systems, e.g. 802.11 (WiFi)
7
Services

Acknowledged connection-oriented
service
Guarantees
Each frame sent is received without error
All frames sent are received in right order
 Network layer always receives correct packets
in the order in which the packets were sent
Three phases:
Connection establishment
 Variables and counters initialization
Frame transmission
Connection release
 Variables, buffers, resources freed up
8
Framing

Fact
Raw bit stream delivered by physical layer
is not error free

Data link layer detects/corrects errors
Framing
Computing checksum
Handling error if any
9
Framing

Approaches
Byte count
Flag bytes with byte stuffing
Flag bits with bit stuffing
Physical layer coding violations
10
Character Count
A field in header specifies number of
characters in a frame.
 Problem?

11
Flag Bytes with Byte Stuffing
A frame delimited by flag bytes
 Four examples of byte sequences before
and after stuffing

12
Flag Bits with Bit Stuffing




Each frame begins and ends with special
bit pattern (flag byte): 01111110
Problem: 6 consecutive 1s in data
Solution: Bit Stuffing: inserting a 0 after 5
consecutive 1s
Used in USB
Original Data
After
Stuffing
After received
and destuffed
13
Physical Layer Coding Violations
Encoding on physical medium
 Framing by invalid physical code

Use some code that does not represent 0
nor 1

Example
Manchester encoding in classic Ethernet

Combination of approaches is possible
E.g., Ethernet and 802.11 use preamble
(well-defined pattern) + byte count
14
Error Control

Using acknowledgement
Positive
Negative
Problem: In some cases, sender waits
for acknowledgement forever
 Solution: Timer
 Problem: Duplicate transmission
 Solution: Sequence number

15
Positive Acknowledgement
Sender sends a message, waits for
acknowledgement from receiver, and
then sends next message
 There’s no free lunch, though
 overhead, delay
 How does it work?

16
Reliability and Acknowledgement

Case 1: no error

Case 2: data lost
Sender Receiver
Time
Data
Sender
Time
Receiver
Data
X
Timeout
Ack.
Data
Ack.
Timeout and retransmission
17
Reliability and Acknowledgement

Case 3: data error
Sender
Time

Case 4: ack. lost
Receiver
Data
Time
Error
Timeout
Sender
Data
Ack.
Timeout and retransmission
Timeout
Receiver
Data
X
Data
Ack.
New problem? Duplicate
Solution: Sequence number
18
Flow Control
Needed
 Problem

When frames are transmitted faster than
receiver can accept, frames will be lost

Solution
Flow control by feedback mechanism
19
Elementary Data Link Protocols

Key Assumptions
Network, data link, and physical layers are
independent processes communicating by
sending messages
Machine A wants to send a long stream of
data to machine B over a reliable,
connection-oriented service
20
Implementation of Physical, Data
Link, and Network Layers
21
Data Structures and Primitives
22
Data Structures and Primitives
23
Data Structures and Primitives
24
Unrestricted Simplex Protocol
Utopia protocol
 Assumptions

Unidirectional data transmission
Transmitting/receiving network layers are
always ready
Processing time is ignored
Infinite buffer space
No errors
25
Unrestricted Simplex Protocol - Sender
26
Unrestricted Simplex Protocol - Receiver
27
Simplex Stop-and-Wait Protocol

Assumptions
Unidirectional data transmission
Transmitting/receiving network layers are
always ready
Finite processing speed
Finite buffer capacity
No errors
Problem: Sender sends too fast
 Stop-and-wait

Senders sends one frame and then waits
for an acknowledgement before processing
28
Simplex Stop-and-Wait Protocol - Sender
29
Simplex Stop-and-Wait Protocol - Receiver
30
Simplex PAR Protocol
For noisy channel
 Positive acknowledgement w/
retransmission (PAR)
 Sender waits for a positive
acknowledgement before advancing to
the next data item
 A. k. a. ARQ (Automatic Repeat
reQuest)

31
PAR Protocol

Assumptions
Unidirectional data transmission
Transmitting/receiving network layers are
always ready
Finite processing speed
Finite buffer capacity
Errors, can be detected

Timer + sequence number
Size (i.e., # bits) of sequence number?
32
PAR Protocol – Sender
33
PAR Protocol – Sender (Cont’d)
34
PAR Protocol – Receiver
35
Download