0% found this document useful (0 votes)
25 views73 pages

DC-Lec-25, 26 & 27 (Data Link Control Protocols)

The document discusses various data link control protocols and concepts. It covers framing techniques including fixed-size, variable-size, character-oriented and bit-oriented framing. It also discusses flow control, error control, and noiseless and noisy channel protocols such as stop-and-wait ARQ.

Uploaded by

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

DC-Lec-25, 26 & 27 (Data Link Control Protocols)

The document discusses various data link control protocols and concepts. It covers framing techniques including fixed-size, variable-size, character-oriented and bit-oriented framing. It also discusses flow control, error control, and noiseless and noisy channel protocols such as stop-and-wait ARQ.

Uploaded by

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

DATA

COMMUNICATION

Lecture- 25, 26 & 27


Recap of Lecture 30

• Checksum
• Single-Bit Error Correction
• Hamming Code
Overview of Lecture
• Data Link Control
• Framing
• Fixed-Sized Framing
• Variable-Sized Framing
• Character Oriented Protocol
• Bit Oriented Protocol
• Flow Control
• Error Control
• Protocols
• Noiseless Channels
• Simplest
• Stop & Wait
• Noisy Channels
• Stop & Wait ARQ
• Go-Back-N ARQ
• Selective Repeat ARQ
Data link control

• The two main functions of the data link layer are


1. Data link control
2. Media access control
Data link control (cont..)
• The first, data link control, deals with the design and procedures
for communication between two adjacent nodes:
i.e. node-to-node communication.

• The second function of the data link layer is media access control,
or how to share the link.

• Data link control functions include;


1. Framing,
2. Flow and
3. Error control, and
4. Software implemented protocols
Framing
Framing
• Data transmission in the physical layer means moving bits in the
form of a signal from the source to the destination.

• The physical layer provides bit synchronization to ensure that the


sender and receiver use the same bit durations and timing.

• The data link layer, on the other hand, needs to pack bits into
frames, so that each frame is distinguishable from another.

• Our postal system practices a type of framing.


Framing (cont..)
• Although the whole message could be packed in one frame, that
is not normally done.

• One reason is that a frame can be very large, making flow and
error control very inefficient.

• When a message is carried in one very large frame, even a


single-bit error would require the retransmission of the whole
message.

• When a message is divided into smaller frames, a single-bit error


affects only that small frame.
Fixed-Size Framing

• Frames can be of Fixed or Variable size.

• In fixed-size framing, there is no need for defining the


boundaries of the frames; the size itself can be used as a
delimiter.

• An example of this type of framing is the ATM wide-area


network, which uses frames of fixed size called cells.
Variable-Size Framing

• In variable-size framing, there is a need of a way to define the


end of the frame and the beginning of the next.

• Historically, two approaches were used for this purpose:

1. Character-oriented approach and


2. Bit-oriented approach.
Character-Oriented Protocols
• In a character-oriented protocol, 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 or error correction redundant bits, are
also multiples 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.
Character-Oriented Protocols (cont..)

• It 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.
• 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 is used.

• The data section is stuffed with an extra byte called the escape
character (ESC), which has a predefined bit pattern.
Character-Oriented Protocols (cont..)

• Whenever the receiver encounters the ESC character, it removes


it from the data section and treats the next character as data, not
a delimiting flag.

• But it creates another problem.


• What happens if the text contains one or more escape characters
followed by a flag?

• The receiver removes the escape character, but keeps the flag,
which is incorrectly interpreted as the end of the frame.
• To solve this problem, the escape characters that are part of the
text must also be marked by another escape character.
Character-Oriented Protocols (cont..)
Character-Oriented Protocols (cont..)

• In other words, 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.

• Character-oriented protocols present another problem in data


communications.
• The universal coding systems in use today, such as Unicode, have
16-bit and 32-bit characters that conflict with 8-bit characters.

• We can say that in general, the tendency is moving toward the


bit-oriented protocols.
Bit-Oriented Protocols
• In this the data section of a frame is a sequence of bits to be
interpreted by the upper layer as text, graphic, audio, video, etc.

• 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 the end of the frame.
Bit-Oriented Protocols (cont..)
• This flag can create the same type of problem we saw in the byte-
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 1 single bit (instead of 1 byte) to prevent
the pattern from looking like a flag, called bit stuffing.
• In bit stuffing, if a 0 and five consecutive 1 bits are encountered,
an extra 0 is added.
• This extra stuffed bit is eventually removed from the data by the
receiver.
• Note that the extra bit is added after one 0 followed by five 1s
regardless of the value of the next bit.
• This guarantees that the flag field sequence does not
inadvertently appear in the frame.
Bit-Oriented Protocols (cont..)
• If the flag like pattern 01111110 appears in the data, it will
change to 011111010 (stuffed) and is not mistaken as a flag by
the receiver.
• The real flag 01111110 is not stuffed by the sender and is
recognized by the receiver.
Flow and Error Control
The most important responsibilities of the data link layer
are flow control and error control. Collectively, these
functions are known as data link control.
Flow control
• Flow control coordinates the amount of data that can be sent
before receiving an acknowledgment.

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

• Any receiving device has a limited speed at which it can process


incoming data and a limited amount of memory (buffer) in
which to store incoming data.

• The receiving device must be able to inform the sending device


before those limits are reached and to request that the
transmitting device send fewer frames or stop temporarily.
Error Control
• In the data link layer, the term error control refers primarily to
methods of error detection and retransmission.

• It allows the receiver to inform the sender of any frames lost or


damaged in transmission and coordinates the retransmission of
those frames by the sender.

• Error control in the data link layer is often implemented simply:


• Any time an error is detected in an exchange, specified frames
are retransmitted.
• This process is called automatic repeat request (ARQ).
PROTOCOLS
PROTOCOLS
• Mainly two type of protocols;

• Unidirectional
• Data frames travel from sender to receiver.
• In response to data frame, a special frames, called ACK and
NAK flow in the opposite direction for flow and error
control purposes, data flow in only one direction.

• Bidirectional (practically used)


• In a real-life network, the data link protocols are
implemented as bidirectional; data flow in both directions.
In these protocols the flow and error control information
such as ACKs and NAKs is included in the data frames in a
technique called piggybacking.
NOISELESS CHANNELS
• Simplest
• Stop & wait
NOISELESS CHANNELS
• Assume we have an ideal channel in which no frames are lost,
duplicated, or corrupted.

• We introduce two protocols for this type of channel.


1. Simplest;
• It does not use flow control.

2. Stop & Wait;


• It uses flow control

• Note: Neither has error control because we have


assumed that the channel is a perfect noiseless channel.
Simplest Protocol
• It has no flow or error control.

• it is a unidirectional protocol in which data frames are traveling


in only one direction-from the sender to receiver.

• We assume that the receiver can immediately handle any frame


it receives with a processing time that is small enough to be
negligible.

• receiver can never be overwhelmed with incoming frames.


The design of the simplest protocol with
no flow or error control
Example
• It is very simple. The sender sends a sequence of frames without
even thinking about the receiver.
• To send three frames, three events occur at the sender site and
three events at the receiver site.
Sender-site algorithm for the simplest protocol

Receiver-site algorithm for the simplest protocol


Stop-and-Wait Protocol
Stop-and-Wait Protocol
• This protocol adds flow control to the previous protocol.

• If data frames arrive at the receiver site faster than they can be
processed, the frames must be stored until their use.
• Normally, the receiver does not have enough storage space,
especially if it is receiving data from many sources.
• This may result in either the discarding of frames or denial of
service.
• To prevent the receiver from becoming overwhelmed with
frames, we somehow need to tell the sender to slow down.
• The sender sends one frame, stops until it receives confirmation
from the receiver, and then sends the next frame.

• We still have unidirectional communication for data frames, but


auxiliary ACK frames (simple tokens of acknowledgment) travel
from the other direction.
Design of Stop-and-Wait Protocol
Sender-site algorithm for Stop-and-Wait
Receiver-site algorithm for Stop-and-Wait
Example OF Stop-and-Wait Protocol
Noisy CHANNELS
• Stop & wait ArQ
• Go back N ARQ
• Selective Repeat ARQ
Stop-and-Wait Automatic Repeat Request

• This protocol adds a simple error control mechanism to the Stop-


and-Wait Protocol.

• To detect and correct corrupted frames, we need to add


redundancy bits to our data frame.

• At receiver site, frame is silently discarded if found corrupted.

• Lost frames are more difficult to handle than corrupted ones.

• When the receiver receives a data frame that is out of order, this
means that frames were either lost or duplicated.
Stop-and-Wait ARQ (cont..)

• The sender keeps a copy of the sent frame.


• At the same time, it starts a timer.
• If the timer expires and there is no ACK for the sent frame, the
frame is resent, the copy is held, and the timer is restarted.
• Since the protocol uses the stop-and-wait mechanism, there is
only one specific frame that needs an ACK.

• Since an ACK frame can also be corrupted and lost, it too needs
redundancy bits and a sequence number.
• The ACK frame for this protocol has a sequence number field.

• In this protocol, the sender simply discards a corrupted ACK


frame or ignores an out-of-order one.
Sequence Numbers

• Every frames need to have sequence number.

• A field is added to the data frame to hold the sequence number of


that frame.

• Since we want to minimize the frame size, we look for the


smallest range that provides unambiguous communication.

• Assume we have used x as a sequence number; we only need to


use x + 1 after that.
• There is no need for x + 2.
Sequence Numbers (cont..)

• Assume that the sender has sent the frame numbered x.

• Three things can happen.

1. The frame arrives safe and sound at the receiver site; the receiver sends
an acknowledgment. The acknowledgment arrives at the sender site,
causing the sender to send the next frame numbered x + 1.

2. The frame arrives safe and sound at the receiver site; the receiver sends
an acknowledgment, but the acknowledgment is corrupted or lost. The
sender resends the frame (numbered x) after the time-out.

3. The frame is corrupted or never arrives at the receiver site; the sender
resends the frame (numbered x) after the time-out.
Acknowledgment Numbers

• The sequence numbers are suitable for both data frames and ACK
frames.

• The acknowledgment numbers always announce the sequence


number of the next frame expected by the receiver.

• For example, if frame 0 has arrived safe and sound, the receiver
sends an ACK frame with acknowledgment 1 (meaning frame 1
is expected next).

• If frame 1 has arrived safe and sound, the receiver sends an ACK
frame with acknowledgment 0 (meaning frame 0 is expected).
Design
Flow diagram
Efficiency

• The Stop-and-Wait ARQ is very inefficient if our channel is thick


and long.

• By thick, we mean that our channel has a large bandwidth; by


long, we mean the round-trip delay is long.

• The product of these two is called the bandwidth-delay product.

• The bandwidth-delay product is a measure of the number of bits


we can send out of our system while waiting for news from the
receiver.
Pipelining

• In networking and in other areas, a task is often begun before the


previous task has ended.
• This is known as pipelining.
• There is no pipelining in Stop-and-Wait ARQ because we need to
wait for a frame to reach the destination and be acknowledged
before the next frame can be sent.

• However, pipelining does apply to our next two protocols


because several frames can be sent before we receive news about
the previous frames.

• Pipelining improves the efficiency of the transmission if the


number of bits in transition is large with respect to the
bandwidth-delay product.
Go-Back-N ARQ
Go-Back-N ARQ

• To improve the efficiency of transmission (filling the pipe),


multiple frames must be in transition while waiting for
acknowledgment.

• we need to let more than one frame be outstanding to keep the


channel busy while the sender is waiting for acknowledgment.

• In this protocol we can send several frames before receiving


acknowledgments; we keep a copy of these frames until the
acknowledgments arrive.
Sequence Numbers

• Frames from a sending station are numbered sequentially.


• However, because we need to include the sequence number of
each frame in the header, we need to set a limit.

• If the header of the frame allows m bits for the sequence number,
the sequence numbers range from 0 to 2m - 1.

• For example, if m is 4, the only sequence numbers are 0 through


15 inclusive.

• However, we can repeat the sequence.

• So the sequence numbers are;


0,1,2,3,4,5,6,7,8,9,10,11,12,13,14, 15,0,1,2,3,4,5,6,7,8,9,10, 11, ...
Sliding Window

• The sliding window is an abstract concept that defines the range


of sequence numbers that is the concern of the sender and
receiver.

• The range which is the concern of the sender is called the send
sliding window; the range that is the concern of the receiver is
called the receive sliding window.

• The send window is an imaginary box covering the sequence


numbers of the data frames which can be in transit.

• The maximum size of the window is 2m-1.


Sliding Window (cont..)

• Figure shows a sliding window of size 15 (m =4).


• The window at any time divides the possible sequence numbers
into four regions.
1. The first region, from the far left to the left wall of the window, defines
the sequence numbers belonging to frames that are already
acknowledged. The sender does not worry about these frames and keeps
no copies of them.
2. The second region, colored in Figure, defines the range of sequence
numbers belonging to the frames that are sent and have an unknown
status. The sender needs to wait to find out if these frames have been
received or were lost. We call these outstanding frames.
3. The third range, white in the figure, defines the range of sequence
numbers for frames that can be sent; however, the corresponding data
packets have not yet been received from the network layer.
4. Finally, the fourth region defines sequence numbers that cannot be used
until the window slides.
Send Sliding Window
Receive Sliding Window
Timers

• Although there can be a timer for each frame that is sent, in this
protocol we use only one.

• The reason is that the timer for the first outstanding frame
always expires first; we send all outstanding frames when this
timer expires.
Acknowledgment

• The receiver sends a positive acknowledgment if a frame has


arrived safe and sound and in order.

• If a frame is damaged or is received out of order, the receiver is


silent and will discard all subsequent frames until it receives the
one it is expecting.
• The silence of the receiver causes the timer of the
unacknowledged frame at the sender site to expire.
• This, in turn, causes the sender to go back and resend all frames,
beginning with the one with the expired timer.
• The receiver does not have to acknowledge each frame received.

• It can send one cumulative acknowledgment for several frames.


Resending a Frame

• When the timer expires, the sender resends all outstanding


frames.

• For example, suppose the sender has already sent frame 6, but
the timer for frame 3 expires.

• This means that frame 3 has not been acknowledged; the sender
goes back and sends frames 3, 4,5, and 6 again.

• That is why the protocol is called Go-Back-N ARQ.


Design

• Figure 11.14 shows the design for this protocol.

• As we can see, multiple frames can be in transit in the forward


direction, and multiple acknowledgments in the reverse
direction.

• The idea is similar to Stop-and-Wait ARQ; the difference is that


the send window allows us to have as many frames in transition
as there are slots in the send window.
Design of Go-Back-N ARQ
Send Window Size
• why the size of the send window must be less than 2m.
• As an example, we choose m=2, which means the size of the
window can be 2m-1, or 3.
• Figure compares a window size of 3 against a window size of 4.
• If the size of the window is 3 (less than 2m which is =4) and all
three acknowledgments are lost, the frame timer expires and all
three frames are resent.
• The receiver is now expecting frame 3, not frame 0, so the
duplicate frame is correctly discarded.
• On the other hand, if the size of the window is 4 (equal to 2m)
and all acknowledgments are lost, the sender will send a
duplicate of frame 0.
• However, this time the window of the receiver expects to receive
frame 0, so it accepts frame 0, not as a duplicate, but as the first
frame in the next cycle. This is an error.
Window size for Go-Back-N ARQ
Example 1
Example 2
Selective Repeat Automatic Repeat
Request
Selective Repeat ARQ

• Go-Back-N ARQ simplifies the process at the receiver site.


• The receiver keeps track of only one variable, and there is no
need to buffer out-of-order frames; they are simply discarded.
• However, this protocol is very inefficient for a noisy link.
• In a noisy link a frame has a higher probability of damage, which
means the resending of multiple frames.
• This resending uses up the bandwidth and slows down the
transmission.

• Selective Repeat ARQ does not resend N frames when just one
frame is damaged; only the damaged frame is resent.
• It is more efficient for noisy links, but the processing at the
receiver is more complex.
Windows

• The Selective Repeat Protocol also uses two windows: a send


window and a receive window.
• However, there are differences between the windows in this
protocol and the ones in Go-Back-N.
• First, the size of the send window is much smaller; it is 2m-1.
• Second, the receive window is the same size as the send window.
• The send window maximum size can be 2m-1.
• For example, if m = 4, the sequence numbers go from 0 to 15, but
the size of the window is just 8 (it is 15 in the Go-Back-N
Protocol).
• The smaller window size means less efficiency in filling the pipe,
but the fact that there are fewer duplicate frames can
compensate for this.
Send & Receive windows for Selective Repeat
ARQ
Design
Window Sizes
• We can now show why the size of the sender and receiver
windows must be at most one half of 2m. For an example, we
choose m = 2, which means the size of the window is 2m-2, or 2.
• Figure 11.21 compares a window size of 2 with a window size of
3.
• If the size of the window is 2 and all acknowledgments are lost,
the timer for frame 0 expires and frame 0 is resent.
• However, the window of the receiver is now expecting frame 2,
not frame 0, so this duplicate frame is correctly discarded.
• When the size of the window is 3 and all acknowledgments are
lost, the sender sends a duplicate of frame O.
• However, this time, the window of the receiver expects to receive
frame 0 (0 is part of the window), so it accepts frame 0, not as a
duplicate, but as the first frame in the next cycle.
• This is clearly an error.
Selective Repeat ARQ, window size
Delivery of data in Selective Repeat ARQ
Example of Selective Repeat ARQ
Summary
• Data Link Control
• Framing
• Fixed-Sized Framing
• Variable-Sized Framing
• Character Oriented Protocol
• Bit Oriented Protocol
• Flow Control
• Error Control
• Protocols
• Noiseless Channels
• Simplest
• Stop & Wait
• Noisy Channels
• Stop & Wait ARQ
• Go-Back-N ARQ
• Selective Repeat ARQ
Suggested Reading

• Section
• 11.1
• 11.2
• 11.3
• 11.4
• 11.5

• “Data Communications and Networking” 4th Edition by


Behrouz A. Forouzan

You might also like