FLOW CONTROL
1
11.2
Data LINK LAYER
This layer provides reliable transmission of a packet by using the
services of the physical layer. This layer is also responsible for node
to node transmission.
Framing: This layer divides the stream of bits received from the network
layer in to small data units, called frames.
Physical addressing: when frame goes to different system this layer adds a
header to the frame which contain the sender and receiver address, called
physical address.
11.3
Flow control: The rate at which sender sends the data is high then the rate at
which receiver receives the data, then there will be a problem. So this layer
control of flow of data.
Error control: The frames may be damaged, lost or duplicated leading errors.
So this layer also control errors.
Acknowledgment: Sent by the receiving end to inform the source that the
frame was received successfully without any error.
Framing: As we know that data link layer creates the frame and it also
recognized the boundaries of frame. This can be accomplished by attaching
special bit patterns to the beginning and end of the frame.
4
FRAMING
The data link layer needs to pack bits into frames, so
that each frame is distinguishable from another. Our
postal system practices a type of framing. The simple
act of inserting a letter into an envelope separates one
piece of information from another; the envelope serves
as the delimiter.
Character Count
Character stuffing
Bit stuffing
Topics discussed in this section:
5
Figure 11.1 A frame in a character-oriented protocol
11.6
7
Figure 11.2 Byte stuffing and unstuffing
8
7
Bit stuffing is the process of adding one
extra 0 if 011111 is encountered in data,
so that the receiver does not mistake
the pattern 0111110 for a flag.
Note
8
Figure 11.4 Bit stuffing and unstuffing
9
11-2 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
Error Control
Topics discussed in this section:
10
Flow control refers to a set of procedures
used to restrict the amount of data
that the sender can send before
waiting for acknowledgment.
Note
Aka: Don’t overwhelm the receiver!
11
Error control in the data link layer is
based on automatic repeat request,
which is the retransmission of data.
Note
12
11-3 PROTOCOLS
Now let us see how the data link layer can combine
framing, flow control, and error control to achieve the
delivery of data from one node to another.
13
Figure 11.5 Taxonomy of protocols discussed in this chapter
14
11-4 NOISELESS CHANNELS
Let us first assume we have an ideal channel in which
no frames are lost, duplicated, or corrupted. We
introduce two protocols for this type of channel.
Simplest Protocol
Stop-and-Wait Protocol
Topics discussed in this section:
15
Figure 11.6 The design of the simplest protocol with no flow or error control
16
 In simplest protocol, there is no flow control and error control
mechanism.
 It is a unidirectional protocol in which data frames travel in
only one direction (from sender to receiver).
 The receiver can immediately handle any received frame with a
processing time that is small enough to be negligible.
 The protocol consists of two distinct procedures :a sender and
receiver.
The sender runs in the data link layer of the source machine
and the receiver runs in the data link layer of the destination
machine.
 No sequence number or acknowledgements are used here.
17
Figure 11.7 Flow diagram for Example 11.1
18
Figure 11.8 Design of Stop-and-Wait Protocol
19
Stop-and-Wait Protocol
The simplest retransmission protocol is stop-and-wait.
Transmitter (Station A) sends a frame over the communication
line and then waits for a positive or negative acknowledgement
from the receiver (station B).
If no error occurs in the transmission, station B sends a
positive acknowledgement (ACK) to station A. transmitter starts
to send the next frame.
If frame is received at station B with errors, then a negative
acknowledgement(NAK) is sent to station A.
Station 'A' must retransmit the old packet in a new frame.
20
Stop-and-Wait Protocol Conti..
There is also a possibility that the information frames or
ACKs may get lost.
 The sender is equipped with a timer. If no recognizable
acknowledgement is received when the timer expires at the end
of time out interval, the same frame is sent again.
The sender which sends one frame and then waits for an
acknowledgement before process is known as stop and wait.
21
Figure 11.9 Flow diagram for Example 11.2
22
11-5 NOISY CHANNELS
Although the Stop-and-Wait Protocol gives us an idea
of how to add flow control to its predecessor, noiseless
channels are nonexistent. We discuss three protocols
in this section that use error control.
Stop-and-Wait Automatic Repeat Request (ARQ)
Go-Back-N Automatic Repeat Request
Selective Repeat Automatic Repeat Request
Topics discussed in this section:
23
In Stop-and-Wait ARQ, the
acknowledgment number always
announces in modulo-2 arithmetic the
sequence number of the next frame
expected.
Note
24
Figure 11.10 Design of the Stop-and-Wait ARQ Protocol
Transport Layer
3-27
Stop-and-Wait ARQ Overview
 Sender waits “reasonable” amount of time for ACK
 Thus Sender needs a countdown timer
 Start the timer when a packet is sent
 retransmits if no ACK received within the timeout period
 if pkt (or ACK) just delayed (not lost):
 retransmission will create duplicate packet
 Thus it requires packet sequence number and ack
number to be used
 Only two numbers are used: 0, 1
 Receiver’s Ack number is what he is expected next
 After receiving Pkt 0, sends back ACK 1
 After receiving Pkt 1, sends back ACK 0
25
Figure 11.11 Flow diagram for Example 11.3
26
27
Stop-and-Wait ARQ is a special case of
Go-Back-N ARQ in which the size of the
send window is 1.
Note
28
Sliding Window
 Send multiple frames before waiting for ACK
 Several frames can be in transit at a time
 Sender window vs. receiver window
 Frames can be ACKed without waiting for the
receiver window to fill up
 Frames may be sent as long as there are unsent
packets in the sender window
 If header of the frame allow k bits ,the sequence
number ranges from 0 to 2^k -1
31
Sliding Window
 Sender window:
 Shrink from left as frames are sent
 Expand from right as you receive ACKs
 The size of sender window is at most 2^k -1
 Sender is also provided with buffer equal to the
window size
Receiver window:
 Shrink from left as frames are received
 Expand from right as ACKs are sent
 The Size of receiver window is 1
30
 Based on sliding window protocol
 All frames after damaged or lost frame are discarded
 Damaged Frames:
 Say, frames 0-5 are sent and all but frame # 3 is
correctly received Receiver sends NAK 3 and discards
subsequent frames
 This signals to sender that frames 0, 1, and 2 are
correctly received and frame 3 is damaged
 Sender retransmits frames 3, 4, and 5
 Same procedure for lost data frames
Go-Back-n ARQ
31
Go-Back-n ARQ
Host A Host B
Data 0
NAK 3
Data 1
Data 2
Data 3
Data 4
Data 5
Error, discard
Data 3
Data 4
Data 5
Discard
Discard
Window size 7
Error in data frame 3
 Lost ACK:
 When sender reaches window capacity, it
starts a timer
 If timer expires, it resends all outstanding
(unACKed) frames
 The receiver discards possible duplicate
frames and sends another ACK
32
Go-Back-n ARQ Conti..
Go-Back-n ARQ Conti..
Host A Host B
Data 0
ACK 3
Data 1
Data 2
Data 0
Data 1
Data 2
Lost
Window Size 3
Lost ACK case
Timer
expires
33
Selective Repeat ARQ
 Problem with Go-back-N:
 Sender: resend many packets with a single lose
 Receiver: discard many good received (out-of-order) packets
 Very inefficient when N becomes bigger (in high-speed network)
 Solution: Receiver individually acknowledges all correctly
received pkts
 buffers pkts, as needed, for eventual in-order delivery to upper
layer
 sender only resends pkts for which ACK not received
 sender keeps timer for each unACKed pkt
 sender window
 N consecutive seq #’s
 again limits seq #s of sent, unACKed pkts
34
Selective Repeat ARQ
Host A Host B
Data 0
NAK 3
Data 1
Data 2
Data 3
Data 4
Data 5
Error, discard
Data 3
Window size 7
Error in data frame 3
Data 6
35
Selective Repeat ARQ
 Lost Data Frames:
 Out-of-sequence delivery is permitted, but
out-of-sequence ACK is not
 When a lost frame is detected, NAK is sent
 If last frame is lost, then receiver does
nothing
 Lost ACK:
 Handled the same way as in go-back-n
36

Flow Control (1).ppt

  • 1.
  • 2.
    11.2 Data LINK LAYER Thislayer provides reliable transmission of a packet by using the services of the physical layer. This layer is also responsible for node to node transmission. Framing: This layer divides the stream of bits received from the network layer in to small data units, called frames. Physical addressing: when frame goes to different system this layer adds a header to the frame which contain the sender and receiver address, called physical address.
  • 3.
    11.3 Flow control: Therate at which sender sends the data is high then the rate at which receiver receives the data, then there will be a problem. So this layer control of flow of data. Error control: The frames may be damaged, lost or duplicated leading errors. So this layer also control errors. Acknowledgment: Sent by the receiving end to inform the source that the frame was received successfully without any error. Framing: As we know that data link layer creates the frame and it also recognized the boundaries of frame. This can be accomplished by attaching special bit patterns to the beginning and end of the frame.
  • 4.
    4 FRAMING The data linklayer needs to pack bits into frames, so that each frame is distinguishable from another. Our postal system practices a type of framing. The simple act of inserting a letter into an envelope separates one piece of information from another; the envelope serves as the delimiter. Character Count Character stuffing Bit stuffing Topics discussed in this section:
  • 5.
    5 Figure 11.1 Aframe in a character-oriented protocol
  • 6.
  • 7.
    7 Figure 11.2 Bytestuffing and unstuffing
  • 8.
  • 9.
    7 Bit stuffing isthe process of adding one extra 0 if 011111 is encountered in data, so that the receiver does not mistake the pattern 0111110 for a flag. Note
  • 10.
    8 Figure 11.4 Bitstuffing and unstuffing
  • 11.
    9 11-2 FLOW ANDERROR 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 Error Control Topics discussed in this section:
  • 12.
    10 Flow control refersto a set of procedures used to restrict the amount of data that the sender can send before waiting for acknowledgment. Note Aka: Don’t overwhelm the receiver!
  • 13.
    11 Error control inthe data link layer is based on automatic repeat request, which is the retransmission of data. Note
  • 14.
    12 11-3 PROTOCOLS Now letus see how the data link layer can combine framing, flow control, and error control to achieve the delivery of data from one node to another.
  • 15.
    13 Figure 11.5 Taxonomyof protocols discussed in this chapter
  • 16.
    14 11-4 NOISELESS CHANNELS Letus first assume we have an ideal channel in which no frames are lost, duplicated, or corrupted. We introduce two protocols for this type of channel. Simplest Protocol Stop-and-Wait Protocol Topics discussed in this section:
  • 17.
    15 Figure 11.6 Thedesign of the simplest protocol with no flow or error control
  • 18.
    16  In simplestprotocol, there is no flow control and error control mechanism.  It is a unidirectional protocol in which data frames travel in only one direction (from sender to receiver).  The receiver can immediately handle any received frame with a processing time that is small enough to be negligible.  The protocol consists of two distinct procedures :a sender and receiver. The sender runs in the data link layer of the source machine and the receiver runs in the data link layer of the destination machine.  No sequence number or acknowledgements are used here.
  • 19.
    17 Figure 11.7 Flowdiagram for Example 11.1
  • 20.
    18 Figure 11.8 Designof Stop-and-Wait Protocol
  • 21.
    19 Stop-and-Wait Protocol The simplestretransmission protocol is stop-and-wait. Transmitter (Station A) sends a frame over the communication line and then waits for a positive or negative acknowledgement from the receiver (station B). If no error occurs in the transmission, station B sends a positive acknowledgement (ACK) to station A. transmitter starts to send the next frame. If frame is received at station B with errors, then a negative acknowledgement(NAK) is sent to station A. Station 'A' must retransmit the old packet in a new frame.
  • 22.
    20 Stop-and-Wait Protocol Conti.. Thereis also a possibility that the information frames or ACKs may get lost.  The sender is equipped with a timer. If no recognizable acknowledgement is received when the timer expires at the end of time out interval, the same frame is sent again. The sender which sends one frame and then waits for an acknowledgement before process is known as stop and wait.
  • 23.
    21 Figure 11.9 Flowdiagram for Example 11.2
  • 24.
    22 11-5 NOISY CHANNELS Althoughthe Stop-and-Wait Protocol gives us an idea of how to add flow control to its predecessor, noiseless channels are nonexistent. We discuss three protocols in this section that use error control. Stop-and-Wait Automatic Repeat Request (ARQ) Go-Back-N Automatic Repeat Request Selective Repeat Automatic Repeat Request Topics discussed in this section:
  • 25.
    23 In Stop-and-Wait ARQ,the acknowledgment number always announces in modulo-2 arithmetic the sequence number of the next frame expected. Note
  • 26.
    24 Figure 11.10 Designof the Stop-and-Wait ARQ Protocol
  • 27.
    Transport Layer 3-27 Stop-and-Wait ARQOverview  Sender waits “reasonable” amount of time for ACK  Thus Sender needs a countdown timer  Start the timer when a packet is sent  retransmits if no ACK received within the timeout period  if pkt (or ACK) just delayed (not lost):  retransmission will create duplicate packet  Thus it requires packet sequence number and ack number to be used  Only two numbers are used: 0, 1  Receiver’s Ack number is what he is expected next  After receiving Pkt 0, sends back ACK 1  After receiving Pkt 1, sends back ACK 0 25
  • 28.
    Figure 11.11 Flowdiagram for Example 11.3 26
  • 29.
    27 Stop-and-Wait ARQ isa special case of Go-Back-N ARQ in which the size of the send window is 1. Note
  • 30.
    28 Sliding Window  Sendmultiple frames before waiting for ACK  Several frames can be in transit at a time  Sender window vs. receiver window  Frames can be ACKed without waiting for the receiver window to fill up  Frames may be sent as long as there are unsent packets in the sender window  If header of the frame allow k bits ,the sequence number ranges from 0 to 2^k -1
  • 31.
    31 Sliding Window  Senderwindow:  Shrink from left as frames are sent  Expand from right as you receive ACKs  The size of sender window is at most 2^k -1  Sender is also provided with buffer equal to the window size Receiver window:  Shrink from left as frames are received  Expand from right as ACKs are sent  The Size of receiver window is 1
  • 32.
    30  Based onsliding window protocol  All frames after damaged or lost frame are discarded  Damaged Frames:  Say, frames 0-5 are sent and all but frame # 3 is correctly received Receiver sends NAK 3 and discards subsequent frames  This signals to sender that frames 0, 1, and 2 are correctly received and frame 3 is damaged  Sender retransmits frames 3, 4, and 5  Same procedure for lost data frames Go-Back-n ARQ
  • 33.
    31 Go-Back-n ARQ Host AHost B Data 0 NAK 3 Data 1 Data 2 Data 3 Data 4 Data 5 Error, discard Data 3 Data 4 Data 5 Discard Discard Window size 7 Error in data frame 3
  • 34.
     Lost ACK: When sender reaches window capacity, it starts a timer  If timer expires, it resends all outstanding (unACKed) frames  The receiver discards possible duplicate frames and sends another ACK 32 Go-Back-n ARQ Conti..
  • 35.
    Go-Back-n ARQ Conti.. HostA Host B Data 0 ACK 3 Data 1 Data 2 Data 0 Data 1 Data 2 Lost Window Size 3 Lost ACK case Timer expires 33
  • 36.
    Selective Repeat ARQ Problem with Go-back-N:  Sender: resend many packets with a single lose  Receiver: discard many good received (out-of-order) packets  Very inefficient when N becomes bigger (in high-speed network)  Solution: Receiver individually acknowledges all correctly received pkts  buffers pkts, as needed, for eventual in-order delivery to upper layer  sender only resends pkts for which ACK not received  sender keeps timer for each unACKed pkt  sender window  N consecutive seq #’s  again limits seq #s of sent, unACKed pkts 34
  • 37.
    Selective Repeat ARQ HostA Host B Data 0 NAK 3 Data 1 Data 2 Data 3 Data 4 Data 5 Error, discard Data 3 Window size 7 Error in data frame 3 Data 6 35
  • 38.
    Selective Repeat ARQ Lost Data Frames:  Out-of-sequence delivery is permitted, but out-of-sequence ACK is not  When a lost frame is detected, NAK is sent  If last frame is lost, then receiver does nothing  Lost ACK:  Handled the same way as in go-back-n 36