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

Lecture.5 Data Link Layer -Flow and Error Control

The document covers the Data Link Layer's flow control, error control, and medium access control methods. It explains flow control techniques like Stop-and-Wait and Sliding Window, as well as error control mechanisms such as Automatic Repeat Request (ARQ) and various protocols like Go-Back-N and Selective Repeat. Additionally, it discusses medium access methods including Random Access and Controlled Access, detailing protocols like CSMA/CD and CSMA/CA for managing data transmission and collision handling.

Uploaded by

said yasin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lecture.5 Data Link Layer -Flow and Error Control

The document covers the Data Link Layer's flow control, error control, and medium access control methods. It explains flow control techniques like Stop-and-Wait and Sliding Window, as well as error control mechanisms such as Automatic Repeat Request (ARQ) and various protocols like Go-Back-N and Selective Repeat. Additionally, it discusses medium access methods including Random Access and Controlled Access, detailing protocols like CSMA/CD and CSMA/CA for managing data transmission and collision handling.

Uploaded by

said yasin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

Data Link Layer:

Flow Control, Error Control and


Medium Access Control

Lecture 5
Flow and Error Control
• 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 (ACK) from the receiver

• The flow of data must not be allowed to overwhelm the receiver

• The receiving device should be able to inform the sender before limits (processing speed
limit and temporal storage limits) are reached and request that the sender sends fewer
frames or stop temporarily.

• The rate of processing is often slower than the rate of transmission. The receiver has a
block of memory called buffer, reserved for storing incoming data until they are
processed.

▪ Two method to the flow of data across communication link are Stop-and-wait and
sliding window
Categories of flow control
Stop-and-Wait
Stop-And-Wait

Frame types
▪ Data: Contain information to be sent
▪ ACK: Acknowledges receipt of data
Rules:
▪ Source transmits Data frame
▪ Source waits for ACK frame before sending next Data frame
▪ Destination receives Data frame and replies with ACK frame
if ready for more
▪ Destination can stop flow of data by not sending ACK frame
Stop-And-Wait…..cont

▪ Advantage of Stop- and -Wait


Simplicity: Each frame is checked and acknowledged
before the next frame is sent

▪ Disadvantage of Stop-and-Wait
Inefficiency: Stop-and-wait is slow. Each frame must travel all the
way to the receiver and the acknowledgement must travel all the
way back before the next frame can be sent
Sliding window

▪ In sliding window method, multiple frames are sent


by sender at a time before needing an
acknowledgment.

▪ Multiple frames sent by source are acknowledged by


receiver using a single ACK frame
Sliding Window
• Sliding window refers to an imaginary boxes that hold the frames
on both sender and receiver side.
• It provides the upper limit on the number of frames that can be
transmitted before requiring an acknowledgment.
• Frames may be acknowledged by receiver at any point even when
window is not full on receiver side.
• Frames may be transmitted by source even when window is not
yet full on sender side.
• The windows have a specific size in which the frames are
numbered modulo- n, which means they are numbered from 0 to
n-l. For e.g. if n = 8, the frames are numbered 0, 1,2,3,4,5,6, 7, 0,
1,2,3,4,5,6, 7, 0, 1, ....
• The size of window is n-1. For e.g. In this case it is 7. Therefore,
a maximum of n-l frames may be sent before an
acknowledgment.
• When the receiver sends an ACK, it includes the number of next
frame it expects to receive. For example in order to
acknowledge the group of frames ending in frame 4, the receiver
sends an ACK containing the number 5. When sender sees an
ACK with number 5, it comes to know that all the frames up to
number 4 have been received.
Example of Sliding Window
Error control
▪ When data-frame is transmitted, there is a probability that data-
frame may be lost in the transit or it is received corrupted. In both
cases, the receiver does not receive the correct data-frame and
sender does not know anything about any loss. In such case, both
sender and receiver are equipped with some protocols which
helps them to detect transit errors such as loss of data-frame.
Hence, either the sender retransmits the data-frame or the receiver
may request to resend the previous data-frame.
Error Control -Refers to procedures to detect and correct errors

➢ Requirement for error control mechanism:


▪ Error detection
▪ Positive Acknowledgement (ACK): if the frame arrived with no
errors
▪ Negative Acknowledgement (NAK): if the frame arrived with
errors
▪ Retransmissions after timeout: Frame is retransmitted after certain
amount of time if no acknowledgement was received
▪ These actions are called Automatic Repeat Request (ARQ)
Error Control
• Usually Error and flow control protocols are combined together to
provide reliable data transfer service called data link control
• Stop-and-Wait ARQ
• Go-Back-N ARQ
• Selective repeat ARQ
• ARQ provide reliable data transfer service over unreliable
networks
• ARQ ensure that transmitted data is delivered accurately to the
destination despite errors that occur during transmission and
satisfies the following:
– Error free
– Without duplicates
– Same order in which they are transmitted
– No loss
Error Control
❑ Automatic Repeat Request (ARQ)

▪ ARQ: anytime an error is detected in an exchange, a negative


acknowledgement is returned (NAK) and the specified frame is
retransmitted.
▪ ARQ’s main function is the retransmission of damaged frames
and lost frames including lost ACK and NAK – where the loss is
detected by the sender instead of the receiver.

➢ There are three types of techniques available which Data-link


layer may deploy to control the errors by ARQ
Error Control
Stop-and-Wait ARQ

▪ In Stop-and-Wait ARQ, Stop-and-Wait is extended to include


retransmission of frames in case of lost or damaged frames

For retransmission to work four features are required:

1. The sending device keeps a copy of last frame transmitted until it


receives acknowledgement of that frame.
2. For identification purpose, both data frame and ACK frames are
numbered alternately 0 and 1.
3. If an error is discovered in a data frame, indicating that it had
been corrupted in the transit, a NAK frame is returned. NAK is
not numbered and it tells the sender to retransmit the last sent
frame
Stop-and-Wait ARQ

4 The sending device is equipped with timer. If an expected


acknowledgement is not received within an allotted time period,
the sender assumes that the last data frame was lost in transit
and sends again
Stop-and-Wait ARQ, damaged data frame
Stop-and-Wait ARQ, lost data frame
Stop-and-Wait ARQ, lost ACK frame
The following transition may occur in Stop-and-Wait ARQ:
1. The sender maintains a timeout counter.
2. When a frame is sent, the sender starts the timeout counter.
3. If acknowledgement of frame comes in time, the sender
transmits the next frame in queue.
4. If acknowledgement does not come in time, the sender
assumes that either the frame or its acknowledgement is
lost in transit. Sender retransmits the frame and starts the
timeout counter.
5. If a negative acknowledgement is received, the sender
retransmits the frame.
Go-back-in

"Go-back-N" Protocols
▪ When errors occur in a continuous ARQ protocol, the simplest
solution is to repeat the frame in error and all subsequent frames,
thus:
How it works
▪ In Go-Back-N ARQ method, both sender and receiver maintain a
window.
▪ The sending-window size enables the sender to send multiple
frames without receiving the acknowledgement of the previous
ones. The receiving-window size enables the receiver to receive
multiple frames and acknowledge them. The receiver keeps track
of incoming frame’s sequence number.
▪ When the sender sends all the frames in window, it checks up to
what sequence number it has received positive acknowledgement.
If all frames are positively acknowledged, the sender sends next set
of frames. If sender finds that it has received NACK or has not
receive any ACK for a particular frame, it retransmits all the
frames after which it does not receive any positive ACK.
Go-back-n, damaged data frame
Go-back-in, lost data frame
Go-back-in, lost ACK
Selective-reject ARQ

Selective Reject
An alternative approach is to only repeat those frames received in
error. This is more complicated and is rarely implemented,
despite having the attraction of apparently greater efficiency.
Problems with selective reject include:
1. Receiver must have storage to save post-NAK frames until the
erroneous frame is received, and logic to re-insert it in the
correct sequence.
2. The sender must be able to send frames out of sequence.
3. The window size for a given size of sequence number is
somewhat less than for go-back-N.
Selective-reject, damage data frame
Medium Access Methods
Medium Access Control

Medium Access Control (MAC) is the method that defines a


procedure a station should follow when it needs to send a frame or
frames.
The use of regulated method ensure that there is no conflict among
the stations.
▪ The problem of controlling the access to the medium is similar to
the rules of speaking in an assembly. Rules are established to
ensure that two people do not speak at the same time
30
Medium Access Methods

MAC can be divided into two broad categories: Random access and
controlled access. See the figure below
Random Access

• With Random Access or contention methods no station is superior


to another station and non of them are assign the control of others.
• No schedule time for a station to transmit -transmission is random
among the stations.
• No rule that specifies what station should send next – stations
complete with each other to access the medium – hence
contention methods
• Each station that has data to send uses the procedure defined in the
protocol in relation to the state of the medium (idle/busy) to make a
32
decision on whether or not to send
Random Access

The procedure that station use to access the medium with Random
Access method must answer the following Questions:

▪ When should the station access the medium?


▪ What should the station do when the medium is busy?
▪ How should the station determine the success or failure of the
transmission?
▪ What should the station do if there is an access conflict?

33
Evolution of Random Access Methods
The first method , known as ALOHA, used a very simple
procedure called Multiple Access (MA). This Method was
improved with addition of procedure that forces the station to
sense the medium before transmitting . This was called Carrier
Sense Multiple Access (CSMA). This method was later evolved
into two parallel methods: CSMA/CD and CSMA/CA

▪ CSMA/CD tries to show what the station should do if a


collision is detected
▪ CSMA/CA tries to avoid the collision
Random Access Methods

• Multiple Access (MA)


• Carrier Sense with Multiple Access (CSMA)
• Carrier Sense with Multiple Access with Collision Detection (CSMA/CD)
• Carrier Sense with Multiple Access with Collision Avoidance (CSMA/CA)
Carrier Sense Multiple Access (CSMA)

The chance of collision can be reduced if a station sense the medium


before trying to use it.
CSMA requires that each station first listen to the medium (or check
the state of the medium) before sending – CSMA is based on the
principle “sense before transmit” or “Listen before talk”

▪ CSMA can reduce the possibility of collision, but can not eliminate it.

37
Collision in CSMA
Vulnerable Time:

❑ Vulnerable Time: Vulnerable time for CSMA is the propagation


time, Tprop . This is the time needed for a signal to propagate
from one end of the medium to the other.
❑ When a station sends a frame, and any other station tries to send
a frame during Vulnerable time, a collision will result.

39
Persistence Strategies

▪ Persistence Strategy: define what a station should do if, when


sensing the medium, it finds it busy.

Two strategies:
Non-persistent Method
Non persistence Method: In the non persistence method, a
station with a frame to send, it senses the medium:
▪ If the medium is idle, it sends immediately
▪ If the medium is not idle it waits a random time and then
sense the medium again
1-Persistent Approach

In persistence strategy, a station


senses the medium. If the medium
is idle, it sends the frame.

❑ 1-persistence: In this method, after the station finds the medium


idle, it sends its frame immediately (with a probability of 1).
❑ 1-persistence method increases the chances of collision as two or
more station may find the medium idle and send their frames
immediately.
P-Persistent Approach

In P-Persistence method, after the


station finds the medium idle, it may or
may not send
It sends with probability p and refrain
from sending with probability 1-p
The station generates the random
number between 1 and 100 . If the
random number is less than 20, the
station will send; otherwise the
station refrain from sending.
The station waits one time slot before ▪ P-Persistence: reduces
sensing the medium again. the chances of collision
and improves the
efficiency
Example of P-Persistent

For example, if p is 0.2, it means that each station, after


sensing an idle line, sends with a probability of 0.2 (20
percent of the time) and refrain from sending with a
probability of 0.8 (80 percent of the time)
Carrier Sense Multiple Access with Collision Detection (CSMA/CD)

▪ CSMA method does not define what should be done if a


collision occurs. That is why it was never implemented.
CSMA/CD, a modified version of CSMA, adds a procedure
to handle the collision
▪ Back off time is between 0 and 2Nx(maximum propagation
time)

45
Collision

▪ If the collision occurs, the frame should be sent


again.
▪ To reduce the probability of collision the second
time, the station should wait- is should back-off.
▪ It should wait a little the first time, more is the
collision occur again, much more if it happens a
third time, and so on
Back-off exponential Method

▪ In the exponential back-off method, the station waits an amount of


time between 0 and 2N x (Maximum propagation time)
▪ N: number of attempted transmission

▪ It waits between 0 and 2 x (Maximum propagation time) for the


first time.
▪ Between 0 and 22 x (Maximum propagation time) for the second
time
CSMA/CD Procedure
Jam Signal

▪ The jam signal is intended to inform other stations


of the situation (i.e. collision). It alerts them that
collision has occurred.

▪ The maximum value of the back-off parameter is 15


CSMA/CA
CSMA/CA avoids collision. CSMA/CA uses one of the
persistence strategies. After it finds the line idle it waits an
IFG (Inter Frame Gap) amount of time.
▪ It then waits another random amount of time.
▪ It sends the frame and sets the timer
▪ If it receives the acknowledgement before the timer
expires, the transmission is successful.

50
CSMA/CA………cont

▪ If the station does not receive acknowledgement, sign for frame


lost or acknowledgement.
▪ The station increment the value of the back-off parameter, wait
for back-off amount of time and re-senses the line again.
▪ CSMA/CA is used in wireless LAN

51
CSMA/CA Procedure
Controlled Access

• In controlled access method, the stations consult each


other to find which station has the right to send.
• The station can not send unless it has been authorized
by other stations.

53
Token Passing Network

In the Token passing method, a station is authorized to send data


when it receives a special frame called a token.
Token Passing

▪ When no data is being sent, a token circulate around the


ring.
▪ If the station needs to send data, it waits for the token.
▪ The station capture the token, sends one or more frames
(as long as it has some frames to send or the time
allocated hasn’t expired).
▪ It releases the token to be used by the successor station

55
Token Passing Procedure

You might also like