The Transmission Control Protocol (TCP) June 6, 1998 TCP 2 What - - PowerPoint PPT Presentation

the transmission control protocol tcp
SMART_READER_LITE
LIVE PREVIEW

The Transmission Control Protocol (TCP) June 6, 1998 TCP 2 What - - PowerPoint PPT Presentation

TCP 1 The Transmission Control Protocol (TCP) June 6, 1998 TCP 2 What are transmission protocols needed for? Addressing: application-to-application addressing Reliable delivery: the receiver application should receive the same data stream


slide-1
SLIDE 1

TCP 1

The Transmission Control Protocol (TCP)

June 6, 1998

slide-2
SLIDE 2

TCP 2

What are transmission protocols needed for?

Addressing: application-to-application addressing Reliable delivery: the receiver application should receive the same data stream the source puts on the net Segment order maintenance: data segments should reach the application in the same order they left the sender Flow control: the data sending speed should adapt itself to the receivers speed Congestion control: the transmission speed cannot be faster than the speed of the slowest link traversed Segmentation: data is sent in segments that provide the highest throughout

June 6, 1998

slide-3
SLIDE 3

TCP 3

Transmission Control Protocol

  • *1981
  • reliable, sequenced byte stream on top of datagram
  • connections with graceful close or hard reset
  • retransmit if no ACK after n· RTO (initially, 6 s)
  • RTO = average + 4 · smoothed mean deviation
  • windowed congestion control: not part of the protocol

spec...

  • windows:

June 6, 1998

slide-4
SLIDE 4

TCP 4

– flow control: avoid overrunning slow receiver ➠ advertised by receiver – congestion control: avoid network overload ➠ maintained by sender – cwnd

  • packet header overhead: 20 bytes

June 6, 1998

slide-5
SLIDE 5

TCP 5

Transmission Control Protocol

Maximum segment size (MSS) set during connection establishment Reliability: acknowledgments, round trip delay estimations and data retransmission Flow control: TCP uses a variable-window mechanism Congestion control: “slow start” and related schemes

June 6, 1998

slide-6
SLIDE 6

TCP 6

TCP Header

U G A C K P S H R

16 31

32-bit sequence number 16-bit source port number 16-bit destination port number 32-bit acknowledgment number (next byte expected) 16-bit urgent pointer 16-bit TCP Checksum

  • ptions (if any)

data (if any)

length R S T S Y N F I N 4-bit header reserved

(6 bits) 16-bit window size 20 bytes

The most common option is the maximum segment size

June 6, 1998

slide-7
SLIDE 7

TCP 7

  • ption.

June 6, 1998

slide-8
SLIDE 8

TCP 8

Connection Establishment and Termination

three-way handshake

segment 1 tao lupus 0.0 SYN 141:141(0) <mss 1024> segment 2 ACK 182 0.002402 (0.0024) 0.007224 (0.0048) segment 3 segment 4 4.155441 (4.1482) FIN 142:142(0) ACK 182 4.156747 (0.0013) segment 5 segment 6 FIN 182:182(0) ACK 143 ACK 142 SYN 181:181(0) <mss 1024> ACK 143 ACK 183 4.158144 (0.0014) 4.180662 (0.0225) segment 7

Each side can just close its transmission side resulting in a

June 6, 1998

slide-9
SLIDE 9

TCP 9

half close.

June 6, 1998

slide-10
SLIDE 10

TCP 10

Connection Establishment

  • tao sends a SYN segment with an initial sequence

number (ISN) and and the maximum segment size (MSS) it is willing to receive.

  • lupus replies with a SYN segment acknowledging ISN

and announcing its MSS.

  • MSS can be at the most as large as the interface segment

size minus 40 bytes.

June 6, 1998

slide-11
SLIDE 11

TCP 11

SLIP lupus SYN <mss 1460> SYN <mss 256> home MTU=296 ethernet MTU=1500 tao

June 6, 1998

slide-12
SLIDE 12

TCP 12

Connection Establishment

Client Server

socket() bind() listen() accept read() write socket() connect() write() read() blocks until connection from client connection establishment data request process request data reply

June 6, 1998

slide-13
SLIDE 13

TCP 13

Connection Termination

  • Each side terminates its half of the connection by

sending a FIN segment

  • After acknowledging the FIN, the other can still send

data: (half close).

  • connection can be aborted with an RST segment

June 6, 1998

slide-14
SLIDE 14

TCP 14

Interactive Data Transfer

  • Data received from the application is usually sent in

segments of MSS

  • interactive applications (rlogin, telnet) ➠ type one

character, generate one packet

  • ➠ the sender can force the delivery of small packets

using the PSH (push) flag

  • With delayed acknowledgments, the receiver delays

sending the acknowledgments until it has some data to send (“piggy-back”) or a 200 ms timer expires.

June 6, 1998

slide-15
SLIDE 15

TCP 15

Interactive Data Transfer

client 0.0 0.015 0.03 delayed ack Ack 2 PSH 1:2(1) ack1 (echo char) PSH 0:1(1) ack1 (char) server PSH 0:1(1) ack1 (char) ack1 PSH 0:1(1) ack 2 (echo char) ack 2 0.0 0.01 0.016 0.015 client server June 6, 1998

slide-16
SLIDE 16

TCP 16

Interactive Data Transfer

  • Sending a lot of small segments can add congestion to a

wide area network

  • Nagle Algorithm: a sender can at most have one
  • utstanding small segment (that has not yet been

acknowledged).

  • All data arriving at TCP from the application are queued

until the currently outstanding segment is acknowledged.

June 6, 1998

slide-17
SLIDE 17

TCP 17

Flow Control in TCP

  • sliding window mechanism to adjust the sender

transmission speed to receiver speed

  • sliding window permits sending of multiple segments

before waiting for an acknowledgment

  • ACK segments indicate the last correctly received byte

and the number of bytes the receiver is still willing to accept (window)

1 2 3 4 5 6 7 8 9 10 11 1 2 3 4 5 6 7 8 9 10 11

win start end of outstanding data win end ack 1

June 6, 1998

slide-18
SLIDE 18

TCP 18

Flow Control in TCP

2 SYN 141:141(0) <mss 1024> WIN 4096 SYN 181:181(0) <mss 1024> ACK 142 WIN 3072 1 4 6 7 5 3 8 3073:4097 (1024) ACK 1, WIN 4096 ACK 3073, WIN 2049 2049:3073 (1024) ACK 1, WIN 4096 1025:2049 (1024) ACK 1, WIN 4096 1:1025 (1024) ACK 1, WIN 4096 ACK 1, WIN 4096 tao lupus

June 6, 1998

slide-19
SLIDE 19

TCP 19

Acknowledgments and Retransmission

  • TCP receiver acknowledges the last correctly received

byte

  • After sending a segment the sender starts a timer.
  • If the timer expires before receiving an acknowledgment

for the sent segment the segment is considered lost and must be retransmitted.

  • The timeout value is calculated dynamically according to

the measured round trip times (RTT). Err = RTT − A A = smoothed RTT A = A + gErr gain g = 1/8

June 6, 1998

slide-20
SLIDE 20

TCP 20

D = D + h (|Err| − D) D = smoothed mean deviation RTO = A + 4D

June 6, 1998

slide-21
SLIDE 21

TCP 21

Round-Trip Time Measurement

  • TCP implementations use a 500-ms clock for time

measurements and timeout determination.

  • Only one measurement is done at a time.
  • At the start of a measurement a counter is set to 0 and is

then incremented every time the 500 ms TCP timer is invoked and the number of the sent segment is remembered.

  • Only after acknowledging the sent segment can a new

measurement start.

  • After a retransmission the timeout value is not updated

until an acknowledgment for a segment arrives that was

June 6, 1998

slide-22
SLIDE 22

TCP 22

not retransmitted (Karn’s algorithm).

June 6, 1998

slide-23
SLIDE 23

TCP 23

Round-Trip Time Measurement

As the 500-ms timer is used for determining the RTT the values used for updating the timeout value might differ up to ±500 ms from the actual value.

tao lupus 1:257(256) ACK 1 0.0 1 2 RTT=1.5 s ACK 257 257:513 (256) ACK 1 513:769 (256) ACK 1 3 4 ACK 513 ACK 769 RTT=0.5 s 1.062 1.063 1.081 1.87 6 5

June 6, 1998

slide-24
SLIDE 24

TCP 24

Congestion Control in TCP

  • A connection’s rate is determined as transmission

window/round trip time.

  • When the sum of the connection rates over a link is

higher than the link rate, segments can be dropped.

  • TCP uses packet drops and timeouts as congestion

indication.

June 6, 1998

slide-25
SLIDE 25

TCP 25

Receiver Router 1 Router 2 Router 4 9 10 13 15 16 17 18 ack 8 ack 6 ack 5 ack 4 ack 2 ack 1 14 12 11 ack 7 ack 3 Router 3 Sender 5kbyte/sec (Bottleneck)1kbyte/sec

June 6, 1998

slide-26
SLIDE 26

TCP 26

Slow Start and Congestion Avoidance

  • To avoid congestion in advance, the sender must adapt its

transmission window to the available link bandwidth.

  • connection establishment: window = 1 MSS: ongestion

window (cwnd)

  • The congestion window is increased by 1 MSS for each

acknowledged segment.

  • At any time the sender has has a transmission window of

transmission window = min(advertised window, congestion windo

June 6, 1998

slide-27
SLIDE 27

TCP 27

Slow Start and Congestion Avoidance

  • slow start ➠ congestion window increases exponentially
  • ➠ congestion (packet drops)
  • timeout ➠ cwnd = 1 MSS.
  • reduce slow start threshold ssthresh by half
  • congestion avoidance = after reaching ssthresh: add

1/cwnd for each ACK ➠ add one segment for RTT

June 6, 1998

slide-28
SLIDE 28

TCP 28

Fast Retransmission and Fast Recovery

  • Using only timeouts as loss indication leads to long idle

periods.

  • fast retransmission: receiver acknowledges out-of-order

segment with an ACK of the last correctly received segment

  • 3 duplicate ACKs ➠ retransmission of the last missing

segment

  • older TCP versions: slow start as for time-out
  • fast recovery: cwnd ← ssthresh + 3

June 6, 1998

slide-29
SLIDE 29

TCP 29

Congestion Control

slow start 65535 t ssthresh cwnd ✝ ✝

congestion avoidance

June 6, 1998

slide-30
SLIDE 30

TCP 30

Congestion Example

  • source and receiver buffers: 8192 bytes
  • router buffer: 2128 bytes
  • link bandwidth: 2128 bytes/s
  • MSS = 1024
  • round trip delay: 1 s

Receiver Router 2 kbytes/sec Sender RTT=1 sec 10 Mbits/sec Ethernet SLIP link

June 6, 1998

slide-31
SLIDE 31

TCP 31

Congestion Example: Slow Start

0:1025 (1024) ACK 1 1 segment 3 win=1024 ACK 1025 2 win=2048 , WIN 8192 segment 4 2.0001 segment 5 1025:2049 (1024) ACK 1 2049:3073 (1024) ACK 1 2.0002 segment 6 WIN 8192 ACK 3073, WIN 8192 ACK 2049, segment 7 win=3072 3.001 win=4096 4.0003 segment 8 segment 10 segment 12 5121:6145 (1024) ACK 1 6145:7169 (1024) ACK 1 segment 11 4097:5121(1024) ACK 1 4.5004 5.5005 6.5006 3073:4097 (1024) ACK 1 segment 9 4.0003 tao lupus time 9217:10241 (1024) ACK 1 10241:11265 (1024) ACK 1 segment 15 segment 16 segment 18 WIN 8192 WIN 8192 ACK 7169, segment 13 segment 14 win=8192 WIN 8192 WIN 8192 segment 13 segment 14 win=5121 5.0004 5.5006 6.5004 7.5006 win=6144 win=7168 8.0007 8.5008 8.5009 ACK 5121, ACK 4097, ACK 6145, 7169:8193 (1024) ACK 1

June 6, 1998

slide-32
SLIDE 32

TCP 32

Congestion Example: Fast Retransmission

10.503 segment 24 tao lupus time segment 20 segment 19 11265:12289 (1024) ACK 1 12289:13313 (1024) ACK 1 8.501 8.5011 WIN 5120 9.0001 10.002 9.0001 WIN 7168 WIN 6144 10.0001 11.002 12289:13313 (1024) ACK 1 segment 21 segment 22 segment 23 segment 25 segment 26 segment 27 segment 28 11.501 11.501 ACK 12289, WIN 8192 13313:14337 (1024) ACK 1 14337:15361 (1024) ACK 1 15361:16385 (1024) ACK 1 ACK 12289, ACK 12289, ACK 12289,

June 6, 1998

slide-33
SLIDE 33

TCP 33

Congestion Example: Fast Retransmission

tao lupus time WIN 8192 WIN 8192 ACK 16385, segment 29 12.501 WIN 1024 16385:17409 (1024) ACK 1 ACK 17409, WIN 2048 segment 30 segment 31 12.501 13.501 segment 32 14.002 14.503 segment 33 17409:18433 (1024) ACK 1 18433:19457 (1024) ACK 1 WIN 8192 WIN 8192 segment 34 segment 35 WIN 3072 WIN 4096 15.004 15.504 segment 36 16.501 19457:20481 (1024) ACK 1 segment 37 WIN 8192 ACK 20481, 17.501 WIN 4352 ACK 18433, ACK 19457,

June 6, 1998

slide-34
SLIDE 34

TCP 34

Congestion Example: Fast Recovery

tao lupus time WIN 8192 ACK 16385, segment 29 12.501 16385:17409 (1024) ACK 1 segment 30 WIN 4096 17409:18433 (1024) ACK 1 segment 31 13.002 12.505 18433:19457 (1024) ACK 1 segment 32 13.503 segment 32 WIN 8192 ACK 17409, 13.505 segment 33 WIN 4352 WIN 8192 segment 34 14.004 WIN 4593 14.503 19457:20481 (1024) ACK 1 ACK 18433, WIN 8192 15.504 WIN 8192 segment 35 WIN 4821 ACK 19457, 14.504 ACK 20481, segment 36 WIN 5038

June 6, 1998

slide-35
SLIDE 35

TCP 35

Silly Window Syndrome and Probe Packets

  • ACKs can get lost ➠ window update lost
  • advertised window size ↓ 0 (freeze) ➠ prevent at sender

and receiver

  • sender: window probes of size 1 at increasing intervals
  • receiver: advertise 0 or ≥ MSS
  • sender: send full-sized segment or wait until everything

ACKed

June 6, 1998

slide-36
SLIDE 36

TCP 36

TCP throughput

Keep pipe occupied ➠ window ↑ bandwidth-delay product Bandwidth-delay product: capacity of “pipe” ➠ continental T3 = 45 Mb/s × 5000 km × 5 µs / km ≈ 140 kB

  • “long, fat pipes”
  • currently, 64 kB window ➠ window scale option
  • RTO update only once per RTT ➠ time stamp option
  • non-congestion losses (wireless) ➠ selective

acknowledgements

June 6, 1998

slide-37
SLIDE 37

TCP 37

TCP throughput

RTCP = 1.22 · MTU RTT √ loss for losses < 16% derivation: R = W · MTU RTT For TCP, packet drop halve window, takes W/2 times to reach W again: RTCP = 0.75WMTU RTT

June 6, 1998

slide-38
SLIDE 38

TCP 38

T/TCP

  • Common TCP application: request to a server, reply to

the client, done.

  • ➠ 10 TCP segments
  • connection establishment + termination: ≥ 2 RTT +

server processing time

June 6, 1998

slide-39
SLIDE 39

TCP 39

T/TCP

  • distinguish between consecutive transactions ➠

connection count (CC) option added to header

  • host maintains a per-host cache of the last seen timeout

value, MSS, window size and the CC value.

  • Client can combine the SYN, FIN, data request and the

current CC value in one segment.

  • If received CC value is larger than the cached CC, the

server can combine the SYN, FIN, ACK of the sender’s SYN and the reply in one segment.

  • The client acks the server’s SYN and FIN in one

segment.

June 6, 1998

slide-40
SLIDE 40

TCP 40

  • ➠ transaction time = RTT + the processing time

June 6, 1998