ppt - Courses

Download Report

Transcript ppt - Courses

Transport Layer TCP and UDP IS250 Spring 2010 [email protected]

Transport Layer Functions

1.

2.

3.

4.

5.

Addressing (ports) Data integrity (error detection) Reliable data transport Flow control Congestion control John Chuang 2

TCP Transmission Rate

  Q: Why limit ourselves to send only four packets at a time?

Q: how much data can be sent before ACK received?

John Chuang 3

Flow Control

Producer Stream of messages Queue Flow control (“Slow down please!”) Consumer Note: We don’t want packet to travel the entire network only to be dropped at the destination.

John Chuang 4

Flow Control: Two Approaches

 Stop-and-go  Sliding Window John Chuang 5

Sliding Window

  Recipient explicitly requests lower send rate by specifying window size (or

MaxUnackedPackets

) Source stops sending when number of unacknowledged data equal to window size

window_size acknowledged

John Chuang

sent can be sent outside window

6

TCP Header: Flow Control

0 Source Port Number (16) 16 Destination Port Number (16) Sequence Number (32) 31 Acknowledgement Number (32) Hdr Len (4) Reserved (6) Flags (6) TCP Checksum (16) Window Size (16) Urgent Pointer (16) Options (if any) Padding Data … John Chuang 7

TCP Flow Control

John Chuang 8

Throughput as Function of Window Size

Sender Receiver

John Chuang

Time

Throughput = Window Size Roundtrip Time 9

Transport Layer Functions

1.

2.

3.

4.

5.

Addressing (ports) Data integrity (error detection) Reliable data transport Flow control Congestion control John Chuang 10

Network Congestion

  If link is congested Router queue fills up Drops packets Source does not receive ACK Resends packets Makes congestion worse John Chuang 11

TCP Congestion Control

      Use packet drop as indicator of congestion Do not send all data to receiver at once Voluntary source-imposed policy (RFC 2581) slow start (SS) congestion avoidance (CA) fast retransmission fast recovery TCP Tahoe: SS + CA + fast retransmission TCP Reno: all four Other variants: TCP SACK, TCP Vegas, TCP Westwood, … John Chuang 12

TCP Congestion + Flow Control window_size acknowledged sent can be sent outside window

  Control transmission rate by setting window size Window size set to be smaller of: rwnd : receiver window (flow control) cwnd : congestion window (congestion control) win = min( rwnd , cwnd )  rwnd  John Chuang set by receiver Question: how does sender set cwnd ?

13

Congestion Window Size

cwnd Congestion Avoidance Slow Start   TCP congestion control is an algorithm for sender to adaptively adjust window size At steady state, cwnd optimal window size oscillates around the Time 14

Slow Start

 Whenever starting traffic on a new connection, or whenever increasing traffic after congestion was experienced: Set cwnd =1 (one segment) Each time a segment is acknowledged increment cwnd by one ( cwnd ++).

 Does Slow Start increment slowly In fact, the increase of cwnd ?

Not really. is exponential John Chuang 15

Slow Start Example

 The congestion window size grows very rapidly

cwnd = 1 cwnd = 2 cwnd = 4

 TCP slows down the increase of cwnd when

cwnd >= ssthresh cwnd = 8 segment 1

ACK for segm ent 1

segment 2 segment 3

ACK for segm ents 2 + 3

segment 4 segment 5 segment 6 segment 7

ACK for segm ents 4+5+6+7 John Chuang 16

Congestion Avoidance

 Slows down “Slow Start” -

If

cwnd > ssthresh each time a segment is acknowledged increment cwnd by 1/cwnd (

then

cwnd += 1/cwnd ).

  So cwnd is increased by one only if all segments have been acknowledged.

(We will learn later how to set ssthresh ) John Chuang 17

Slow Start/Congestion Avoidance Example

 Assume that ssthresh = 8

14 12 10 8 6 4 2 0 t= 0

ssthresh

t= 2 t= 4

Roundtrip times

t= 6

John Chuang

cwnd = 1 cwnd = 2 cwnd = 4 cwnd = 8 cwnd = 9 cwnd = 10

18

TCP Congestion Control Pseudo code Initially:

cwnd = 1; ssthresh = infinite;

New ack received:

if (cwnd < ssthresh) /* Slow Start*/ cwnd = cwnd + 1; else /*Congestion Avoidance*/ cwnd = cwnd + 1/cwnd;

Timeout:

/* Multiplicative decrease */ ssthresh = 0.5 * win; cwnd = 1; win = min(cwnd, rwnd); while (next < unack + win) transmit next packet; SEQ # unack win next 19

The big picture

cwnd Timeout Congestion Avoidance Slow Start 1 Time 20

Cumulative and Duplicate ACKs

  TCP uses cumulative ACK ACK N means all bytes up to N-1 have been received

cwnd = 1 cwnd = 2 cwnd = 4

ACK 2

segment 1

ACK for segm ent 1

segment 2 segment 3

 Duplicate ACKs may be due to cwnd = 2 packets reordering

cwnd = 8

lost packet John Chuang ACK 4 ACK 3

segment 4 segment 5 segment 6 segment 7

ACK 4 ACK 4 ACK 4 ACK for segm ents 4+5+6+7 21

Fast Retransmit/Fast Recovery

cwnd Congestion Avoidance Slow Start    1 Retransmit after 3 duplicated ACKs Don’t want for timeout No need to slow start again halve cwnd At steady state, cwnd optimal window size.

oscillates around the Time 22

TCP Congestion Control Shortcomings

    “Fairness criterion” Is “equal division” of resources always desirable?

Estimating congestion by retransmission is flawed for wireless links Depends on accurate implementation - cheating possible Application can avoid congestion control by using UDP John Chuang 23