Sie sind auf Seite 1von 51

The Data Link Layer

gobir@nitt.edu

Agenda

UNIT-II: The Data Link Layer


Error Detection and Correction Parity LRCCRC Hamming Code Low Control and Error
Control Stop and wait ARQ Sliding window
HDLC LAN IEEE 802 Standards Wireless LAN
Bridges .

OSI LAYERS

Background

The design principles for the second


layer in our model, the data link layer.

It deals with algorithms for achieving


reliable, efficient communication of
whole units of information called frames
(rather than individual bits, as in the
physical layer) between two adjacent
machines.

Background

The two machines are connected by a


communication
channel
that
acts
conceptually like a wire (e.g., a coaxial
cable, telephone line, or wireless channel).
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.

Background

Machine A just puts the bits on the wire, and


machine B just takes them off. Unfortunately,
communication
channels
make
errors
occasionally.
They have only a finite data rate, and there
is a nonzero propagation delay between the
time a bit is sent and the time it is received.
The limitations have important implications for
the efficiency of the data transfer.

Introduction

The protocols used for communications must


take all these factors into consideration.

These protocols are the subject of this


chapter

Protocols by looking at the nature of errors


and how they can be detected and
corrected.

a series of increasingly complex protocols,


each one solving more and more of the
problems present in this layer.

The Data Link Layer


Data Link Layer Design Issues

Error Detection and Correction

Elementary Data Link Protocols

Sliding Window Protocols

The Data Link Layer


Data Link Layer Design Issues

Error Detection and Correction

Elementary Data Link Protocols

Sliding Window Protocols

Design Issue - Intro

10

The data link layer uses the services of the physical


layer to send and receive bits over communication
channels.

It has a number of functions, including:


1. Providing a well-defined service interface to the network
layer.
2. Dealing with transmission errors.
3. Regulating the flow of data so that slow receivers are
not swamped by fast senders.

Design Issue - Intro

11

The data link layer takes the packets it gets from


the network layer and encapsulates them into
frames for transmission.

Each frame contains a frame header, a payload field


for holding the packet, and a frame trailer.

Key Portfolio

12

Frame management forms the heart of what the


data link layer does.
Explicitly about the protocols, many of the
principles here are error control and flow control.
Reliability is an overall goal, and it is achieved when
all the layers work together.
Many networks, these functions are found mostly in the
upper layers, with the data link layer doing the minimal
job that is good enough.
However, no matter where they are found, the principles
are pretty much the same.

The Data Link Layer


Data Link Layer Design Issues
Services, Framing, Error Control & Flow Control
Error Detection and Correction

Elementary Data Link Protocols

Sliding Window Protocols

13

Services Provided to the


Network Layer

14

The function is to provide services 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.
On the source machine is an entity, call it a
process, in the network layer that hands some
bits to the data link layer for transmission to the
destination.

Services Provided to the


Network Layer

15

The job of the data link layer is to transmit the bits


to the destination machine so they can be handed
over to the network layer there.
Virtual Communication

The actual transmission follows the path of, but it is


easier to think in terms of two data link layer
processes communicating using a data link protocol.
Actual Communication

Services Provided to the


Network Layer

16

(a) Virtual communication (b) Actual communication

In terms of layers
Network

Link

Virtual data path


Physical

CSE 461 University of Washington

Actual data path

17

In terms of layers
Network

Link

Virtual data path


Physical

CSE 461 University of Washington

Actual data path

18

Typical Implementation of
Layers

CSE 461 University of Washington

19

Services Provided to the


Network Layer

20

The data link layer can be designed to


offer various services. The actual
services that are offered vary from
protocol to protocol.
Three reasonable possibilities
1. Unacknowledged connectionless service.
2. Acknowledged connectionless service.
3. Acknowledged connection-oriented service.

The Data Link Layer


Data Link Layer Design Issues
Services, Framing, Error Control & Flow Control
Error Detection and Correction

Elementary Data Link Protocols

Sliding Window Protocols

21

Framing

22

To provide service to the network layer the data link


layer must use the service provided to it by physical
layer.
Stream of data bits provided to data link layer is not
guaranteed to be without errors.
Errors could be:
Number of received bits does not match number of transmitted
bits (deletion or insertion)
Bit Value

It is up to data link layer to correct the errors if


necessary.

Framing Key aspect

23

The approach is for the data link layer to break


up the bit stream into discrete frames,
compute a short token called a checksum for
each frame, and include the checksum in the
frame when it is transmitted.
When a frame arrives at the destination, the
checksum is recomputed.

If the newly computed checksum is different from


the one contained in the frame, the data link layer
knows that an error has occurred and takes steps to
deal with it.
e.g., discarding the bad frame and possibly also
sending back an error report.

Framing

24

Breaking up the bit stream into frames is more


difficult than it at first appears.
A good design must make it easy for a receiver to
find the start of new frames while using little of the
channel bandwidth.
Four methods:
1.
2.
3.
4.

In practice, the physical layer often helps


to identify frame boundaries
E.g., Ethernet, 802.11

Byte count.
Flag bytes with byte stuffing.
Flag bits with bit stuffing.
Physical layer coding violations.

Framing

25

1. Byte
count

2. Flag bytes
with byte
stuffing
3. Flag bits
with bit
stuffing
4. Physical
layer coding
violations

Byte Count: Framing


Method

26

The first framing method uses a field in the header to specify


the number of bytes in the frame.
When the at the destination sees the byte count, it knows
how many bytes follow and hence where the end of the
frame is.
This technique is shown in Figure for four small example frames of
sizes 5, 5, 8, and 8 bytes, respectively.

Byte Count:Framing Method

27

The trouble with this algorithm is that the count can be garbled by a transmission
error.
For example, if the byte count of 5 in the second frame of Figure becomes a 7 due to a
single bit flip, the destination will get out of synchronization.

It will then be unable to locate the correct start of the next frame. Even if the
checksum is incorrect so the destination knows that the frame is bad, it still has
no way of telling where the next frame starts.
Sending a frame back to the source asking for a retransmission does not help
either, since the destination does not know how many bytes to skip over to get to
the start of the retransmission.

For this reason, the byte count method is rarely used by itself

Byte Stream

28

(a) Without errors. (b) With one error.

Framing

29

1. Byte
count

2. Flag
bytes with
byte stuffing
3. Flag bits
with bit
stuffing
4. Physical
layer coding
violations

Flag Bytes with Byte


Stuffing Framing Method

30

The second framing method gets around the problem of


resynchronization after an error by having each frame start
and end with special bytes.
flag byte, is used as both the starting and ending

Two consecutive flag bytes indicate the end of one frame


and the start of the next.
Thus, if the receiver ever loses synchronization it can just search for two flag
bytes to find the end of the current frame and the start of the next frame.

Flag Bytes with Byte


Staffing Framing Method

31

Better idea:
Have a special flag byte value that means
start/end of frame
Replace (stuff) the flag inside the frame
with an escape code
Complication: have to escape the escape
code too!

Framing (2)
Rules:

32

Replace each FLAG in data with ESC FLAG


Replace each ESC in data with ESC ESC

Framing (2)

33
a. A frame delimited
by flag bytes.
b. Four examples of
byte
sequences
before and after
byte stuffing.

The byte-stuffing scheme depicted in Figure is a slight


simplification of the one used in PPP (Point-to-Point Protocol),
which is used to carry packets over communications links.

Framing

34

1. Byte
count

2. Flag bytes
with byte
stuffing

3. Flag bits
with bit
stuffing
4. Physical
layer coding
violations

Flag Bits with Bit Stuffing


Framing Method

35

The third method of delimiting the bit stream gets


around a disadvantage of byte stuffing, which is that it
is tied to the use of 8-bit bytes.
Framing can be also be done at the bit level, so frames
can contain an arbitrary number of bits made up of units
of any size.
It was developed for the once very popular HDLC (High
Level Data Link Control) protocol.
Each frame begins and ends with a special bit pattern,
01111110 or 0x7E in hexadecimal. This pattern is a flag
byte.

Flag Bits with Bit Stuffing


Framing Method
Can stuff at the bit level too
Rules
Assume a flag has six consecutive 1s
On transmit, after five 1s in the data,
insert a 0
On receive, a 0 after five 1s is deleted

36

Flag Bits with Bit Stuffing


Framing Method

37

(a) The original data.


(b) The data as they appear on
the line.
(c)The data as they are stored in
the receivers memory after destuffing.
When the receiver sees five consecutive incoming 1 bits, followed by a 0
bit, it automatically destuffs (i.e., deletes) the 0 bit.
Just as byte stuffing is completely transparent to the network layer in both
computers, so is bit stuffing.
If the user data contain the flag pattern, 01111110, this flag is transmitted
as 011111010 but stored in the receivers memory as 01111110

Framing

38

1. Byte
count

2. Flag bytes
with byte
stuffing

3. Flag bits
with bit
stuffing
4. Physical
layer coding
violations

Physical Layer Coding


Violations

39

Many data link protocols use a combination of these


methods for safety.
A common pattern used for Ethernet and 802.11 is
to have a frame begin with a well-defined pattern
called a preamble.
This pattern might be quite long (72 bits is typical for
802.11) to allow the receiver to prepare for an incoming
packet.

The preamble is then followed by a length (i.e.,


count) field in the header that is used to locate the
end of the frame.

Framing

40

1. Byte
count

2. Flag bytes
with byte
stuffing
3. Flag bits
with bit
stuffing
4. Physical
layer coding
violations

The Data Link Layer


Data Link Layer Design Issues
Services, Framing, Error Control & Flow Control
Error Detection and Correction

Elementary Data Link Protocols

Sliding Window Protocols

41

Error Control

42

After solving the marking of the frame with start and


end the data link layer has to handle eventual errors
in transmission or detection.
Ensuring that all frames are delivered to the network layer
at the destination and in proper order.

The usual way to ensure reliable delivery is to


provide the sender with some feedback about what is
happening at the other end of the line.

Error Control

43

The protocol calls for the receiver to send back


special control frames bearing positive or negative
acknowledgements about the incoming frames.
If the sender receives a positive acknowledgement about
a frame, it knows the frame has arrived safely.
On the other hand, a negative acknowledgement means
that something has gone wrong and the frame must be
transmitted again.

Error Control

44

An additional complication comes from the


possibility that hardware troubles may cause a frame
to vanish completely (e.g., in a noise burst).
In this case, the receiver will not react at all, since it
has no reason to react.
Similarly, if the acknowledgement frame is lost, the
sender will not know how to proceed.

It should be clear that a protocol in which the sender


transmits a frame and then waits for an
acknowledgement, positive or negative, will hang
forever if a frame is ever lost due to, for example,
malfunctioning hardware or a faulty communication
channel.

Error Control

45

This possibility is dealt with by introducing timers into


the data link layer.
When the sender transmits a frame, it generally also
starts a timer.
The timer is set to expire after an interval long
enough for the frame to reach the destination, be
processed there, and have the acknowledgement
propagate back to the sender.
Normally, the frame will be correctly received and the
acknowledgement will get back before the timer runs
out, in which case the timer will be canceled.

Error Control

46

However,
if
either
the
frame
or
the
acknowledgement is lost, the timer will go off,
alerting the sender to a potential problem.

The obvious solution is to just transmit the frame


again. However, when frames may be transmitted
multiple times there is a danger that the receiver
will accept the same frame two or more times and
pass it to the network layer more than once.

Error Control

47

To prevent this from happening, it is generally


necessary to assign sequence numbers to outgoing
frames, so that the receiver can distinguish
retransmissions from originals
The whole issue of managing the timers and
sequence numbers so as to ensure that each frame
is ultimately passed to the network layer at the
destination exactly once, no more and no less, is an
important part of the duties of the data link layer
(and higher layers).

Flow Control

48

Another important design issue that occurs in the


data link layer (and higher layers as well) is what to
do with a sender that systematically wants to
transmit frames faster than the receiver can accept
them.

This situation can occur when the sender is running


on a fast, powerful computer and the receiver is
running on a slow, low-end machine.

Flow Control

49

Important Design issue for the cases when the


sender is running on a fast powerful computer
and receiver is running on a slow low-end
machine.
Two approaches:
1. Feedback-based flow control
2. Rate-based flow control

Flow Control
Feedbackbased flow
control

Receiver sends back information to


the sender giving it permission to
send more data, or

Ratebased flow
control

Built in mechanism that


limits the rate at which
sender may transmit data,
without
the
need
for
feedback from the receiver.

Telling sender how receiver is doing.

50

Summary
Data Link Layer Design Issues
Services, Framing, Error Control & Flow Control
Error Detection and Correction

Elementary Data Link Protocols

Sliding Window Protocols

51

Das könnte Ihnen auch gefallen