Transport Layer (TCP/UDP) Where we are in the Course Moving on up - - PowerPoint PPT Presentation

transport layer tcp udp where we are in the course
SMART_READER_LITE
LIVE PREVIEW

Transport Layer (TCP/UDP) Where we are in the Course Moving on up - - PowerPoint PPT Presentation

Transport Layer (TCP/UDP) Where we are in the Course Moving on up to the Transport Layer! Application Transport Network Link Physical CSE 461 University of Washington 2 Three-Way Handshake (3) Suppose delayed, duplicate Active


slide-1
SLIDE 1

Transport Layer (TCP/UDP)

slide-2
SLIDE 2

Where we are in the Course

  • Moving on up to the Transport Layer!

CSE 461 University of Washington 2

Physical Link Network Transport Application

slide-3
SLIDE 3

CSE 461 University of Washington 3

Three-Way Handshake (3)

  • Suppose delayed, duplicate

copies of the SYN and ACK arrive at the server!

  • Improbable, but anyhow …

Active party (client) Passive party (server)

slide-4
SLIDE 4

CSE 461 University of Washington 4

Three-Way Handshake (4)

  • Suppose delayed, duplicate

copies of the SYN and ACK arrive at the server!

  • Improbable, but anyhow …
  • Connection will be cleanly

rejected on both sides 

Active party (client) Passive party (server)

X X

REJECT REJECT

slide-5
SLIDE 5

Connection Release

  • Orderly release by both parties when done
  • Delivers all pending data and “hangs up”
  • Cleans up state in sender and receiver
  • Key problem is to provide reliability while releasing
  • TCP uses a “symmetric” close in which both sides

shutdown independently

CSE 461 University of Washington 5

slide-6
SLIDE 6

CSE 461 University of Washington 6

TCP Connection Release

  • Two steps:
  • Active sends FIN(x), passive ACKs
  • Passive sends FIN(y), active ACKs
  • FINs are retransmitted if lost
  • Each FIN/ACK closes one direction
  • f data transfer

Active party Passive party

slide-7
SLIDE 7

CSE 461 University of Washington 7

TCP Connection Release (2)

  • Two steps:
  • Active sends FIN(x), passive ACKs
  • Passive sends FIN(y), active ACKs
  • FINs are retransmitted if lost
  • Each FIN/ACK closes one direction
  • f data transfer

Active party Passive party 1 2

slide-8
SLIDE 8

TCP Connection State Machine

CSE 461 University of Washington 8

Both parties run instances

  • f this state

machine

slide-9
SLIDE 9

TCP Release

  • Follow the active party

CSE 461 University of Washington 9

slide-10
SLIDE 10

TCP Release (2)

  • Follow the passive party

CSE 461 University of Washington 10

slide-11
SLIDE 11

TCP Release (3)

  • Again, with states …

CSE 461 University of Washington 11

1 2 CLOSED Active party Passive party FIN_WAIT_1 CLOSE_WAIT LAST_ACK FIN_WAIT_2 TIME_WAIT CLOSED ESTABLISHED (timeout) ESTABLISHED

slide-12
SLIDE 12

TIME_WAIT State

  • Wait a long time after sending all segments and

before completing the close

  • Two times the maximum segment lifetime of 60 seconds
  • Why?
  • ACK might have been lost, in which case FIN will be resent

for an orderly close

  • Could otherwise interfere with a subsequent connection

CSE 461 University of Washington 12

slide-13
SLIDE 13

Flow Control

slide-14
SLIDE 14

Recall

  • ARQ with one message at a time is Stop-and-Wait

(normal case below)

CSE 461 University of Washington 14

Frame 0 ACK 0 Timeout Time Sender Receiver Frame 1 ACK 1

slide-15
SLIDE 15

Limitation of Stop-and-Wait

  • It allows only a single message to be outstanding

from the sender:

  • Fine for LAN (only one frame fit)
  • Not efficient for network paths with BD >> 1 packet

CSE 461 University of Washington 15

slide-16
SLIDE 16

Limitation of Stop-and-Wait (2)

  • Example: R=1 Mbps, D = 50 ms
  • RTT (Round Trip Time) = 2D = 100 ms
  • How many packets/sec?
  • What if R=10 Mbps?

CSE 461 University of Washington 16

slide-17
SLIDE 17

Sliding Window

  • Generalization of stop-and-wait
  • Allows W packets to be outstanding
  • Can send W packets per RTT (=2D)
  • Pipelining improves performance
  • Need W=2BD to fill network path

CSE 461 University of Washington 17

slide-18
SLIDE 18

Sliding Window (2)

  • What W will use the network capacity?
  • Ex: R=1 Mbps, D = 50 ms
  • Ex: What if R=10 Mbps?

CSE 461 University of Washington 18

slide-19
SLIDE 19

Sliding Window (3)

  • Ex: R=1 Mbps, D = 50 ms
  • 2BD = 106 b/sec x 100. 10-3 sec = 100 kbit
  • W = 2BD = 10 packets of 1250 bytes
  • Ex: What if R=10 Mbps?
  • 2BD = 1000 kbit
  • W = 2BD = 100 packets of 1250 bytes

CSE 461 University of Washington 19

slide-20
SLIDE 20

Sliding Window Protocol

  • Many variations, depending on how buffers,

acknowledgements, and retransmissions are handled

  • Go-Back-N
  • Simplest version, can be inefficient
  • Selective Repeat
  • More complex, better performance

CSE 461 University of Washington 20

slide-21
SLIDE 21

Sliding Window – Sender

  • Sender buffers up to W segments until they are

acknowledged

  • LFS=LAST FRAME SENT, LAR=LAST ACK REC’D
  • Sends while LFS – LAR ≤ W

CSE 461 University of Washington 21

.. 5 6 7 .. 2 3 4 5 2 3 .. LAR LFS W=5 Acked Unacked 3 .. Unavailable Available

  • seq. number

Sliding Window

slide-22
SLIDE 22

Sliding Window – Sender (2)

  • Transport accepts another segment of data from the

Application ...

  • Transport sends it (as LFS–LAR  5)

CSE 461 University of Washington 22

.. 5 6 7 .. 2 3 4 5 2 3 .. LAR W=5 Acked Unacked 3 .. Unavailable Sent

  • seq. number

Sliding Window LFS

slide-23
SLIDE 23

Sliding Window – Sender (3)

  • Next higher ACK arrives from peer…
  • Window advances, buffer is freed
  • LFS–LAR  4 (can send one more)

CSE 461 University of Washington 23

.. 5 6 7 .. 2 3 4 5 2 3 .. LAR W=5 Acked Unacked 3 .. Unavailable Available

  • seq. number

Sliding Window LFS

slide-24
SLIDE 24

Sliding Window – Go-Back-N

  • Receiver keeps only a single packet buffer for the

next segment

  • State variable, LAS = LAST ACK SENT
  • On receive:
  • If seq. number is LAS+1, accept and pass it to app, update

LAS, send ACK

  • Otherwise discard (as out of order)

CSE 461 University of Washington 24

slide-25
SLIDE 25

Sliding Window – Selective Repeat

  • Receiver passes data to app in order, and buffers out-of-
  • rder segments to reduce retransmissions
  • ACK conveys highest in-order segment, plus hints about out-
  • f-order segments
  • TCP uses a selective repeat design; we’ll see the details later

CSE 461 University of Washington 25

slide-26
SLIDE 26

Sliding Window – Selective Repeat (2)

  • Buffers W segments, keeps state variable LAS = LAST

ACK SENT

  • On receive:
  • Buffer segments [LAS+1, LAS+W]
  • Send app in-order segments from LAS+1, and update LAS
  • Send ACK for LAS regardless

CSE 461 University of Washington 26

slide-27
SLIDE 27

Sliding Window – Retransmissions

  • Go-Back-N uses a single timer to detect losses
  • On timeout, resends buffered packets starting at LAR+1
  • Selective Repeat uses a timer per unacked segment

to detect losses

  • On timeout for segment, resend it
  • Hope to resend fewer segments

CSE 461 University of Washington 27

slide-28
SLIDE 28

Sequence Numbers

  • Need more than 0/1 for Stop-and-Wait …
  • But how many?
  • For Selective Repeat, need W numbers for packets, plus

W for acks of earlier packets

  • 2W seq. numbers
  • Fewer for Go-Back-N (W+1)
  • Typically implement seq. number with an N-bit

counter that wraps around at 2N—1

  • E.g., N=8: …, 253, 254, 255, 0, 1, 2, 3, …

CSE 461 University of Washington 28

slide-29
SLIDE 29

Sequence Time Plot

CSE 461 University of Washington 29

Time

  • Seq. Number

Acks (at Receiver) Delay (=RTT/2) Transmissions (at Sender)

slide-30
SLIDE 30

Sequence Time Plot (2)

CSE 461 University of Washington 30

Time

  • Seq. Number

Go-Back-N scenario

slide-31
SLIDE 31

Sequence Time Plot (3)

CSE 461 University of Washington 31

Time

  • Seq. Number

Loss Timeout Retransmissions

slide-32
SLIDE 32

Problem

  • Sliding window has pipelining to keep network busy
  • What if the receiver is overloaded?

CSE 461 University of Washington 32

Streaming video Big Iron Wee Mobile Arg …

slide-33
SLIDE 33

Sliding Window – Receiver

  • Consider receiver with W buffers
  • LAS=LAST ACK SENT, app pulls in-order data from buffer with

recv() call

CSE 461 University of Washington 33

Sliding Window .. 5 6 7 5 2 3 .. LAS W=5 Finished 3 .. Too high

  • seq. number

5 5 5 5 Acceptable

slide-34
SLIDE 34

Sliding Window – Receiver (2)

  • Suppose the next two segments arrive but app does

not call recv()

CSE 461 University of Washington 34

.. 5 6 7 5 2 3 .. LAS W=5 Finished 3 .. Too high

  • seq. number

5 5 5 5 Acceptable

slide-35
SLIDE 35

Sliding Window – Receiver (3)

  • Suppose the next two segments arrive but app does

not call recv()

  • LAS rises, but we can’t slide window!

CSE 461 University of Washington 35

.. 5 6 7 5 2 3 .. LAS W=5 Finished 3 .. Too high

  • seq. number

5 5 5 5 Acked

slide-36
SLIDE 36

Sliding Window – Receiver (4)

  • Further segments arrive (in order) we fill buffer
  • Must drop segments until app recvs!

CSE 461 University of Washington 36

Nothing Acceptable! .. 5 6 7 5 2 3 .. W=5 Finished 3 .. Too high

  • seq. number

5 5 5 5 Acked LAS

slide-37
SLIDE 37

Sliding Window – Receiver (5)

  • App recv() takes two segments
  • Window slides (phew)

CSE 461 University of Washington 37

Acceptable .. 5 6 7 5 2 3 .. W=5 Finished 3 ..

  • seq. number

5 5 5 5 Acked LAS

slide-38
SLIDE 38

Flow Control

  • Avoid loss at receiver by telling sender the available

buffer space

  • WIN=#Acceptable, not W (from LAS)

CSE 461 University of Washington 38

Acceptable .. 5 6 7 5 2 3 .. W=5 Finished 3 ..

  • seq. number

5 5 5 5 Acked LAS

slide-39
SLIDE 39

Flow Control (2)

  • Sender uses lower of the sliding window and flow

control window (WIN) as the effective window size

CSE 461 University of Washington 39

Acceptable .. 5 6 7 5 2 3 .. LAS W=3 Finished 3 .. Too high

  • seq. number

5 5 5 5 Acked

slide-40
SLIDE 40

CSE 461 University of Washington 40

Flow Control (3)

  • TCP-style example
  • SEQ/ACK sliding window
  • Flow control with WIN
  • SEQ + length < ACK+WIN
  • 4KB buffer at receiver
  • Circular buffer of bytes
slide-41
SLIDE 41

Topic

  • How to set the timeout for sending a retransmission
  • Adapting to the network path

CSE 461 University of Washington 41

Lost? Network

slide-42
SLIDE 42

Retransmissions

  • With sliding window, detecting loss with timeout
  • Set timer when a segment is sent
  • Cancel timer when ack is received
  • If timer fires, retransmit data as lost

CSE 461 University of Washington 42

Retransmit!

slide-43
SLIDE 43

Timeout Problem

  • Timeout should be “just right”
  • Too long wastes network capacity
  • Too short leads to spurious resends
  • But what is “just right”?
  • Easy to set on a LAN (Link)
  • Short, fixed, predictable RTT
  • Hard on the Internet (Transport)
  • Wide range, variable RTT

CSE 461 University of Washington 43

slide-44
SLIDE 44

Example of RTTs

CSE 461 University of Washington 44

100 200 300 400 500 600 700 800 900 1000 20 40 60 80 100 120 140 160 180 200

Round Trip Time (ms) BCNSEABCN Seconds

slide-45
SLIDE 45

Example of RTTs (2)

CSE 461 University of Washington 45

100 200 300 400 500 600 700 800 900 1000 20 40 60 80 100 120 140 160 180 200

Round Trip Time (ms) Variation due to queuing at routers, changes in network paths, etc. BCNSEABCN Propagation (+transmission) delay ≈ 2D Seconds

slide-46
SLIDE 46

Example of RTTs (3)

CSE 461 University of Washington 46

100 200 300 400 500 600 700 800 900 1000 20 40 60 80 100 120 140 160 180 200

Round Trip Time (ms) Timer too high! Timer too low! Need to adapt to the network conditions Seconds

slide-47
SLIDE 47

Adaptive Timeout

  • Smoothed estimates of the RTT (1) and variance in RTT (2)
  • Update estimates with a moving average

1. SRTTN+1 = 0.9*SRTTN + 0.1*RTTN+1 2. SvarN+1 = 0.9*SvarN + 0.1*|RTTN+1– SRTTN+1|

  • Set timeout to a multiple of estimates
  • To estimate the upper RTT in practice
  • TCP TimeoutN = SRTTN + 4*SvarN

CSE 461 University of Washington 47

slide-48
SLIDE 48

Example of Adaptive Timeout

CSE 461 University of Washington 48

100 200 300 400 500 600 700 800 900 1000 20 40 60 80 100 120 140 160 180 200

RTT (ms) SRTT Svar Seconds

slide-49
SLIDE 49

Example of Adaptive Timeout (2)

CSE 461 University of Washington 49

100 200 300 400 500 600 700 800 900 1000 20 40 60 80 100 120 140 160 180 200

RTT (ms) Timeout (SRTT + 4*Svar) Early timeout Seconds

slide-50
SLIDE 50

Adaptive Timeout (2)

  • Simple to compute, does a good job of tracking

actual RTT

  • Little “headroom” to lower
  • Yet very few early timeouts
  • Turns out to be important for good performance

and robustness

CSE 461 University of Washington 50