What is TCP

Transmission Control Protocol (TCP) is a transport protocol which operates at Transport layer (OSI level 4) of network model.

TCP is used on top of IP protocol for reliable transmission of packets.

TCP is a connection-oriented method of communication.

How TCP works

TCP conducts a three-way handshake between a client and a server and then establishes a connection. After a connection is established, client and server continuously negotiate on how much data is sent and received though a windowing process.

Every packet receipt is acknowledged. If any packet receipt has not been acknowledged, it is retransmitted.

TCP ensures that after receiving, the data packets are in the same order as before sending. This is done by reordering data packets in cases when they are received in incorrect order.

TCP header has length of 20 bytes.

Three-way handshake

Three-way handshake consists of steps:

  1. client sends SYN packet to server,
  2. server sends SYN-ACK packet back to client,
  3. client sends ACK packet to server.