TCP Connection Setup EXample 09:23:33.0423181P128.2.222.198.3123>192.216.219.96.80:s 4019802004:4019802004(0)win65535<mss1260,nop,nop, sackOK>(DF) 09:23:33.1183291P192.216.219.96.80>128.2.222.198.3123:s 3428951569:3428951569(0)ack4019802005win5840<mss 1460, nop, nop, sackOK> (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 <mss 1260,nop,nop,sackOK> (DF) 09:23:33.118329 IP 192.216.219.96.80 > 128.2.222.198.3123: S 3428951569:3428951569(0) ack 4019802005 win 5840 <mss 1460,nop,nop,sackOK> (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