πͺ What are Port Numbers?
A port number is a 16-bit number (from 0 to 65535) that identifies a specific application or process on a device. While an IP address gets network traffic to the right computer, the port number gets that traffic to the right application on that computer.
Analogy: If an IP address is the street address of an apartment building, the port number is the specific apartment number. It ensures the delivery goes to the correct resident (application).
π Categories of Port Numbers
Ports are divided into three main ranges:
-
Well-Known Ports (0 - 1023) These are reserved for standard, system-level services. Common examples include:
- Port 80: HTTP (Standard web traffic)
- Port 443: HTTPS (Secure web traffic)
- Port 53: DNS
- Port 22: SSH (Secure Shell)
- Port 25: SMTP (Email sending)
-
Registered Ports (1024 - 49151) These are registered for specific user applications (e.g., many database services use these).
-
Dynamic or Ephemeral Ports (49152 - 65535) These are used for temporary, outbound connections. When your web browser connects to a website, it uses a random port from this range as its source port.
π€ How Ports are Used in a Connection
A network connection is defined by a pair of sockets. A socket is the combination of an IP address and a port number.
For example, when you visit google.com:
- Your Device (Client):
Source IP:Source Port(e.g.,192.168.1.10:51234) - Googleβs Server:
Destination IP:Destination Port(e.g.,142.250.196.110:443)
The router uses this full address information to shuttle traffic between your browser and Googleβs web server.
π¬ Sub-Topic: Inspecting Port Numbers with Wireshark
π€ What is Wireshark?
Wireshark is a free and powerful network protocol analyzer. It captures and displays the data packets traveling on your network, allowing you to see whatβs happening in real-time.
π Finding Port Numbers in Wireshark
- Start Capture: Open Wireshark, select your active network interface (e.g., βWi-Fiβ), and start the capture by clicking the shark fin icon.
- Generate Traffic: Open a web browser and visit a website.
- Stop Capture: Return to Wireshark and click the red square to stop the capture.
- Analyze the Packet List: The main window shows all captured packets. Look for traffic involving your computerβs IP address.
- Inspect Packet Details:
- Click on a packet in the list.
- In the βPacket Detailsβ pane below, expand the Transmission Control Protocol (TCP) or User Datagram Protocol (UDP) section.
- Inside, you will clearly see the Source Port and Destination Port for that specific packet of data.