Lesson 44: Port Numbers and Sockets (Service Identification)
We established that the Transport Layer (L4) uses Port Numbers to direct traffic to the correct application on a multi-tasking host. This concept is crucial for understanding how services work.
What is a Port Number?
A Port Number is a 16-bit number (0 to 65535) used to identify a specific application or service running on a computer. If the IP address is the physical building, the port number is the apartment number within that building.
The Three Port Ranges:
- Well-Known Ports (0 to 1023): Reserved for the most common, standard network services.
- Registered Ports (1024 to 49151): Assigned by IANA for specific services, often used by third-party software.
- Dynamic/Private Ports (49152 to 65535): Used by client machines when they initiate a connection to a server (ephemeral ports).
Key Well-Known Ports (TCP/UDP)
| Port | Protocol | Usage |
|---|---|---|
| 20, 21 | TCP | File Transfer Protocol (FTP) |
| 22 | TCP | Secure Shell (SSH) |
| 23 | TCP | Telnet (Unsecure remote access) |
| 25 | TCP | Simple Mail Transfer Protocol (SMTP) |
| 53 | TCP/UDP | Domain Name System (DNS) |
| 80 | TCP | Hypertext Transfer Protocol (HTTP) |
| 443 | TCP | HTTPS (Secure Web) |
The Socket
A socket is the combination of the IP address and the port number (e.g., 192.168.1.5:80). A socket uniquely identifies a single connection endpoint.