How to calculate Network Address and Broadcast Address

To calculate the network and broadcast addresses for an IPv4 address, you need the IP address and the subnet mask (or a prefix length, also known as CIDR notation).

The process involves converting these numbers into binary and performing a bitwise AND operation for the network address and a bitwise OR operation for the broadcast address.


What is Network Address:

A network address is a unique identifier assigned to a network or a subnet within a larger network. It is not an address assigned to a specific device, but rather a collective identifier for all devices that are part of that particular network segment. In the context of IPv4, the network address is the first address in the range of IP addresses for a given subnet.

Key Characteristics Network Address:

  • Identifies the Network: The primary purpose of the network address is to identify the network itself, allowing routers to efficiently forward data packets to the correct network. Routers use the network portion of the IP address to make routing decisions.
  • Cannot Be Assigned to a Device: You cannot assign the network address to a host (like a computer, printer, or server) on the network. It’s a reserved address for the network as a whole.
  • Determined by the Subnet Mask: The network address is calculated by combining an IP address with a subnet mask. The subnet mask determines which part of the IP address represents the network and which part represents the host.

What is Broadcast Address:

A broadcast address is a special IP address used to send data to all devices on a network simultaneously. Instead of targeting a single host, a packet sent to the broadcast address is delivered to every device within that specific network segment.

A broadcast address is the last address in a range of IP addresses for a given subnet. It is formed by setting all the host bits of the IP address to ‘1’s. When a device sends a packet to this address, the network router or switch recognizes it as a broadcast and forwards the packet to every device connected to that network segment.

Key Characteristics of Broadcast Address:

  • Network-Wide Communication: It facilitates one-to-many communication, which is useful for tasks like dynamic host configuration protocol (DHCP) requests, where a new device needs to request an IP address from a DHCP server.
  • Cannot Be Assigned to a Device: Like the network address, the broadcast address is reserved and cannot be assigned to an individual host.
  • Calculated Using the Subnet Mask: You can determine the broadcast address for a network by performing a bitwise OR operation between the IP address and the inverse of the subnet mask. For example, if a network has the IP address 192.168.1.1 and a subnet mask of 255.255.255.0, the broadcast address would be 192.168.1.255.

How to Calculate Network Address and Broadcast Address

The rule is followed while calculating Network and Broadcast Address of any given IPV4 address

Step1: Convert both IP Address and Subnet Mask to Binary Number

First, convert both the IP address and the subnet mask into their 32-bit binary representations. Each octet (the number between the dots) is a byte and is converted into an 8-bit binary number.

Example:

  • IP Address: 192.168.1.10
  • Subnet Mask: 255.255.255.0

Binary Conversion:

  • IP Address: 11000000.10101000.00000001.00001010
  • Subnet Mask: 11111111.11111111.11111111.00000000

Step 2. Calculate the Network Address by performing Bitwise AND Operation between Binary of IP and Subnet Mask

The network address is the first address in the subnet. To find it, perform a bitwise AND operation between the binary IP address and the binary subnet mask. A bitwise AND compares corresponding bits from both numbers; if both bits are 1, the result is 1; otherwise, it’s 0.

Example:

  • IP Address: 11000000.10101000.00000001.00001010
  • Subnet Mask: 11111111.11111111.11111111.00000000
  • Bitwise AND: 11000000.10101000.00000001.00000000

Convert the resulting binary back to decimal:

  • 11000000 = 192
  • 10101000 = 168
  • 00000001 = 1
  • 00000000 = 0

Network Address: 192.168.1.0


Step 3. Calculate the Broadcast Address by Performing Bitwise OR operation between binary of IP and inverted Binary of Subnet Mask

The broadcast address is the last address in the subnet. It’s used to send data to all devices on the network. To find it, first find the inverse of the subnet mask. Then, perform a bitwise OR operation between the IP address and the inverted subnet mask. A bitwise OR compares corresponding bits; if either bit is 1, the result is 1; otherwise, it’s 0.

Example:

  • IP Address: 11000000.10101000.00000001.00001010
  • Subnet Mask: 11111111.11111111.11111111.00000000

Inverse of Subnet Mask:

  • 00000000.00000000.00000000.11111111

Bitwise OR:

  • IP Address: 11000000.10101000.00000001.00001010
  • Inverse Mask: 00000000.00000000.00000000.11111111
  • Bitwise OR: 11000000.10101000.00000001.11111111

Convert the resulting binary back to decimal:

  • 11000000 = 192
  • 10101000 = 168
  • 00000001 = 1
  • 11111111 = 255

Broadcast Address: 192.168.1.255