TCP Notes
**Transmission Control Protocol (TCP) - Detailed Notes**
**Introduction:**
- TCP is a **connection-oriented** protocol that provides reliable, ordered, and error-checked
delivery of data.
- It operates at the **Transport Layer** (Layer 4) of the OSI model.
**Key Features:**
- **Reliable Data Transfer:** Ensures all data reaches the destination without errors and in the
correct order.
- **Connection-Oriented:** Establishes a connection before data transfer using a three-way
handshake.
- **Flow Control:** Manages the rate of data transmission between sender and receiver.
- **Error Checking:** Uses checksums to detect errors.
- **Congestion Control:** Adjusts data transmission rate based on network traffic conditions.
**How TCP Works:**
1. **Connection Establishment (Three-Way Handshake):**
- SYN: Sender sends a synchronization (SYN) packet.
- SYN-ACK: Receiver responds with a SYN-ACK packet.
- ACK: Sender sends an acknowledgment (ACK) packet, and connection is established.
2. **Data Transfer:**
- Data is divided into segments.
Page 1
TCP Notes
- Each segment is acknowledged upon receipt.
- Retransmission occurs if acknowledgments are not received.
3. **Connection Termination (Four-Step Process):**
- FIN: Sender sends a Finish (FIN) packet.
- ACK: Receiver acknowledges with an ACK.
- FIN: Receiver sends its own FIN.
- ACK: Sender sends a final acknowledgment.
**TCP Header Format:**
- **Source Port**: 16 bits
- **Destination Port**: 16 bits
- **Sequence Number**: 32 bits
- **Acknowledgment Number**: 32 bits
- **Data Offset**: 4 bits
- **Reserved**: 3 bits
- **Flags**: 9 bits (URG, ACK, PSH, RST, SYN, FIN)
- **Window Size**: 16 bits
- **Checksum**: 16 bits
- **Urgent Pointer**: 16 bits
- **Options and Padding**
**Important Concepts:**
- **Flow Control (Sliding Window Protocol):** Controls how much data the sender can transmit
before needing an acknowledgment.
Page 2
TCP Notes
- **Congestion Control (TCP Tahoe, TCP Reno):** Techniques to avoid overwhelming the network.
- **Timeout and Retransmission:** If acknowledgment not received within a timeout, data is
retransmitted.
- **Ordered Data Transfer:** Ensures segments are reassembled in correct order.
**Advantages of TCP:**
- Reliable data transfer.
- Error checking and correction.
- Congestion control.
- Flow control and ordered delivery.
**Disadvantages of TCP:**
- Slower than UDP due to overhead.
- More complex due to connection management and reliability features.
**Applications of TCP:**
- Web browsing (HTTP/HTTPS)
- Email (SMTP, IMAP, POP3)
- File Transfer (FTP)
- Remote access (SSH, Telnet)
Page 3