flow control © prof. aiman hanna department of computer science concordia university montreal,...

42
Flow Control Flow Control © Prof. Aiman Hanna © Prof. Aiman Hanna Department of Computer Science Department of Computer Science Concordia University Concordia University Montreal, Canada Montreal, Canada

Upload: amberly-wells

Post on 17-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

Flow ControlFlow Control

© Prof. Aiman Hanna© Prof. Aiman HannaDepartment of Computer Science Department of Computer Science

Concordia University Concordia University Montreal, CanadaMontreal, Canada

Page 2: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

22

FF low Control low Control Communication Issues: Communication Issues:

• What if error correction is not possibleWhat if error correction is not possible

• What if messages are very longWhat if messages are very long

• How retransmission can be initiated How retransmission can be initiated

• What if sending and receiving computers have different What if sending and receiving computers have different speedspeed

• What if the receiver is busier than the senderWhat if the receiver is busier than the sender

• What if the receiver needs to sendWhat if the receiver needs to send

Page 3: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

33

FF low Control low Control Two functions are important for effective communication:Two functions are important for effective communication:

• Error Control Error Control • Flow ControlFlow Control

Error Control: Error Control: • How devices check for errors How devices check for errors • What is done if errors are foundWhat is done if errors are found

Flow Control:Flow Control: • Avoids the sender from overwhelming the receiver Avoids the sender from overwhelming the receiver • Determines when a frame can, or cannot, be sentDetermines when a frame can, or cannot, be sent• Determines when a frame should be sent another time (resent) Determines when a frame should be sent another time (resent) • Ensures that all related frames arrive at their destination and in the proper Ensures that all related frames arrive at their destination and in the proper

orderorder

Page 4: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

44

SS ignaling ignaling Elementary approach to flow controlElementary approach to flow control Sender continues to send as long as the receiver is capable of Sender continues to send as long as the receiver is capable of

receiving receiving Once the receiver is incapable of receiving, it signals the senderOnce the receiver is incapable of receiving, it signals the sender Sender then stops until another signal is issued by the receiver Sender then stops until another signal is issued by the receiver

Figure 8.1 – Flow Control Using

Signaling

Page 5: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

55

SS ignaling ignaling Examples of signaling include: Examples of signaling include:

• DTE-DCE communication, RS-232 for example DTE-DCE communication, RS-232 for example

• X-ON / X-OFFX-ON / X-OFF RS-232 uses different line for each signalRS-232 uses different line for each signal

Alternatively, the signal can be sent as a part of the transmitted dataAlternatively, the signal can be sent as a part of the transmitted data

This is referred to as This is referred to as in-band signalingin-band signaling

The receiver has to analyze the incoming data and acts accordinglyThe receiver has to analyze the incoming data and acts accordingly

DC1 & DC3 are two ASCII codes (hexadecimal codes 11 & 13) can be used DC1 & DC3 are two ASCII codes (hexadecimal codes 11 & 13) can be used for X-ON & X-OFFfor X-ON & X-OFF

X-ON & X-OFF can be used for flow control X-ON & X-OFF can be used for flow control

Page 6: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

66

SS ignaling ignaling

Figure 8.2 – Flow Control Using In-Band Signaling

Page 7: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

77

FF rame-Oriented Control rame-Oriented Control X-ON & X-OFF protocol is byte-oriented X-ON & X-OFF protocol is byte-oriented

Sometimes, data is sent frame by frame and not one byte at a timeSometimes, data is sent frame by frame and not one byte at a time

In such cases, the protocol has to enforce some restrictions on the number of frames In such cases, the protocol has to enforce some restrictions on the number of frames sent to allow flow control sent to allow flow control

Figure 8.3 – Sending and Receiving between Users

Page 8: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

88

FF rame-Oriented Control rame-Oriented Control Examples of frame-oriented control protocols include: Examples of frame-oriented control protocols include:

• Unrestricted Unrestricted protocolprotocol

• Stop-and-Wait Stop-and-Wait protocolprotocol

Page 9: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

99

FF rame-Oriented Control rame-Oriented Control Unrestricted protocolUnrestricted protocol Assumes receiver has unlimited capacity of buffer Assumes receiver has unlimited capacity of buffer

space, or it will never run out of buffer space somehowspace, or it will never run out of buffer space somehow

Figure 8.4 – Unrestricted Flow Control

Page 10: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1010

FF rame-Oriented Control rame-Oriented Control Stop-and-Wait protocolStop-and-Wait protocol Sender sends one frame, then waits for an acknowledgment Sender sends one frame, then waits for an acknowledgment

(ACK) from the receiver (ACK) from the receiver

If the frame is damaged, this will also be indicated in the ACKIf the frame is damaged, this will also be indicated in the ACK

Figure 8.5 – stop-and-wait Flow Control

Page 11: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1111

FF rame-Oriented Control rame-Oriented Control Stop-and-Wait protocolStop-and-Wait protocol Analysis of stop-and-waitAnalysis of stop-and-wait

• What if frame is lost?What if frame is lost?

• What is ACK is lost?What is ACK is lost?

• What if ACK is received but it is damaged?What if ACK is received but it is damaged?

• What about efficiency; What about efficiency; Is the protocol too slow and there is a lot of waiting at both sides? Is the protocol too slow and there is a lot of waiting at both sides? What is good about that protocol? What is good about that protocol?

Page 12: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1212

FF rame-Oriented Control rame-Oriented Control Protocol Efficiency Protocol Efficiency There are different ways to measure efficiency There are different ways to measure efficiency

One measure to efficiency is the One measure to efficiency is the Effective Date RateEffective Date Rate

Effective date rate is number of transferred bits per unit Effective date rate is number of transferred bits per unit of timeof time

It can be calculated as:It can be calculated as:Number of sent data bits / Elapsed time between sending of two Number of sent data bits / Elapsed time between sending of two

consecutive frames consecutive frames

Page 13: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1313

FF rame-Oriented Control rame-Oriented Control Protocol Efficiency Protocol Efficiency

Assume: Assume:

R: bit rate (bps)R: bit rate (bps)

S: signal speed (meters/S: signal speed (meters/µsec) µsec)

D: distance between sender and receiver (meters)D: distance between sender and receiver (meters)

T: time to create a frameT: time to create a frame

F: frame bits (# of bits per frame including header)F: frame bits (# of bits per frame including header)

N: data bits (# of data bits per frame) N: data bits (# of data bits per frame)

A: number of bits in an ACK frameA: number of bits in an ACK frame

Page 14: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1414

FF rame-Oriented Control rame-Oriented Control Protocol Efficiency Protocol Efficiency

Figure 8.4 – Time Required to Send a Frame to Receiver

Page 15: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1515

FF rame-Oriented Control rame-Oriented Control Protocol Efficiency Protocol Efficiency For the unrestricted protocol, elapsed time between sending For the unrestricted protocol, elapsed time between sending

consecutive frames is: consecutive frames is: time = T + F/Rtime = T + F/R

EDR = N/(T + F/R)EDR = N/(T + F/R)

For the stop-and-wait protocol, it is:For the stop-and-wait protocol, it is:time to send a frame + time to get ACK backtime to send a frame + time to get ACK back time = (T + F/R + D/S) + (T + A/R + D/S)time = (T + F/R + D/S) + (T + A/R + D/S)

Note:Note: the time needed to create an ACK frame may actually differ from the the time needed to create an ACK frame may actually differ from the time needed to create a full frame. We assume that the two are the same time needed to create a full frame. We assume that the two are the same just for simplicityjust for simplicity

EDR = N/[2(T + D/S) + (F + A)/R]EDR = N/[2(T + D/S) + (F + A)/R]

Page 16: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1616

FF rame-Oriented Control rame-Oriented Control Protocol Efficiency Protocol Efficiency Example:Example: Assume: Assume:

• R = 10 Mbps (10 bits /R = 10 Mbps (10 bits /µsec) µsec) • S = 200 meters/µsecS = 200 meters/µsec• D = 200 meters D = 200 meters • T = 1 µsecT = 1 µsec• F = 200 bitsF = 200 bits• N = 160 bitsN = 160 bits• A = 40 bits A = 40 bits

For the unrestricted protocol:For the unrestricted protocol:

EDR = N/(T + F/R) ≈ 7.6 MbpsEDR = N/(T + F/R) ≈ 7.6 Mbps

For the stop-and-wait protocol, For the stop-and-wait protocol,

EDR = N/[2(T + D/S) + (F + A)/R] ≈ 5.7 MbpsEDR = N/[2(T + D/S) + (F + A)/R] ≈ 5.7 Mbps

Page 17: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1717

SS liding Window Protocols liding Window Protocols The unrestricted protocol and the stop-and-wait protocol are two The unrestricted protocol and the stop-and-wait protocol are two

extremes extremes

In practice, we may need some other protocol that falls in In practice, we may need some other protocol that falls in between these extremes between these extremes

Sliding Window protocols provide such alternative Sliding Window protocols provide such alternative

Two major implementation of sliding window protocols are:Two major implementation of sliding window protocols are:• Go-back-Go-back-nn

• Selective RepeatSelective Repeat

Page 18: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1818

SS liding Window Protocols liding Window Protocols Sliding window protocol numbers the frames to be sent Sliding window protocol numbers the frames to be sent

and defines a window of these frames and defines a window of these frames

Figure 8.7 – A Sliding Window Protocol

Page 19: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

1919

Go-Back-Go-Back-nn Protocol Protocol Go-back-n requires frames to be received in the same order they Go-back-n requires frames to be received in the same order they

are sent are sent

The receiver hence rejects all out-of-order frames; in other The receiver hence rejects all out-of-order frames; in other words, it rejects all frames but the next expected one words, it rejects all frames but the next expected one

In reality, communication can be full-duplex, so data is sent in In reality, communication can be full-duplex, so data is sent in both directions both directions

Instead of sending separate ACK frames, ACKs can be sent Instead of sending separate ACK frames, ACKs can be sent along with dataalong with data

This is called This is called piggybackingpiggybacking

Page 20: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2020

Go-Back-Go-Back-nn Protocol Protocol

Figure 8.9 – Typical Frame Format

Figure 8.8 – Two-Way Communication between Devices A and B

Page 21: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2121

Go-Back-Go-Back-nn Protocol Protocol Details of Go-back-n:Details of Go-back-n:

• If the Number field in the frame has k bits, then frames can be numbered If the Number field in the frame has k bits, then frames can be numbered from 0 from 0 2 2kk - 1 - 1

• If there is more than 2If there is more than 2kk frames, then frame numbers are duplicated frames, then frame numbers are duplicated For example, if k=3, then frames will be 0, 1, …, 6, 7, 0, 1, …For example, if k=3, then frames will be 0, 1, …, 6, 7, 0, 1, …

• Receiver expects frames in order. Any out-of-order frames are rejected Receiver expects frames in order. Any out-of-order frames are rejected and a NACK is sent for the expected frame and a NACK is sent for the expected frame

• If the expected frame is received but damaged, then it is discarded and a If the expected frame is received but damaged, then it is discarded and a NACK is sentNACK is sent

• Not every frame is explicitly ACKedNot every frame is explicitly ACKed

For example, if sender sends frames 35, 36, 37, 38 & 39, ACKs for 36 & For example, if sender sends frames 35, 36, 37, 38 & 39, ACKs for 36 & 39 may be sent. ACK for 36 implicitly indicates that 35 & 36 were 39 may be sent. ACK for 36 implicitly indicates that 35 & 36 were accepted. ACK for 39 implicitly indicate that 37, 38 & 39 were accepted accepted. ACK for 39 implicitly indicate that 37, 38 & 39 were accepted

Page 22: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2222

Go-Back-Go-Back-nn Protocol Protocol Details of Go-back-n (continue…):Details of Go-back-n (continue…):

• Piggybacking is used whenever possible, however frames must be ACKed Piggybacking is used whenever possible, however frames must be ACKed within a specific time periodwithin a specific time period

• An An ACK timerACK timer is defined; if this timer reaches its limit, the frame must be is defined; if this timer reaches its limit, the frame must be ACKed even without piggybacking ACKed even without piggybacking

• If there sender does not receive an ACK within with a time period (a If there sender does not receive an ACK within with a time period (a frame timerframe timer is used here), it assumes that something has gone wrong and is used here), it assumes that something has gone wrong and so it resends so it resends everyevery packet in its window packet in its window

In other words, the sender goes back to the beginning of the window (n) In other words, the sender goes back to the beginning of the window (n) and resends all frames in the window; that is the reason behind the name: and resends all frames in the window; that is the reason behind the name: go-back-ngo-back-n

Page 23: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2323

Go-Back-Go-Back-nn Protocol Protocol What is the maximum window size? What is the maximum window size?

Figure 8.10 – Protocol Failure when Window Size = 2k

Page 24: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2424

Go-Back-Go-Back-nn Protocol Protocol What is the maximum window size? What is the maximum window size?

Figure 8.11 – Protocol Success when Window Size = 2k -1

Page 25: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2525

Selective Repeat Protocol Selective Repeat Protocol Go-back-n works well only under certain conditions (what are Go-back-n works well only under certain conditions (what are

these?)these?)

Once these conditions change, the protocol becomes less Once these conditions change, the protocol becomes less efficient efficient

Selective repeat provides an alternative Selective repeat provides an alternative

With selective repeat, the receiver is required to accept (buffers) With selective repeat, the receiver is required to accept (buffers) frames even they are out of orderframes even they are out of order

All frames must however be reordered before being delivered All frames must however be reordered before being delivered

Page 26: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2626

Selective Repeat Protocol Selective Repeat Protocol Details of Selective Repeat:Details of Selective Repeat:

Selective repeat is similar to go-back-n in the following:Selective repeat is similar to go-back-n in the following:

• Uses the same frame formatUses the same frame format• All frames are numbered using k-bit field All frames are numbered using k-bit field • Sender has a window that defines the maximum number of outstanding Sender has a window that defines the maximum number of outstanding

frames frames • ACKs are piggybacked whenever possibleACKs are piggybacked whenever possible• Not all frames are explicitly ACKedNot all frames are explicitly ACKed• Uses NACKs for damaged and out-of-order framesUses NACKs for damaged and out-of-order frames• There is an ACK timer that is used to force the sending of an ACK frame There is an ACK timer that is used to force the sending of an ACK frame

if piggybacked is not possible if piggybacked is not possible

The similarities end here! The similarities end here!

Page 27: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2727

Selective Repeat Protocol Selective Repeat Protocol Details of Selective Repeat (continue…):Details of Selective Repeat (continue…):

Figure 8.13 – Sending & Receiving Windows for Selective Repeat Protocol

Page 28: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2828

Selective Repeat Protocol Selective Repeat Protocol Details of Selective Repeat Details of Selective Repeat (continue…):(continue…):

• Out-of-order frames are buffered until all the ones that precede them Out-of-order frames are buffered until all the ones that precede them arrivearrive

• Once a receiver detects out-of-order arrival, it sends NACK for the Once a receiver detects out-of-order arrival, it sends NACK for the expected frame expected frame

• If the sender receive NACK, it resends only that frameIf the sender receive NACK, it resends only that frame

• Once all consecutive frames arrive, they are delivered and the receiving Once all consecutive frames arrive, they are delivered and the receiving window is advancedwindow is advanced

• If a frame timer expires, only that frame is resentIf a frame timer expires, only that frame is resent

• Piggybacking may not ACK the last received frame; rather it ACKs the Piggybacking may not ACK the last received frame; rather it ACKs the highest one delivered to the userhighest one delivered to the user

Page 29: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

2929

Selective Repeat Protocol Selective Repeat Protocol What is the maximum window size? What is the maximum window size?

Constraint: window size must be <= ½ of 2Constraint: window size must be <= ½ of 2kk; which is <= 2; which is <= 2k-1k-1

Figure 8.14 – Protocol Failure: Receiving Window size is > 2K-1

Page 30: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3030

Selective Repeat Protocol Selective Repeat Protocol What is the maximum window size? What is the maximum window size?

Constraint: window size must be <= ½ of 2Constraint: window size must be <= ½ of 2kk; which is <= 2; which is <= 2k-1k-1

Figure 8.15 – Protocol Failure: Sending Window size is > 2K-1

Page 31: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3131

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols Unrestricted and stop-and-wait efficiency were affected Unrestricted and stop-and-wait efficiency were affected

by many factors such as distance, raw bit rate, …etc.by many factors such as distance, raw bit rate, …etc.

Here also, there are many factors that can affect the Here also, there are many factors that can affect the efficiency of a sliding window protocol; for example, efficiency of a sliding window protocol; for example, the timer value to trigger resent, the number of frames the timer value to trigger resent, the number of frames carrying piggybacking ACKs, …etc. carrying piggybacking ACKs, …etc.

For simplicity, assume that there are no errors, and that For simplicity, assume that there are no errors, and that there is enough data sent back so piggybacking is there is enough data sent back so piggybacking is always used always used

Page 32: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3232

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols Assume: Assume:

R: bit rate (bps)R: bit rate (bps)

S: signal speed (meters/S: signal speed (meters/µsec) µsec)

D: distance between sender and receiver (meters)D: distance between sender and receiver (meters)

T: time to create a frameT: time to create a frame

F: frame bits (# of bits per frame including header)F: frame bits (# of bits per frame including header)

N: data bits (# of data bits per frame) N: data bits (# of data bits per frame)

A: number of bits in an ACK frameA: number of bits in an ACK frame

W: window sizeW: window size

Page 33: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3333

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols Now, there are two possibilities:Now, there are two possibilities:

Case 1) Sender window never reaches its maximum sizeCase 1) Sender window never reaches its maximum size• This is the case when ACKs come back fast enough so the sender just This is the case when ACKs come back fast enough so the sender just

advances its window and sends againadvances its window and sends again

• This case then resembles the unrestricted protocol This case then resembles the unrestricted protocol

Case 2) The sender sends all frames in its window before getting any Case 2) The sender sends all frames in its window before getting any ACK backACK back• This is the case when the sender This is the case when the sender WW frames at a time and then waits for an frames at a time and then waits for an

ACKACK

• This then resembles stop-and-wait, but with window size This then resembles stop-and-wait, but with window size WW instead of 1 instead of 1

The two cases can then be compared by looking at the time needed The two cases can then be compared by looking at the time needed to send W frames to send W frames

Page 34: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3434

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols• To construct and send 1 frame, we need T + F/RTo construct and send 1 frame, we need T + F/R

to construct and send W frames, we need W( T + F/R) to construct and send W frames, we need W( T + F/R)

• To construct and send ACK back, we need T + A/RTo construct and send ACK back, we need T + A/R• Since ACKs are piggybacked, we need T + F/RSince ACKs are piggybacked, we need T + F/R

• We also need D/S for traveling time between sender and receiver We also need D/S for traveling time between sender and receiver Total time to send 1 frame and get ACK back is: Total time to send 1 frame and get ACK back is:

2 (T + F/R +D/S) 2 (T + F/R +D/S)

For Case 1 (resembling unrestricted protocol): For Case 1 (resembling unrestricted protocol): W( T + F/R) > 2 (T + F/R +D/S)W( T + F/R) > 2 (T + F/R +D/S)

For Case 2 (resembling W-Oriented stop-and-wait): For Case 2 (resembling W-Oriented stop-and-wait): W( T + F/R) < 2 (T + F/R +D/S)W( T + F/R) < 2 (T + F/R +D/S)

Page 35: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3535

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols

Figure 8.17 –Sending All Windowed Frames and Waiting

Page 36: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3636

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols What is the effective data rate then?What is the effective data rate then?

• Case 1 is actually the unrestricted protocol, hence Case 1 is actually the unrestricted protocol, hence

EDR = N/(T + F/R) EDR = N/(T + F/R)

• Case 2 is actually the W-Oriented stop-and-wait, hence Case 2 is actually the W-Oriented stop-and-wait, hence

EDR = (W * N)/[2(T + D/S) + (F + A)/R] EDR = (W * N)/[2(T + D/S) + (F + A)/R]

Here W * N replaced N in the original calculation. Why?Here W * N replaced N in the original calculation. Why?

Page 37: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3737

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols Example:Example: Assume: Assume:

• R = 10 Mbps (10 bits /R = 10 Mbps (10 bits /µsec) µsec) • S = 200 meters/µsecS = 200 meters/µsec• D = 200 meters D = 200 meters • T = 1 µsecT = 1 µsec• F = 200 bitsF = 200 bits• N = 160 bitsN = 160 bits• A = 40 bits A = 40 bits • W = 4 framesW = 4 frames

Applying these values, Case 1 condition is the one satisfied; so it Applying these values, Case 1 condition is the one satisfied; so it is unrestricted version and the efficiency can be calculated as:is unrestricted version and the efficiency can be calculated as:

EDR = N/( T + F/R) ≈ 7.6 MbpsEDR = N/( T + F/R) ≈ 7.6 Mbps

Page 38: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3838

EE fficiency of Sliding Window fficiency of Sliding Window ProtocolsProtocols Example:Example: Assume: Assume:

• R = 10 Mbps (10 bits /R = 10 Mbps (10 bits /µsec) µsec) • S = 200 meters/µsecS = 200 meters/µsec• D = 5000 meters D = 5000 meters • T = 1 µsecT = 1 µsec• F = 200 bitsF = 200 bits• N = 160 bitsN = 160 bits• A = 40 bits A = 40 bits • W = 4 framesW = 4 frames

Applying these values, Case 2 condition is the one satisfied; soApplying these values, Case 2 condition is the one satisfied; so

EDR = (W * N)/[2(T + D/S) + (F + F)/R] EDR = (W * N)/[2(T + D/S) + (F + F)/R] = (4 * 160 bits)/[2(1 = (4 * 160 bits)/[2(1 µsec + 5000 meters/µsec + 5000 meters/ 200 meters/µsec200 meters/µsec) + 400 bits/ 10 bits /) + 400 bits/ 10 bits /µsecµsec] ] = 640 bits /[2(26 = 640 bits /[2(26 µsec) + 40 µsec] µsec) + 40 µsec] = 640 bits / 96 = 640 bits / 96 µsecµsec = 6.96 = 6.96 MMbpsbps

Notice that in that example all ACKs are piggybacked so F replaces A in the computation of EDR Notice that in that example all ACKs are piggybacked so F replaces A in the computation of EDR

Page 39: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

3939

PP rotocol Correctness rotocol Correctness Does these protocols work? Will they fail in other cases that we Does these protocols work? Will they fail in other cases that we

do not know? do not know?

In order to guarantee that a protocol works, formal proof is In order to guarantee that a protocol works, formal proof is neededneeded

However, sometimes it is very difficult to derive formal proofs However, sometimes it is very difficult to derive formal proofs

A reasonable alternative in such cases is verification A reasonable alternative in such cases is verification

Two common verification tools are:Two common verification tools are:• Finite State Machines (FSM)Finite State Machines (FSM)• Petri Net (similar to FSM in that it uses graphs to represent states and Petri Net (similar to FSM in that it uses graphs to represent states and

transitions, but does it in a different way)transitions, but does it in a different way)

Page 40: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

4040

PP rotocol Correctness rotocol Correctness Finite State Machine Finite State Machine

Indicates all possible states Indicates all possible states

Indicates the different events that changes one state to another (or Indicates the different events that changes one state to another (or possibly back to the same state) possibly back to the same state)

An event that causes a change of state is called An event that causes a change of state is called state transitionstate transition

A State Transition Diagram (STD) can then be used to represent A State Transition Diagram (STD) can then be used to represent an algorithm an algorithm

Page 41: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

4141

PP rotocol Correctness rotocol Correctness Finite State MachineFinite State Machine What can you observe by looking at the following STD?What can you observe by looking at the following STD?

Figure 8.18 – General State Transition Diagram

Page 42: Flow Control © Prof. Aiman Hanna Department of Computer Science Concordia University Montreal, Canada

4242

PP rotocol Correctness rotocol Correctness Finite State MachineFinite State Machine STD for a simplified go-back-n protocolSTD for a simplified go-back-n protocol Assume: k=1, window size is 1, no time-out or retransmission and data go from sender to receiverAssume: k=1, window size is 1, no time-out or retransmission and data go from sender to receiver This is like stop-and-wait protocol with frame numbers This is like stop-and-wait protocol with frame numbers

(x,y) (x,y) ≡ ≡ x is the ACK number and y is the next expected frame numberx is the ACK number and y is the next expected frame numberfor example, (0,1) means there is an ACK for frame 0 and the next expected frame is 1for example, (0,1) means there is an ACK for frame 0 and the next expected frame is 1

Figure 8.19 – STD for a stop-and-wait Protocol with Frame Numbers