100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Python

Transport Layer Basics

Learn how the transport layer provides process-to-process delivery between applications running on different hosts.

Transport LayerBeginner8 min readJul 8, 2026
Analogies

Introduction

The transport layer is Layer 4 of the OSI model and sits directly above the network layer. While the network layer (IP) is responsible for getting packets from one host to another across a network, the transport layer takes on a more precise job: delivering data from a specific process on the sending host to a specific process on the receiving host. This is often called process-to-process, or end-to-end, delivery.

🏏

Cricket analogy: Just as getting the team bus to the stadium (network layer) is different from getting the ball into a specific fielder's hands (transport layer), IP delivers to the host while the transport layer delivers to the exact process.

Explanation

A single computer can run many applications at once - a web browser, an email client, a music streaming app - all sharing the same network connection. IP only gets data as far as the correct machine; it has no concept of which application on that machine should receive it. The transport layer solves this using port numbers, which identify individual processes, combined with the concept of a socket (an IP address plus a port). The two dominant transport-layer protocols are TCP (Transmission Control Protocol) and UDP (User Datagram Protocol), which take very different approaches to delivering data but both rely on this same addressing model.

🏏

Cricket analogy: A stadium (IP address) hosts many activities at once, nets practice, a match, media interviews, so gate numbers (ports) direct each visitor to the right area, just as TCP and UDP use port numbers to reach the right app.

Beyond addressing individual processes, the transport layer also provides services that the network layer does not guarantee, such as reliability, ordering, and flow/congestion control (in TCP's case), or a lightweight, low-overhead path for applications that can tolerate loss (in UDP's case). It also performs segmentation - breaking application data into smaller units, called segments (TCP) or datagrams (UDP), that fit within the limits imposed by lower layers - and reassembly on the receiving end.

🏏

Cricket analogy: TCP is like a Test match innings insisting every ball is bowled in strict order with no dropped deliveries, while UDP is like a quick exhibition six-hitting contest that tolerates a missed swing; both segment the game into overs for delivery.

Example

python
import socket

# A simple TCP client illustrating process-to-process delivery.
# The destination is identified by BOTH an IP address (which host)
# and a port number (which process/service on that host).
HOST = "93.184.216.34"  # example.com's IP
PORT = 80                # the HTTP server process listens here

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
    s.sendall(b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
    response = s.recv(4096)
    print(response[:100])

Analysis

In the example, the network layer's job ends once the packet reaches the machine at 93.184.216.34. It is the transport layer, using port 80, that hands the data to the correct process - the web server - rather than to some other application also running on that machine. This division of labor is what allows the network layer to stay simple and focused on routing, while the transport layer handles multiplexing multiple application conversations over a single network path and, in TCP's case, provides reliability guarantees the network layer does not offer.

🏏

Cricket analogy: Once the team bus reaches the stadium gate at address 93.184.216.34, that's the network layer's job done, but it's the gate number (port 80) that gets you specifically to the players' entrance, not the media or VIP gate.

Key Takeaways

  • The transport layer provides process-to-process (end-to-end) delivery, distinct from the network layer's host-to-host delivery.
  • Ports identify individual application processes on a host; a socket is the combination of an IP address and a port.
  • TCP and UDP are the two main transport-layer protocols, offering very different trade-offs.
  • The transport layer segments application data for transmission and reassembles it on arrival.
  • Services like reliability, ordering, flow control, and congestion control are implemented at this layer, not the network layer.

Practice what you learned

Was this page helpful?

Topics covered

#Python#ComputerNetworksStudyNotes#ComputerNetworks#TransportLayerBasics#Transport#Layer#Explanation#Example#StudyNotes#SkillVeris