TCP 1
The Transmission Control Protocol (TCP)
June 6, 1998
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
TCP 1
June 6, 1998
TCP 2
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
TCP 3
spec...
June 6, 1998
TCP 4
– flow control: avoid overrunning slow receiver ➠ advertised by receiver – congestion control: avoid network overload ➠ maintained by sender – cwnd
June 6, 1998
TCP 5
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
TCP 6
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
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
TCP 7
June 6, 1998
TCP 8
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
TCP 9
half close.
June 6, 1998
TCP 10
number (ISN) and and the maximum segment size (MSS) it is willing to receive.
and announcing its MSS.
size minus 40 bytes.
June 6, 1998
TCP 11
SLIP lupus SYN <mss 1460> SYN <mss 256> home MTU=296 ethernet MTU=1500 tao
June 6, 1998
TCP 12
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
TCP 13
sending a FIN segment
data: (half close).
June 6, 1998
TCP 14
segments of MSS
character, generate one packet
using the PSH (push) flag
sending the acknowledgments until it has some data to send (“piggy-back”) or a 200 ms timer expires.
June 6, 1998
TCP 15
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
TCP 16
wide area network
acknowledged).
until the currently outstanding segment is acknowledged.
June 6, 1998
TCP 17
transmission speed to receiver speed
before waiting for an acknowledgment
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
TCP 18
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
TCP 19
byte
for the sent segment the segment is considered lost and must be retransmitted.
the measured round trip times (RTT). Err = RTT − A A = smoothed RTT A = A + gErr gain g = 1/8
June 6, 1998
TCP 20
D = D + h (|Err| − D) D = smoothed mean deviation RTO = A + 4D
June 6, 1998
TCP 21
measurements and timeout determination.
then incremented every time the 500 ms TCP timer is invoked and the number of the sent segment is remembered.
measurement start.
until an acknowledgment for a segment arrives that was
June 6, 1998
TCP 22
not retransmitted (Karn’s algorithm).
June 6, 1998
TCP 23
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
TCP 24
window/round trip time.
higher than the link rate, segments can be dropped.
indication.
June 6, 1998
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
TCP 26
transmission window to the available link bandwidth.
window (cwnd)
acknowledged segment.
transmission window = min(advertised window, congestion windo
June 6, 1998
TCP 27
1/cwnd for each ACK ➠ add one segment for RTT
June 6, 1998
TCP 28
periods.
segment with an ACK of the last correctly received segment
segment
June 6, 1998
TCP 29
slow start 65535 t ssthresh cwnd ✝ ✝
congestion avoidance
June 6, 1998
TCP 30
Receiver Router 2 kbytes/sec Sender RTT=1 sec 10 Mbits/sec Ethernet SLIP link
June 6, 1998
TCP 31
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
TCP 32
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
TCP 33
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
TCP 34
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
TCP 35
and receiver
ACKed
June 6, 1998
TCP 36
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
acknowledgements
June 6, 1998
TCP 37
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
TCP 38
the client, done.
server processing time
June 6, 1998
TCP 39
connection count (CC) option added to header
value, MSS, window size and the CC value.
current CC value in one segment.
server can combine the SYN, FIN, ACK of the sender’s SYN and the reply in one segment.
segment.
June 6, 1998
TCP 40
June 6, 1998