Introduction
Binary notation makes a split inside an octet visible. Convert each byte of a dotted IPv4 address to eight bits, then use the same bit positions to reconstruct the address from a binary diagram.
Formula and calculation
value = octet1×256^3 + octet2×256^2 + octet3×256 + octet4IPv4 octets are ordered from most significant to least significant. Binary output uses exactly 32 bits, including leading zeroes in each octet.
- octet · byte
- one decimal address component from 0 through 255
Method and concepts
The place values within an octet are 128, 64, 32, 16, 8, 4, 2 and 1. A one contributes its place value. A zero contributes nothing while retaining its position. Four complete octets form the 32-bit address, with the first dotted octet at the most significant end.
- Start with four decimal octets, or with a binary address in the format shown by the input field.
- Keep each eight-bit boundary visible while checking the result. Add the place values for the one bits within each group.
- For subnet work, count the prefix bits from the left across groups. The remaining positions can vary within that prefix.
IPv4 addresses and packet headers diagram
- IP packet · 1,500 bytes
- IPv4 header · 20 bytes
- IP payload · 1,480 bytes
- TCP data · 1,460 bytes
Worked examples
Find the bit positions in 192.0.2.13
- 192 = 128 + 64, giving 11000000. Zero gives 00000000, and 2 gives 00000010.
- For 13 choose 8, 4 and 1. Its eight positions read 00001101. In network order the groups are 11000000 00000000 00000010 00001101.
- To check the reverse direction, add 8 + 4 + 1 in the last group. At /28 its first four bits belong to the prefix, so this last octet can vary from 0 through 15.
IPv4 addresses and packet headers: Read the first IPv4 byte 0x45
- 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.
- Multiply 5 by 4 bytes to obtain the 20-byte header. With Total Length 1,500, the IP payload contains 1,480 bytes.
- 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
| Octet | Binary | Nonzero weights |
|---|---|---|
| 192 | 11000000 | 128 + 64 |
| 0 | 00000000 | None |
| 2 | 00000010 | 2 |
| 13 | 00001101 | 8 + 4 + 1 |
Reading the result
The zeros at the left of each group preserve its width. They make it possible to lay a mask directly underneath the address and see exactly which bit positions a subnet calculation retains.
Common mistakes
- Writing 13 as four bits in an address diagram and joining it directly to the preceding octet.
- Reversing the order of bit weights. The rightmost position contributes one.
Frequently asked questions
Why is 128 written 10000000?
The single one occupies the 2^7 position and all smaller positions are zero. The adjacent value 127 uses all seven lower positions instead.
How do I read 10101010 without a calculator?
Add the weights under the one bits. Here 128 + 32 + 8 + 2 gives 170.
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
- RFC 791, Internet Protocol, sections 3.1 and 3.2
Reference source for the concepts and service described in this guide.
- RFC 791 · IPv4 header and address format
- RFC 1191 · IPv4 path MTU discovery
- IANA · Protocol numbers

