TCP (The Transmission Control Protocol)

Introduction
The Transmission Control Protocol (TCP) is intended for use as a highly reliable host-to-host protocol between hosts in a packet-switched computer communication network.

Basic Data Transfer
TCP transfers a continuous stream of data in each direction between the users by packing the data into segments for transmission through a network system.

Reliability
TCP has the ability to recover when data is damaged, lost, duplicated or delivered out of order. This is done by giving a sequence number to each packet transmitted and requiring an acknowledgment (ACK) from the receiving TCP. The sequence number can be used by the receiver to rearrange packets that arrived out of order and to eliminate duplicates. By computing and checking a checksum any damaged segments will be discarded. Packets not being acknowledged by the receiver will be retransmitted by the sender.

Flow Control
Flow control is TCP’s method of not sending more data than the receiver can currently handle. TCP have a “window” that specify how large the next sequence number can be beyond the last segment received. This “window” is sent along with every ACK that gets sent.

Multiplexing
Each host using TCP can have multiple connections that are communication. The TCP provides a set of addresses or ports within each host and this is concatenated with the network and host addresses from the internet communication layer to form a socket. A pair of sockets then uniquely identifies a connection.

Connections
To provide functionality such as reliability and flow control, TCPs must initialize and maintain certain status information for each data stream. The combination of this information, including sockets, sequence numbers and window sizes is called a connection.

Connections is being set up by the TCP’s of two processes when they wish to communicate, and once they have completed the communication session, they connection is terminated to free up resources.

Why TCP?
TCP is popular because it is very safe to use, making sure that data sent is received in an orde red way and that all of the data is received, by providing recovery from package loss. As seen above, TCP provides flow control to avoid overwhelming receivers with data, but in addition to that, it provides Congestive Control (see own article) to enable it to utilize as much as possible of the network available.

A disadvantage that TCP got is that it is a relativly slow protocol, because certain features like retransmission of lost packeges are done after a timeout, and that all packets sent have to be acknowledged by the sender it becomes impossible match the speed of protocols that don't provide such services, like UDP.

RFC:
http://tools.ietf.org/html/rfc793