background image
TCP/IP Protocols
223
This three-way connection establishment flow must complete before data transfer can begin.
The connection exists between the two sockets, although there is no single socket field in the
TCP header. Of the three parts of a socket, the IP addresses are implied based on the source and
destination IP addresses in the IP header. TCP is implied because a TCP header is in use, as
implied by the protocol field value in the IP header. Therefore, the only parts of the socket that
need to be encoded in the TCP header are the port numbers.
Two single-bit portions of the flags field of the TCP header are used to signal the three-step
process for connection establishment. Called the SYN and ACK flags, these bits have a
particularly interesting meaning. SYN means, "Synchronize the sequence numbers," which is
one necessary component in initialization for TCP. The ACK field means "the acknowledgment
field is valid in this header." Until the sequence numbers are initialized, the acknowledgment
field cannot be very useful. Also notice that in the initial flow in Figure 5-7, no acknowledgment
number is shown--this is because that number is not valid yet. Because the ACK field must be
present in all the ensuing segments, the ACK bit will continue to be set until the connection is
terminated.
The sequence and acknowledgment number fields are initialized to any number that fits into
the 4-byte fields; the actual values shown in Figure 5-7 are simply example values. The
initialization flows are each considered to have a single byte of data, as reflected in the
acknowledgment number fields in the example.
Figure 5-8 shows TCP connection termination.
Figure 5-8
TCP Connection Termination
This four-way termination sequence is straightforward and uses an additional flag, called the
FIN bit. (FIN is short for "finished," as you might guess.) One interesting note: Before the
device receiving the first FIN segment sends the third flow in the sequence, TCP notifies the
application that the connection is coming down. TCP waits on an acknowledgment from the
application before sending the segment. That's why the second flow is required: To
PC
ACK, FIN SEQ=1000
PC
ACK A
CK=1471
ACK A
CK=1001
ACK, FIN A
CK=1001
SEQ=1470
ch05.fm Page 223 Monday, March 20, 2000 5:06 PM