15-441 Computer Networking Lecture 18-More TCP Congestion Control
15-441 Computer Networking Lecture 18 – More TCP & Congestion Control
Good Ideas so far Flow control Stop wait ° Parallel stop&wait Sliding window(e.g, advertised windows) OSs recovery Timeouts Acknowledgement-driven recovery(selective repeat or cumulative acknowledgement Congestion control AIMD> fairness and efficiency How does TCP actually implement these? Lecture 18: TCP Details
2 Lecture 18: TCP Details Good Ideas So Far… • Flow control • Stop & wait • Parallel stop & wait • Sliding window (e.g., advertised windows) • Loss recovery • Timeouts • Acknowledgement-driven recovery (selective repeat or cumulative acknowledgement) • Congestion control • AIMD → fairness and efficiency • How does TCP actually implement these?
Outline The devilish details of tcp TCP connection setup and data transfer TCP reliability Be nice to your data TCP congestion avoidance · Be nice to your routers Lecture 18: TCP Details
3 Lecture 18: TCP Details Outline • The devilish details of TCP • TCP connection setup and data transfer • TCP reliability • Be nice to your data • TCP congestion avoidance • Be nice to your routers 3
Sequence Number Space Each byte in byte stream is numbered ·32 bit va|ue · Wraps around Initial values selected at start up time TCP breaks up the byte stream into packets Packet size is limited to the maximum Segment size Each packet has a sequence number Indicates where it fits in the byte stream 13450 1495016050 17550 packet 8 packet 9 packet 10 Lecture 18: TCP Details
4 Lecture 18: TCP Details Sequence Number Space • Each byte in byte stream is numbered. • 32 bit value • Wraps around • Initial values selected at start up time • TCP breaks up the byte stream into packets. • Packet size is limited to the Maximum Segment Size • Each packet has a sequence number. • Indicates where it fits in the byte stream packet 8 packet 9 packet 10 13450 14950 16050 17550
Establishing Connection Three-Way handshake Each side notifies other of starting sequence number SYN: Seqc it will use for sending ° Why not simply chose0? Must avoid overlap with earlier ACK: Seqc+1 incarnation SYN: Seqs Security issues Each side acknowledges ACK: Seqs+1 other's sequence number SYN-ACK: Acknowledge sequence number 1 Can combine second sYn Client Server with first acK Lecture 18: TCP Details
5 Lecture 18: TCP Details Establishing Connection: Three-Way handshake • Each side notifies other of starting sequence number it will use for sending • Why not simply chose 0? • Must avoid overlap with earlier incarnation • Security issues • Each side acknowledges other’s sequence number • SYN-ACK: Acknowledge sequence number + 1 • Can combine second SYN with first ACK SYN: SeqC ACK: SeqC+1 SYN: SeqS ACK: SeqS+1 Client Server
TCP Connection Setup EXample 09:23:33.0423181P128.2.222.198.3123>192.216.219.96.80:s 4019802004:4019802004(0)win65535(DF) 09:23:33.1183291P192.216.219.96.80>128.2.222.198.3123:s 3428951569:3428951569(0)ack4019802005win5840 (DF) 09:23:33.1184051P128.2.222.198.3123>192.216.219.96.80 ack 3428951570win65535(DE) · Client sYn SeqC: Seg #4019802004, window 65535, max seg. 1260 · Server SYn-ACK+SYN Receive:#4019802005(=SeqC+1) SeqS: Seq #3428951569, window 5840, max. seg 1460 · Client sYn-ACK Receive:#3428951570(=Seqs+1) Lecture 18: TCP Details 6
6 Lecture 18: TCP Details TCP Connection Setup Example • Client SYN • SeqC: Seq. #4019802004, window 65535, max. seg. 1260 • Server SYN-ACK+SYN • Receive: #4019802005 (= SeqC+1) • SeqS: Seq. #3428951569, window 5840, max. seg. 1460 • Client SYN-ACK • Receive: #3428951570 (= SeqS+1) 09:23:33.042318 IP 128.2.222.198.3123 > 192.216.219.96.80: S 4019802004:4019802004(0) win 65535 (DF) 09:23:33.118329 IP 192.216.219.96.80 > 128.2.222.198.3123: S 3428951569:3428951569(0) ack 4019802005 win 5840 (DF) 09:23:33.118405 IP 128.2.222.198.3123 > 192.216.219.96.80: . ack 3428951570 win 65535 (DF)
TCP State Diagram: Connection Setup ient LOSED active OPEn Server create feB passive OPEN CLOSE Snd SYN create TCB delete tcB LISTEN CLOSE delete TcB rcV sYn SEND Snd SYNacK snd syn SYN TCV sYn SYN RCVD snd AcK SENT rcv ack of syn RCV SYN ACK Snd AcK CLOSE Send fin ESTAB Lecture 18: TCP Details
7 Lecture 18: TCP Details TCP State Diagram: Connection Setup CLOSED SYN SENT SYN RCVD ESTAB LISTEN active OPEN create TCB Snd SYN create TCB passive OPEN delete TCB CLOSE delete TCB CLOSE snd SYN SEND snd SYN ACK rcv SYN Send FIN CLOSE rcv ACK of SYN Snd ACK Rcv SYN, ACK rcv SYN snd ACK Client Server
Tearing Down Connection Either side can initiate tear down A B Send FIN signal FIN SegA Im not going to send any more data CK, SegA+1 Other side can continue Data sending data ACK Half open connection Must continue to acknowledge FIN, SeqB Acknowledging FIN ACK, SeqB+1 Acknowledge last sequence number 1 Lecture 18: TCP Details
8 Lecture 18: TCP Details Tearing Down Connection • Either side can initiate tear down • Send FIN signal • “I’m not going to send any more data” • Other side can continue sending data • Half open connection • Must continue to acknowledge • Acknowledging FIN • Acknowledge last sequence number + 1 A B FIN, SeqA ACK, SeqA+1 ACK Data ACK, SeqB+1 FIN, SeqB
TCP Connection Teardown Example 09:54:17.5853961P128.2.222.198.4474>128.2.210.194.6616:E 1489294581:1489294581(0)ack1909787689win65434(DF) 09:54:17.585732IP128.2.210.194.6616>128.2.222.198.4474:E 1909787689:1909787689(0)ack1489294582win5840(DF) 09:54:17.585764IP128.2.222.198.4474>128.2.210.194.6616 ack 1909787690win65434(DF) · Session Echo client on 128.2.222 198 server on 128.2.210.194 Client FIN SeqC:1489294581 Server AcK +FIN Ack:1489294582(=SeqC+1) seqs:1909787689 ClientACK AcK:1909787690(=SeqS+1 ecture 18: TCP Details
9 Lecture 18: TCP Details TCP Connection Teardown Example • Session • Echo client on 128.2.222.198, server on 128.2.210.194 • Client FIN • SeqC: 1489294581 • Server ACK + FIN • Ack: 1489294582 (= SeqC+1) • SeqS: 1909787689 • Client ACK • Ack: 1909787690 (= SeqS+1) 09:54:17.585396 IP 128.2.222.198.4474 > 128.2.210.194.6616: F 1489294581:1489294581(0) ack 1909787689 win 65434 (DF) 09:54:17.585732 IP 128.2.210.194.6616 > 128.2.222.198.4474: F 1909787689:1909787689(0) ack 1489294582 win 5840 (DF) 09:54:17.585764 IP 128.2.222.198.4474 > 128.2.210.194.6616: . ack 1909787690 win 65434 (DF)
State Diagram: Connection Tear-down CLOSE send fin Active CloseESTAB CLOSE rCV FIn Passⅳ ve close send fIn send AcK FIN CLOSE WAIT-1 WAIT rCV fIN ACK snd AcK CLOSE rcv fIN+ACK snd FIN FIN WAIT2 snd ACK CLOSING AST-ACK rcv ACK of FIN rcv AcK df FIN rcV fIN CLOSED imeout=2msl snd AcK delete tcb Lecture 18: TCP Details
10 Lecture 18: TCP Details State Diagram: Connection Tear-down CLOSING CLOSE WAIT FIN WAIT-1 ESTAB TIME WAIT snd FIN CLOSE send FIN CLOSE rcv ACK of FIN LAST-ACK CLOSED FIN WAIT-2 snd ACK rcv FIN delete TCB Timeout=2msl send FIN CLOSE send ACK rcv FIN snd ACK rcv FIN rcv ACK of FIN snd ACK rcv FIN+ACK ACK Active Close Passive Close