IPv4 · Local calculator

IPv4 Calculator

An interface record often contains an address such as 192.0.2.77/26. The four decimal numbers identify the interface address. The number after the slash tells you which other addresses share its prefix.

Inputs

Result

Interface address
192.0.2.77
Position in subnet
Interior host position
Network prefix
192.0.2.64/26
Subnet mask
255.255.255.192
Last address
192.0.2.127
Broadcast
192.0.2.127
Address count
64
Host range
192.0.2.65 – 192.0.2.126
Host positions
62
Address offset
13
Address bits Prefix 26 · 6 host bits

Binary address value 11000000000000000000001001001101. The first 26 bits belong to the prefix.

Conventional subnet, excluding both endpoints. Special-purpose ranges can further restrict assignment.

In this guide12 sections

Introduction

An interface record often contains an address such as 192.0.2.77/26. The four decimal numbers identify the interface address. The number after the slash tells you which other addresses share its prefix.

Formula and calculation

Address block from a prefix
addresses = 2^(width − prefix); last = network + addresses − 1

A prefix fixes the leading bits and leaves the remaining bits available to identify values in the block. The calculator aligns the network address by clearing those remaining bits.

width · bits: 32 for IPv4 or 128 for IPv6
address length
prefix · bits
number of leading network bits
network · address
first aligned address in the block

Method and concepts

An IPv4 address occupies four octets, each eight bits wide. A prefix fixes the leftmost bits of that 32-bit value. Holding those bits constant and setting every remaining bit to zero gives the first address of the block. Setting every remaining bit to one gives its last address.

  1. Read the address and prefix length together from the interface record. A four-part address alone leaves the subnet boundary unspecified.
  2. Enter the address and prefix. Compare the input with the calculated network address to see which host bits were cleared.
  3. Use the two block boundaries when comparing addresses. For a conventional multiaccess LAN, use the host range when counting possible interface assignments.

IPv4 addresses and packet headers diagram

  1. IP packet · 1,500 bytes
  2. IPv4 header · 20 bytes
  3. IP payload · 1,480 bytes
  4. TCP data · 1,460 bytes
Read the sizes as a decomposition. After removing a 20-byte IPv4 header, a further 20-byte TCP header leaves 1,460 bytes for TCP data.

Worked examples

Locate 192.0.2.77 inside a /26

  1. A /26 keeps 24 bits from the first three octets and two bits from the last. Six host bits give a block of 64 addresses.
  2. Write 77 as 01001101. Keeping the first two bits gives 01000000, or 64. Filling the remaining six with ones gives 01111111, or 127.
  3. The block is 192.0.2.64/26. On a conventional LAN its first and last ordinary host addresses are 192.0.2.65 and 192.0.2.126.

IPv4 addresses and packet headers: Read the first IPv4 byte 0x45

  1. Split 0x45 into the high hex digit 4 and low digit 5. The upper four bits identify version 4. The lower four encode an IHL of five words.
  2. Multiply 5 by 4 bytes to obtain the 20-byte header. With Total Length 1,500, the IP payload contains 1,480 bytes.
  3. If Protocol is 6 and the TCP header also occupies 20 bytes, the segment carries 1,460 application bytes. Adding IPv4 or TCP options reduces that amount at the same packet size.

Reference table

IPv4 Calculator reference
Value for 192.0.2.77/26Last octet in binaryDecimal
Input0100110177
Network0100000064
Last address01111111127

Reading the result

Both block endpoints belong to the prefix. Under the conventional LAN interpretation, the bottom endpoint names the network and the top endpoint is its directed broadcast. Address assignment also depends on local reservations and the purpose of the address space.

Common mistakes

  • Taking the first three octets as the network boundary for every address.
  • Using the block's first address as the default gateway. The gateway is an assigned interface address chosen by the operator.

Frequently asked questions

Can two interfaces have the same first three octets and different subnets?

Yes. With /26, 192.0.2.77 belongs to the .64 block while 192.0.2.130 belongs to the .128 block. Their fourth octets carry network bits.

What can a calculation tell me about active devices?

It gives the mathematical boundaries of the prefix. An inventory or address-management record is needed to identify which addresses have actually been assigned.

What does /32 mean on a route?

All 32 address bits must match. The route represents exactly one IPv4 value and can identify a loopback or another specific destination.

Is the IPv4 Protocol number the service port?

No. The protocol number selects a payload format, for example UDP 17. A UDP header then carries source and destination port numbers.

How many bytes are in the minimum IPv4 header?

The minimum header is 20 bytes. The IHL field counts 32-bit words, so a value of five represents 20 bytes; options can make it longer.

Does IPv4 Total Length include Ethernet framing?

No. It counts the IPv4 header and IPv4 payload. Link-layer framing is outside that length field.

What happens when an IPv4 packet is larger than an outgoing MTU?

Depending on the Don't Fragment setting and path behavior, it may be fragmented or dropped with an ICMP message. Path MTU discovery uses this feedback to find a usable packet size.

Does an IPv4 Protocol number identify a TCP or UDP port?

No. The Protocol field identifies the payload protocol, such as TCP or UDP. A TCP or UDP header then contains the service ports.

What does TTL protect against?

IPv4 Time To Live bounds how many forwarding hops a packet can survive. Routers decrement it so a packet cannot circulate forever in a forwarding loop.

Is the IPv4 header checksum an end-to-end payload checksum?

No. It covers the IPv4 header only and is recomputed when mutable header fields such as TTL change. Transport protocols have separate integrity fields.

Can IPv4 fragmentation be reassembled at every router?

No. Fragmentation can occur during forwarding when permitted, but fragments are normally reassembled by the destination host, not each intermediate router.

Why use documentation IPv4 ranges in examples?

The designated documentation blocks avoid using a real organization's address in examples. They should not be treated as ordinary public service addresses.

What is the difference between limited broadcast and directed broadcast?

The limited broadcast address is 255.255.255.255 and is confined to the local link. A directed broadcast targets the all-ones host part of a particular IPv4 subnet and is commonly filtered by routers.

Can two routers advertise the same IPv4 prefix?

They can provide alternative routes to the same prefix. Routing policy and metrics determine whether one is preferred or both are installed for load sharing.

Why is classful addressing considered historical?

The original A, B, and C boundaries fixed network sizes at coarse octet edges. CIDR allows a prefix boundary at any bit and is used for modern allocation and routing.

What is the IPv4 header checksum recalculated over?

It covers the IPv4 header, not the payload. Because forwarding changes TTL, a router updates the checksum as the packet traverses the path.

When can a /31 IPv4 prefix be useful?

On a point-to-point link, RFC 3021 allows both addresses to be assigned to the two endpoints. It avoids reserving separate network and broadcast values where those functions are not needed.

Further learning and references