Contents

Introduction
Network ID
Subnet Mask
Supernet
VLSM
Private IP Address

Introduction

What is IP Address? Even a non-IT person knows that the IP Address is the network address of a PC. ISP could know the physical location of an IP Address so that police in the TV drama (in Hong Kong) always catch bad guys by finding out their IP Address. And how about Subnet Mask? This article will explain both of them.

ipv4

Network ID

Version 4 is the IP (Internet Protocol) version commonly used nowadays. It is also called IPv4. IPv4 is consisted of 32 Bits value, that is 32 digits of 1 or 0. For example, 00001011110000100011111101100100. It is only readable by machine, but not human. For easier to remember, we divide the IP Address into 4 groups and add a dot between each groups like this, 00001011.11000010.00111111.01100100. And then translate each group from binary to decimal. It becomes the common format that we always see, 11.194.63.100. Each computer, mobile phone, tablet, camera, etc should have an unique IP Address to communicate. But my computer do not connect with your computer directly, how the two computers communicate? The answer is router. Routers help to find out the location of the IP Address and transmit the data to the destination and vice versa.

Router have a list or route records. Each record consist of IP Address and its relative location. If a message comes to the router, it sends the message to another router depends on the list of records. The routers delivery the messages one by one until the message arrive the destination. Like DHL, a courier receives a document and dispatches it to a station. Another courier dispatches it to the other station and so on. At last, a courier collect the document and take to the receiver.

ipv4

ipv4

It is a tiny model of the computer network. Since there are million thousands of routers in the real world, how do routers remember all the IP Addresses and their relative locations? For instance, R1 not only need to remember 167.42.36.12, 5.90.13.28 and their location, and also 167.24.23.53, 167.63.75.112, 167.69.54.167, 5.12.43.83, 5.90.36.13 and so on. It is not possible. So, we need to group all the similar IP Address with the same prefix to the same location to reduce the total number of records.

ipv4

By using this method, we can assign the IP Addresses with different prefix to different companies so that routers can record the IP Addresses and its locations effectively. To make it clear, we call the first 8 Bits as Network ID and the resting 24 Bits as Host ID. Take 11.194.63.100 as an example, 11 is the Network ID and 194.63.100 is the Host ID.

00001011.11000010.00111111.01100100
Network ID                   Host ID

To indicate a Network ID, we change all the resting Bits to 0 other than the first 8 Bits. For example, 11.0.0.0.

But please try to calculate that how many IP Addresses are there in the same Network ID? That is, how many possible values are there for Network ID 11.0.0.0?

11.X.X.X  => 00001011.XXXXXXXX.XXXXXXXX.XXXXXXXX

The total number equals to 2 to the power of 24, that is 16,777,216 different values. That is good for very big companies like Microsoft or IBM. I mean they can really use up this number of IP Addresses. But it wastes a lot of IP Addresses if we give it to a small company.

On the other hand, we can only assign IP Addresses to 256 companies for Network ID from 0 to 255. Of course, it is not enough. Some experts give us a solution. We can increase the number of Network ID Bits (it also decreases the number of Host ID Bits at the same time). For example, increase the number of Network ID Bits to 16 Bits, the number of Network ID will increase from 256 to 65,536 that can be assigned to much more companies. But each Network ID can only support 65,536 hosts. By using this concept, there are three different categories for Network ID, those are Class A, Class B and Class C.

Class A

If the first Bit of Network ID is 0, use the first 8 Bits to be the Network ID. Every Class A contains 2^24 = 16,777,216 IP Addresses.

Class B

If the first 2 Bits of Network ID are 10, use the first 16 Bits to be the Network ID. Every Class B contains 2^16 = 65,536 IP Addresses.

Class C

If the first 3 Bits of Network ID are 110, use the first 24 Bits to be the Network ID. Every Class C contains 2^8 = 256 IP Addresses.

ClassNetwork IDLength of Network IDLength of Host IDNumber of IP
A 0XXXXXXX 8 24 16,777,216
B 10XXXXXX.XXXXXXXX 16 16 65,536
C 110XXXXX.XXXXXXXX.XXXXXXXX 24 8 256

We can also know the IP range of the network. For example, Network ID 11.0.0.0 is a Class A network and Network ID is 00001011. So, all 00001011.XXXXXXXX.XXXXXXXX.XXXXXXXX belongs to this network, the IP range will be from 11.0.0.0 to 11.255.255.255.

We call it Classful Network when using this method to classify the network. Any Routing Protocol that support Classful Network is a Classful Routing Protocol, such as, RIPv1 and IGRP.

Subnet Mask

Classful is good! And what else? Networking develop so rapid and the Network ID is not enough again. Computer experts come out to help us as usual, they suggest to divide the Class A, B and C Network into smaller network that is called Subnet. Since we already known that tuning the length of Network ID can varies the size of network, so why we only use 8, 16 and 24 prefix? We can use any lengths!

For example, a Class C network 200.52.62.0 (11001000.00110100.00111110.00000000), the length of Network ID is 24 and it contains 256 IP Addresses. If we increase the length of Network ID to 25, the network will be divided into 2 pieces and each of them contains 128 IP Addresses.

ClassNetwork IDLength of Network IDLength of Host IDNumber of IP
Original Network 11001000.00110100.00111110 24 8 256
Subnet A 11001000.00110100.00111110.0 25 7 128
Subnet B 11001000.00110100.00111110.1 25 7 128

Subnet A contains IP Addresses 11001000.00110100.00111110.0XXXXXXX, that is from 200.52.62.0 to 200.52.62.127

Subnet B contains IP Addresses 11001000.00110100.00111110.1XXXXXXX, that is from 200.52.62.128 to 200.52.62.255

Problems! The rule of Classful Address has been broken! We do not know the length of Network ID now since it varies. So, we need to have Subnet Mask. From now on, add a Subnet Mask behind the IP Address for calculating the length of Network ID. Subnet Mask is also a 32 Bits value. Take the example at previous session, the Network ID length of Subnet A is 25. We changes it to 25 1s and pad it to 32 Bits with 0s (add 7 0s). The Subnet Mask of Subnet A will become 11111111.11111111.11111111.10000000, that is 255.255.255.128. To represent the IP Address 200.52.62.86 in Subnet A, we need to write 255.255.255.128 / 255.255.255.128.

To calculate the Network ID, first step is translating both the IP Address and Network Mask to binary. And then use "AND" algorithm.

IP Address 
1 1 0 0 1 0 0 0 . 0 0 1 1 0 1 0 0 . 0 0 1 1 1 1 1 0 . 0 0 1 1 1 0 0 0
Subnet Mask 
1 1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 . 1 0 0 0 0 0 0 0
Network ID 
1 1 0 0 1 0 0 0 . 0 0 1 1 0 1 0 0 . 0 0 1 1 1 1 1 0 . 0 0 0 0 0 0 0 0

And we get the Network ID = 200.52.62.0

Another example, 200.52.62.136 / 255.255.255.128

IP Address 
1 1 0 0 1 0 0 0 . 0 0 1 1 0 1 0 0 . 0 0 1 1 1 1 1 0 . 1 0 0 0 1 0 0 0
Subnet Mask 
1 1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 . 1 1 1 1 1 1 1 1 . 1 0 0 0 0 0 0 0
Network ID 
1 1 0 0 1 0 0 0 . 0 0 1 1 0 1 0 0 . 0 0 1 1 1 1 1 0 . 1 0 0 0 0 0 0 0

We get the Network ID = 200.52.62.128

Other than binary and decimal, we can use prefix to represent Subnet Mask. Prefix is the number of 1 Bits. If we want to write 255.255.255.0, we can write /24 alternately. If we want to write 255.252.0.0, we can write /14 alternately. It is more convenient.

Supernet

We can split the network into subnet, we can also merge networks to form Supernet oppositely. For example, we have four continuously networks, 16.2.64.0 / 255.255.255.0, 16.2.65.0 / 255.255.255.0, 16.2.66.0 / 255.255.255.0 and 16.2.67.0 / 255.255.255.0. To merge the four networks, change the IP Addresses to binary,

00010000.00000010.01000000.00000000
00010000.00000010.01000001.00000000
00010000.00000010.01000010.00000000
00010000.00000010.01000011.00000000

The binary Network ID shows that the first 22 Bits are the same. In other words, if we decrease the Network ID length to 22 Bits, it includes the four networks. So, the Supernet Network ID would be 00010000.00000010.01000000.00000000, that is 16.2.64.0. And the Subnet Mask is 22 Bit, equal to 255.255.252.0.

VLSM

The free style (freely increase and decrease) of Subnet Mask is called Variable Length Subnet Masking (VLSM). A network that used VLSM is called Classless Network. Routing Protocol which support Classless Network is called Classless Routing Protocol, such as OSPF and EIGRP.

Remember that the first IP Address in a network is called Network ID, it cannot be used for hosts. The last IP Address in a network is called Broadcast Address and cannot be used for hosts also. When using VLSM, a meaningful network should contain more than 2 IP Addresses. So, Subnet Mask /30, /31, /32 is not a usable mask.

Subnet MaskPrefixNumber of IPActual Usable IPRemark
255.255.255.252 /30 4 2  
255.255.255.248 /29 8 6  
255.255.255.240 /28 16 14  
255.255.255.224 /27 32 30  
255.255.255.192 /26 64 62  
255.255.255.128 /25 128 126  
255.255.255.0 /24 256 254 Traditional Class C
255.255.254.0 /23 512 510  
255.255.252.0 /22 1,024 1,022  
255.255.248.0 /21 2,048 2,046  
255.255.240.0 /20 4,096 4,094  
255.255.224.0 /19 8,192 8,190  
255.255.192.0 /18 16,384 16,382  
255.255.128.0 /17 32,768 32,766  
255.255.0.0 /16 65,536 65,534 Traditional Class B
255.254.0.0 /15 131,072 131,070  
255.252.0.0 /14 262,144 262,142  
255.248.0.0 /13 524,288 524,286  
255.240.0.0 /12 1,048,576 1,048,574  
255.224.0.0 /11 2,097,152 2,097,150  
255.192.0.0 /10 4,194,304 4,194,302  
255.128.0.0 /9 8,388,608 8,388,606  
255.0.0.0 /8 16,777,216 16,777,214 Traditional Class A
254.0.0.0 /7 33,554,432 33,554,430  
252.0.0.0 /6 67,108,864 67,108,862  
248.0.0.0 /5 134,217,728 134,217,726  
240.0.0.0 /4 268,435,456 268,435,454  
224.0.0.0 /3 536,870,912 536,870,910  
192.0.0.0 /2 1,073,741,824 1,073,741,822  
128.0.0.0 /1 2,147,483,648 2,147,483,646  
0.0.0.0 /0 4,294,967,296 4,294,967,294  

Private IP Address

Some IP Addresses is reserved for internal use or testing only. It is not routed on the Internet. They are very famous network (Private IP) that you may know this already,

10.0.0.0 - 10.255.255.255 (16,777,216 IP Address)
172.16.0.0 - 172.31.255.255 (1,048,576 IP Address)
192.168.0.0 - 192.168.255.255 (65,536 IP Address)

Since the routers on the Internet do not handle these IP Addresses. If we want to use these addresses for our internal network and these hosts want to access Internet, we need to use Network Address Translation (NAT). NAT translates Private IP Addresses to Public IP Addresses. A very good example is the wireless router in our home. The PCs in our home have Private IP Addresses. They connect to the routers by this Private IP and the router translate the Private IP to Public IP to allow the PCs to access the Internet.

ipv4

Source