0% found this document useful (0 votes)
26 views46 pages

Datalink Layer

Uploaded by

syed.12682
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)
26 views46 pages

Datalink Layer

Uploaded by

syed.12682
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/ 46

WELCOME

Data Communication and


Computer Networks
Instructor:
Muhammad Daud Abbasi
Email: [email protected]

Lecture 2
Datalink layer
Learning Outcomes

Understanding of:
 Data Communication components and char-
acteristics
Data Link Layer

The Services Provided by the Link Layer

It is responsible for transmitting frames from one node to the next.


Its major duties are …
 Framing
 Link Access
 Flow Control(Reliable Delivery)
 Error Detection and Control
 Framing
A frame consists of a data field, in which the network-layer datagram is
inserted, and a number of header fields
 Link Access
A medium access control (MAC) protocol specifies the rules by which a frame is
transmitted onto the link
 Flow Control(Reliable Delivery)
When a link-layer protocol provides reliable delivery service, it guarantees to
move each network-layer datagram across the link without error. Similar to a
transport-layer reliable delivery service, a link-layer reliable delivery service can
be achieved with acknowledgments and retransmission.
 Error Detection and Control
The link-layer hardware in a receiving node can incorrectly decide that a bit in a
frame is zero when it was transmitted as a one, and vice versa.
Data Link Sublayers

The Data-Link layer contains two sublayers that are described in the IEEE-802 LAN
standards:

Data-Link Control (DLC)

Media Access Control (MAC)


Data Link Control

First we will discuss Data-link layer

Data-link control (DLC) deals with procedures for communication between two
adjacent nodes—node-to-node communication—no matter whether the link is
dedicated or broadcast
– Framing
– flow control
– error control
Framing

The data link layer packs bits into frames, so that each frame is distinguishable
from another

Framing in the data-link layer separates a message from one source to a des-
tination by adding a sender address and a destination address.
Frame Size

Frame Size

Frames can be of fixed or variable size.


fixed-size framing
In fixed-size framing, there is no need to define the boundaries of the frames; the
size itself can be used as a delimiter.

Variable-size framing
In variable-size framing, we need a way to define the end of one frame and the
beginning of the next. Historically, two approaches have been used for this purpose:

• character-oriented approach
• bit-oriented approach.
Character-Oriented Framing
Character-Oriented Framing
In character-oriented (or byte-oriented) framing, data to be carried are 8-bit characters from a coding
system such as ASCII. The header, which normally carries the source and destination addresses and
other control information, and the trailer, which carries error detection redundant bits, are also multi-
ples of 8 bits. To separate one frame from the next, an 8-bit (1-byte) flag is added at the beginning and
the end of a frame. The flag, composed of protocol-dependent special characters, signals the start or
end of a frame.
Character-Oriented Framing
Byte-stuffing
Character-oriented framing was popular when only text was exchanged by the
data-link layers. The flag could be selected to be any character not used for text
communication. Now, however, we send other types of information such as graphs,
audio, and video; any pattern used for the flag could also be part of the information.
If this happens, the receiver, when it encounters this pattern in the middle of the
data, thinks it has reached the end of the frame. To fix this problem, a byte-
stuffing strategy was added to character-oriented framing. In byte stuffing (or
character stuffing), a special byte is added to the data section of the frame when
there is a character with the same pattern as the flag. The data section is stuffed
with an extra byte. This byte is usually called the escape character (ESC) and has
a predefined bit pattern. Whenever the receiver encounters the ESC character, it
removes it from the data section and treats the next character as data, not as a
delimiting flag.
Character-Oriented Framing

Byte Stuffing and un-stuffing


What happens if the text contains one or more escape characters followed by a byte with the same pattern as the
flag?
To solve this problem , if the escape character is part of the text, an extra one is added to show that the second
one is part of the text

Byte stuffing is the process of


adding one extra byte whenever
there is a flag or escape character
in the text.
Bit-Oriented Framing

in bit-oriented framing, the data section of a frame is a sequence of bits to be interpreted by the upper
layer as text, graphic, audio, video, and so on.

However, in addition to headers (and possible trailers), we still need a delimiter to separate one frame from
the other. Most protocols use a special 8-bit pattern flag, 01111110, as the delimiter to define the
beginning and end of the frame, as shown in Figure
Bit Stuffing
This flag can create the same type of problem we saw in the character-oriented protocols. That is, if
the flag pattern appears in the data, we need to somehow inform the receiver that this is not the end
of the frame. We do this by stuffing one single bit (instead of one byte) to prevent the pattern from
looking like a flag. The strategy is called bit stuffing.

Bit stuffing is the process of adding one extra 0


whenever five consecutive 1s follow a 0 in the
data, so that the receiver does not mistake the
pattern 0111110 for a flag
Flow Control

Flow control refers to a set of procedures used to restrict the amount of data that
the sender can send before waiting for acknowledgment

Ensuring the sending entity does not overwhelm the receiving entity
Preventing buffer overflow (giving ample time to the processor to process)
Error Control

Error control in the data link layer is based on automatic repeat request, which is
the retransmission of data.
Automatic repeat request (ARQ)
– Error detection (Damaged Frames, Lost Frames)
– Positive acknowledgment
– Negative acknowledgement and retransmission
– Retransmission after timeout

Dr. Manzoor 17
Model of Frame Transmission
Data Link Control

Dr. Manzoor 19
Noiseless Channel

Let us assume we have an ideal channel in which no frames are lost, duplicated, or
corrupted

For such a channel we have…


– Simplest Method (no flow control)
– Stop-and-Wait Method (with flow control)

None of the above have error control as they are for noiseless (ideal) channel

Dr. Manzoor 20
Simplest Method

Dr. Manzoor 21
Stop-And-Wait

The sender sends one frame


Stops and Waits until it receives
confirmation from the receiver
Then sends the next frame
Thus Flow Control
Noisy Channel

In reality noiseless (error-free) channels do not exist


Therefore, in noisy channel, we need error control as well
Error control in the data link layer is based on Automatic Repeat Request (ARQ)

Dr. Manzoor 23
Automatic Repeat Request (ARQ)

Stop and wait

Go back N

Selective repeat
Stop and Wait ARQ

It is the simplest (i) flow and (ii) error control mechanism


Source transmits frame & keeps a copy
Destination receives frame and replies with acknowledgement
Source waits for ACK before sending next frame

Dr. Manzoor 25
Stop and Wait ARQ

If received frame damaged, discard it


– Transmitter has timeout
– If no ACK within timeout, retransmit
Numbering the frames prevents the retaining of duplicate frames
– ACK number defines the number of next expected frame
– Use ACK0 and ACK1
Operation of Stop and Wait

We can have four different situations in the transmission of a


frame:
1. Normal operation
2. Loss of frame (or Damaged frame)
3. Loss of ACK (or Damaged ACK)
4. Delay of ACK
1. Normal Operation
2. Lost or damaged frame

Lost or damaged frames are handled in


the same manner (No ACK)
3. Lost or damaged ACK

If ACK damaged transmitter will not recog-


nize it
– Transmitter will retransmit
– Receiver gets two copies of frame

Dr. Manzoor 30
4. Delayed ACK

Dr. Manzoor 31
Go-back-N ARQ

Stop-and-Wait ARQ is simple but inefficient

To improve efficiency multiple frames should be in transition while waiting for ACK

Transmitter can send W frames without ACK

A copy of each frame is kept until ACK arrives

Each frame is numbered


Sliding Window

In sliding window method, multiple frames are sent by sender at a time before need-
ing an acknowledgment

Sliding window refers to an imaginary boxes that hold the frames on both sender and
receiver side.
Sender sliding window

Sender uses a window to hold


frames until ACK
Frames on left of window are ac-
knowledged
Frames on right can’t be sent until
window slides over
Receiver sliding window

The size of window at receiver is 1


The receiver is always waiting for a specific frame to arrive in a specific
order
Go-Back-N Acknowledgment

If no error, ACK as usual with next frame expected


Receiver can send one cumulative ACK for several frames
If error,
– Discard that frame and all future frames until error frame received correctly
– Transmitter must go back and retransmit that frame and all subsequent frames

i.e. Go-Back-N
Operation of Go-back-N

We can have four different situations in the transmission of a frame:


1. Normal operation
2. Loss of frame (or Damaged frame)
3. Loss of ACK (or Damaged ACK)
4. Delay of ACK

Dr. Manzoor 37
1. Normal Operation
2. Lost or damaged frame
3 & 4. Lost or delayed ACK

If next ACK arrives before expiration of any timer then no re-


transmission
If next ACK arrives after timeout, the frame and all later
frames will be retransmitted.

Dr. Manzoor 40
Selective Repeat ARQ
Go-back-N ARQ
– simplifies the process at receiver site
– very inefficient for a noisy channel (resending many frames when
only one was damaged)
Solution: Selective Repeat ARQ
– Processing at receiver is complex
– More efficient for noisy links (resends damaged frames only)

Dr. Manzoor 41
Lost frame
Bandwidth-Delay Product

“Efficiency of an ARQ system can be measured by the product of


bandwidth (bps) and round-trip delay (sec)”
“It is a measure of the number of bits that can be sent out of a system
while waiting for ACKs”
Example
In a Stop-and-Wait ARQ system, the bandwidth of the line is 1 Mbps, and 1 bit takes 20 ms to
make a round trip. What is the bandwidth-delay product? If the system data frames are 1000 bits
in length, what is the utilization percentage of the link?

Solution
The bandwidth-delay product is

1  106 (bits/Sec)  20  10-3 (Sec) = 20,000 bits

The system can send 20,000 bits during the time it takes for the data to go from the sender to the receiver
and then back again. However, the system sends only 1000 bits. We can say that the link utilization is only
1000/20,000, or 5%. For this reason, for a link with high bandwidth or long delay, use of Stop-and-Wait
ARQ wastes the capacity of the link.
Example
What is the utilization percentage of the link in the previous example if the link
uses Go-Back-N ARQ with a 15-frame sequence?

Solution
The bandwidth-delay product is still 20,000. However , now the system can
send up to 15 frames or 15,000 bits during a round trip. This means the
utilization is 15,000/20,000, or 75 percent. Of course, if there are damaged
frames, the utilization percentage is much less because (some) frames have to
be resent.

Dr. Manzoor 45
THANK YOU

You might also like