Course contentsShow
← Computer Science
Lesson 1483 of 2,87234. Internet Protocol SuiteFree lesson

TCP Port Numbers and Multiplexing

How TCP uses source and destination port numbers to multiplex multiple connections on a single host.

TCP Port Numbers and Multiplexing

What you'll learn: How TCP uses port numbers to manage multiple simultaneous connections on a single machine.

The Problem: One IP, Many Applications

Imagine your computer is like an apartment building with one street address (its IP address). When a delivery arrives, how does the postal service know which apartment to deliver to? TCP solves this exact problem using port numbers.

How Port Numbers Work

A port number is a 16-bit value (0–65535) that identifies a specific application or service on a host. Every TCP connection is uniquely identified by four pieces of information:

  • Source IP address
  • Source port number
  • Destination IP address
  • Destination port number

This four-tuple lets TCP distinguish between different connections, even when multiple applications on the same computer communicate with the same remote server.

Multiplexing in Action

Multiplexing is the process of combining multiple data streams into one channel. In TCP's case, it means your computer can run a web browser, email client, and video chat simultaneously—all sharing the same network interface and IP address—because each application uses different port numbers.

When a TCP segment arrives, the operating system examines the destination port number in the TCP header and delivers the data to the correct application. When sending data, the source port number tells the remote host where to send replies.

Well-Known Ports

Port numbers 0–1023 are reserved for standard services (HTTP uses 80, HTTPS uses 443, SSH uses 22). Your applications typically use ephemeral ports (49152–65535) as source ports for outgoing connections.

Key Takeaway: TCP port numbers enable multiplexing by allowing a single host to maintain many simultaneous connections, routing each segment to the correct application based on the destination port in the TCP header.