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

Mod2.Data Link Layer - 1

Uploaded by

rithualex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Mod2.Data Link Layer - 1

Uploaded by

rithualex
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

Data Link Layer

Module2
Data Link Layer Design Issues/Functionalities
of DLL
• Services Provided to the Network Layer
• Framing
• Error Control
• Flow Control

2
Functions of the Data Link Layer
• To accomplish the above goals DLL 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.

• Frame management forms the heart of DLL

3
Relationship between packets and frames.

4
Services provided to the Network Layer

• The function of the data link layer 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

5
Services provided to the Network Layer

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
6
Services provided to the Network Layer

The actual transmission follows the Path as shown below

Actual Communication.
7
Services provided to the Network Layer

• DLL commonly provides 3 services


• Unacknowledged connectionless service
• Acknowledged connectionless service
• Acknowledged connection-oriented service

8
Framing
• Data-link layer takes the packets from the Network Layer and
encapsulates them into frames.
• Process of breaking down a stream of bits into smaller, manageable
units called frames is known as Framing
• To provide service to the network layer, the data link layer must use
the service provided to it by the physical layer.
• What the physical layer does is accept a raw bit stream and attempt
to deliver it to the destination.
• This bit stream is not guaranteed to be error free.
Framing
• The number of bits received may be less than, equal to, or more than
the number of bits transmitted, and they may have different values.
• It is up to the data link layer to detect and, if necessary, correct errors.
• The usual approach is for the data link layer to break the bit stream
up into discrete frames and compute the checksum for each frame.
• 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- Types

• Framing can be of two types

1. Fixed-sized Framing
2. Variable – Sized Framing
Fixed-sized Framing
• Here the size of the frame is fixed and so the frame length acts as delimiter of
the frame.
• Consequently, it does not require additional boundary bits to identify the
start and end of the frame.
Framing- Types
• Variable – Sized Framing
• Here, the size of each frame to be transmitted may be different.
• So additional mechanisms are kept to mark the end of one frame and the
beginning of the next frame.
• One way to achieve this framing is to insert time gaps between frames, much
like the spaces between words in ordinary text.
• However, networks rarely make any guarantees about timing, so it is possible
these gaps might be squeezed out or other gaps might be inserted during
transmission.
Methods of Framing

1. Character count.
2. Flag bytes with byte stuffing.
3. Starting and ending flags, with bit stuffing.
4. Physical layer coding violations.
1. Character count.

• Uses a field in the header to specify the number of characters in the


frame.
• When the data link layer at the destination sees the character count,
it knows how many characters follow and hence where the end of the
frame is

Without errors
Character count

• The trouble with this method is that the count can be garbled by a
transmission error.
• For example, if the character count of 5 becomes a 7, the destination
will get out of synchronization and will be unable to locate the start of
the next frame
• For this reason, the character count method is rarely used anymore.
2.Flag bytes with byte stuffing

• The problem with character count can be overcome by this method.


• In this method each frame start and end with special bytes called
FLAG byte as shown below

• if the receiver ever loses synchronization, it can just search for the
flag byte to find the end of the current frame.
• Two consecutive flag bytes indicate the end of one frame and start of
the next one.
Flag bytes with byte stuffing
• A serious problem occurs with this method when binary data, such as
object programs or floating-point numbers, are being transmitted.
• It may easily happen that the flag byte's bit pattern occurs in the data.
• This situation will usually interfere with the framing.
• One way to solve this problem is to have the sender's data link layer
insert a special escape byte (ESC) just before each ''accidental'' flag
byte in the data.
• The data link layer on the receiving end removes the escape byte
before the data are given to the network layer.
• This technique is called byte stuffing or character stuffing.
• Thus, a framing flag byte can be distinguished from one in the data
by the absence or presence of an escape byte before it.
Four examples of byte sequences before and after
stuffing.
Framing

✔Flag bytes with byte stuffing


✔If an escape byte occurs in the middle of the data, it is also
stuffed with an escape byte.
✔Thus, any single escape byte is part of an escape sequence,
whereas a doubled one indicates that a single escape occurred
naturally in the data
✔Application:
✔Used in PPP (point-to-point protocol)
✔most home computers use PPP to communicate with their
Internet service provider
✔Disadvantage of this framing method
✔it is closely tied to the use of 8-bit characters
✔Not all character codes use 8-bit characters.
✔UNICODE uses 16-bit characters

21
3.Starting and ending flags, with bit stuffing

• Technique allows data frames to contain an arbitrary number of bits


and allows character codes with an arbitrary number of bits per
character.
• Each frame begins and ends with a special bit pattern, 01111110 (in
fact, a 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.
This bit stuffing is analogous to byte stuffing, in which an escape byte
is stuffed into the outgoing character stream before a flag byte in the
data
Starting and ending flags, with bit stuffing

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

• With bit stuffing, the boundary between two frames can be unambiguously
recognized by the flag pattern.

• Thus, if the receiver loses track of where it is, all it has to do is scan the input
for flag sequences,
• since they can only occur at frame boundaries and never within the data
Starting and ending flags, with bit stuffing-Example

• (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
4.Physical layer coding violations
• only applicable to networks in which the encoding on the
physical medium contains some redundancy
• Eg: 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
25
Error Control
• To make sure all frames are eventually delivered to the
network layer at the destination and in the 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
• For reliable delivery, 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 26
Error Control
• Problem:
• hardware troubles may cause a frame to vanish completely
• In this case, the receiver will not react at all, since it has no
reason to react.
• Thus sender transmits a frame and then waits for an
acknowledgement, positive or negative, will hang forever if a
frame is ever lost
• Solution:
• by introducing timers into the DLL

27
Error Control

✔Use of Timer in DLL


• 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.
• acknowledgement will get back before the timer runs out
• in which case the timer will be canceled
• 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 28
Error Control

• Another Problem : receiving frames multiple times


• Solution:
• to assign sequence numbers to outgoing frames, so that the
receiver can distinguish retransmissions from originals

29
Flow Control
• Mechanisms used to prevent a fast sender from
overloading a slow receiver with data
• This situation occurs when the sender is running on a fast
(or lightly loaded) computer and the receiver is running
on a slow (or heavily loaded) machine.
• The sender keeps pumping the frames out at a high rate
until the receiver is completely swamped.
• 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
• Two approaches
• feedback-based flow control
• rate-based flow control 30
Flow Control
• 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
• The protocol contains well-defined rules about
when a sender may transmit the next frame

• 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

31
Problems
Given the output after byte-stuffing: FLAG A B ESC ESC C ESC ESC ESC
FLAG ESC FLAG D F FLAG. What is the original data?
solution
ANS: A B ESC C ESC FLAG FLAG D F
Question
The following character encoding is used in a data link protocol: A:
01000111; B: 11100011; FLAG: 01111110; ESC: 11100000 Show the bit
sequence transmitted (in binary) for the four-character frame: A B ESC
FLAG when each of the following framing methods are used:
(a) Character count
(b) Flag bytes with byte stuffing.
(c) Starting and ending flag bytes, with bit stuffing.
Solution
ANS: a) 00000100 01000111 11100011 11100000 01111110
b) 01111110 01000111 11100011 11100000 11100000 11100000
01111110 01111110
c) 01111110 01000111 110100011 11100000 011111010 0111110
QUESTION
The following character encoding is used in a data link protocol: A:
11010101; B: 10101001; FLAG: 01111110; ESC: 10100011 Show the bit
sequence transmitted (in binary) for the five-character frame: A ESC B
ESC FLAG when each of the following framing methods are used:
(a) Flag bytes with byte stuffing.
(b) Starting and ending flag bytes, with bit stuffing.
SOLUTION
ANS:
a) 01111110 11010101 10100011 10100011 10101001 10100011
10100011 10100011 01111110 01111110
b) 01111110 11010101 10100011 10101001 10100011 011111010
0111110
• A bit string, 0111101111101111110, needs to be transmitted at the
data link layer. What is the string actually transmitted after bit
stuffing?
Ans
The output is 011110111110011111010
• The following data fragment occurs in the middle of a data stream for
which the bytestuffing algorithm described in the text is used: A B ESC
C ESC FLAG FLAG D. What is the output after stuffing?

You might also like