IP Address Class
If you remember the network analogy that we used earlier in the blog furniture was successfully delivered to the correct house because the trucks(which is the IP packets in networking world) knows where exactly to go. Also if you remember every junction/signal has a board that has information about the which direction to take for you to reach the house.
The house address in our example above can be equated to IP addresses in the networking world. Because it is the IP address that uniquely identifies a laptop/PC/Server/Phone or anything that gets connected to network. And hence it is very important that the IP address needs to be unique because duplicate IP address will create confusion about whom exactly to communicate, similar to if there are same address for more than one house.
So if an IP address is a unique identifier like a house address, what is an IP network? An IP network is a group of addresses that can be grouped together; physically or logically(we will get into what logically means). You can think of an IP network as a group of houses in the same community. The community will have the same name and individual houses will have a house number attached to it.
When house address across the world follow some formats like to have Country, State, Postal Code the rule in the networking world is a little different. IP address is 32bit dotted decimal number as shown below with 4 octets and each octet having 8 bits.
If all the bit in the all the octet have the value of 0 then the IP address will look like : –
0.0.0.0 and if all the bits are having value 1 then it will be 255.255.255.255; when you convert the binary to decimal.
When you have 0 for all the bits IP address in binary will look as below:-
When you have 1 for all the bits IP address in binary will look as below:-
This means IPv4 address can have take a range of IP Addresses from 0.0.0.0 to 255.255.255.255
These ranges of IP address are divided into 5 classes namely Class A, Class B, Class C, Class D and Class E.
Class D is used for multicast which means once a packet is sent to this IP address multiple devices(who are registered) are going to receive it if the device is registered or configured for the service. Class E is reserved for experimental purposes.
Let us concentrate our discussion with Class A, B and C as they are unicast IP addresses. Unicast means the packet is targeted to a single server or host. Let us understand how many different networks and host we will be available in each of these Classes.
For routers to identify which class that IP address belongs to there are few bits in each class that is reserved. Below are the reservations for each class:
If you convert the decimal value of the first octet of Class A address into binary the first bit will always be 0, and for Class B first and second bits will be always 10 and finally for class C the first 3 bits will be 110. This is a way to identify the IP address belongs to which class.
For class A network the first octet ie first 8bits are reserved for network and rest of the 3 octets are reserved for host. Out of first 8bits the first bit is always 0 and hence the total number of network that can be formed in class A is using 7 bits. Hence maximum number of first octet numbers that can be generated are 2^7. But 0 and 127 is reserved and that brings the maximum number of networks to 2^7 – 2 = 126. Which means the maximum number class A network available is 126 . Now if you check the number of hosts that can be created using a class A network is 2^24 – 2 = 16,777,214; 2 IP address need to be minused because 1 is broadcast and another is network ID(We will talk more about the network ID later).
For Class B there are total of 16 bits(first 2 octets) for forming the network. But since first 2 bits are always “10” the available networks that can be formed is using a combination of 14 bits, that means 2^14 = 16384 networks available and for each network there are 2^16 – 2 = 65,534 hosts available.
For Class C there are 3 octets that are used for forming the network, but since first 3 bits are always set to 110 we have 21 bits remaining (24 – 3 = 21). Hence we have 2^21 =2,097,152 possible networks and 2^8 – 2 = 254 possible hosts per network.
Also notice for each of the Class there is a default netmask which tells how many bits are for network and how many bits are for hosts. For Class A default mask is 255.0.0.0 When we convert the dotted decimal mask 255.0.0.0 to binary it will be 1111 1111.0000 0000.0000 0000.0000 0000. All the 1 bits indicate that it is the network bits and all the 0 bits indicate those are the host bits. Similarly for each of class as show below:
Which class of the address to be chosen for your organization depends on the how large the organization is and how many hosts, and network will be needed for your organization. For example if you have fewer hosts needed then it is very clear that you can use Class C versus if you have a lot of hosts then you will use the class A network.
So to summarize; the unicast(address assigned/targeted to single host/server) can be broadly categorized into 3 Classes A, B and C. The IP address in any of the class has 2 parts
- Network
- Host
The subnet mask of the IP address helps us to understand which is the network and which one is the host.
Network ID and Broadcast ID for Classful Network
Let us understand the network ID(also called as network address or simply network) and Broadcast ID (also called as broadcast network address or network broadcast). As we have seen earlier depending on the class IP address belongs to we assign some bits for the network and some bits for hosts. For example if it is class A then the first octet is reserved for the network and the rest of 3 octets for host.
Lets take an example 10.1.1.1 IP address. Based in the first octet it is clear that the IP address below to Class A and default mask is 255.0.0.0. Hence the network part is 10 and host part .1.1.1
Network ID is the IP that we get when we make all the host bit to zero. In our example the host part .1.1.1; ie the last 3 octets when we made all of the binary bits to 0 the IP address will look like : –
10.0.0.0 which is the network ID for the IP address 10.1.1.1
Broadcast ID is the IP address we get when we make all the host bit to 1. So in our example the host part .1.1.1; ie the last 3 octet if we made all the bits(in binary) to 1 then the IP will look like
10.255.255.255 which is the broadcast ID.
The network ID and broadcast ID is reserved and can not be assigned as an IP address to any host in that network. So given an IP address for us to find the Network ID and Broadcast ID is a pretty simple 4 steps process.
- Identify which Class the IP address belongs to
- Split the network part and host part
- To get the Network ID make all the bits in the host part to 0
- To get the Broadcast ID make all the bits in the host part to 1