Ports in Networking

Anirudh Rajmohan
3 min readMay 19, 2020

--

How these rarely explained concepts play a vital role in IT networking.

Note: This article is Part III of a three part series explaining how data flows as packets of information on the internet.

The modern internet communicates by sending all information as packets of data. The entire protocol of routing packets of data through network devices such as routers is called TCP-IP protocol.

Suggested reading if you haven’t already: DNS , TCP-IP

The TCP-IP protocol essentially determines how the packets of internet are sent and received by devices connected to the internet. However, in a typical day, billions of packets are transmitted across the internet. Each device could be sending or receiving packets of data related to multiple applications.

Imagine a situation where you are trying to communicate with your friend over multiple mobile apps from your phone. Let’s say, you want to text your friend over WhatsApp, then feel like sharing a pic over Instagram, and then also remember to share a meme from Facebook.

According to the TCP-IP protocol, your WhatsApp text message, Instagram pic and Facebook meme are all sent to your friend as packets of data. These packets contain packet headers(remember the letter-envelope analogy) with the source address being your own cellphone’s IP address and the destination address being your friend’s IP address.

Once your friend’s receives all the packets of data corresponding to all three forms of communication, it would be important for your friend’s phone to be able to determine the right app to use to open the right packets of data.

The packet(s) of data containing the text message should only be opened by WhatsApp, the packet(s) containing the picture should only be opened by Instagram and the packet containing the meme should only be opened by Facebook.

Keep in mind, that it is not the type of media(text, picture, video etc.) that we are focused on but on opening the right packet of data meant for the right application.

Port numbers are used to identify the right application to handle the relevant packets of data.

The TCP-IP packet headers not only contains provisions for storing the source and destination IP address but also the port numbers. The port number is a unique number used to identify the application a packet of data needs to be handled with.

In this case, the packets of data containing a text message will have a port number corresponding to WhatsApp to let the receiving device(your friend’s phone) that those packets of data need to be opened by the WhatsApp mobile app installed on their system.

Similarly, the packet headers of packets containing the Instagram pic and Facebook port number are marked with corresponding port numbers) and your friend’s device will open them in the corresponding mobile apps of Instagram and Facebook respectively.

Networking Big Picture:

Together with DNS and TCP-IP, port numbers constitute a routing protocol that forms the backbone of internet communication.

Step 1: DNS

As soon as you enter a website into your browser, the DNS identifies the IP address of the web server hosting the website. Port number 53 is used.

Step 2: TCP-IP

Once the right server is identified by DNS, a HTTP connection(3-way handshake is established), and the route through which the packets of data should flow via the internet is identified by Border Gateway Protocol(BGP).

Step 3: Port Numbers

The packets of data contain the source and destination IP addresses as well as the port numbers to indicate the app/service with which they need to be handled.

Why is this important?

Almost every website, app or web service that you access off the internet will work using the above networking trio of protocols. Or at least a variation of it.
Understanding this flow of packets is also important because it helps to understand common scenarios like blocking content for certain regions( firewalls are setup with rules that block certain IP addresses or certain port numbers(or even combination of both IP address and port numbers). Or for redirecting users of a certain region to certain versions of websites( for example, US visitors can be redirected to web servers hosting www.amazon.com while UK visitors can be redirected to web servers hosting www.amazon.uk).

There can be a myriad of other examples that can be taken to showcase how stuff works on the internet, all piggybacking on top of these 3 protocols.

--

--