140 likes | 206 Views
More on IP TCP. ELEN 602 Lecture 15. TCP Streams. Application. Application. byte stream. byte stream. segments. Transmitter. Receiver. Send buffer. Receive buffer. ACKs. TCP end-to-end Flow control. Transmitter. Receiver. Send Window. Receive Window. S last +W a -1.
E N D
More on IP TCP ELEN 602 Lecture 15
TCP Streams Application Application byte stream byte stream segments Transmitter Receiver Send buffer Receive buffer ACKs
TCP end-to-end Flow control Transmitter Receiver Send Window Receive Window Slast+Wa-1 Rlast+WR+1 Rlast ... ... ... Rnext Rnew Octets transmitted and ACKed Slast Srecent 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 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
TCP Segment 0 4 10 16 24 31 Source Port Destination Port Sequence Number Acknowledgement Number U A P R S F Header R C S S Y I Reserved Window Size Length G K H T N N Checksum Urgent Pointer Options Padding Data
TCP Pseudoheader 0 8 16 31 Source IP Address Destination IP Address 0 0 0 0 0 0 0 0 Protocol = 6 TCP Segment Length
3-way Handshake for connection establishment Host A Host B SYN, Seq_no = x SYN, Seq_no = y, ACK, Ack_no = x+1 Seq_no = x+1, ACK, Ack_no = y+1
Sequence numbers Host A Host B SYN, Seq_no = n SYN, Seq_no = n, ACK, Ack_no = n+1 Seq_no = n+1, ACK, Ack_no = n+1 Delayed segment with Seq_no = n+2 will be accepted
TCP application example Host B (Server) Host A (Client) socket bind listen accept (blocks) socket connect (blocks) SYN, Seq_no = x SYN, Seq_no = y, ACK, Ack_no = x+1 connect returns Seq_no = x+1, ACK, Ack_no = y+1 write read (blocks) accept returns read (blocks) request message read returns write read (blocks) reply message read returns
TCP Window control Host A Host B t0 Seq_no = 1, Ack_no = 2000, Win = 2048, No Data t1 Seq_no = 2000, Ack_no = 1, Win = 1024, Data = 2000-3023 t2 Seq_no = 3024, Ack_no = 1, Win = 1024, Data = 3024-4047 t3 Seq_no = 1, Ack_no = 4048, Win = 512, Data = 1-128 t4 Seq_no = 4048, Ack_no = 129, Win = 1024, Data = 4048-4559
Data TCP Header overhead TCP Header 20 bytes of TCP header 20 bytes of IP header IP Header
Connection Termination Host A Host B FIN, seq = 5086 ACK = 5087 Data, seq. = 303, ACK = 5087 Deliver 150 bytes ACK = 453 FIN, seq. =453, ACK = 5087 ACK = 454
TCP State diagram CLOSED passive open, create TCB applic.close active open,create TCB send SYN LISTEN receive SYN, send SYN, ACK receive RST send SYN applic. close or timeout, delete TCB SYN_SENT SYN_RCVD receive SYN, send ACK receiveACK receive SYN, ACK, send ACK applic. close, send FIN ESTABLISHED receive FIN, send ACK applic. close, send FIN CLOSE_WAIT receive FIN send ACK applic. close send FIN CLOSING FIN_WAIT_1 receive ACK LAST_ACK receive ACK receive ACK receive FIN, ACK send ACK receive FIN send ACK 2MSL timeout delete TCB FIN_WAIT_2 TIME_WAIT
Routing for mobile hosts Foreign network Home network Foreign agent Mobile host 2 Home agent Internet 3 1 Correspondent host
IP to IP Encapsulation Outer IP Header IP Header IP Header IP Payload IP Payload