Transport Layer
Transport Layer
Whether you're loading a web page, sending an email, downloading a file, and watching a video — all at the same time — your computer is running many network conversations at once, all sharing the same physical connection to the Internet. Something has to make sure each reply goes back to the right application, in the right order, without one slow download starving everything else. That job belongs to the Transport Layer.
What Is the Transport Layer?
The Transport Layer is the fourth layer of the OSI (Open Systems Interconnection) Model, sitting above the Network Layer and below the Session Layer. Its core responsibility is process-to-process delivery: getting data from an application running on one host to the corresponding application running on another host.
This is a different job from the Network Layer below it. The Network Layer (IP) only cares about getting a packet from one device to another device, using IP addresses — it has no concept of "applications" at all. The Transport Layer takes over from there: once data has arrived at the right machine, the Transport Layer makes sure it reaches the right application on that machine, using port numbers rather than IP addresses to tell applications apart.
Position in the OSI Model
| # | Layer | Function |
|---|---|---|
| 7 | Application | User-facing applications and services |
| 6 | Presentation | Data formatting, encryption, compression |
| 5 | Session | Session setup and management |
| 4 | Transport | End-to-end communication between applications |
| 3 | Network | Routing and logical (IP) addressing |
| 2 | Data Link | Node-to-node delivery across a single link |
| 1 | Physical | Transmission of raw bits |
Sitting in the middle of the stack, the Transport Layer acts as the bridge between what applications need (reliable, ordered, application-specific delivery) and what the network actually provides (best-effort delivery of packets between devices).
Why the Transport Layer Matters
Imagine a single computer that is simultaneously browsing a website, downloading a file, streaming a video, and sending an email. All of this traffic arrives and leaves over the same network interface, interleaved together. Without something to sort it out, there would be no way to know which incoming data belonged to which application, whether anything was missing, or whether an application was being sent data faster than it could handle.
The Transport Layer solves these problems by making sure:
- Data reaches the correct application, not just the correct device.
- Data is delivered in the proper order, even if it didn't arrive that way.
- Lost data is retransmitted, for applications that require it.
- A fast sender doesn't overwhelm a slow receiver.
Transport Layer Protocols: TCP and UDP
The Internet relies on two primary Transport Layer protocols, which take very different approaches to the same problem.
| TCP | UDP | |
|---|---|---|
| Connection | Connection-oriented (handshake required) | Connectionless |
| Reliability | Reliable — guarantees delivery | Best-effort — no guarantees |
| Ordering | Guaranteed | Not guaranteed |
| Speed/overhead | Slower, higher overhead | Faster, lower overhead |
| Typical uses | Web (HTTP/HTTPS), email, file transfer, banking | Video streaming, online gaming, VoIP, live broadcast |
TCP (Transmission Control Protocol) is connection-oriented and prioritizes reliability: it provides error detection and recovery, flow control, sequence numbering, acknowledgments, and congestion control. When you download a PDF, every byte matters — if a packet is lost, TCP detects the gap and retransmits it, and reorders anything that arrived out of sequence before handing it to the application.
UDP (User Datagram Protocol) is connectionless and prioritizes speed: it sends data without establishing a connection first, and without acknowledgments or retransmissions. During a live video stream, a dropped frame that would take time to retransmit is far less disruptive than the stall caused by waiting for it — so UDP simply moves on, accepting some loss in exchange for lower delay.
(TCP and UDP are explored in full technical depth, alongside newer protocols like SCTP, DCCP, and QUIC, in the companion lesson, Transport Layer Protocols.)
How Data Moves Through the Transport Layer
Communication through the Transport Layer is bidirectional:
- Sending:
Application → Transport Layer → Network Layer - Receiving:
Network Layer → Transport Layer → Application
On the sending side, the Transport Layer takes data from an application, may split it into smaller units, and hands it to the Network Layer for delivery across the network. On the receiving side, it takes incoming data from the Network Layer, reconstructs it, and hands it to the correct waiting application.
Services Provided by the Transport Layer
1. End-to-End Delivery
This is the Transport Layer's defining job: moving data from the sending application to the specific receiving application, regardless of how many networks or routers sit in between. When you send a message through a messaging app, the Transport Layer is what ensures it travels from your app process to your friend's app process — not just from your phone to theirs.
2. Reliable Delivery
"Reliable" doesn't happen automatically — the underlying network only promises best-effort delivery, where packets can be lost, corrupted, delayed, or duplicated. Protocols like TCP build reliability on top of that by implementing four mechanisms:
Error Control
No transmission medium is perfectly error-free; noise, interference, and hardware faults can corrupt data in transit. To catch this, the sender attaches error-checking information (a checksum) to each segment. The receiver recalculates the checksum on arrival and compares it; if it doesn't match, the segment is discarded and the sender is asked to retransmit it. This is why, for example, a corrupted chunk of a downloaded installer gets silently re-fetched rather than producing a broken file.
Sequence Control
Before transmission, data is broken into smaller units called segments. Because these segments can travel across different routes through the network, they may arrive out of order. The Transport Layer assigns a sequence number to each segment so the receiver can reassemble them correctly — for instance, segments arriving as 3, 1, 2 are reordered to 1, 2, 3 before being passed up to the application.
Loss Control
Segments can also go missing entirely. Since every segment carries a sequence number, the receiver can detect a gap — if segments 1, 2, 3, 4, 5 are expected but segment 3 never arrives, the receiver notices the missing number and requests it again.
Duplication Control
Network issues (such as retransmission after a delayed acknowledgment) can occasionally cause the same segment to arrive more than once. Because each segment is numbered, the receiver can recognize and discard duplicates — turning a received sequence of 1, 2, 2, 3, 4 into 1, 2, 3, 4 before the application ever sees it. Without this, an application might process the same data twice.
3. Flow Control
Flow control prevents a fast sender from overwhelming a slow receiver. Without it, the receiver's buffer could overflow, forcing it to drop incoming packets — which only creates more retransmissions and congestion.
The common solution is the sliding window protocol: the receiver continuously tells the sender how much more data it is currently able to accept (its available buffer space), and the sender limits its transmission rate to stay within that window. It's the same idea as pouring water into a glass at a rate the glass can hold — not faster than it can accept — so it never overflows.
4. Multiplexing and Demultiplexing
A single network connection is shared by many applications at once, and the Transport Layer is what makes this possible.
- Multiplexing is the process of combining data from multiple applications (a browser, a download, a video player) so it can be sent out over the same underlying network connection.
- Demultiplexing is the reverse: when data arrives, the Transport Layer inspects it and delivers each piece to the correct waiting application — email data to the mail client, browser data to the browser, video data to the media player.
Multiplexing can also be described from the perspective of how transport and network connections relate to one another:
- Upward multiplexing — several transport-layer connections share a single network-layer connection, improving resource utilization and reducing cost.
- Downward multiplexing — a single transport-layer connection is split across multiple network paths, which can increase throughput when individual links have limited capacity.
Addressing in the Transport Layer
Getting data to the right device only solves half the problem — it still has to reach the right application on that device. The Transport Layer solves this with port numbers.
A port number identifies a specific application or service on a device. Some well-known examples:
| Application | Port Number |
|---|---|
| HTTP | 80 |
| HTTPS | 443 |
| FTP | 21 |
| SMTP | 25 |
| DNS | 53 |
Transport Service Access Point (TSAP)
Formally, the combination that identifies where a transport-layer connection terminates is called a Transport Service Access Point (TSAP). In practice, on the Internet, a TSAP is simply implemented as the pairing of an IP address and a port number.
Together, IP address + port number uniquely identify a specific application process on a specific device — for example:
192.168.1.10:443
Here, 192.168.1.10 identifies the device, and 443 identifies that it's specifically the HTTPS service being addressed on that device.
Walking Through a Real Request
Suppose a student opens a website in their browser. Here's where the Transport Layer fits into that sequence:
- The browser generates an HTTP request.
- TCP divides the request into segments.
- Each segment is assigned a sequence number.
- The Network Layer routes these packets across the Internet to the destination server.
- The server receives the packets.
- TCP reassembles the segments in the correct order.
- The webpage is displayed correctly in the browser.
Steps 2, 3, and 6 — segmenting, sequencing, and reassembling — are all Transport Layer responsibilities, sandwiched between the application generating the request and the network actually carrying it.
Advantages and Limitations
Advantages
- Provides true end-to-end, application-to-application communication.
- Offers reliable data transfer when needed (via TCP).
- Performs error detection and recovery.
- Controls data flow to match the receiver's capacity.
- Supports many applications sharing one network connection, through multiplexing.
- Maintains correct ordering and removes duplicate data.
Limitations
- Reliability mechanisms (like TCP's acknowledgments and retransmissions) add processing and bandwidth overhead.
- Maintaining connection state consumes memory and CPU on both endpoints.
- Flow control and congestion control add implementation complexity.
- Applications that don't need reliability (like live streaming) still have to actively choose a lighter-weight protocol like UDP to avoid unnecessary overhead.
Related Concepts
- Network Layer (IP) — delivers packets between devices; the Transport Layer builds on top of this to deliver data to specific applications.
- Sliding Window Protocol — the general mechanism TCP uses for both flow control and efficient pipelined transmission.
- Congestion Control — a related but distinct concern from flow control, covered alongside TCP's behavior in the Transport Layer Protocols lesson.