TCP - (Transmission Control Protocol)


It’s one of the core protocols of the Internet Protocol Suite (often called TCP/IP). Its main job is to make sure data is sent reliably(no data lost, no duplicates, correct order, no corruption) from one computer to another over a network.

Some application of TCP protocol: World Wide Web(HTTP, HTTPS), Email(SMTP, IMAP, POP3), File transfer(FTP), Remote logins(SSH) etc.

TCP protocol operations

  1. Connection Establishment
  2. Data Transfer
  3. Connection Termination

TCP segment/packet structure


TCP Packet/Segment = TCP Header + TCP Payload

TCP Header

Source port: 16 bits (2 bytes) Destination port: 16 bits (2 bytes) Sequence number: 32 bits (4 bytes) Acknowledgment number: 32 bits (4 bytes) Data offset: 4 bits, Reversed: 4 bits

Flags (8 bits at offset 12)

  • CWR: Congestion Window Reduced – 1 bit
  • ECE: ECN-Echo – 1 bit
  • URG: Urgent – 1 bit
  • ACK: Acknowledgement – 1 bit
  • PSH: Push – 1 bit
  • RST: Reset – 1 bit
  • SYN: Synchronize – 1 bit
  • FIN: Finish – 1 bit

Window: 16 bits Checksum: 16 bits Urgent Pointer: 16 bits options: 0 - 320 bits

TCP Header Size:

Minimum Size: 20 bytes (no options) Maximum Size: 60 bytes (max allowed options)