Understanding IP Address and Subnet Mask (A Historical Perspective)

IP Logical Parts

Two most important functions in a data network are:

  1. To uniquely identify each host or computer or device participating in network. This is called addressing.
  2. To be able to connect and move data packets between any devices in a network. This is often called switching and routing by connecting devices to switches and routers respectively.

An IP address and Subnet Mask are very basic entities of data network.

What is an IP Address?


An IP address is a 32 bit number like 11000000101010000000000100000001 in binary or 3232235777 in decimal. So it is written in 4 parts like 11000000.10101000.00000001.00000001 in binary form and 192.168.1.1 in decimal form. This way it is easier to understand.

Now, a unique number is sufficient to identify each host in a network but that alone cannot help in reaching from one host to another. Imagine if every house in world had a unique number or some name, but no state, city and country info. Would it be possible to reach a particular house even if its number is known?

So logically, addresses are made up of parts, like state, city, street and finally house number. Most of the parts of an address are common to many people, like people living at same street or city. Generally only the house number and name finally differentiates between any two similar addresses.

Similarly in case of IP address, we logically partition an IP address in parts so that we can reach a computer from anywhere (yes, obviously if the route exists). Also not that logically partitioning an IP address is different than writing an IP address in 4 parts, that’s just a notation.

So to keep things simple we generally divide an IP address in two logical parts. One is network part and the other is host part. Network part is like street, city, state which is shared by multiple IP addresses. Host part is like house number and name of the person. Both parts together uniquely identifies a host or computer. We can also partition an IP address in more than two parts.

What is a subnet mask?


Subnet mask is a 32 bit number just like an IP address and is written just like it. But subnet mask is not used as a 32 bit number. It cannot hold just any value like IP address. Subnet mask is something which draws a line somewhere is an IP address to help logically partition an IP address into logical parts. Now again, from logical parts I don’t mean writing an IP address as four 8 bit numbers, that’s the notation. I mean logical parts like Network, Sub-network and host, just like state, city and house number.

A subnet mask should only have continuous 1s starting from MSB (Most Significant Bit). Like 11111111.11111111.00000000.00000000. Which means first 16 bits of an IP address belongs to network part and rest is host part. A subnet mask can also have non-contiguous 1s, but that is strictly discouraged and not recommended by RFC 950.

Why is it called Subnet Mask, why not Network Mask?


“Subnet” means sub-network. So the purpose of subnet mask was to create another partition (3rd part) in an IP Address after network part. But then how we defined and identified the network part of an IP address? Why we required another logical partition of sub-networks when we already had network part? Now, to understand all this we need to know a little history of how networks worked in its starting days.

History of Subnet Mask


In 1969:

THERE WAS NO SUBNET MASK!!!

THERE WERE NO NETWORK CLASSES (CLASS A, B, C, D and E)

Standard reserved first 8 bits for network part. That meant we could only have 254 distinct networks and each network can have 16,777,214 IP addresses.

In 1981:

NETWORK CLASSES WERE INTRODUCED!!!

AGAIN, THERE WAS NO SUBNET MASK!!!

24-bits for host address can hold 16,777,214 IP addresses. Not every organization in world requires a network of thousands of computers. Rather we required more networks of smaller size. Also it was clear that different organization have different requirement of network size. This meant that we will have to partition IP addresses in a way so that we can have different sizes of network. The different size of network bits created different classes of network, which we called Class A, Class B and Class C.

But as there was nothing other than IP address, not even subnet mask, we needed a way to identify what is the network class of a given IP address. Take 12.1.2.3 for an example. We cannot identify what part of it belongs to network and to host without any other information given.

In 1981, numbers of networks being used were very less and were limited to 6 LSB (Least Significant Bits) of Network bits (First 8 bits). You can say if 50 networks existed at that time then 50 will take a value of 00110010. So by standard we fixed the values of MSBs of first octet to identify class of an IP address which automatically divided the decimal value of first octet in ranges. Also we wanted that new scheme should not cause to change existing IP addresses in use.

For example Class A’s IP address will always have MSB always 0. Which means any class A address will always be between 0-127 in its first octet.

Class

Network Bits

Host Bits

Range First Octet

Leading Bits

Class A

8

24

0-127

0XXXXXXX

Class B

16

16

128-191

10XXXXXX

Class C

24

8

192-224

110XXXXX

Class D

Not Defined

Not Defined

225-239

1110XXXX

Class E

Not Defined

Not Defined

240-255

1111XXXX

In 1985:

Enough, we require a Subnet Mask now!

Finally in RFC 950 Subnetting was introduced. Soon after classes were introduced, as number of organizations grew at a very past pace, we realized that we needed some way to further partition a network into Sub-networks of smaller sizes. Here was the subnet mask introduced. That is why it is called a “subnet” mask, but not network mask. Use of a subnet mask along with an IP Address also gave the flexibility to define subnets of various sizes to network administrators.

IP Subnet

Network Devices, Operating systems and protocols were updated to accommodate for subnet mask. Classes still existed. Still we used the MSBs to identify Class of an IP address. Subnet mask always took value greater than 255.0.0.0 like 255.240.0.0. We used it to further subnet a Classful network. Subnet mask logically partitioned an IP address into three parts. This methodology of allocating IP addresses is called Classful Networking.

From 1993 onwards:

Classless Networking was introduced!

Why do we need to divide an IP address in three parts, why not just two? You can just merge subnet part with network part using a subnet mask or call it a Network Prefix. Why do we need classes anymore? Nowadays when we enter an IP address 192.168.1.1 in network card properties, subnet mask 255.255.255.0 will be automatically populated in subnet mask field. This does not mean that we cannot set subnet mask 255.0.0.0 for an IP address 192.168.1.1 in case of classless networking. It is just that we are being compatible with Classful network and respecting private IP range. But technically it will work with any network prefix. Network devices, operating systems and protocols do not care about classes anymore.

Students pay a lot of attention to Classful networking, but very less on classless networking. In order to understand classless networking we need to understand how networks evolved. What were the challenges time to time and why we introduced classes, subnet mask, Classless Inter-Domain Routing and finally IPv6?

I will not dig into details of classless networking in this post or why it was necessary (may be in another post), but will only emphasize on the fact that we do not follow Classful networking anymore. Classful networking optimized addressing part of networking, but Classless networking optimized addressing as well as routing mechanism. It made easier to move packets between hosts in a network. Earlier it was Classful Routing and now with Classless Networking it is Classless Inter-Domain Routing (CIDR).

About Dinesh Sharma

Experienced system architect, programmer, and trainer. This blog is a way of giving back and helping the community. So feel free to ask a question or to leave a comment.

  • Ondrej Slacik

    Well done! Amazing insight into IP addressing!

  • Khan

    what is most important part in IP address ?

    • Matthew Shapiro

      The entire thing, probably.. you can’t communicate with a host unless you have the full address (or use multicast..)

  • taimoor malik

    just awesomedetails brother If i wanna contact you regarding networking knowledge so how can i do this ?????? me taimoor malik

    • Thanks Taimoor. Just drop me an email using “Contact Me” if you have any queries.

  • Thanks Bro… it will help my students with better understanding of IP Addresses.
    🙂

  • Rising Lee

    Thanks for the informative history of subnet 🙂 Two thumbs up!

  • muslim abubakar adamu

    nice answer ip addressing question

  • muslim abubakar adamu

    what is most important of mac address and what is the use of mac

    • Peter Afternoon Flaten

      The MAC is used to identify a NIC on the local network. MAC is a bridge from the Physical Layer to the Data Link Layer. Every frame header contains source and destination MAC address information. This header information is used by network switches to direct traffic all based on the MAC addresses. The ARP (address resolution protocol) uses the IP network (Network Layer) to find the unique MAC addresses on the local network so computers trying to send data can complete their frame header so the data can go out on the network.

  • Om Bhadauria

    i like your post and i am trying to get some best information about ip address if you have some thing more for me please send me on [email protected]

  • aprogrammer

    Thanks for the post. You could add here additional information like here – http://sysadm.pp.ua/internet/network-planning.html . With links to RFC, address calculation and so on. Wish it will help.

  • Ananth Kadaba

    Thanks Dinesh, for the very good post. Very clear and useful information about IP addressing.

  • Sunena Garg

    Thank you so much….It was really helpful…..

  • Fried

    I really like the dear information you offer in your articles. In order to understand classless networking we need to understand how networks evolved. What were the challenges time to time and why we introduced classes, subnet mask, Classless Inter-Domain Routing and finally IPv6.

    Fried

  • Eve

    Thank you so so much, this was awesome ^_^ I just loved it