0% found this document useful (0 votes)
14 views77 pages

Unit 2 (Part-1) - Data Link Layer

Uploaded by

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

Unit 2 (Part-1) - Data Link Layer

Uploaded by

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

DATA LINK Layer

Unit 2(Part-1)
Frame design considerations
The first and foremost task of the data link layer is to format the user data as
series of frames each having a predefined structure. A frame contains user data
and control fields. Each frame is processed as one entity for error and flow
control, i.e. if an error is detected, the whole frame is retransmitted.

The format of a frame, in general, consists of three components

• Header

• Data

. Trailer.
Types of Frame Formats

The frame format is so designed that the receiver is always able to locate the
beginning of a frame and its various fields, and is able to separate the data
field.

To identify a frame and its various fields, field identifiers/delimiters are


incorporated in it.

These are unique symbols which indicate by the presence the beginning and
end of a frame or a specific field.
The header and the trailer consist of one or more fields containing data
link protocol control information.
The frame starts with a flag to identify the start of frame

The flag is followed by an address field.

The control field contains the sequence number of the frame, acknowledgement
of the receipt of a frame or other control information. The data field contains the
user data received from the network layer.
The frame check sequence (FCS) contains bits for error detection. Each
HDLC frame is always followed by a flag which acts as a frame delimiter.
For example,the flags in an HDLC frame indicate the start and end of the frame. The
requirement of field identifiers and delimiters is determined by the frame structure.

A data link protocol may adopt fixed or variable formats of the frames. In fixed format, all the
fields are always present in all the frames. In variable format, the presence of any field is
optional. The length of a frame may also be fixed or variable.
Thus, there are several

possibilities:

Variable format-variable length

Fixed format-fixed length

Fixed format-variable length.


Variable format-variable length.

● All the fields are optional and if a field is present, its size is variable.
● In all, delimiters/identifiers are required. X is the frame start identifier.
The presence of each field is indicated by a field identifier which also acts
as delimiter for the previous field.
● As the size of frame is variable an end delimiter Y is required to indicate
the end of the frame.
Fixed format-fixed length.
In this case the format of the frame is decided once for all and the field sizes
are also fixed in all the frames.

Only on identifier is required at the beginning of the frame.


On receipt of the identifier, the receiver able to identify all the fields as the
format of the frame and the sizes of the various fields an known to the receiver
in advance.
Fixed format-variable length.

In this case frame start and end identifier/delimiters are required.


The identifier for the first field is not required as the frame identifier a
identifies the field. As regards other fields, field delimiters are required for
each field.
Transparency
Transparency refers to providing a service to the users wherein no
restriction is placed on the contents of the user data.

● Since any bit pattern can be sent by the user. problems may arise if the
data field contains bit patterns similar to the field
identifiers/delimiters.
● For example, if the data field of the HDLC frame contains a bit pattern
identical to the flag. the receiver may mistake it for the end flag of the
frame.
Therefore, the field identifiers and delimiters should not be present in any
field apart from their predefined locations in the frame.
Bit-Oriented and Byte-Oriented Data Link Protocols

● The data link protocols can be categorized as bit-oriented and byte-oriented


data link protocols.
● In a bit-oriented data link protocol, control information is coded at bit level
and the length of the data field may not be a multiple of bytes
● Bit level implies that a control symbol need not to be one full byte.
● For example, in HDLC protocol which is a bit-oriented protocol, the first bit of
the control field of the HDLC frame indicates the type of frame,
● Byte-oriented data link protocols define all the control symbols that are at least
one byte long. The size of data field is also a multiple of bytes
FLOW CONTROL MECHANISMS
● Flow control mechanisms are incorporated to ensure that the data link layer at the
sending end does not send more frames containing data than what the data link layer
at receiving end is capable of handling.
● Therefore, the receiver is provided with a control to regulate the flow of the
incoming frames.
● This control is in the form of an acknowledgement which is sent by the receiver.
The acknowledgement serves two purposes:
● It clears the sender to transmit the next data frame.
● It acknowledges receipt of all previous frames.
There are two methods of flow control:
● stop and wait
● sliding window

In stop-and-wait mechanism, the sending end sends one data frame at a time and waits for an
acknowledgement (ACK) from the receiver.
Stop-and-Wait Flow
Control
In stop-and-wait flow control, the receiver can temporarily stop flow of data
frames by withholding the acknowledgement.

Alternatively, it can request for temporary suspension of transmission of the


data frames by sending ACK and WAIT (WACK).

On receipt of WACK, the sending end waits for ACK to recommence transmission
of the next data frame.

WACK suspends transmission of data frames only.


Link utilization in stop-and-wait flow control.
In the stop-and-wait flow control mechanism, only one data frame is sent at a
time and each frame is individually acknowledged. The data frame and the
acknowledgement take a certain amount of propagation time to travel across
the link.

. If average size of a frame is L bits and the data rate is R.


If average size of a frame is L bits and the data rate is R. sending device (A) shall
complete transmission of one frame in time given by t_{f} = L/R

If tp is the propagation time, the frame is completely received by receiving


device
(B) after time t_f+f_p

.To calculate the best possible utilization of the link, let us assume that
● the receiver sends back acknowledgement immediately on receipt of
a data frame.
● the size of the acknowledgement frame is very small and
● there are no errors in the data frame or its acknowledgement
The sending end (A) will receive the acknowledgement after time
t_f+ tp+tp , and can send the next data frame immediately
thereafter.

Out of the total time t_{f} + 2tp


A has utilized the link for time t_f, only for transmission of its data frame
Therefore, link utilization efficiency U is given by
In Stop-and-Wait, after sending one frame, the sender must wait for an acknowledgment before
sending the next frame. During this time, the link remains idle. Therefore, the utilization is the ratio
of the time spent sending data to the total time spent on one transmission cycle (transmitting the
frame + waiting for acknowledgment).

● Total Time: This includes:


○ Frame Transmission Time (t_f): Time to send the frame.
○ Round Trip Time (2t_p): Time for the frame to travel to the receiver and for the
acknowledgment to come back.

So, the total time per frame is tf+2tp.


● When A is small (low propagation delay compared to transmission time), utilization
UUU approaches 1, meaning the link is efficiently used.

● When A is large (high propagation delay), the utilization decreases significantly, meaning
a lot of time is spent waiting for acknowledgments, reducing efficiency.
Calculate the maximum link utilization efficiency for stop-and-wait flow
control mechanism if the frame size is 2400 bits, bit rate is 4800 bps, and
distance between the devices is 2000 km. Speed of propagation over the
transmission media can be taken as 200,000 km/s.
problem 2:
You are transmitting a data frame of size 1,000 bits over a link with
a data rate of 1 Mbps (1,000,000 bits per second). The propagation
delay from the sender to the receiver is 10 ms. Calculate the link
utilization U.( refer to your note book)
Sliding Window Flow Control

In sliding window flow control mechanism, the sending end continues to


transmit the next data frame without waiting for acknowledgement for the
last frame

In this case the sender sends six more data frames before it receives
acknowledgement for the first data frame. Therefore, the link does not remain
idle and link utilization efficiency is improved.
Sliding window flow control is based on the following
acknowledgement mechanism:
● Each data frame carries a sequence number for its identification.
● The receiver acknowledges receipt of one or more data frames by sending
back a numbered acknowledgement. The acknowledgement frame is
written as RR-N (Receive Ready-N). N is the sequence number of the next
data frame the receiver expects to receive.
● All previous data frames are assumed acknowledged on receipt of an
acknowledgement. Note that all data frames are still acknowledged but
may not be individually
A sends data frames DO to D5. It receives acknowledgements RR2 and RRS. By sending RR2, the receiver
is acknowledging receipt of data frames bearing numbers DO and DI. RR3 is lost but it does not matter
because RR5 acknowledges all previous frames.
To stop the transmission of data frames temporarily, the receiving end can
send another type of acknowledgement, Receive Not Ready (RNR-N).

RNR-N is acknowledgement for data frames up to D(N-1) and a request to


stop further transmission temporarily.

RNR-N is equivalent to WACK of stop-and-wait mechanism.


Sliding window.
In sliding window flow control, the sender and the receiver need to store the
sent data frames temporarily in their respective buffers.

The sender needs buffer because it needs to keep copies of all the sent frames
for which acknowledgements are yet to be received.

The receiver may request for retransmission of a data frame that it received
with errors
The buffer size needs to be just sufficient to accommodate as many frames that
can be sent in the time required to get the acknowledgement of a data frame

. As soon as an acknowledgement for a sent data frame is received, the sender


can remove the copy of the frame from its buffer and let the next waiting
frame to occupy the buffer
The receiver stores the received data frames temporarily in its buffer because
the frames may be received out of sequence and it must put them in sequence
before processing them for retrieval of user data.

Data frames are received out of sequence when a frame is lost in


transit or received with errors.

A frame received with errors is as good as not received because the error may
be in its sequence number.
Limited memory availability at sending and receiving ends restricts
maximum number of data frames that

● can be sent by the sending end without receiving an acknowledgement


from the receiver, and
● can be received out of sequence at the receiving end.
We can consider the sending end buffer as window that contains frames waiting
to be transmitted or acknowledged.
As the acknowledgements are received, the copies of acknowledged frames are
deleted and new frames enter the window and line up for their turn.

It is equivalent to sliding the window to accommodate new frames and to expel


the acknowledged frames

Physically the window is defined in terms of three parameters


•Lower window edge (LWE),
•Upper window edge (UWE), and
•Window size (W)
Window at transmitting
end.

At the transmitting end, the window contains


● copies of those data frames that have been transmitted but
their acknowledgements are yet to be received,
● and the data frames which are next to be transmitted.

There can be altogether W such data frames in the window. When an


acknowledgement is received, copies of acknowledged data frames are
deleted from the window by sliding up the window. Equivalent number of
data frames awaiting transmission make entry in the window.
Window at receiving end.
At the receiving end, the window contains the sequence numbers of the
data frames the receiver is ready to accept.
Any received data frame having sequence number which is not in the window
is discarded. When an acknowledgement is sent, the window slides up to the
sequence number of data frame for which acknowledgement is to be sent
next.
The receiver does not send acknowledgements on receipt of data
frames immediately when it.is too busy or there are missing data
frames.
● Flow control mechanism.
● Device A is sending frames to device B.
● Let us assume that the window size is seven and the window is initially located on data
frames DO to D6.
● A initiates the transmission with its first frame D0 followed by frames D1, D2, etc.
● A can send frames up to D6 without getting any acknowledgement from B.
● While A is in the process of sending D2, it receives an acknowledgement RR2
from B. A slides the window by two frames deleting copies of DO and D1 from
the window.
● Data frames D2 to D8 now occupy the window and frames up to D8 can be sent
without waiting for further acknowledgement.
● At the receiving end B accepts D0 and DI data frames. It releases RR2 acknowledging
receipt of D0 and D1, and removes these frames from the window. The receive window
that was at DO-D6 slides to D2-D8. It next receives D2, D3, and D4 and releases RR5.
DATA LINK ERROR CONTROL
Two types of errors can occur during transmission of frames from one device to the other,
•Content error
•Flow integrity errors.

Errors contained in a received frame are termed content errors. Flow integrity errors refer to the
lost or duplicate data frames and acknowledgements. Data link error control takes care of both the
types of errors.

Content errors are detected using parity check or cyclic redundancy check bits. The check bits are
added as the trailer in a frame at the sending end. Their span of check usually cover all the bits in
the frame except the frame identifier If the flag itself is corrupted, the receiver will not recognize
the arrival of the frame
The most common method of content error correction is retransmission of the
frames. The receiver informs the sending end of the error and the sending end
retransmits the frame. Note that it is essential for the sending end to retain a
copy of the transmitted frame until it is acknowledged by the receiver.

For flow integrity errors, the data link protocols specify the procedures to be
adopted to detect and recover the missing/duplicate frames and
acknowledgements. These procedures are built into the flow control
mechanisms.
ERROR CONTROL IN STOP-AND-WAIT
There are two ways of implementing the content error control in
stop-and-wait mechanism,

Stop-and-wait using timeout


Stop-and-wait using negative acknowledgement (NAC) for

timeout Error Control Using Numbered Frames


Stop-and-Wait Using Timeout
In this case, the sender maintains a timer and if the acknowledgement is
not received within a predefined time interval, it retransmits the frame.

A is the sender of data frames and B is the receiver. B sends


acknowledgements.
a. Lost or damaged data frames
● • A sends a data frame and starts the timer.
● The frame is lost in transit. B does not receive any frame, or B receives the data
frame with content errors. It discards the frame.
● A waits for ACK and after timeout retransmits the frame.
B. Lost or delayed ACK
● B sends ACK for the received data frame
● The ACK is lost or is delayed. After timeout, A retransmits the frame
● B receives duplicate data frames but B does not know that the received frame is
duplicate frame.

c. Delayed Acknowledgement/Data

Assume the sender sends the data, which is also received by the receiver. The receiver then
transmits the acknowledgment, which is received after the sender’s timeout period. After a
timeout on the sender side, a long-delayed acknowledgement might be wrongly
considered as acknowledgement of some other recent packet.
Problems associated with Stop and Wait
Stop-and-Wait Using Negative Acknowledgement
(NAK)
the receiver sends a positive acknowledgement (ACK) if there is no content
error in the received data frame; else it responds with a
negative acknowledgement (NAK).

The sending end continues with the next data frame if it receives an ACK or
repeats the previous frame if it receives a NAK.
Lost or damaged data frame

• A sends a data frame and starts the timer.


The data frame is lost in transit. B does not receive any frame. A does not
receive ACK/ NAK. After expiry of timer, A retransmits the data frame.

B receives the data frame with content errors. It replies with a NAK. A
receives NAK before timeout. It immediately retransmits the data frame.
Lost or delayed NAK
B sends NAK for the received data frame with errors. The NAK is lost or is
delayed. After timeout, A retransmits the data frame in either case.

In case of delayed NAK, A having retransmitted the data frame, assumes that
the received NAK is for the retransmitted data frame and it retransmits the
data frame again B receives duplicate data frame but B does not know that the
received frame is duplicate frame.
Error Control Using Numbered Frames
To distinguish between consecutive frames and acknowledgements, a sequence number is
attached to them.

Since only one frame or one acknowledgement is in transit, only two numbers 0 and 1 are
required.

The data frames are alternatively assigned numbers 0 and I. We will call data frames as DO and
DI.

The ACKS and NAKS also carry the number.

The usual practice for assigning number to ACKS and NAKS is to indicate the number of data
frame next wanted, e.g. ACKI indicates to the sender that DI is required next.

It also implies that previous data frame DO has been received. NAKI indicates that DI is required
next because last received data frame DI had errors
ERROR CONTROL IN SLIDING WINDOW MECHANISM
In the sliding window mechanism, each frame is assigned a sequence number
and, therefore, a more elaborate error control scheme is feasible.

The receiver keeps track of the sequence numbers of the incoming data frames.

If any out-of-sequence frame is received, immediately, a request for


retransmission of the missing frame is sent. There are two choices for the
retransmission mechanism:

• Selective retransmission

• Go-back-N.
Selective retransmission.
In selective retransmission, the receiver maintains a window of data frames
that it is ready to accept.

The receive window size is usually same as transmit window size.


Whenever the receiver detects a missing data frame, it requests retransmission
of the missing data frame by sending a Selective Reject (SREJ-N).

N is the sequence number of the missing data frame.


On receipt of SREJ-N, the sending end retransmits frame N and then it
continues with the ongoing transmission.

The receiver accepts the succeeding data frames meanwhile if they are
received.
When the data frame N is received, it arranges all the frames in proper
sequence, retrieves the user data, and hand it over to the next upper layer.
selective retransmission/ selective repeat ARQ
1. The transmitter has sent frame 1,2,3,4 in the first attempt
2. After sending 4 frames, transmitter find feedback from receiver as Rej-2 , indicating
frame -2 detected with error
3. the transmitter re align its window with frame-2 is repeated followed by frame with
sequence number 5 and onwards
Go-Back-N
In go-back-N retransmission, the receiver maintains a window of size

1. The receiver can, therefore, accept only the next data frame in

sequence.

Whenever it notices a missing frame, it requests retransmission of the missing


data frame by sending Reject (REJ-N).

If any other data frame, other than frame N is received before frame N, the
receiver discards it.

REJ-N indicates request for retransmission of the all data frames starting with
the frame N.
Go-Back-N.
Go-Back-N.

● the receiver has encountered error, checksum of frame-2 is not


matches, the receiver plans feedback accordingly
● the feedback signal send by the receiver is RR-2, denoting frame 1 is
received successfully and receiver is waiting for frame 2 and onwards
● after getting the feedback RR-2, the transmitter realigns its window
from frame -2 and onwards
● here transmitter has to send frame -2 and onwards , no matter frame 3
and frame 4 are received correctly
● receiver discards all the frame from where the error is detected
In both the above schemes missing frames are detected when an
out-of-sequence frame is received.

REJ or SREJ are not sent on detection of content error in the received data
frame as the error could be in the sequence number of the frame itself.
The receiver waits for the next correct frame and then declares the missing

frame. Both SREJ-N and REJ-N also acknowledge receipt of data frames up to

N-1.
Error control using selective retransmission
a. Loss of a data frame
A has its transmit window at DO-D6. It sends DO.
B has its receive window at DO-D6. It receives DO, replies with RRI, and slides its
receive window to D1-D2

A sends DI which is lost in transit or is received with errors by B. A receives RRI


and it slides window to data frames D1-D7. A sends D2.

B accepts D2. But it finds missing data frame D1. It sends SREJ1. After sending a
SREJI, B cannot send RR till it receives the missing data frame D1 because sending
RR3 would imply receipt of all earlier frames.
A missing data frame is detected by the receiver when the next data
frame in sequence is received.

If the lost frame was the last data frame in the transmit window, the
receiver will never respond with SREJ.

Therefore, the sender maintains a timer. The timer is started when the
sender sends the last frame in the transmit window.

After timeout, it repeats all the frames in the window.

Alternatively, it solicits response from the receiver by sending a command.


b. Loss of RR or SREJ. If an RR is lost or delayed, the next RR released by the
receiver acknowledges all the previous data frames. Therefore, the operation is
unaffected. If there is no subsequent RR, the sender initiates action as indicated
above after the timeout.

To account for the possibility of loss of SREJ, the receiver also maintains a
timer. It is started as soon as SREJ is released. If the required data frame is not
received within timeout, SREJ is sent again by the receiver.
Error Control Using Go-Back-N
window size of seven at the sending end (A). The window size at the receiving
end (B)
a. Loss of a data frame
● A has its transmit window at DO-D6.
● It sends Do. B has its receive window at DO. It receives DO, replies with RR1 and
slides its receive window to DI
● A sends DJ which is lost in transit or is received with errors by B.
● A receives RR1 and it slides window to data frames D1-D7. A sends D2.
● On receipt of D2, B finds missing data frame DI. B discards
D2 and sends REJI. A sends D3. B discards D3.
● A receives REJI. It sends D1. B accepts D1 and sends RR2.
● A sends D2.
● On receipt of RR2, A slides its window to D2-D8.
● A sends D3. B accepts D2 and sends RR3
b. Loss of a RR or REJ
. If an RR is lost or delayed, the next RR released by the receiver acknowledges
all the previous data frames. Therefore, the operation is unaffected.

If there is no subsequent RR, the sender initiates action as indicated above


after the timeout.

To account for the possibility of loss of REJ, the receiver maintains a timer
and retransmits the REJ after timeout.
SEQUENCE NUMBERING OF THE FRAMES IN SLIDING
WINDOW FLOW CONTROL
In the sliding window mechanism, all data frames are given a binary
sequence number having a fixed number of bits.

Any numbering scheme of fixed size has a finite count sequence after which it
must start all over again from the beginning.

If sequence number consists of n bits, the length of the count sequence would
be 2".

For example, the three-bit numbering scheme counts from 0 to 7 and then
starts again from 0
On receipt of RR2, A sends all the four data frames in the window and waits for
acknowledgement. Suppose all the four data frames are lost in transit. After
timeout A challenges B. B repeats the previous acknowledgement (RR2).

A assumes that this RR2 is acknowledgement of the data frame D1 it just sent.
RR2 also acknowledges D0, D3, and D2. But as we know, B did not receive
these four frames.
This anomaly is resolved by restricting the window size to three (Figure 8.27b).
When B repeats RR2, A immediately realizes the loss of three frames it just
sent. Therefore, the maximum window size is restricted to 2"-1 for an n-bit
sequence number.
PIGGYBACKING ACKNOWLEDGEMENTS
● In general, both the devices will exchange information and will send data
frames and acknowledgements
● In the sliding window flow control mechanism, the acknowledgements can be sent
through special acknowledgement frames or, alternatively, they can be piggybacked
on a data frame.
● Thus, a data frame will have two sequence numbers, one for the data frame and the
other for the acknowledgement.
● Only RR can be piggybacked on a data frame.
● If a data frame does not have any new RR to report, it repeats the last RR sequence

number.

● REJ, SREJ, and RNR are always sent as separate frames.


PIGGYBACKING ACKNOWLEDGEMENTS
A to B: The top part shows that A is sending a data frame Data-N to B, along with an
acknowledgment RR-M of a frame received earlier from B.
B to A: Similarly, B sends Data-P to A, along with acknowledgment RR-Q of a
previous frame from A.
● Sequence Numbers:
○ M, Q are the sequence numbers for the acknowledgment frames,
acknowledging the last successfully received data frames.
○ N, P are the sequence numbers for the data frames.
Purpose of Piggybacking:
● In a simple communication scenario, acknowledgment frames (ACKs) are sent
back to the sender to inform it that the data has been received successfully.
● Piggybacking helps avoid sending a separate acknowledgment frame by
utilizing the same frame that contains data, saving time and bandwidth.
QUESTION BANK

1) Calculate the maximum link utilization efficiency for stop and wait flow control mechanism
is the frame size is 2400bits, bitrate is 4800bps, distance between the devices is 2000km
and speed of propagation over the transmission media can be taken as 200000km/s

2) a) What is the smallest size of Ethernet Frame? What is the largest size of Ethernet Frame?

3) In case of selective retransmission error control method in Sliding window, with a suitable
example explain what will happen if
a) a. Last frame in the transmit window is lost.
b) b. RR is lost or delayed.
c) c. SREJ is lost
QUESTION BANK

4. Draw the sender and receiver windows for a system using go-back- N ARQ, given the following:
a. Frame 0 is sent; frame 0 is acknowledged
b. Frames 1, 2 and 3 are sent; frames 1,2 and 3 are acknowledged
c. Frames 4, 5 and 6 are sent; NAK 5 is received.
d. Frames 5, 6 and 7 are sent; frames 4 through 7 are acknowledged.

5.What do you understand by piggybacking acknowledgement? (2)

6. Explain in detail how error control is done in the stop and wait flow control technique. (8)

7. Draw the sender and receiver windows for selective retransmission in the following scenario and
state the new frame that the sender can send and Justify.
i. six frames are sent and received. All acknowledgements are loss.
ii. Frames 0, 1, 2, 3 are sent and acknowledged New 2 frames are sent (6)
QUESTION BANK

8. Write a note on:


1)Sequence numbering of frames in sliding
2) Error control using numbered frames, window flow control stop and wait mechanism.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy