Authors Top

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

1. Overview

An IP address is a combination of the host and network address. Along with an IP address, we also need the subnet mask to get the exact network address and different logical addresses from a specific network.

Subnetting is one of the most important methods used by classful IP addressing, and it saves lots of IP addresses from being wasted.

In this tutorial, we’ll discuss IP address, broadcast address, network address, and subnet mask in detail. We’ll also present and explain how to determine network and broadcast addresses using an IP address and a subnet mask with numerical examples.

2. IP Address

The term IP address alludes to the Internet Protocol address. In order to transmit data from one computer to another, we require an address or identification for both devices. However, there’re distinctive ways to communicate, but commonly, computers far from each other communicate using the internet and IP address.

Moreover, it’s an address uniquely assigned to each device connected to the network. Therefore, we use an IP address to identify a specific device in a network for communication. Additionally, it’s also called logical address. There’re two categories of IP addresses: global and local IP addresses.

Global IP addresses are accessible for every device connected to the internet. In contrast, local IP addresses aren’t accessible out of that network. Additionally, the network router can assign it manually or dynamically to a host device.

Now, based on the addressing scheme, we can divide IP addresses into two categories: IPv4 and IPv6. An IPv4 has a 32 bit long address and has 4 octets. Additionally, an IP address can range from \mathsf{} to \mathsf{}:


In IPv4, there’re two kinds of addressing: classful and classless. Classful IP addressing is divided further into \mathsf{5} classes: A, B, C, D, and E. Moreover, we can perceive the class of an IP address using the first few bits in binary form notation.

Furthermore, we can divide the IP addresses into classes based on the requirement. Specifically, Class A is designed for substantial organizations. Furthermore, we generally use classes B, C, D, E for mid-size organizations, small organizations, multicasting, and experimental uses:

Rendered by

Furthermore, as we connect more devices to the internet or network, there might be a situation when we don’t have any free unique IP address to assign to new devices. Hence, to overcome this situation, IPv6 is introduced.

IPv6 is the most recent version of the Internet Protocol. Moreover, we express it in hexadecimal format. This newest version was developed by the Internet Engineering Task Force in 1994 to fulfill the exploding needs of Internet users and devices.

Moreover, IPv6 uses a 128-bits addressing scheme and offers many features not present in IPv4. Next, let’s take a look at an IPv6 address: FDEC:BS68:7654:3210:ADFF:QBGF:2522:FIIF

Some of the features in IPv6 are built-in security, scoped addresses, auto-configuration, Quality of Service (QoS), new header format, and larger address space. Most importantly, most operating systems released since 2000 supports IPv6 either directly or indirectly.

3. Network Address

We know that an IP address combines a network and broadcast address. Therefore, the IP address class determines the network ID, often known as the network address.

In general, we use the first \mathbf{8} bits of the IP address for the network address in class A. Similarly, we specify the first 16 and 32 bits for the network address in classes B and C.

Moreover, as class A uses 8 bits of IP address for the network address, there can be a maximum of 127(2^7) network addresses possible. Similarly, Class B uses 16 bits, but the first 2 bits are always 10. Hence, we use the remaining bits to assign network addresses. With the remaining 14 bits, there can be 2^{14} network addresses.

Similarly, class C uses 24 bits, but 3 bits are always 110. Hence, we use the remaining 21 bits to assign network addresses, which means there can be 2^{21} network addresses:

Network address

4. Broadcast Address

In any network, when we need to send data to a host device connected to the network, a router uses a broadcast address. Additionally, every network has one unique broadcast address.

The process of sending data to every device or node connected to a network is known as broadcasting. Moreover, there’s only one source in broadcasting, and other host devices are the destinations.

Next, we can simply replace the last bits of a network address by \mathsf{1}, and that would turn into a broadcast address. Therefore, we can determine the broadcast address of any network using the subnet mask and the IP address of that network.

Let’s take an example. Let’s take a class C IP address: It’s a network address. Accordingly, the broadcast address for the given network address would be

5. Subnet Mask

A subnet mask is used in a process known as subnetting, in which a large network is divided into smaller networks. More specifically, it’s like dividing a network into several contiguous network groups, and each group is known as a subnet. Furthermore, this process is implemented to reduce the wastage of IP addresses due to classful addressing.

A subnet mask is used to determine the network address and host address:

Rendered by

6. Determining Network and Broadcast Address

Let’s take an example for calculating network and broadcast addresses using a subnet mask. Now, in order to calculate network and broadcast addresses, we need two pieces of information: the IP address of the device and the subnet mask of the network.

Let’s assume the IP address is and the subnet mask is

The first step is to write down the IP address and subnet mask in binary:

    \[IP \hspace{0.1cm} Address = = 1100 0000. 1010 1000. 0000 0010. 0000 0100\]

    \[Subnet \hspace{0.1cm} mask = = 1111 1111 . 1111 1111. 1111 1111. 1111 0000\]

Bits in the subnet mask which are \matfsf{1} denotes the network address. Similarly, the bits which are \matfsf{0} will be used for the broadcast address:

Subnetmask and ip addr example


In this example, we can see that the last 4 bits of the subnet mask are \matfsf{0}. Hence, this means we can connect 14 devices ( - and the broadcast IP address will be Therefore, the network address will be

Network host ids subnet mask

Hence, we can also rewrite the above IP address: Here, 28 refers to the 28 bits of the subnet mask, which are \matfsf{1}.

There might be some confusion on how we derive network addresses from a subnet mask. From the above example, it’s clear that bits which are \matfsf{1} in the subnet represent a network address.

Moreover, the IP address belongs to class C. Hence, we know that in class C, the first 24 bits of the IP address is used for the network address, and the rest is used for the host address. In contrast, there’s a case in subnet mask where network addresses can exceed 24 bits.

In general, the division of the first 24 bits for network and host addresses is the default configuration for the class C IP address. Hence, we can change that by changing the number of \matfsf{1} in the subnet mask. Moreover, we know that the default subnet mask for class C is

Therefore, for example, we can change some bits of the subnet mask:

    \[IP \hspace{0.1cm} Address = = 1100 0000. 1010 1000. 0000 0010. 0000 0100\]

    \[Subnet \hspace{0.1cm} mask = = 1111 1111 . 1111 1111. 1111 1111 . 1111 0000\]

Let’s change a bit of the subnet mask:

    \[Subnet \hspace{0.1cm} mask = = 1111 1111. 1111 1111. 1111 1111. 111 \mathbf{0} 0000\]

Hence, the IP address with this subnet mask will be in a different network. This is the way we can divide a network using the subnet mask. Therefore, now we can rewrite the IP address as

7. Conclusion

In this tutorial, we discussed IP address, broadcast address, network address, and subnet mask thoroughly. We also presented numerical examples explaining how to determine network and broadcast addresses using an IP address and a subnet mask.

Authors Bottom

If you have a few years of experience in Computer Science or research, and you’re interested in sharing that experience with the community, have a look at our Contribution Guidelines.

Comments are closed on this article!