What is a port in computer networking? Explained with examples.


It’s always helpful to use a real-world example to illustrate a technical concept. Numerous people live in a large building, having multiple apartments. Each apartment is assigned a unique number that has significance within that building only. While the building’s postal address is globally unique and reachable from any corner of the globe.

Similarly, in a computer network, a port number is analogous to an apartment number, while an IP address is similar to a postal address of the building. When a real letter arrives, it first makes its way to the building and then to a specific apartment.

What is a port number?

A port number is an integer value of size two bytes (sixteen bits) long. For a network communication an application reserves a port over an IP address (bind with IP and port). After that, no other application can use that port on the same host.

Network applcation and port number:

A port number is a two-byte (sixteen-bits) long integer value. A network communication application reserves a port over an IP address for network communication (bind with IP and port). After that, no other application on the same host may use that port.

Network packets and ports.

A network packet has destination and source ports in the protocol header along with the source and destination IP addresses. For example, a UDP or TCP application specify the ports in its header. The receiver host looks for the port in the destination address and sends it to the application that is listening for that host.

Which layer has the port information?

As per the OSI model, the transport layer has the mapping between the ports and user applications. For example, the TCP layer has, mapping between ports and user applications (e.g FTP, SCP, etc).

Network packet routing and ports.

When two nodes communicate, a packet moves from source to destination via intermediate routers. The port information is not relevant for the rouets. Only the end nodes look for the port to identify the correct application.

For example, an HTTP server (e.g www.google.com), binds on a known port on the server machine and starts listening for the client request. On another side, a client uses the service by sending a request to the server’s IP address and port.

The request also contains the client’s port and IP address. But here port is generally not a standard port number.

Firewall and ports.

A firewall is an additional layer of security for an organization. It protects the company resources from being hacked or misused. Each request that enters the company network is examined by the firewall if it detects a suspicious packet id dried.

On a firewall, the port number is also scanned. If the port coming in destination address is opened on firewall request enters in the company premises else not.

What is the range for port numbers?

Because the value is 16 bits long, it could theoretically range from 0 to 65535. However, this is not the case; certain ports cannot be used because they are in use by system applications. The following table summarises the division of ranges according to RFC-6056.

PortsMeaning
0 to 1023 Well Known ports (r.g FTP, DNS, etc.)
1024 to 49151Registered Ports (e.g 36412 for S1AP)
49151 to 65535 Private Ports. You can use these ports without worry.