Transport Layer in Detail (TCP/IP Model)
The Transport Layer is the third layer in the TCP/IP model and is responsible for end-to-end communication, data segmentation, reliability, and flow control. It ensures that data is delivered accurately and efficiently between applications running on different devices.
Key Functions of the Transport Layer
- Segmentation & Reassembly
- Breaks large data into smaller segments for transmission.
- Reassembles segments at the destination in the correct order.
- End-to-End Communication
- Ensures data is transferred between specific application processes on different devices.
- Reliability (TCP Only)
- Uses acknowledgments (ACKs) to confirm data receipt.
- Retransmits lost or corrupted packets.
- Flow Control
- Prevents sender from overwhelming the receiver with too much data.
- Uses sliding window protocol to manage data flow.
- Multiplexing & Demultiplexing
- Allows multiple applications to use the network simultaneously.
- Uses port numbers to identify different services (e.g., HTTP, FTP, DNS).
- Error Detection & Correction
- Detects corrupted segments using checksums and requests retransmission.
- Congestion Control
- Monitors network conditions and adjusts data transmission rate accordingly.
- Uses algorithms like Slow Start, Congestion Avoidance, and Fast Retransmit.
Protocols in the Transport Layer
The Transport Layer mainly consists of two protocols:
1. TCP (Transmission Control Protocol) – Reliable Communication
- Connection-oriented (establishes a connection before sending data).
- Ensures ordered, error-free, and complete data delivery.
- Uses Three-Way Handshake for connection establishment.
- Uses flow control, error detection, and congestion control.
- Used for applications requiring high reliability, such as:
- Web Browsing (HTTP/HTTPS)
- Email (SMTP, IMAP, POP3)
- File Transfer (FTP, SFTP)
2. UDP (User Datagram Protocol) – Faster, Unreliable Communication
- Connectionless (no need to establish a connection).
- Faster but does not guarantee ordered or error-free delivery.
- No retransmissions or flow control.
- Used for applications requiring low latency, such as:
- Video Streaming (YouTube, Netflix)
- Online Gaming
- VoIP (Voice over IP, Skype, Zoom calls)
- DNS (Domain Name System)
Transport Layer Headers (TCP vs UDP)
1. TCP Header (More Fields for Reliability & Control)
Field | Description |
---|---|
Source Port | Identifies sending application. |
Destination Port | Identifies receiving application. |
Sequence Number | Keeps track of packet order. |
Acknowledgment Number | Confirms receipt of data. |
Header Length | Size of the TCP header. |
Flags | Controls TCP connection setup and termination. |
Window Size | Controls flow of data. |
Checksum | Detects errors. |
Urgent Pointer | Indicates urgent data transmission. |
Options | Additional settings for performance tuning. |
2. UDP Header (Simpler, No Reliability Mechanisms)
Field | Description |
---|---|
Source Port | Identifies sending application. |
Destination Port | Identifies receiving application. |
Length | Specifies total segment size. |
Checksum | Ensures data integrity. |
Port Numbers in the Transport Layer
The Transport Layer uses port numbers to identify different services on a device.
Categories of Port Numbers:
Range | Description | Examples |
---|---|---|
0 – 1023 | Well-Known Ports | HTTP (80), HTTPS (443), FTP (21), SMTP (25), DNS (53) |
1024 – 49151 | Registered Ports | MySQL (3306), RDP (3389) |
49152 – 65535 | Dynamic/Private Ports | Used for temporary client connections |
Example:
- A web browser (Chrome) requests a webpage using port 80 (HTTP) on a web server.
- The web server responds using the same port 80, but the client assigns a random dynamic port (e.g., 50500) for this session.
Flow Control in Transport Layer
Flow control ensures that the sender does not send too much data for the receiver to handle.
1. Sliding Window Protocol (TCP Only)
- Controls the amount of data a sender can transmit before waiting for an acknowledgment.
- Types of Sliding Window:
- Static Window: Fixed-size window.
- Dynamic Window (Adaptive): Adjusts based on network conditions.
2. Stop-and-Wait Protocol
- Sender sends one packet and waits for an acknowledgment before sending another.
- Simple but inefficient for large data transfers.
Congestion Control in Transport Layer
Congestion occurs when too much data is sent, overwhelming the network.
TCP Congestion Control Techniques:
- Slow Start: Starts with a small amount of data and gradually increases.
- Congestion Avoidance: Monitors network congestion and slows transmission when needed.
- Fast Retransmit: Resends lost packets without waiting for a timeout.
- AIMD (Additive Increase, Multiplicative Decrease): Increases window size slowly but decreases rapidly during congestion.
Multiplexing & Demultiplexing
- Multiplexing: Allows multiple applications to use the network simultaneously by assigning different port numbers.
- Demultiplexing: Ensures received data is delivered to the correct application based on port numbers.
Example:
- A computer can browse the web (HTTP on port 80) and check email (IMAP on port 143) at the same time.
- TCP/UDP handles directing the correct data to the right application.
Comparison: TCP vs UDP in the Transport Layer
Feature | TCP | UDP |
---|---|---|
Connection Type | Connection-Oriented | Connectionless |
Reliability | Reliable (ACKs, retransmissions) | Unreliable (No ACKs) |
Ordering | Ensures packets arrive in order | No guaranteed order |
Error Checking | Yes (Checksum, retransmissions) | Yes (Checksum only) |
Flow Control | Yes (Sliding Window) | No |
Congestion Control | Yes (Slow Start, AIMD) | No |
Speed | Slower (due to reliability checks) | Faster (low overhead) |
Best For | Web browsing, email, file transfers | Streaming, gaming, VoIP |
Conclusion
The Transport Layer plays a crucial role in ensuring efficient, reliable, and controlled communication between devices. It provides two main protocols:
- TCP for reliability, ordering, and error correction.
- UDP for fast, lightweight communication where speed is prioritized over reliability