Unit 2 (Part-1) - Data Link Layer
Unit 2 (Part-1) - 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.
• 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.
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 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:
● 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.
● 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
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.
On receipt of WACK, the sending end waits for ACK to recommence transmission
of the next data frame.
.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.
● 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 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).
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
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
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,
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
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 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.
• 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 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.
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.
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
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.
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.
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.
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.
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