|
|
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: