0% found this document useful (0 votes)
15 views

Module-2-DataLinkLayer

Uploaded by

Safa Hamza
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Module-2-DataLinkLayer

Uploaded by

Safa Hamza
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 60

The Data Link

Layer
Module -3

Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
• Data link layer is deals with algorithms for
achieving reliable efficient communication
between two adjacent machines( connected
machines).
• The DLL provides the functional and procedural
means to transfer data between machines and
might provide the means to detect and possibly
correct errors that may occur in the physical
layer.
• Machine A puts some bits on the wire and B
just takes them off

2
Shijo M Joseph Dept of Computer Science
• Local delivery of frames/ data units
• DLL do not cross the boundaries of a local
network.
• Inter network routing and global addressing
are higher layer functions.
• It has two sub layers
• 1. logical control layer
• 2. media access control

Shijo M Joseph Dept of Computer Science


• Logical link layer multiplexes protocols
running at top of the data link layer and
optionally provide flow control,
acknowledgement and error notification.
• LCC provides addressing and control of
data link
• MAC may refer to the sub layer that
determines who to access the media at
any one time.

Shijo M Joseph Dept of Computer Science


Data Link Layer Design Issues
• Providing a well defined service interface to
the network layer
• Framing :determining how the bits of the
physical layer are grouped into frames.
• Error control: Dealing with transmission errors
• Flow control :regulate the flow of frames so
that slow receivers are not bogged down by
the fast senders.

Shijo M Joseph Dept of Computer 5


Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Data Link Layer
• Algorithms for achieving:
– Reliable, +
– Efficient,
communication of a whole units – frames (as opposed to
bits – Physical Layer) between two machines.
• Two machines are connected by a communication
channel that acts conceptually like a wire (e.g.,
telephone line, coaxial cable, or wireless channel).
• Essential property of a channel that makes it “wire-
like” connection is that the bits are delivered in exactly
the same order in which they are sent.
Shijo M Joseph Dept of Computer Science
Data Link Layer
• For ideal channel (no distortion, unlimited
bandwidth and no delay) the job of data link
layer would be trivial.
• However, limited bandwidth, distortions and
delay makes this job very difficult.

Shijo M Joseph Dept of Computer Science


Data Link Layer Design Issues
• Data Link layer
– Takes the packets from Physical layer, and
– Encapsulates them into frames for transmission
– Each frame contain a frame header a payload
filed for holding the packet and frame trailer
– Frame management is the heart of the data link
layer

Shijo M Joseph Dept of Computer Science


Packets and Frames

Relationship between packets and frames.


Shijo M Joseph Dept of Computer 9
Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Services Provided to the Network Layer
• Principal Service Function of the data link layer is to
transfer the data from the network layer on the source
machine to the network layer on the destination
machine.
– Process in the network layer that hands some bits to the
data link layer for transmission.
– Job of data link layer is to transmit the bits to the
destination machine so they can be handed over to the
network layer there (see figure in the next slide).

Shijo M Joseph Dept of Computer Science


Network Layer Services

(a) Virtual communication. (b) Actual communication.


Shijo M Joseph Dept of Computer 11
Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Possible Services Offered

1. Unacknowledged connectionless service.


2. Acknowledged connectionless service.
3. Acknowledged connection-oriented service.

Shijo M Joseph Dept of Computer 12


Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Unacknowledged Connectionless
Service

• It consists of having the source machine


send independent frames to the
destination machine without having the
destination machine acknowledge them.
• Example: Ethernet, Voice over IP, etc. in
all the communication channel were real
time operation is more important that
quality of transmission.

Shijo M Joseph Dept of Computer Science


Acknowledged Connectionless Service
• Each frame send by the Data Link layer is
acknowledged and the sender knows if a specific
frame has been received or lost.
• Typically the protocol uses a specific time period that if
has passed without getting acknowledgment it will re-
send the frame.
• This service is useful for commutation when an
unreliable channel is being utilized (e.g., 802.11 WiFi).

• Network layer does not know frame size of the


packets and other restriction of the data link layer.
Hence it becomes necessary for data link layer to
have some mechanism to optimize the transmission.
Shijo M Joseph Dept of Computer Science
Acknowledged Connection Oriented Service

• Source and Destination establish a connection


first.
• Each frame sent is numbered
– Data link layer guarantees that each frame sent is
indeed received.
– It guarantees that each frame is received only once
and that all frames are received in the correct
order.
• Examples:
– Satellite channel communication,
– Long-distance telephone communication, etc.
Shijo M Joseph Dept of Computer Science
Acknowledged Connection Oriented
Service
• Three distinct phases:
1. Connection is established by having both side
initialize variables and counters needed to keep
track of which frames have been received and
which ones have not.
2. One or more frames are transmitted.
3. Finally, the connection is released – freeing up
the variables, buffers, and other resources used
to maintain the connection.
Shijo M Joseph Dept of Computer Science
Framing
• 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
Shijo M Joseph Dept of Computer Science
• Transmission of the data link layer starts with
breaking up the bit stream
– into discrete frames
– Computation of a checksum for each frame, and
– Include the checksum into the frame before it is
transmitted.
• Receiver computes its checksum error for a
receiving frame and if it is different from the
checksum that is being transmitted will have to
deal with the error.

• Framing is more difficult than one could think!


Shijo M Joseph Dept of Computer Science
Framing Methods

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

Shijo M Joseph Dept of Computer 19


Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Byte Count Framing Method
• It uses a field in the header to specify the
number of bytes in the frame.
• Once the header information is being received
it will be used to determine end of the frame.
• See figure in the next slide:
• Trouble with this algorithm is that when the
count is incorrectly received the destination will
get out of synch with transmission.
– Destination may be able to detect that the frame
is in error but it does not have a means (in this
algorithm) how to correct it.
Shijo M Joseph Dept of Computer Science
Framing (1)

A byte stream. (a) Without errors. (b) With one error.


Shijo M Joseph Dept of Computer 21
Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Flag Bytes with Byte Staffing Framing Method
• This methods gets around the boundary detection of
the frame by having each appended by the frame start
and frame end special bytes.
• If they are the same (beginning and ending byte in the
frame) they are called flag byte.
• In the next slide figure this byte is shown as FLAG.
• If the actual data contains a byte that is identical to the
FLAG byte (e.g., picture, data stream, etc.) the
convention that can be used is to have escape
character inserted just before the “FLAG” character.

Shijo M Joseph Dept of Computer Science


Framing (2)

a) A frame delimited by flag bytes.


b) Four examples of byte sequences before and after byte stuffing.
Shijo M Joseph Dept of Computer 23
Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Flag Bits with Bit Stuffing Framing Method
• This methods achieves the same thing as Byte
Stuffing method by using Bits (1) instead of Bytes (8
Bits).
• It was developed for High-level Data Link Control
(HDLC) protocol.
• Each frames begins and ends with a special bit patter:
– 01111110 or 0x7E <- Flag Byte
– Whenever the sender’s data link layer encounters five
consecutive 1s in the data it automatically stuffs a 0 bit
into the outgoing bit stream.
– USB uses bit stuffing.
Shijo M Joseph Dept of Computer Science
Framing (3)

Bit stuffing. (a) The original data. (b) The data as they appear on
the line. (c) The data as they are stored in the receiver’s memory after destuffing.

Shijo M Joseph Dept of Computer 25


Science
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Physical layer coding violation

The last method of framing 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. Normally, a 1 bit is a high-low pair and a 0 bit is a low-high
pair.
The scheme means that every data bit has a transition in the
middle, making it easy for the receiver to locate the bit boundaries.
The combinations high-high and low-low are not used for data but
are used for delimiting frames in some protocols

Shijo M Joseph Dept of 26


Computer
Computer Networks, Fifth Edition by Andrew TanenbaumScience
and David Wetherall, © Pearson Education-Prentice Hall, 2011
Framing

• Many data link protocols use a combination


of presented methods for safety. For
example in Ethernet and 802.11 each frame
begin with a well-defined pattern called a
preamble.
• Preamble is typically 72 bits long.
• It is then followed by a length fileld.

Shijo M Joseph Dept of Computer Science


Error Control
• 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.
• Unacknowledged connectionless service: it is
OK for the sender to output frames
regardless of its reception.
• Reliable connection-oriented service: it is
NOT OK.
Shijo M Joseph Dept of Computer Science
Error Control
• Reliable connection-oriented service usually will
provide a sender with some feedback about what is
happening at the other end of the line.
– Receiver Sends Back Special Control Frames.
– If the Sender Receives positive Acknowledgment it
will know that the frame has arrived safely.
• Timer and Frame Sequence Number for the Sender
is Necessary to handle the case when there is no
response (positive or negative) from the Receiver .

Shijo M Joseph Dept of Computer Science


Flow Control

• Another 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

Shijo M Joseph Dept of Computer Science


Feedback-based Flow Control

• Receiver sends back information to the sender giving it


permission to send more data, or
• Telling sender how receiver is doing.

Shijo M Joseph Dept of Computer Science


Rate-based Flow Control

• Built in mechanism that limits the rate at which sender may


transmit data, without the need for feedback from the receiver.

Shijo M Joseph Dept of Computer Science


Flow Control
• Another important design issue that occurs in the data
link layer is what to do with a sender that
systematically wants to transmit frames faster than the
receiver can accept them.
• This situation can easily occur when the sender is
running on a fast computer and the receiver is running
on a slow machine.
• The sender keeps pumping the frames out at a high
rate until the receiver is completely flooded.
• Even if the transmission is error free, at a certain point
the receiver will simply be unable to handle the frames
as they arrive and will start to lose some.
Shijo M Joseph Dept of Computer Science
• Two approaches are commonly used to prevent this
situation feed- back based flow control and rate-
based flow control.
• In feedback-based flow control, the receiver
sends back information to the sender giving it
permission to send more data or at least telling the
sender how the receiver is doing.
• In the rate-based flow control, the protocol has a
built-in mechanism that limits the rate at which
senders may transmit data, without using feedback
from the receiver.
Shijo M Joseph Dept of Computer Science
Elementary Data Link Protocols
• it is useful to make explicit some of the assumptions
underlying the model of communication.
• We assume that in the physical layer, data link layer,
and network layer are independent processes that
communicate by passing messages back and forth.
• In many cases, the physical and data link layer
processes will be running on a processor inside a
special network I/O chip and the network layer code
will be running on the main CPU.
• These protocols deal with communication errors, but
not the problems caused by computers crashing and
rebooting.
Shijo M Joseph Dept of Computer Science
• When the data link layer accepts a packet, it
encapsulates the packet in a frame by adding a data
link header and trailer to it.
• Thus, a frame consists of an embedded packet, some
• control information in the header, and a checksum in
the trailer.
• The frame is then transmitted to the data link layer on
the other machine.

Shijo M Joseph Dept of Computer Science


• Initially, the receiver has nothing to do. It just sits
around waiting for something to happen.
• In the example protocols of this chapter we will
indicate that the data link layer is waiting for
something to happen by the procedure call
wait_for_event (&event).

Shijo M Joseph Dept of Computer Science


• When a frame arrives at the receiver, the hardware computes
the checksum. If the checksum is incorrect i.e., there was a
transmission error, the data link layer is so informed event =
cksum_err.
• If the inbound frame arrived undamaged, the data link layer is
also informed event = frame_arrival
• As soon as the receiving data link layer has acquired an
undamaged frame, it checks the control information in the
header, and if everything is all right, passes the packet portion
to the network layer.
• Under no circumstances is a frame header ever given to a
network layer

Shijo M Joseph Dept of Computer Science


Unrestricted Simplex Protocol
• The Unrestricted Simplex Protocol is a simple
protocol. Data are transmitted in one direction only.
Both the transmitting and receiving network layers are
always ready.
• Processing time can be ignored. Infinite buffer space
is available. And best of all, the communication
channel between the data link layers never damages
or loses frames.
• This is an unrealistic protocol, and hence nicknamed
utopia.

Shijo M Joseph Dept of Computer Science


Shijo M Joseph Dept of Computer Science
• The protocol consists of two distinct procedures, a
sender and a receiver.
• The sender runs in the data link layer of the source
machine, and the receiver runs in the data link layer of
• the destination machine
• The only event type possible is frame_arrival i.e., the
arrival of an undamaged frame.

Shijo M Joseph Dept of Computer Science


• The sender is in an infinite while loop just pumping
data out onto the line as fast as it can.
• The body of the loop consists of three actions- go
fetch a packet from the network layer, construct an
outbound frame using the variable s, and send the
frame on its way.
• Only the info field of the frame is used by this protocol,
because the other fields have to do with error and
• flow control and there are no errors or flow control
restrictions here.

Shijo M Joseph Dept of Computer Science


• The receiver is equally simple. Initially, it waits for
something to happen, the only possibility being the
arrival of an undamaged frame.
• Eventually, the frame arrives and the procedure
wait_for_event returns, with event set to frame_arrival.
The call to from_physical_layer removes the newly
arrived frame from the hardware buffer and puts it in
• the variable r, where the receiver code can get at it.
• Finally, the data portion is passed on to the network
layer, and the data link layer settles back to wait for
the next frame, effectively suspending itself until the
frame arrives. Shijo M Joseph Dept of Computer Science
Simplex Stop and Wait Protocol
• The main problem we have to deal with here is
how to prevent the sender from flooding the
receiver with data faster than it is able to process
them.
• if the receiver requires a time t to execute
from_physical_layer and to_network_layer, the
sender must transmit at an average rate less than
one frame per time t.
• Moreover, if we assume that no automatic buffering
and queueing are done within the receiver’s
hardware, the sender must never transmit a new
frame until the old one has been fetched by
from_physical_layer.
Shijo M Joseph Dept of Computer Science
• In certain restricted circumstances, it might be
possible for the sender to simply insert a delay
into protocol 1 to slow it down sufficiently to
keep from swamping the receiver.
• However, more usually, each data link layer
will have several lines to attend to, and the
time interval between a frame arriving and its
being processed may vary considerably

Shijo M Joseph Dept of Computer Science


• If the network designers can calculate the
worst-case behavior of the receiver, they can
program the sender to transmit so slowly that
even if every frame suffers the maximum
delay, there will be no overruns. The trouble
with this approach is that it is too conservative.
• It leads to a bandwidth utilization that is far
below the optimum, unless the best and worst
cases are almost the same.

Shijo M Joseph Dept of Computer Science


• A more general solution to this dilemma is to have the
receiver provide feedback to the sender.
• A more general solution to this dilemma is to have
the receiver provide feedback to the sender which in
effect gives the sender permission to transmit the
next frame.
• After having passed a packet to its network layer, the
receiver sends a little dummy frame back to the
sender which, in effect, gives the sender permission
to transmit the next frame.

Shijo M Joseph Dept of Computer Science


• After having sent a frame, the sender is required by
the protocol to bide its time until the little dummy
frame arrives
• Using feedback from the receiver to let the sender
know when it may send more data is an example of
the flow control mentioned earlier.
• Protocols in which the sender sends one frame and
then waits for an acknowledgement before
proceeding are called stop-and-wait.
• An example of a simplex stop-and-wait protocol
• is given here.
Shijo M Joseph Dept of Computer Science
...
A simplex stop-and-wait protocol.
Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
The only difference between receiver1 and receiver2 is
that after delivering a packet to the network layer,
receiver2 sends an acknowledgement frame back to
the sender before entering the wait loop again.
Only the arrival of the frame and not its content back at
the sender is important, the receiver need not put
any particular information in it.

Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Simplex Protocol For Noisy Channel
Now let us consider the normal situation of a
communication channel that makes errors. Frames
may be either damaged or lost completely.
However, we assume that if a frame is
damaged in transit, the receiver hardware will detect
this when it computes the checksum.
If the frame is damaged in such a way that the
checksum is nevertheless correct, this protocol can
fail i.e., deliver an incorrect packet to the network
layer.

Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
a) The network layer on machine A gives a series of
packets to its data link layer, which must ensure that
an identical series of packets are delivered to the
network layer on machine B by its data link layer.
b) In particular, the network layer on B has no way of
knowing that a packet has been lost or duplicated,
so the data link layer must guarantee that no
combination of transmission errors, however unlikely,
can cause a duplicate packet to be delivered to a
network layer. For this a sequence number can be
included.

Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
At each instant of time, the receiver expects a particular
sequence number next. Any arriving frame
containing the wrong sequence number is rejected
as a duplicate.
When a frame containing the correct sequence number
arrives, it is accepted and passed to the network
layer.

Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Protocol 3 differs from its predecessors in
that both sender and receiver have a variable
whose value is remembered while the data link
layer is in the wait state.
The sender remembers the sequence number
of the next frame to send in
next_frame_to_send; the receiver remembers
the sequence number of the next frame
expected in frame_expected.
Each protocol has a short initialization phase
before entering the infinite loop.
Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
After transmitting a frame, the sender starts the timer
running. If it was already running, it will be reset to allow
another full timer interval.
The time interval should be chosen to allow enough
time for the frame to get to the receiver, for the receiver to
process it in the worst case, and for the
acknowledgement frame to propagate back to the sender.
Only when that time interval has elapsed is it safe to
assume that either the transmitted frame or its
acknowledgement has been lost, and to send a duplicate.
If the timeout interval is set too short, the sender will
transmit unnecessary frames. While these extra frames
will not affect the correctness of the protocol, they will
hurt performance

Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
After transmitting a frame and starting the timer, the
sender waits for something exciting to happen.
Only three possibilities exist: an acknowledgement
frame arrives undamaged, a damaged
acknowledgement frame staggers in, or the timer
expires.
If a valid acknowledgement comes in, the sender
fetches the next packet from its network layer and puts
it in the buffer, overwriting the previous packet.

Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
It also advances the sequence number. If a
damaged frame arrives or no frame at all
arrives, neither the buffer nor the sequence
number is changed so that a duplicate can be
sent.
When a valid frame arrives at the receiver, its
sequence number is checked to see if it is a
duplicate. If not, it is accepted, passed to the
network layer, and an acknowledgement is
generated. Duplicates and damaged frames
are not passed to the network layer.
Shijo M Computer
Joseph Dept Networks,
of Computer Science
Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011
End

Computer Networks, Fifth Edition by Andrew Tanenbaum and David Wetherall, © Pearson Education-Prentice Hall, 2011

You might also like