TCP

21
TCP Transport Control Protocol

description

TCP. Transport Control Protocol. Introduction. UDP provides the connection less, unreliable, datagram service TCP provides the connection oriented, reliable, byte stream service. TCP Services. Best sized chunks Adaptive timeout and retransmission strategy Acknowledgements Checksums - PowerPoint PPT Presentation

Transcript of TCP

Page 1: TCP

TCP

Transport Control Protocol

Page 2: TCP

2003-2004 - Information management2Groep T Leuven – Information department2/35

Introduction• UDP provides the connection less, unreliable,

datagram service• TCP provides the connection oriented,

reliable, byte stream service

Page 3: TCP

2003-2004 - Information management3Groep T Leuven – Information department3/35

TCP Services• Best sized chunks• Adaptive timeout and retransmission strategy• Acknowledgements• Checksums• Re-sequencing• Discard duplicates• Flow control

Page 4: TCP

2003-2004 - Information management4Groep T Leuven – Information department4/35

TCP Header

IPHeader

IPHeader

TCPHeader

TCPHeader TCP dataTCP data

TCP segment

IP datagram

20 bytes 20 bytes

Page 5: TCP

2003-2004 - Information management5Groep T Leuven – Information department5/35

TCP Header

20 bytes

16-bit Source port number

32-bit sequence number

16-bit urgent pointer

Options (if any)

Data (if any)

16-bit Destination port number

32-bit acknowledgement number

16-bit window size

16-bit TCP checksum

header length

reservedURG

PSH

RST

SYN

FIN

ACK

0 15 16 31

Page 6: TCP

2003-2004 - Information management6Groep T Leuven – Information department6/35

Connection establishment : 3-way handshake

SYN 12345:12345 (0)<mss 1024>

Client

Ack 67891

SYN 67890:67890 (0)ack 12346 <mss 1024>

Server

Segment 2

Segment 1

Segment 3

SYN 12345:12345 (0) <mss 1024>SYN seq# : (seq#+#bytes) (#bytes) option

Page 7: TCP

2003-2004 - Information management7Groep T Leuven – Information department7/35

Best Sized Chunks• Option MSS (maximum segment size)• Announced on session establishment• Interactive data --> byte per byte (Nagle

algorithm)• Bulk data uses MSS

Page 8: TCP

2003-2004 - Information management8Groep T Leuven – Information department8/35

Connection TerminationClient

ack 67891

FIN 67890:67890 (0)ack 12345 <mss 1024>

Server

Segment 2

Segment 4

Segment 3

FIN 12345:12345 (0)ack 67891 <mss 1024>

Ack 12346

Segment 4

Page 9: TCP

2003-2004 - Information management9Groep T Leuven – Information department9/35

Reset a connection

<src port 1087 > <dst port 2000>

SYN 12345:12345 (0)win 4096

<mss 1024>

Client Server

Segment 2

Segment 1

<src port 2000 > <dst port 1087>

RST 0:0 (0)ACK 12346

Win 0

No ICMP !!!

Server isNOTRunning Service onPort 2000

Page 10: TCP

2003-2004 - Information management10Groep T Leuven – Information department10/35

Half open connections

SYN 12345:12345 (0)<mss 1024>

Client

ack 67891

SYN 67890:67890 (0)ack 12346 <mss 1024>

Server

Segment 2

Segment 1

Segment 3

P 12346:12350 (4)ack 67891

P 67891:67899 (8)ack 12351

Segment 4

Segment 5

REBOOT ??????

Page 11: TCP

2003-2004 - Information management11Groep T Leuven – Information department11/35

Adaptive timeout and retransmission strategy

• Exponential backoff– t, 2t, 4t, 8t, 16t, 32t, 64t seconds until 9

min• TCP calculates rrt --> used for timeout value

(t)

Page 12: TCP

2003-2004 - Information management12Groep T Leuven – Information department12/35

Acknowledgements & Flow Control Overview

• Full duplex• Piggy backing• Controls for the receiver

– Sliding window protocol • Controls for the sender

– slow start : congestion window– Congestion avoidance :slow start

treshold

Page 13: TCP

2003-2004 - Information management13Groep T Leuven – Information department13/35

Full duplexClient Server

Full duplex trafficpossible becausesequence numberand acknowledgenumber efficient

Page 14: TCP

2003-2004 - Information management14Groep T Leuven – Information department14/35

Sliding window protocolClient

Fast SenderServer

Slow Receiver

Slow receiver controls the flow by resizing the Windowack 67891, win 0

PSH 67890, win 4096

PSH 55890, win 4096

PSH 44890, win 4096

ack 67891, win 4096

ack 67891, win 4096

PSH 99890, win 4096

PSH 88890, win 4096

PSH 77890, win 4096

Slow receiver shifts thewindow (same seq nr)

ack 99891, win 0 Slow receiver acknowledges (seq nr + 1)

Page 15: TCP

2003-2004 - Information management15Groep T Leuven – Information department15/35

Slow Start - Window size – buffer size

ack 1

1

1

1

1

receiver

receiver

sender

sender

ack 1

ack 1

ack 1

ack 2 & 3

2

2

2

2

receiver

receiver

sender

sender

ack 2 & 3

ack 2 & 3

ack 2

time 0 time 8

time 1

time 2

time 3

time 4

time 5

time 6

time 7

time 10

time 12

time 13

time 15

time 14

3

3

3

3 time 9

ss-window=1 ss-window=2

Page 16: TCP

2003-2004 - Information management16Groep T Leuven – Information department16/35

Slow Start - Window size – buffer size (continued)

ack 4&5&6

4

4

4

4

receiver

receiver

sender

sender

ack 4&5&6&7

ack 4&5

ack 4

8

8

8

8

receiver

receiver

sender

sender

ack 8-11

ack 8

time 16 time 24

time 17

time 18

time 20

time 21

time 22

time 23

time 25

time 28

time 26

time 31

time 30

9

9

9

9

time 29

ack 3

117

6 5

5

6 5

7 6 5

7 6

7

10

10

1012 11

1012 1113

12 111314

12131415

ack 5&6&7ss-window=4ss-window=8

Page 17: TCP

2003-2004 - Information management17Groep T Leuven – Information department17/35

• Increasing the congestion window will not improve the system anymore, in effect, it will get worse !

receiver

sender time 32

time 33

time 34

ss-window=16

Slow Start - Window size – buffer size (continued)

13141516

14151617

15161718

16171819

. . .

Page 18: TCP

2003-2004 - Information management18Groep T Leuven – Information department18/35

How big should the window be ?8 segments outstanding Andunacknowledged

Capacity (bits) = bandwidth (bits/sec) x round-trip-time (sec)

OR

Page 19: TCP

2003-2004 - Information management19Groep T Leuven – Information department19/35

Capacity = bandwidh x delay

431 2

431 2 875 6

double RTT

RTT

431 2

RTT

431 2

Page 20: TCP

2003-2004 - Information management20Groep T Leuven – Information department20/35

Congestion

124 3124 3 124 3

ACK

Bottleneck Congestion

R1 R2

Fast LAN Fast LANSlow WAN

ss-window=16 congestion-window=16 - no ack - time out

Page 21: TCP

2003-2004 - Information management21Groep T Leuven – Information department21/35

0

5

10

15

20

25

30

35

40

45

0 10 20 30 40 50

Slow StartExponential Growth

Congestion Avoidance PhaseLinear Growth

Congestion Avoidance