TCP introduction
The TCP is a Transport Layer protocol which is also part of the TCP/IP internet protocol stack, and provides the interface between the network layer below, and the application layer above.
The TCP has the following properties:
- Stream data transfer - From the application's viewpoint, TCP transfers a contiguous stream of bytes.
- Reliable service - TCP assigns a sequence number to each byte transmitted, and expects a positive acknowledgment (ACK) from the receiving TCP. If the ACK is not received within a timeout interval, the data is retransmitted. The receiving TCP uses the sequence numbers to rearrange the segments when they arrive out of order, and to eliminate duplicate segments.
- Offers flow control through the use of a sliding window and other mechanisms, to optimize the data transfer through the network. More info regarding this later.
- Multiplexing - To allow for many processes within a single host to use TCP communication facilities simultaneously, the TCP provides a set of addresses or ports within each host. Concatenated with the network and host addresses from the internet communication layer, this forms a socket. A pair of sockets uniquely identifies each connection.
- Connection Oriented.
- And more...
The Sliding Window
Sliding window algorithms are a method of flow control for network data transfers.
TCP uses a sliding window algorithm, which allows a sender to have more than one unacknowledged packet "in flight" at a time, which improves network throughput.
Key concepts of the Sliding Window
- Both the sender and receiver maintain a finite size buffer to hold outgoing and incoming packets from the other side.
- Every packet sent by the sender, must be acknowledged by the receiver. The sender maintains a timer for every packet sent, and any packet unacknowledged in a certain time, is resent.
- The sender may send a whole window of packets before receiving an acknowledgement for the first packet in the window.
This results in higher transfer rates, as the sender may send multiple packets without waiting for each packet's acknowledgement.
- The Receiver advertises a window size that tells the sender how much data it can receive, in order for the sender not to fill up the receivers buffers.