A Post on Ports

Advertisements

Hello everyone,

Michael here, and today’s post will explore the perfectly juicy world of networking port numbers.

I know I did mention port numbers throughout my Wireshark series of posts, but I thought port numbers were worth more explanation as they, like IP addresses, are critical to understanding various aspects of cybersecurity like network traffic.

Anyway, let’s get started!

But First, The Im-Port-Ance of Ports

What is a port exactly? It’s basically a checkpoint that indicates where network connections begin and end. There are four main types of ports in networking:

  • Physical ports (think the places where you’d plug in a USB or an HDMI cable on your device)
  • Network ports (think checkpoints in the software that allow programs to begin and end connections)
  • Serial & parallel ports (think the precursors to USB ports in older hardware)
    • Serial ports transmit data one bit at a time while parallel ports transmit data multiple bits at a time-in parallel, perhaps?
  • Virtual ports (think software-defined checkpoints that allow programs to begin and end connections without the need for physical hardware)

The Im-Port-Ant Port Numbers

Now that we understand what ports do, let’s dive into the juicier side-the port numbers themselves!

In networking, port numbers are represented by integers that can range from 0-65,535. Now you may be wondering why is 65,535 the highest possible port number?

Port numbers are stored as 16-bits in individual data packets (remember the meatball sub analogy I used to explain packets and the three-way handshake?).

Since bits can have two individual states-0 and 1-and with 16 bits in total, the total amount of port numbers possible in modern networking is:

Yes, even though there are 65,356 possible port numbers total, port numbers start at port 0, so the highest possible port number would be 65,535.

There are three different categories of port numbers:

  • 0-1023 (the well-known ports): port numbers reserved for specific protocols like port 80 for HTTP or port 443 for HTTPS
  • 1024-49151 (the registered ports): port numbers used for specific applications like MySQL (remember that from the early blog posts?)
  • 49152-65535 (the dynamic ports): temporary port numbers used for client connections, like the port number my browser might’ve used to connect to this blog

Commonly Used Ports

With all the possible port numbers out there, surely you wouldn’t need to know all 65,535 of them right?

Correct! But there are certainly a handful worth knowing, like these:

PortProtocol
20/21File Transfer Protocol
22Secure Shell Login
23Telnet remote login service
25Simple Mail Transfer Protocol
53Domain Name System
67/68Dynamic Host Configuration Protocol
80HyperText Transfer Protocol
110Post Office Protocol
143Internet Message Access Protocol
161Simple Network Management Protocol
443HyperText Transfer Protocol Secure
3306MySQL
3389Remote Desktop Protocol

From our explanation of ports, you may be wondering what their significance is in the networking world. One certainly important aspect of port numbers is that they help ensure that data in transit reaches the correct service, especially for applications running on the same device. For instance, if someone is trying to connect to a site on their browser while also somehow managing a MySQL database while they’re at it, then port numbers would help ensure that the browser data reaches port 80 or 443 (ideally 443 as it’s more secure) and that whatever data that person is trying to transmit to MySQL correctly reaches port 3306.

I know this is a unique analogy but think of ports in networking like a school crossing guard guiding both kids and traffic along a given street during the day. If you remember going to school as a kid and seeing the crossing guard direct you & your peers to the school grounds while also directing the surrounding traffic to its destination, then you can think of ports as the “crossing guards” of network traffic who are there to guide the incoming data packets to their correct destinations.

Lowest Port, Highest Port

Now that I’ve discussed some common ports as well as the types of ports you may encounter in networking, I want to explore the lowest possible port (port 0) and the highest possible port (port 65535). Even if this wasn’t on your mind, I want to dive in anyway!

First of all, what is it about port 0? In TCP, port 0 is a reserved, unusable port while in UDP, port 0 essentially means “there’s no port”. Think of port 0 like the mysterious “year 0” in the Gregorian calendar-it’s there, but just like port 0, year 0 doesn’t exist, as the Gregorian calendar goes from 1 BC to 1 AD.

Now as for the highest possible port number-port 65535-well, there’s really nothing special about it. Since port 65535 falls in the dynamic ports range, it’s simply another port that can be used for temporary connections, just like ports 45912-65534.

Thanks for reading,

Michael

Leave a Reply

Turn on JavaScript to leave a comment.