Illustrated TCP/IP
by Matthew G. Naugle Wiley Computer Publishing, John Wiley & Sons, Inc. ISBN: 0471196568 Pub Date: 11/01/98 |
Previous | Table of Contents | Next |
A connection will only be active after the sender and receiver exchange a few control packets to establish the connection. This is known as the three-way handshake. Its purpose to synchronize each endpoint at the start of a TCP connection with a sequence number and acknowledgment number.
Refer to slide 215. Station A will place an active OPEN call to TCP to request connection to a remote network stations application. Station A will build a TCP header with the SYN (the sync bit shown was shown previously in the TCP Header fields) bit set and then assign an initial sequence number (it does not always start at 0 and can start at any number; I have chosen 100) and place it in the Sequence Number field. Other fields will be set in the TCP header (not pertinent to us at this time) and the packet will be given to IP for transmission to station B.
Station B will receive this packet and notice it is a connection attempt. If station B can accept a new connection it will acknowledge station A by building a new packet. Station B will set the SYN and the ACK bits in the TCP header shown in the slide, place its own initial sequence number (200) in the Sequence field of the packet, and the Acknowledgment field will be set to 101 (the station A sequence number plus 1, indicating the next expected sequence number).
Station A will receive this response packet and notice it is an acknowledgment to its connection request. Station A will build a new packet, set the ACK bit, fill in the sequence number to 101, fill in the acknowledgment number to 200 + 1, and send the packet to station B. Once this has been established, the connection is active and data and commands from the application (such as TELNET) may pass over the connection. As data and commands pass over the connection, each side of the connection will maintain its own sequence number tables for data being sent and received across the connection. They will always be in ascending order.
Sequence numbers do not have to and probably will not start at 0. However, it is fundamentally important to note that they will wrap to 0.
Previous | Table of Contents | Next |