ELEN 602 Lecture 15 More on IP TCP 1 TCP Streams Application Application byte stream byte stream segments Transmitter Receiver Send buffer Receive buffer ACKs 2 TCP end to end Flow control Transmitter Send Window Receiver Receive Window Slast Wa 1 Octets transmitted Slast and ACKed Srecent Rlast Rlast WR 1 Slast Ws 1 Slast oldest unacknowledged octet Srecent highest numbered transmitted octet Slast Wa 1 highest numbered octet that can be transmitted Slast Ws 1 highest numbered octet that can be accepted from the application Rnext Rnew Rlast highest numbered octet not yet read by the application Rnext next expected octet Rnew highest numbered octet received correctly Rlast WR 1 highest numbered octet that can be accommodated in receive buffer 3 TCP Segment 0 4 10 16 Source Port 24 31 Destination Port Sequence Number Acknowledgement Number Header Length Reserved UAP R S F R C S S Y I GKH T NN Checksum Window Size Urgent Pointer Options Padding Data 4 TCP Pseudoheader 0 8 16 31 Source IP Address Destination IP Address 00000000 Protocol 6 TCP Segment Length 5 3 way Handshake for connection establishment Host A Host B SYN Seq no x no k c A K y AC o n q e SYN S Seq no x 1 ACK A ck no y x 1 1 6 Sequence numbers Host A Host B SYN Seq no n no n 1 k c A K n AC o n q e S SYN Seq no n 1 A C K Ack no n 1 Delayed segment with Seq no n 2 will be accepted 7 TCP application example Host B Server Host A Client socket connect blocks connect returns write read blocks SYN Seq no x no y A q e S SYN Seq no x 1 socket bind listen accept blocks x 1 o n k c C K A ACK A ck no request m essage y 1 accept returns read blocks read returns ge reply messa write read blocks read returns 8 Host A TCP Window control 1 Seq no t1 t2 Seq no 2 0 00 Ack n Seq no 3 0 Seq n t4 A ck D 2048 No in W 00 no 20 o 1 Win 24 Ack n o 1 Win 0 k no 4 c A 1 o Seq no 4 0 48 Ack n 1024 D Host B ata t0 ata 2000 3023 1024 D ata 3024 4047 12 Data 1 2 1 5 48 Win o 1 29 W in 1024 8 Data 404 8 t3 455 9 9 TCP Header overhead Data 20 bytes of TCP header 20 bytes of IP header TCP Header IP Header 10 Connection Termination Host A Host B FIN seq 5 086 ACK 5087 Deliver 150 bytes CK 5087 A 3 0 3 q e s Data ACK 4 53 FIN seq K 50 8 C A 3 5 4 7 ACK 454 11 CLOSED en applic close op passive open create TCB e tiv ac TCP State diagram B TC N te Y ea S cr end s N Y LISTEN S K C e v A i se rece SYN nd e d v n i e e SY s applic close rec T N S R or timeout receive SYN SYN SENT SYN RCVD delete TCB send ACK recei veAC receive SYN ACK K applic send ACK close ESTABLISHED recei ve F s send e n d AC IN se o l K FIN c c i N pl CLOSE WAIT ap d FI n se receive FIN applic close CLOSING FIN WAIT 1 send ACK send FIN rec receive se eiv LAST ACK ACK nd e F receive receive AC IN ACK K A ACK CK FIN WAIT 2 receive FIN send ACK TIME WAIT 2MSL timeout delete TCB 12 Routing for mobile hosts Foreign network Home network Home agent Foreign agent Mobile host 2 Internet 3 1 Correspondent host 13 IP to IP Encapsulation Outer IP Header IP Header IP Header IP Payload IP Payload 14
View Full Document