DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Introducing the Internet protocols

Transmission Control Protocol (TCP)

TCP provides reliable delivery of streamed data over a connection established between protocol ports on networked hosts. TCP ensures that data is not damaged, lost, duplicated, or delivered out of order to a receiving process. This prevents programmers from having to build such safeguards into applications.

TCP can transfer a continuous byte stream simultaneously in each direction between two hosts. It divides each stream into segments for transmission and reassembles the stream from received segments.

TCP can recover data that is damaged, lost, duplicated, or delivered out of order. It achieves this reliability by assigning a sequence number to each segment that it transmits, and requiring a positive acknowledgment (ACK) that the remote host has received it. If an ACK is not received within a timeout period, TCP retransmits the segment. The receiver uses the sequence numbers to order segments that may be received out of order, and to eliminate duplicates. The integrity of the data is verified by recalculating the segment's checksum. If this disagrees with the value in the received header, the receiver discards the segment and waits for the sender to retransmit.

TCP governs the amount of data sent to it by returning a window size with every ACK. The window indicates the amount of data that may next be sent. This allows TCP to prevent incoming data overflowing its buffer.

TCP allows many processes within a single host to use the TCP communications facilities simultaneously. A port number and host IP address uniquely identify a socket. A pair of sockets uniquely identifies a connection.

TCP initializes and maintains information for each data stream including sequence numbers, window sizes, and connection state.

The format of a TCP header is illustrated in ``TCP header format''.

TCP header format

A TCP header contains the following fields:


source port
The protocol port number sending the information.

destination port
The protocol port number receiving the information.

sequence number
The sequence number within a stream of the first byte of data in this segment.

acknowledgment number
The sequence number that the sender of a acknowledgment (ACK) expects to receive next. This value is 1 more than the sequence number of the last byte that was successfully received.

data offset
The position, measured in bytes, of the segment data relative to the start of the segment header.

flags
Control bits that identify the purpose of the segment:

URG
There is urgent data that should be delivered as quickly as possible.

ACK
Acknowledge reception of a valid segment.

PSH
Request that the data be passed to the application as soon as possible.

RTS
Reset the connection.

SYN
Synchronize sequence numbers at the start of the data stream.

FIN
The sender has reached the end of its data stream.

window
The amount of data that the receiver is willing to accept.

checksum
A number that is computed to ensure the integrity the segment header and data.

urgent pointer
If the URG flag is set, this field indicates the position of the last byte of urgent data relative to the sequence number.

options
A list of optional specifications such as the maximum segment size (MSS) sent when initiating a connection, and timestamps.

padding
Null bytes which are added to make the header an integral number of 32-bit words long.

© 2002 Caldera International, Inc. All rights reserved.
UnixWare 7 Release 7.1.3 - 30 October 2002