22
ECE2305: Flow Control Basics Communication and Networking Flow Control Basics D. Richard Brown III (selected figures from Stallings Data and Computer Communications 10th edition) D. Richard Brown III 1 / 22

Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Communication and NetworkingFlow Control Basics

D. Richard Brown III

(selected figures from Stallings Data and Computer Communications 10th edition)

D. Richard Brown III 1 / 22

Page 2: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Context

So far, we have focused primarily on the physical layer and sendingsignals over a “transmission link”.

We now turn our attention to the transport layer and sending data over a“data link”.

Data link control:

1. Frame synchronization: detecting beginning and end of each frame

2. Flow control: ensuring the transmitter does not overwhelm thereceiver

3. Error control: dealing with errors in frames

4. Addressing: uniquely identifying transmitters and receivers

5. Distinguishing control information from data

6. Link management: initiation, maintenance, termination of data links

D. Richard Brown III 2 / 22

Page 3: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

D. Richard Brown III 3 / 22

Page 4: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Flow Control: Motivation and Notation

A receiver typically has a buffer for receiving data. In the absence of flowcontrol, the receiver’s buffer may overflow while it is processing data orperforming other tasks.

Notation:

tprop : propagation time of data link (assumed to be the same in both directions)

tframe : frame transmission time

tproc : processing time at TX and RX to react to frame or ACK

tack : acknowledgement transmission time

n : number of frames

We want our flow control protocol to be efficient. A common measure ofefficiency is “link utilization”, defined as

U =time spent transmitting data in n frames

total time required to send n frames and receive ACKs≤ 1.

D. Richard Brown III 4 / 22

Page 5: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Flow Control

Can be fairly efficient if thetransmission uses large frames.

Smaller frames often used, however,since:

I Receive buffer size limited.

I Long frames have higherprobability of block error.

I Short frames allow for easiermultiplexing with other users.

D. Richard Brown III 5 / 22

Page 6: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Flow Control Example

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0

0

0 1 2 3 4 5 6 0 1 2 3 4 5 6

ack

0 1 2 3 4 5 6 0 1 2 3 4 5 6 1

0 1

0 1 2 3 4 5 6 0 1 2 3 4 5 6

ack

0 1 2 3 4 5 6 0 1 2 3 4 5 6 2

0 1 2

0 1 2 3 4 5 6 0 1 2 3 4 5 6

ack

0 1 2 3 4 5 6 0 1 2 3 4 5 6 (etc)

Sender frames Receiver Frames

ORANGE frames have been sent but are

currently unacknowledged

GREEN frames have been acknowledged

D. Richard Brown III 6 / 22

Page 7: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Link Utilization

The total time to send n frames (and receive the acknowledgements) canbe expressed as

T = n (tframe + tprop + tproc + tack + tprop + tproc) .

Since only ntframe seconds is actually used to transmit the frames, the linkutilization is

U =tframe

tframe + tack + 2tprop + 2tproc

where the overhead of the stop-and-wait flow control protocol is in red.

In many cases, tack � tframe and tproc ≈ 0, hence we can express the linkutilization more simply as

U =tframe

tframe + 2tprop=

1

1 + 2a

where a =tproptframe

.

D. Richard Brown III 7 / 22

Page 8: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Link Utilization

10−1

100

101

102

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

a = tprop

/tframe

link u

tiliz

ation

D. Richard Brown III 8 / 22

Page 9: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Bit Length of a Link

Notation:

R : data rate of link (bits per second)

d : physical length of link (meters)

V : velocity of propagation (meters per second)

We can compute the “bit length” of the link in bits as

B =Rd

V

where B represents the number of bits present on the link when thetransmitter is streaming data at rate R.

Denoting the frame length in bits as L, we can write

a =tproptframe

=d/V

L/R=

Rd

LV=

B

L.

Better link utilization when L � B (short bit length of link or long frame).D. Richard Brown III 9 / 22

Page 10: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Link Utilization Visualization

D. Richard Brown III 10 / 22

Page 11: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Link Utilization Example 1

Suppose we have a 200 m optical fiber operating at 1 Gbps. Thepropagation velocity of optical fiber is typically about 2× 108 m/s. Theframe length is 8000 bits (1000 octets).

The bit length of the link can be computed as

B =Rd

V=

109 · 2002× 108

= 1000 bits.

The link utilization using stop-and-wait flow control is

U =1

1 + 2a=

1

1 + 2B/L=

1

1 + 2000/8000=

4

5

which means that the link is being used 80% of the time to transmit data(20% of the time is overhead).

D. Richard Brown III 11 / 22

Page 12: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Stop-and-Wait Link Utilization Example 2

Suppose we have a 72000 km satellite link operating at 1 Mbps. Thepropagation velocity of wireless transmission is close to 3× 108 m/s. Theframe length is 8000 bits (1000 octets).

The bit length of the link can be computed as

B =Rd

V=

106 · 72× 106

3× 108= 240× 103 bits.

The link utilization using stop-and-wait flow control is

U =1

1 + 2a=

1

1 + 2B/L=

1

1 + (480× 103)/8000≈ 0.0164

which means that the link is being used approximately 1.6% of the time totransmit data (98.4% of the time is overhead).

D. Richard Brown III 12 / 22

Page 13: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding Window Flow Control

Basic idea:

I Improve efficiency (link utilization) by pipelining transmissions

I Allow multiple frames to be transmitted without requiring immediateacknowledgement of each frame

I Each frame must have a sequence numberI Sliding window (buffer) of W frames:

I Transmitter can send up to W frames without ACKI ACK (receive ready (RR)) from receiver can acknowledge multiple

frames and specifies the sequence number of next expected frameI Receiver can also ACK frames and halt further transmission (receive

not ready (RNR))I Normal ACK/RR resumes transmission

I Note that W = 1 corresponds to stop-and-wait flow control.

D. Richard Brown III 13 / 22

Page 14: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding-Window Flow Control: W = 7

D. Richard Brown III 14 / 22

Page 15: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding-Window Flow Control: W = 7

D. Richard Brown III 15 / 22

Page 16: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0

0

0 1 2 3 4 5 6 0 1 2 3 4 5 6

rr(1)

1

0 1

0 1 2 3 4 5 6 0 1 2 3 4 5 6

2

0 1 2

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

3

0 1 2 3

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

Sender frames Receiver Frames

4

5

rr(2)

rr(3)

rr(4)

0 1 6

0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6

0

0 1 2 3 4 5 6 0

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2

0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6 0 1 2 3 4 5 6

1

2

rr(6)

3 0 1 2 3 4 5 6 0 1 2 3 4 5 6

4 0 1 2 3 4 5 6 0 1 2 3 4 5 6

5

0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3

0 1 2 3 4 5 6 0 1 2 3 4

0 1 2 3 4 5 6 0 1 2 3 4 5

0 1 2 3 4 5 6 0 1 2 3 4 5 6

rr(5)

0 1 2 3 4 5 6 0 1 2 3 4 5 6

rr(6)

Stalled here: can’t send frame 5

because RR(6) may be ambiguous.

ORANGE frames have been sent but are

currently unacknowledged

GREEN frames have been acknowledged

6

rr(0)

0 1 2 3 4 5 6 0 1 2 3 4 5 6

0 1 2 3 4 5 6 0 1 2 3 4 5 6

D. Richard Brown III 16 / 22

Page 17: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding-Window Link Utilization Analysis (part 1 of 2)

If ACKs can be received before slidingwindow is exhausted, then A can transmitcontinuously without interruption. The linkutilization in this case is U = 1.

Assume negligible processing time andtframe � tack. Time to first ACK:

T1 = tframe + tprop + tprop (seconds)

=L

R+ 2

d

V(seconds)

Sliding window duration:

TW =WL

R(seconds)

We have U = 1 if

TW ≥ T1 ⇔ W ≥ 2a+ 1

where a = RdLV

.

D. Richard Brown III 17 / 22

Page 18: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding-Window Link Utilization Analysis (part 2 of 2)

If ACKs are not received until after thesliding window is exhausted, i.e.,

W < 2a+ 1

then A must pause transmission.

The link utilization in this case is

U =TW

T1

=WL/R

L/R+ 2d/V

=W

2a+ 1

where a = RdLV

.

In general, we have

U = min

{W

2a+ 1, 1

}.

D. Richard Brown III 18 / 22

Page 19: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding-Window Link Utilization

10−1

100

101

102

103

0

0.2

0.4

0.6

0.8

1

a = tprop

/tframe

link u

tiliz

ation

stop−and−wait

sliding−window W=7

sliding−window W=127

D. Richard Brown III 19 / 22

Page 20: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding-Window Link Utilization Example 1

Suppose we have a 200 m optical fiber operating at 1 Gbps. Thepropagation velocity of optical fiber is typically about 2× 108 m/s. Theframe length is 8000 bits (1000 octets).

The link utilization using sliding-window flow control is

U = min

{W

1 + 2a, 1

}= min

{W

1.25, 1

}=

{1 W ≥ 245 W = 1.

In other words, W = 2 is sufficient to achieve 100% link utilization.

D. Richard Brown III 20 / 22

Page 21: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Sliding Window Link Utilization Example 2

Suppose we have a 72000 km satellite link operating at 1 Mbps. Thepropagation velocity of wireless transmission is close to 3× 108 m/s. Theframe length is 8000 bits (1000 octets).

The link utilization using sliding-window flow control is

U = min

{W

1 + 2a, 1

}= min

{W

61, 1

}=

{1 W ≥ 61W61 W < 61.

In other words, W = 61 is sufficient to achieve 100% link utilization. If wego with W = 7, we get ≈ 11.5% link utilization, which is not very good(but is better than stop-and-wait).

D. Richard Brown III 21 / 22

Page 22: Communication and Networking Flow Control Basics · 2020. 11. 2. · Communication and Networking Flow Control Basics D. Richard Brown III (selected gures from Stallings Data and

ECE2305: Flow Control Basics

Final Remarks

I Primary purpose of flow control: allow receiver to control the rate offrame transmissions and avoid buffer overflow

I How? Receiver transmits acknowledgements (ACKs) to sender

I Acknowledgements (RR) permit sender to transmit more packets ortells transmitter to stop (RNR).

I Stop-and-wait flow controlI Simple but low link utilization, especially if propagation delays are large

I Sliding-window flow controlI Sequence numbering and occasional ACK/RRs used to improve link

utilizationI More complicated to implementI W = 1 sliding-window is the same as stop-and-waitI Higher values of W typically achieve better link utilization (assuming

no frame errors)

D. Richard Brown III 22 / 22