IAE Academy

IPv4 formulas

IPv4: addressing, CIDR, fragmentation and NAT. 9 formulas for GATE CS Computer Networks, each with when to use it. Each is explained in the topic notes.

All 9 IPv4 formulas

ADDRESSES IN A BLOCK

For a block with prefix length p, counting the network and broadcast addresses.

USABLE HOSTS IN A BLOCK

For a block with prefix length p. The two subtracted addresses are the network and broadcast addresses. Valid for p up to 30.

NUMBER OF SUBNETS (CIDR CONVENTION)

s is the number of host bits borrowed (new prefix length minus old prefix length). All-zeros and all-ones subnets are allowed.

NUMBER OF SUBNETS (OLDER CLASSFUL CONVENTION)

Only when the question excludes the all-zeros and all-ones subnet numbers.

BLOCK SIZE IN THE INTERESTING OCTET

The interesting octet is the one where the mask is neither 255 nor 0. Subnets start at multiples of the block size in that octet. If p is a multiple of 8 there is no such octet: the host part is whole octets.

MAXIMUM DATA PER FRAGMENT

H is the header length in bytes (20 without options). Data in every fragment except the last must be a multiple of 8 bytes.

NUMBER OF FRAGMENTS

L is the original total length in bytes, H the header length. Assumes a single fragmentation at one link and the same header length H in every fragment.

FRAGMENT OFFSET FIELD

Measured from the start of the original datagram's data. MF = 1 for every fragment except the last.

DATA BYTES CARRIED BY A FRAGMENT

Byte positions in the original data, numbered from 0. Total length is in bytes; HLEN is in 4-byte words.

Where this was asked: 2018 (1), 2020 (2), 2022 (2), 2023 (1), 2024 (7), 2025 (4), 2026 (3). See the 20 previous-year questions on IPv4. This shows what was asked, not what will be asked.