What does the OSI transport layer do?
The transport layer provides end-to-end delivery of data between applications on different devices, and controls how data is split, transmitted, checked, and reassembled.
Short formulation for an interview:
The transport layer is responsible for reliable or fast data transfer between hosts, providing segmentation, error control, flow control, and port handling. The main protocols are TCP and UDP.
Main functions of the transport layer (L4)
1. Data segmentation and reassembly
The transport layer:
- splits application data into segments (TCP) or datagrams (UDP)
- reassembles them back into a stream after delivery
2. Segment numbering
Each segment gets a number (sequence number), which allows:
- assembling data in the correct order
- detecting lost segments
This is a key mechanism of TCP.
3. Controlling data delivery
L4 determines exactly how data is transmitted:
TCP: reliable delivery
- acknowledgments (ACK)
- retransmission
- ordering of segments
- congestion control
- three-way handshake
UDP: fast delivery
- delivers without guarantees
- used where speed matters and packet loss is acceptable
- no handshake, no ACK, no ordering control
4. Flow control
Allows the receiver to regulate the amount of data the sender transmits.
TCP uses the Window Size mechanism:
- if the buffer overflows, the window shrinks
- if data is processed quickly, the window grows
5. Error control
The transport layer checks data for errors:
- TCP uses a checksum
- if data is corrupted, the segment is dropped and resent
UDP also uses a checksum, but it does not guarantee reliability.
6. Multiplexing by ports
The transport layer uses port numbers:
- a port determines which application the data is intended for
- one IP address can serve many applications at the same time
Example ports:
- 80: HTTP
- 443: HTTPS
- 53: DNS
- 22: SSH
7. Establishing and terminating a connection (TCP)
A TCP connection goes through stages:
- SYN → SYN/ACK → ACK: establishment
- FIN/ACK → FIN/ACK → ACK: termination
UDP does not establish connections.
Transport layer protocols
TCP (Transmission Control Protocol)
- reliable
- connection-oriented
- guarantees delivery
- error control
- congestion control
- used by: HTTP(S), FTP, SSH, SMTP, IMAP
UDP (User Datagram Protocol)
- fast
- no delivery guarantee
- connectionless
- used by: VoIP, streaming, games, DNS
What the transport layer does NOT do
The transport layer is not responsible for:
- routing (that is layer 3)
- MAC addresses and frames (that is layer 2)
- encryption (layer 6, 7)
- access to the transmission medium (layer 2)
Example of the transport layer at work
Suppose you visit a website:
- The browser sends an HTTP request: L7
- The data is passed to TCP: L4
- TCP splits it into segments and numbers them
- L3 adds IP addresses and creates a packet
- L2 adds a MAC address and forms an Ethernet frame
- The data goes out onto the network
- On the server, TCP reassembles the segments and checks the order
- It passes the reassembled data to the HTTP server
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.