CMPT 371

36
© Janice Regan, CMPT 128, 2007-2012 CMPT 371 Data Communications and Networking Pipelined reliable data transfer 1

description

CMPT 371. Data Communications and Networking Pipelined reliable data transfer. Stop and Wait: Utilization: examples (3). a = ( R × d ) / ( V × L ) U = T f / T t = 1 / (1+2a) Case 1: WAN using ATM over optical fiber link d = 1000 km, L = 424 bits, R = 155.52 Mbps - PowerPoint PPT Presentation

Transcript of CMPT 371

Page 1: CMPT 371

© Janice Regan, CMPT 128, 2007-2012

CMPT 371Data Communications and Networking

Pipelined reliable data transfer

1

Page 2: CMPT 371

Stop and Wait: Utilization: examples (3)

a = ( R × d ) / ( V × L )

U = Tf / Tt = 1 / (1+2a)

Case 1: WAN using ATM over optical fiber link d = 1000 km, L = 424 bits, R = 155.52 Mbps

V = 2×108 m/s Gives a ≈ 1850, and U = 0.00027

a = ( R × d ) / ( V × L )

U = Tf / Tt = 1 / (1+2a)

Case 1: WAN using ATM over optical fiber link d = 1000 km, L = 424 bits, R = 155.52 Mbps

V = 2×108 m/s Gives a ≈ 1850, and U = 0.00027

Janice Regan © Sept 2007-2013 2

Page 3: CMPT 371

Stop and Wait Utilization: examples (4)

a = ( R × d ) / ( V × L )

U = Tf / Tt = 1 / (1+2a)

Case 2: LAN d = 0.1 to 10 km, L = 1000 bits, R = 10 Mbps

V = 2×108 m/s Gives a = 0.005 to 0.5, and U = 0.5 to 0.99

a = ( R × d ) / ( V × L )

U = Tf / Tt = 1 / (1+2a)

Case 2: LAN d = 0.1 to 10 km, L = 1000 bits, R = 10 Mbps

V = 2×108 m/s Gives a = 0.005 to 0.5, and U = 0.5 to 0.99

Janice Regan © Sept 2007-2013 3

Page 4: CMPT 371

Stop and Wait Utilization: examples (5)

a = ( R × d ) / ( V × L )

U = Tf / Tt = 1 / (1+2a)

Case 3: Modem d = 5000 km, L = 1000 bits, R = 56,000

V = 2×108 m/s Gives a = 1.4, and U = 0.26

a = ( R × d ) / ( V × L )

U = Tf / Tt = 1 / (1+2a)

Case 3: Modem d = 5000 km, L = 1000 bits, R = 56,000

V = 2×108 m/s Gives a = 1.4, and U = 0.26

Janice Regan © Sept 2007-2013 4

Page 5: CMPT 371

Stop and Wait: Utilization Factors Utilization improves when a is smaller

a = ( R × d ) / ( V × L )

Therefore, utilization improves when The length of the frame, L, increases The data rate, R, and/or the link length, d,

decrease The bit length of the link (Rd/V) is less than

the frame length

Utilization improves when a is smaller

a = ( R × d ) / ( V × L )

Therefore, utilization improves when The length of the frame, L, increases The data rate, R, and/or the link length, d,

decrease The bit length of the link (Rd/V) is less than

the frame length

Janice Regan © Sept 2007-2013 5

Page 6: CMPT 371

Stop and Wait: Utilization Factors Physical factors, optimization of performance

limit L, R, and d Available buffer size, and resource sharing

will limit L Performance optimization indicates small L

(minimize retransmission) Performance optimization indicates largest

possible R Link length, d, set by topology of network

Physical factors, optimization of performance limit L, R, and d Available buffer size, and resource sharing

will limit L Performance optimization indicates small L

(minimize retransmission) Performance optimization indicates largest

possible R Link length, d, set by topology of network

Janice Regan © Sept 2007-2013 6

Page 7: CMPT 371

Stop and Wait: Utilization Factors

Janice Regan © Sept 2007-2013 7

Rd/V < L (a<1)Rd/V ≥ L (a ≥1)Stalling 2003: figure 7.2

t0

t0+1

t0+a

t0+1+a

t0+1+2a

t0

t0+a

t0+1

t0+1+a

t0+1+2a

Page 8: CMPT 371

Improving Stop and Wait Flow Control Stop and Wait Flow Control utilizes the channel inefficiently

particularly when the link length is greater than the frame length WHY?

Because Stop and Wait Flow Control allows only one frame to be in transit between two given stations

Consider a more complicated system of flow control (Sliding Window) which allows N≥1 frames to be in transit.

What is the cost of allowing multiple frames to be in transit simultaneously? All frames of data in transit must be buffered at the sending station

until after the ACK from the receiving station arrives at the sending station, buffering at the receiving station may or may not be used

Increased complexity, frames may arrive out of order or be duplicated

More information needed in frame headers

Janice Regan © Sept 2007-2013 8

Page 9: CMPT 371

Why multiple Frames?

Janice Regan © Sept 2007-2013 9

DestinationSource Frame 0 Frame 1

a = 4

W=6

DestinationSource

a = 4

W=1

Frame 1

Frame 5 Frame 4 Frame 3 Frame 2

Page 10: CMPT 371

Improving Stop and Wait Flow Control Stop and Wait Flow Control utilizes the channel

inefficiently particularly when the link length is greater than the frame length

WHY? Because Stop and Wait Flow Control allows only one frame to be in transit between two given stations

Consider a more complicated system of flow control (Sliding Window) which allows N≥1 frames to be in transit.

What is the cost of allowing multiple frames to be in transit simultaneously? All frames of data in transit must be buffered at the sending station

until after the ACK from the receiving station arrives at the sending station, buffering at the receiving station may or may not be used

Increased complexity, frames may arrive out of order or be duplicated

More information needed in frame headers Janice Regan © Sept 2007-2013 10

Page 11: CMPT 371

Janice Regan © Sept 2007-2013 11Stallings 2003; Figure 7.3

Sliding Window Flow Control

Page 12: CMPT 371

Description: following diagrams The packet with packet number base is shown

after the . It is the oldest unacknowledged packet.

Packets [0, base-1] have already been sent and acknowledged

Packets between and the right hand end of the dark blue window are in the sliding window

Packets between base and the darker blue window [base, nextseqnum-1] have been sent but have not been acknowledged

Janice Regan © Sept 2007-2013 12

Page 13: CMPT 371

Sliding Window Flow Control

Janice Regan © Sept 2007-2013 13

F0

F1

F2

F4

F5

ACK1

ACK4

ACK6

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0 5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

F3

ACK2

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

ACK5

Page 14: CMPT 371

Sliding Window Flow Control At the receiver

After an acknowledgement is sent the window “slides” to the right by m. For the previous example m=1

both ends of the receiver’s sliding window move together (the length of the window does not change)

The number of the ACK indicates the next packet the receiver expects (the first packet the receiver must save in its sliding window buffer)

ACKs are usually cumulative: By sending ACKn the receiver is saying I have all packets up to packet n-1, the next packet I expect is n.

Darker blue shows the remaining unused buffer space

Janice Regan © Sept 2007-2013 14

Page 15: CMPT 371

Sliding Window Flow Control At the source

When an ACK is received the window “slides” to the right by m. In the previous example m=1

Both ends of the source’s sliding window move together (the length of the window does not change)

Packets are sent one after the other until the end of the sliding window is reached

When ACKn is received the source knows that the first packet it needs to save in its sliding window buffer is packet n.

Darker blue shows the remaining unused buffer space

Janice Regan © Sept 2007-2013 15

Page 16: CMPT 371

Sliding Window Utilization 1 The total time to send a frame of data and receive the resulting

ACK is

Tt = tFRAME + tACK + ( 2 × tPROP ) + tPROCF + tQF+ tPROCA +tQA

The total time spent transmitting data frames for a window of length W frames is

Tf = W× tFRAME

The link utilization, U, of the channel in the absence of errors and losses is

U = Tf / Tt

If errors and losses make retransmissions necessary, and the average number of transmissions per frame is Nrsw then

U = Tf / ( Nrsw × Tt )Janice Regan © Sept 2007-2013 16

Page 17: CMPT 371

Sliding Window Utilization: 2

)12(1

)12()21/(

aW

aWaWU

Janice Regan © Sept 2007-2013 17

Assume protocol has the following properties Processing and queuing time is negligible

(tPROCF ≈ 0, tPROCA ≈ 0, tQF ≈ 0 , tQA ≈ 0)

The acknowledgment frame is small compared to the data frame (tFRAME >> tACK or tFRAME + tACK ≈ tFRAME )

No errors or losses

The maximum link utilization, U, is

Where a = tPROP / tFRAME = ( R × d ) / ( V × L )

Page 18: CMPT 371

Sliding Window ARQ Utilization: 1 All frames of data in transit must be buffered at the

sending station until after the ACK from the receiving station arrives at the sending station. Frames are numbered modulo M

Source entity (sender) transmits frames from its sliding window until its send buffer is exhausted. A timeout timer is set when each frame begins transmitting.

Destination entity (receiver) receives a frame and Sends and ACK then advances its sliding window if it has one Sends a NACK

Janice Regan © Sept 2007-2013 18

Page 19: CMPT 371

Sliding Window ARQ Utilization: 2

Source entity receives ACK or NACK and stops timer for received frame. If an ACK is received the source entity may advance

its sliding window If a NACK is received the NACKed frame is

retransmitted. Frames following the NACKed frame may also be retransmitted.

If a timeout timer expires the frame with an expired timer is retransmitted. Frames following that frame may also be retransmitted.

Janice Regan © Sept 2007-2013 19

Page 20: CMPT 371

Continuous ARQs: Go Back N

Not all implementations or protocols with flow control based on sliding windows use or allow NACKs, your textbook shows an example, Go Back N without NACKs.

When a packet transmission timer expires, the expired frame and all previously transmitted frames following the expired frame will be retransmitted. One timer is used, it is set when the first packet enters the pipeline and

reset each time an ACK is received (only if more packets are presently in the pipeline)

In all cases the destination entity does not buffer frames. If a frame is received out of order the frame is discarded.

Janice Regan © Sept 2007-2013 20

Page 21: CMPT 371

Go Back N ARQ: Lost Frame (timeout)

Janice Regan © Sept 2007-2013 21

F0

F2

F3

F4

F5

ACK1

ACK2

ACK1

F1

F2

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

05 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

F1

*0

0

0

0

0

0

0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

ACK1

ACK1

ACK1

Timeout expired

Discard packet

Discard packet

Discard packet

Discard packet

Page 22: CMPT 371

Janice Regan © Sept 2007-2013 22

Go Back N ARQ: Lost ACK

F0

F2

F3

F4

F5

ACK1

ACK7

F6

F7

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

05 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0F1

*

0

0

0

0

0

0

0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

0

F1

ACK2

ACK4

ACK5

ACK6

Page 23: CMPT 371

Choosing window size To choose the optimal window size need to look

at the utilization First need limits on the window size

Smallest 1 frame (becomes stop and wait) Largest determined by the largest integer N that can

fit into the sequence number field in the packet header.

For N available packet can have window as large as N-1 If window is of length N there may be ambiguity as to

whether the packet is a retransmission of packet M from the previous cycle or a new packet M for this cycle

Janice Regan © Sept 2007-2013 23

Page 24: CMPT 371

Why is N-1 the limit? (1) Consider a window size > N-1. For example

consider N=4, with a window size of 4. The first four packets are sent and received, the

ACKs of the four packets are lost

The source times out because no ACKs are received and retransmits the first 4 packets.

The receiver expects the second four packets, 0, 1, 2, 3

It receives packet 0,

it will think it is the expected packet 0 Janice Regan © Sept 2007-2013 24

1 2 3 0 1 2 3 0 1 2 30

0 1 2 3

0?

Page 25: CMPT 371

Why is N-1 the limit? (2) Consider a window size = N-1. For example

consider N=4, with a window size of 3. The first three packets are sent and received, the

ACKs of the three packets are lost

The source times out because no ACKs are received and retransmits the first 3 packets.

The receiver expects the second three packets, 3, 0, 1 (it already sent the ACKS)

It receives packet 0,

packet 0 is out of order and will be droppedJanice Regan © Sept 2007-2013 25

1 2 3 0 1 2 3 0 1 20

0 1 2

0?

Page 26: CMPT 371

26

Go Back N Utilization: 1 If errors and losses make retransmissions necessary then

U = Tf / ( Nrsw × Tt )

If no timers expire, Nrsw,, is the average number of transmissions per frame, Na. Otherwise Nrsw is a function f(Na)

Let Pf be the probability that a given frame contains errors. The probability that it will take i attempts to transmit the frame is

Each error requires that K frames be retransmitted The average number of retransmissions Na

(original transmission and i-1 retransmissions of K frames)

)1(1f

if PP

Janice Regan © Sept 2007-2013

f

ff

if

ifa P

KPPPPKiN

1

1111

1

1 )(])([

Page 27: CMPT 371

What is K? Round trip travel time means Tt / TFRAME frames will be

transmitted before the ACK for the first frame is received.

For a window length W ≥ Tt / TFRAME

:.K≈Tt / TFRAME (=2a+1)

For a window length W <Tt / TFRAME :. K≈W

.Janice Regan © Sept 2007-2013 27

Frame 5Destination

Frame 7 Frame 6 Frame 5

W = 8 a>4 K≈9

DestinationSource Frame 2 Frame 1

W = 2 K≈2

ACK 1 ACK 2 ACK 3 ACK 4Frame 8

Source

Page 28: CMPT 371

28

Go Back N ARQ Utilization: 2

Now substitute our estimates of K

To give

FRAMEFRAME

FRAME

TTWTT

TTWWK

tt

t

//

/

tff

fftrf TKPP

TPTNTU

)1(

)1()/(

Janice Regan © Sept 2007-2013

FRAME

FRAME

t

FRAME

TTWPP

P

TTWTWPP

TP

U

tfT

Tf

f

ttff

ff

/)1(

)1(

/)1(

)1(

Page 29: CMPT 371

29

Go Back N ARQ Utilization: 3

Assume that Processing time is negligible, transmission time for Frames is »

than for ACKs no ACKs or NACKs are lost or damaged, and that the timeout

timer never expires Then

If the assumption is relaxed then the longer time for retransmission (timeout duration) must be included in the analysis. A separate probability for retransmission frames due to lost ACKs and NACKs may also be introduced

12

)21(

)1(

12)12)(1(

)1(

aWaP

P

aWaWPP

PW

U

f

f

ff

f

)21(/ aTTFRAMEt

Janice Regan © Sept 2007-2013

Page 30: CMPT 371

Selective Repeat ARQs: When the source entity receives a NACK, only

the NACKed frame will be retransmitted. When a timer expires, only the expired frame

will be retransmitted. The destination entity buffers segments and

maintains its own sliding window. The destination entity resequences frames that

arrive out of order

Janice Regan © Sept 2007-2013 30

Page 31: CMPT 371

Selective Repeat ARQ: timeout (text)

Janice Regan © Sept 2007-201331

F0

F2

F3

F4

F5

ACK0

ACK1

ACK2

F1

F6

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 05 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

F1

* 5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

5 6 7 0 1 2 3 4 5 60 1 2 3 4 7 0

ACK4

ACK3

ACK5

Timeout

Page 32: CMPT 371

Choosing window size To choose the optimal window size need to look

at the utilization First need limits on the window size

Smallest 1 frame (becomes stop and wait) Largest determined by the largest integer N that can

fit into the sequence number field in the packet header.

For N available sequence numbers can have window as large as N/2 If window is of length N there may be ambiguity as to

whether the packet is a retransmission of packet M from the previous cycle or a new packet M for this cycle

Janice Regan © Sept 2007-2013 32

Page 33: CMPT 371

Why is N/2 the limit? (1) Consider a window size > N/2. For example

consider N=4, with a window size of 3. The first three packets are sent and received, the

ACKs of the three packets are lost

The source times out because no ACKs are received and retransmits the first 3 packets.

The receiver expects the second three packets, 3, 0, 1 (it already sent the ACKS)

It receives packet 0, can’t

tell if packet 3 missing or retransmitting packet 0Janice Regan © Sept 2007-2013 33

1 2 3 0 1 2 3 0 1 20

0 1 2

0?

Page 34: CMPT 371

Why is N/2 the limit? (2) Consider a window size > N/2. For example

consider N=4, with a window size of 2. The first two packets are sent and received, the

ACKs of the two packets are lost

The source times out because no ACKs are received and retransmits the first 2 packets.

The receiver expects the second two packets, 2, 3 (it already sent the ACKS for 0 and 1)

It receives packet 0,

must be a retransmission! Janice Regan © Sept 2007-2013 34

1 2 3 0 1 2 3 0 10

0 1

0?

Page 35: CMPT 371

35

Selective Repeat Utilization: 1 If errors and losses make retransmissions necessary, then for sliding

window flow control

U = Tf / ( Nrsw × Tt )If no timers expire, Nrsw,, is the average number of transmissions per frame, Na. Otherwise Nrsw is a function f(Na)

Let Pf be the probability that a given frame contains errors. The probability that it will take i attempts to transmit the frame is

Each error requires that 1 frame be retransmitted The average number of retransmissions Na

(original transmission and i-1 retransmissions)

fif

ifa P

PPiN

1

1)1(

1

1

)1(1f

if PP

Janice Regan © Sept 2007-2013

Page 36: CMPT 371

36

Selective Repeat Utilization: 2 Assume that no ACKs or NACKs are lost or damaged,

and that the timeout timer never expires Then Nr is the average number of transmissions per frame and

the channel utilization is

Also assuming that Processing time is negligible The acknowledgment frame is small compared to the data

frame

.

)12(1

)12()21/()1(

aWP

aWaPWU

f

f

Janice Regan © Sept 2007-2013

U = (1-Pf)Tf / Tt