Transport Layer
The Transport Layer is the fourth layer of the OSI (Open Systems Interconnection) model and is responsible for end-to-end communication between devices in a network. It ensures that data is delivered accurately, efficiently, and reliably from the source to the destination.
Segmentation & Reassembly
Breaks large messages into smaller packets (segmentation).
Reassembles packets in the correct order at the destination.
Flow Control
Prevents overwhelming a slow receiver by controlling the data flow.
Uses techniques like Sliding Window Protocol.
Error Control
Ensures data is received without errors using checksums and acknowledgments.
Multiplexing & Demultiplexing
Allows multiple applications to share the same network connection using port numbers.
Ensures data is delivered to the correct application.
Connection Management
Supports connection-oriented and connectionless communication.
Example: TCP establishes a connection using a three-way handshake before data transfer.
Protocol
Type
Features
TCP (Transmission Control Protocol)
Connection-Oriented
Reliable, error-checking, ordered delivery
UDP (User Datagram Protocol)
Connectionless
Faster, no error checking, unordered delivery
When you visit a website (HTTP request), the Transport Layer uses TCP to:
Establish a connection.
Break the request into packets.
Ensure packets arrive correctly at the web server.
Reassemble packets at the destination.
When you stream a video (YouTube, Netflix), the Transport Layer may use UDP because:
It prioritizes speed over reliability.
Minor packet loss doesn’t significantly impact the experience.
The Transport Layer ensures reliable or fast data delivery.
It uses TCP (for reliability) and UDP (for speed).
It handles segmentation, error control, flow control, and multiplexing.
Transport Layer Headers: TCP & UDP (Detailed Explanation)
The Transport Layer in the OSI model uses headers to manage communication between devices. These headers contain important information like source and destination ports, sequence numbers, and error-checking fields.
TCP is a connection-oriented protocol, meaning it ensures reliable communication by establishing a connection, maintaining data integrity, and ensuring error checking and retransmission if necessary.
TCP Header Structure (20–60 bytes)
A TCP header has mandatory 20 bytes and can extend up to 60 bytes with options.
Field
Size (Bits)
Description
Source Port
16
Identifies the sending application/process
Destination Port
Identifies the receiving application/process
Sequence Number
32
Keeps track of the order of data being sent
Acknowledgment Number
Acknowledges receipt of data from the other side
Data Offset (Header Length)
4
Specifies the length of the TCP header
Reserved
3
Reserved for future use, usually set to 0
Flags (Control Bits)
9
Controls connection setup, teardown, and data transfer
Window Size
Indicates the amount of data the receiver can handle
Checksum
Error-checking field for data integrity
Urgent Pointer
Indicates if there is urgent data to process
Options (Optional)
0-320 (variable)
Used for extra features like timestamps, window scaling
TCP Flags (Control Bits)
TCP uses flags (control bits) to manage the connection and data flow. Here are the important ones:
Flag
Meaning
Function
SYN
Synchronize
Initiates a connection (used in the 3-way handshake)
ACK
Acknowledge
Confirms receipt of data
FIN
Finish
Gracefully closes a connection
RST
Reset
Abruptly closes a connection
PSH
Push
Tells the receiver to process data immediately
URG
Urgent
Indicates urgent data that should be processed first
Example of a TCP Header in Action
Imagine you are loading a webpage (using HTTP, which runs on TCP). Here’s what happens:
Your computer sends a TCP SYN packet (with a random sequence number) to the web server.
The server responds with SYN-ACK, acknowledging your request.
Your computer sends ACK, completing the three-way handshake.
Data transfer begins, with each packet carrying a sequence number.
After the data is received, TCP sends an ACK to confirm delivery.
When done, the connection is closed using FIN and ACK.
UDP is a connectionless, faster, but unreliable protocol. Unlike TCP, it does not guarantee data delivery, order, or retransmission.
UDP Header Structure (8 bytes)
UDP has a fixed 8-byte header, making it lightweight and fast.
Length
Specifies the total size of the UDP packet (header + data)
Provides basic error-checking (optional in IPv4, mandatory in IPv6)
Example of a UDP Header in Action
Imagine you are streaming a video on YouTube (which uses UDP). Here’s what happens:
The server sends video packets to your device using UDP.
If a packet is lost, UDP does not retransmit it (to keep the stream smooth).
The video may momentarily glitch, but playback continues.
Since UDP does not require acknowledgments, it is faster than TCP.
Feature
TCP
UDP
Header Size
20–60 bytes
8 bytes
Connection
Connection-oriented
Reliability
Reliable (ensures data delivery)
Unreliable (no guarantees)
Error Checking
Checksum + Retransmission
Checksum only
Use Cases
Web browsing, email, file transfer (FTP)
Streaming, gaming, VoIP
TCP header is larger and contains more fields for reliable data transfer.
UDP header is smaller, making it faster but with no guarantees of delivery.
Last changed2 months ago