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

Transport Layer TCP and UDP

  • Upload
    aglaia

  • View
    42

  • Download
    0

Embed Size (px)

DESCRIPTION

Transport Layer TCP and UDP. IS250 Spring 2010 [email protected]. Transport Layer Functions. Addressing (ports) Data integrity (error detection) Reliable data transport Flow control Congestion control. TCP Transmission Rate. - PowerPoint PPT Presentation

Citation preview

Page 1: Transport Layer TCP and UDP

Transport LayerTCP and UDP

IS250Spring 2010

[email protected]

Page 2: Transport Layer TCP and UDP

John Chuang 2

Transport Layer Functions

1. Addressing (ports)2. Data integrity (error

detection)3. Reliable data transport4. Flow control5. Congestion control

Page 3: Transport Layer TCP and UDP

John Chuang 3

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?

Page 4: Transport Layer TCP and UDP

John Chuang 4

Producer Consumer

Queue

Streamof messages

Flow Control

Flow control (“Slow down please!”)

Note: We don’t want packet to travel the entire network only to be dropped at the destination.

Page 5: Transport Layer TCP and UDP

John Chuang 5

Flow Control: Two Approaches

Stop-and-go Sliding Window

Page 6: Transport Layer TCP and UDP

John Chuang 6

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

acknowledged sent can be sentoutside window

window_size

Page 7: Transport Layer TCP and UDP

John Chuang 7

TCP Header: Flow Control

Options (if any)

0 3116

Padding

Data

TCP Header

Source Port Number (16) Destination Port Number (16)

Sequence Number (32)

Acknowledgement Number (32)

Hdr Len(4)

Flags (6) Window Size (16)Reserved (6)

TCP Checksum (16) Urgent Pointer (16)

Page 8: Transport Layer TCP and UDP

John Chuang 8

TCP Flow Control

Page 9: Transport Layer TCP and UDP

John Chuang 9

Throughput as Function of Window Size

Sender

Receiver

Time

Throughput = Window Size

Roundtrip Time

Page 10: Transport Layer TCP and UDP

John Chuang 10

Transport Layer Functions

1. Addressing (ports)2. Data integrity (error

detection)3. Reliable data transport4. Flow control5. Congestion control

Page 11: Transport Layer TCP and UDP

John Chuang 11

Network Congestion

If link is congested- Router queue fills up- Drops packets

Source does not receive ACK - Resends packets- Makes congestion worse

Page 12: Transport Layer TCP and UDP

John Chuang 12

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, …

Page 13: Transport Layer TCP and UDP

John Chuang 13

TCP Congestion + Flow Control

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 set by receiver Question: how does sender set cwnd?

acknowledged sent can be sentoutside window

window_size

Page 14: Transport Layer TCP and UDP

14

Congestion Window Size

TCP congestion control is an algorithm for sender to adaptively adjust window size

At steady state, cwnd oscillates around the optimal window size

Time

cwnd

Slow Start

CongestionAvoidance

Page 15: Transport Layer TCP and UDP

John Chuang 15

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? Not really. In fact, the increase of cwnd is exponential

Page 16: Transport Layer TCP and UDP

John Chuang 16

Slow Start Example

The congestion window size grows very rapidly

TCP slows down the increase of cwnd when cwnd >= ssthresh

segment 1

ACK for segment 1

cwnd = 1

cwnd = 2 segment 2

segment 3

ACK for segments 2 + 3

cwnd = 4 segment 4

segment 5

segment 6

segment 7

ACK for segments 4+5+6+7cwnd = 8

Page 17: Transport Layer TCP and UDP

John Chuang 17

Congestion Avoidance

Slows down “Slow Start”

- If cwnd > ssthresh then each time a segment is acknowledged increment cwnd by 1/cwnd (cwnd += 1/cwnd).

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

(We will learn later how to set ssthresh)

Page 18: Transport Layer TCP and UDP

John Chuang 18

Slow Start/Congestion Avoidance Example

Assume that ssthresh = 8

0

2

4

6

8

10

12

14

t=0 t=2 t=4 t=6

Roundtrip times

Cw

nd (

in s

egm

ents

)

ssthresh

Page 19: Transport Layer TCP and UDP

19

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;

unack next

win

SEQ #

Page 20: Transport Layer TCP and UDP

20

The big picture

Time

cwnd

Timeout

Slow Start

CongestionAvoidance

1

Page 21: Transport Layer TCP and UDP

John Chuang 21

Cumulative and Duplicate ACKs

TCP uses cumulative ACK

ACK N means all bytes up to N-1 have been received

Duplicate ACKs may be due to- packets reordering

- lost packet

segment 1

ACK for segment 1

cwnd = 1

cwnd = 2 segment 2

segment 3

ACK 3cwnd = 4 segment 4

segment 5

segment 6

segment 7

ACK for segments 4+5+6+7cwnd = 8

ACK 4ACK 4ACK 4

ACK 4

ACK 2

cwnd = 2

Page 22: Transport Layer TCP and UDP

22

Fast Retransmit/Fast Recovery

Retransmit after 3 duplicated ACKs- Don’t want for timeout

No need to slow start again- halve cwnd

At steady state, cwnd oscillates around the optimal window size.

Time

cwnd

Slow Start

CongestionAvoidance

1

Page 23: Transport Layer TCP and UDP

John Chuang 23

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