Skip to main content

RFC 793 - TRANSMISSION CONTROL PROTOCOL

DARPA INTERNET PROGRAM
PROTOCOL SPECIFICATION

Published: September 1981
Status: Internet Standard (STD 7)
Author: Jon Postel (Information Sciences Institute, USC)
Organization: DARPA Internet Program


Status of this Memo

This RFC specifies a standard for the DARPA Internet community. Hosts on the DARPA Internet are expected to adopt and implement this standard.


Abstract

The Transmission Control Protocol (TCP) is intended for use as a highly reliable host-to-host protocol between hosts in packet-switched computer communication networks, and in interconnected systems of such networks.

This document describes the functions to be performed by the Transmission Control Protocol, the program that implements it, and its interface to programs or users that require its services. TCP provides connection-oriented, reliable, byte stream service.


Table of Contents

Preface

1. Introduction

  • 1. Introduction
    • 1.1 Motivation
    • 1.2 Scope
    • 1.3 About This Document
    • 1.4 Interfaces
    • 1.5 Operation

2. Philosophy

  • 2. Philosophy
    • 2.1 Elements of the Internetwork System
    • 2.2 Model of Operation
    • 2.3 The Host Environment
    • 2.4 Interfaces
    • 2.5 Relation to Other Protocols
    • 2.6 Reliable Communication
    • 2.7 Connection Establishment and Clearing
    • 2.8 Data Communication
    • 2.9 Precedence and Security
    • 2.10 Robustness Principle

3. Functional Specification

  • 3. Functional Specification
    • 3.1 Header Format
    • 3.2 Terminology
    • 3.3 Sequence Numbers
    • 3.4 Establishing a Connection
    • 3.5 Closing a Connection
    • 3.6 Precedence and Security
    • 3.7 Data Communication
    • 3.8 Interfaces
    • 3.9 Event Processing

Appendices


Core Concepts Quick Reference

TCP Header Format

    0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Port | Destination Port |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Sequence Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Acknowledgment Number |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Data | |U|A|P|R|S|F| |
| Offset| Reserved |R|C|S|S|Y|I| Window |
| | |G|K|H|T|N|N| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Checksum | Urgent Pointer |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| data |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Key TCP Features

FeatureDescription
Connection-OrientedMust establish connection before communication (three-way handshake)
Reliable TransmissionAcknowledgment, retransmission, and sequencing mechanisms
Byte StreamTreats data as a continuous stream of bytes
Flow ControlSliding window mechanism
Congestion ControlPrevents network congestion
Full-DuplexSimultaneous bidirectional transmission

Connection States

CLOSED → LISTEN → SYN-RECEIVED → ESTABLISHED → FIN-WAIT-1 → ...

Main states:
- CLOSED: Closed
- LISTEN: Listening
- SYN-SENT: SYN sent
- SYN-RECEIVED: SYN received
- ESTABLISHED: Connection established
- FIN-WAIT-1: First FIN wait
- FIN-WAIT-2: Second FIN wait
- CLOSE-WAIT: Close wait
- CLOSING: Closing
- LAST-ACK: Last acknowledgment
- TIME-WAIT: Time wait

Three-Way Handshake

Client                          Server
| |
| SYN (seq=x) |
|------------------------------->|
| |
| SYN-ACK (seq=y, ack=x+1) |
|<-------------------------------|
| |
| ACK (ack=y+1) |
|------------------------------->|
| |
| ESTABLISHED |

Four-Way Handshake (Connection Termination)

Active Side                    Passive Side
| |
| FIN (seq=x) |
|------------------------------->|
| |
| ACK (ack=x+1) |
|<-------------------------------|
| |
| FIN (seq=y) |
|<-------------------------------|
| |
| ACK (ack=y+1) |
|------------------------------->|
| |
| CLOSED |

TCP vs UDP Comparison

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityReliableUnreliable
OrderingGuarantees orderNo guarantee
SpeedSlowerFast
OverheadHigh (20-60 byte header)Low (8 byte header)
Flow ControlYesNo
Congestion ControlYesNo
Use CasesHTTP, FTP, EmailDNS, Video streaming, Gaming

  • Official Text: RFC 793 (TXT)
  • Official Page: RFC 793 DataTracker
  • Standard: STD 7
  • Related Protocols:
    • RFC 791 (IP) - Network Layer
    • RFC 792 (ICMP) - Control Messages
    • RFC 768 (UDP) - Comparison Protocol
    • RFC 2581 (TCP Congestion Control)
    • RFC 5681 (TCP Congestion Control Update)
    • RFC 7323 (TCP Extensions)

Important Note: TCP is one of the core protocols of the Internet transport layer. Combined with the IP protocol, it forms the foundation of the TCP/IP protocol stack. It provides reliable, connection-oriented byte stream service and is the basis for many application protocols such as HTTP, FTP, and SMTP.