Understanding IP addresses

Vineet Pal Singh
DevOps Dudes
Published in
4 min readMay 27, 2020
Fotomay/Shutterstock

TL;DR

Ever wondered how with just an IP address your data travels across the world with n number of networks and hosts in between to get confused with?

Computer network works on IP address but we seldom see ourselves typing the IP address in our browser because for us it is comparatively harder to remember numbers than names.

DNS Overhead

So, when we type www.google.com in our browser, our ISP (internet service provider) provides us with a service called DNS (domain name service) which helps in converting a domain name to an IP address.
This is called DNS overhead because we wanted to reach Google and not the DNS but we had to in order to get the IP address.
This happens for the first time and then the browser caches the IP address for some time until expired.

Octets and Classes

Each IP address has a size of 32 bits and comes with a network ID and a host ID to which it has to travel.
For better readability, it is represented divided into 4 octets of 8 bits each and converted to decimal number.

Octets

Below is how we represent an IP address, here we took an example of IP address: 10.1.2.3.

The IP address is divided into different classes based on the placing of 1 and 0.

Class A

If an IP address starts with 0, in binary, such IP addresses will fall under class A network.
Network ID is decided by first octet and host ID by remaining 3 octets.
Thus, available networks are 2⁷ and likewise, host IP addresses are 2²⁴ which is ~16 mil.

Class B

If an IP address starts with 10, in binary, such IP addresses will fall under class B network.
Network ID is decided by first 2 octets and host ID by remaining 2 octets.
Thus, available networks are 2¹⁴ and likewise, host IP addresses are 2¹⁶.

Class C

If an IP address starts with 110, in binary, such IP addresses will fall under class C network.
Network ID is decided by first 3 octets and host ID by the last octet.
Thus, available networks are 2²¹ and likewise, host IP addresses are 2⁸.

Classes

With this, for class A network, the first octet has now remained with 7 bits which is 128 (2⁷) in decimal number and similarly, 64 (2⁶) and 32 (2⁵) for class B and class C network.

Thus, the range of first bit in an IP address is:

  • Class A: 0–127
  • Class B: 128–191
  • Class C: 192–223

For example, given an IP address of 172.31.1.2, the first octet is 172.
172 falls between 128 and 191, so 172.31.1.2 is a Class B address.

Casting

Casting is nothing but sending data stream.

Unicast

A data transfer where a single sender and a single recipient is involved, in short, one-to-one transmission.

Unicast

Broadcast

As the name suggests, it is a one-to-all transfer technique.

  • Limited Broadcasting
    When a sender is broadcasting data in the same network of source address, we use 255.255.255.255 (all the 32 bits of IP address set to 1), called as limited broadcasting address.
Limited Broadcasting
  • Direct Broadcasting
    When a sender is broadcasting data to a different network, this is done by translating all the host ID part bits of the destination address to 1, called a direct broadcast address.
    For example, a destination network is 10.0.0.0, thus, direct broadcast address will be 10.255.255.255.
Direct Broadcasting

Because of the direct broadcast address and network address, we do not use the first and last IP address in a network.

So, the available host addresses in each network class are:

  • Class A: 2²⁴ - 2
  • Class B: 2¹⁶ - 2
  • Class C: 2⁸ - 2

Port

Each process is defined by a port number which is mostly fixed for a particular process, like 80 and 443 is reserved for web service, 25 for SMTP, etc.
So, when we type www.google.com it automatically assumes port number as 80 or 443 depending on the protocol HTTP or HTTPS respectively.

I believe this shall give one an understanding of how with the help of IP address and port number, the client reaches to a destination process and communicate!

--

--