Introduction

Rationale

The following is an overview of the motivation behind the use of TCP, and the type of services which the protocol provides.

The TCP protocol is intended for use as a reliable host-to-host communications protocol between hosts in a computer network, and between interconnected networks. It is a conection-oriented, end-to-end reliable protocol, which is designed to fit into a layered hierarchy of protocols:

In order for TCP to build a reliable, connection-oriented service on top of the less reliable layers below it, it must be able to achieve the following:

Basic Data Transfer

TCP must be able to continuously transfer data bidirectionally between the users on either end of the connection. It achieves this by collecting a number of octets into TCP 'packets' which can then be transmitted via the lower level protocols in the stack.

Reliability

Since TCP is a reliable protocol, it is able to recover when data being sent to it is inconsistent in some way, such as transmitted packets being lost, duplicated or damaged. To this end, a sequence number is assigned to each packet sent by TCP, and a corresponding acknowledgement must be returned by the receiving TCP. If this acknowledgement is not received within a defined timeout period (long enough to allow for a reasonable amount of latency between the two ends) then the packet is retransmitted. When packets are received at the other end, the sequence numbers are used to reconstruct the correct order of the packets, which may not have been received in the correct order.

Flow Control

The concept of 'sliding windows' is used to control the amount of data which is sent between the two ends of a TCP connection. Every time that the receiver sends an acknowledgement of a packet it also returns a 'window' to the sender, which indicates the range of sequence numbers which the receiver is prepared to accept from the sender. If a packet outwith this range is received it is discarded. This window is used by the sender to ensure that it doesn't send data at a greater rate than the receiver is prepared to accept.

Multiplexing

TCP is designed in such a way as to allow multiple processes or applications on a single machine to use its communication facilities at the same time. It uses a set of ports within the host, which, when used in conjunction with the network address from the Internet communication layer, forms a socket. A pair of these sockets uniquely identify each connection.

Connections

A TCP connection has certain status information associated with each data stream, such as socket numbers, sequence numbers and window sizes. This information is agreed between the two sides of the connection while the connection is being negotiated.

Precedence and Security

The two parties in the TCP communication can indicate the security and precedence of the communication.