1266 Chapter 61
61.6 A Closer Look at TCP
Knowing some of the details of the operation of TCP helps us to debug applications
that use TCP sockets, and, in some cases, to make such applications more efficient. In
the following sections, we look at:
z the format of TCP segments;
z the TCP acknowledgement scheme;
z the TCP state machine;
z TCP connection establishment and termination; and
z the TCP TIME_WAIT state.
61.6.1 Format of a TCP Segment
Figure 61-2 shows the format of the TCP segments that are exchanged between the
endpoints of a TCP connection. The meanings of these fields are as follows:
z Source port number: This is the port number of the sending TCP.
z Destination port number: This is the port number of the destination TCP.
z Sequence number: This is the sequence number for this segment. This is the offset
of the first byte of data in this segment within the stream of data being transmit-
ted in this direction over the connection, as described in Section 58.6.3.
Figure 61-2: Format of a TCP segment
Header
Header
length
(4 bits)
Reser-
ved
(4 bits)
Source port number Destination port number
Window size
TCP checksum Urgent pointer
Options (if present)
(0 – 40 bytes)
Sequence number
Acknowledgement number
20 bytes
(^)
Control
(8 bits)
Data (if present)
(0+ bytes)
01516 31