IPv4 Addressing and Binary Fundamentals

Learning Objectives

Pre-Quiz: The 32-Bit IPv4 Address

A colleague writes an IPv4 address as 192.300.10.1. Without any conversion, why can you immediately tell it is invalid?

Because valid IPv4 addresses may only contain the digits 0 and 1
Because 300 exceeds 255, and no 8-bit octet can represent a value that large
Because an address can never have two octets that both contain the digit 0
Because the second octet must always be smaller than the first octet

Why did the designers of IPv4 split the 32-bit address into four octets and write them in dotted-decimal form?

The dots change the underlying number so routers can process it faster
Each octet is stored on a separate physical wire, so four groups are required
Chunking the 32 bits into four readable decimal groups makes the address manageable for humans without altering the underlying value
Splitting into octets increases the total number of addresses available

An octet can hold exactly 256 distinct values, yet the highest value you can write is 255. What explains this?

One value is always reserved for the network, leaving 255 usable
The 256 values are counted starting at 0, so they span 0 through 255 inclusive
255 and 256 both fit in 8 bits, but 256 is skipped by convention
An 8-bit field actually holds only 255 values, not 256

The IPv4 address space contains roughly 4.29 billion addresses. Which fact most directly produces that number?

There are 32 total bits, and 2^32 is about 4.29 billion
There are 4 octets, and 4 × 255 gives about 1,020 addresses
Each octet holds 256 values, and 256 × 4 gives 1,024 addresses
The dots between octets each add a billion possibilities

In the address 192.168.10.1, what exactly does the number 168 represent?

The decimal stand-in for the second 8-bit octet of the 32-bit address
A separator that marks the boundary between network and host
The number of hosts allowed on the network
A 16-bit value spanning the first two octets

The 32-Bit IPv4 Address

Key Points

An IPv4 address is a 32-bit number. Because 32 bits is unwieldy to read all at once, IPv4 splits the address into four equal groups of 8 bits each, and each group is called an octet (the prefix oct- means eight). Four octets of 8 bits each gives 4 × 8 = 32 bits total.

Figure 2.1: The 32-bit IPv4 address split into four 8-bit octets

graph TD A["IPv4 Address (32 bits)"] A --> O1["Octet 1 (8 bits)"] A --> O2["Octet 2 (8 bits)"] A --> O3["Octet 3 (8 bits)"] A --> O4["Octet 4 (8 bits)"] O1 --> D1["Decimal 0-255"] O2 --> D2["Decimal 0-255"] O3 --> D3["Decimal 0-255"] O4 --> D4["Decimal 0-255"]

Writing out all 32 bits — for example 11000000101010000000101000000001 — is error-prone. So we use dotted-decimal notation: convert each 8-bit octet into its decimal equivalent (0 to 255) and separate the four numbers with dots. That 32-bit string becomes the familiar 192.168.10.1. The same address lives in two representations at once:

RepresentationOctet 1Octet 2Octet 3Octet 4
Dotted-decimal192168101
Binary11000000101010000000101000000001

The dots are purely for human convenience; the computer sees one continuous 32-bit stream. Each octet spans 0 to 255 because an 8-bit field represents exactly 2^8 = 256 distinct values, counted starting at 0. The minimum 0 is every bit off (00000000); the maximum 255 is every bit on (11111111). Because each of the four octets independently spans 0-255, the whole space holds 2^32 ≈ 4.29 billion addresses. If you ever see an octet larger than 255, you know instantly it is invalid.

Visual animation — coming soon

Post-Quiz: The 32-Bit IPv4 Address

A colleague writes an IPv4 address as 192.300.10.1. Without any conversion, why can you immediately tell it is invalid?

Because valid IPv4 addresses may only contain the digits 0 and 1
Because 300 exceeds 255, and no 8-bit octet can represent a value that large
Because an address can never have two octets that both contain the digit 0
Because the second octet must always be smaller than the first octet

Why did the designers of IPv4 split the 32-bit address into four octets and write them in dotted-decimal form?

The dots change the underlying number so routers can process it faster
Each octet is stored on a separate physical wire, so four groups are required
Chunking the 32 bits into four readable decimal groups makes the address manageable for humans without altering the underlying value
Splitting into octets increases the total number of addresses available

An octet can hold exactly 256 distinct values, yet the highest value you can write is 255. What explains this?

One value is always reserved for the network, leaving 255 usable
The 256 values are counted starting at 0, so they span 0 through 255 inclusive
255 and 256 both fit in 8 bits, but 256 is skipped by convention
An 8-bit field actually holds only 255 values, not 256

The IPv4 address space contains roughly 4.29 billion addresses. Which fact most directly produces that number?

There are 32 total bits, and 2^32 is about 4.29 billion
There are 4 octets, and 4 × 255 gives about 1,020 addresses
Each octet holds 256 values, and 256 × 4 gives 1,024 addresses
The dots between octets each add a billion possibilities

In the address 192.168.10.1, what exactly does the number 168 represent?

The decimal stand-in for the second 8-bit octet of the 32-bit address
A separator that marks the boundary between network and host
The number of hosts allowed on the network
A 16-bit value spanning the first two octets
Pre-Quiz: Binary and Decimal Conversion

Reading the place values of an octet left to right (128, 64, 32, 16, 8, 4, 2, 1), what pattern relates each column to its neighbor?

Each place value is double the one to its right (and half the one to its left)
Each place value is 32 greater than the one to its right
Each place value is the square of the one to its right
The place values repeat in a cycle after the fourth column

Convert the binary octet 10101100 to decimal by summing the place values under each 1.

172
176
168
160

Using the "highest column that fits" method, what is 244 in binary?

11110100
11101100
11110010
11100100

In the decimal-to-binary subtraction method, what happens to your running total right after you write a 1 for a column?

You subtract that column's place value from the running total
You add that column's place value to the running total
You reset the running total to 128 and start over
You divide the running total in half

Subnet-mask bytes are values with contiguous 1s from the left, like 128, 192, 224, 240. Following that pattern, what is the binary for 240?

11110000
11100000
00001111
11111000

Binary and Decimal Conversion

Key Points

Every subnetting operation flows through binary, so fluent conversion is the core skill of the chapter. Within a single octet, each bit position carries a fixed place value, reading left to right from most to least significant bit:

Bit position2^72^62^52^42^32^22^12^0
Place value1286432168421

Commit this row to memory: 128, 64, 32, 16, 8, 4, 2, 1. The decimal value of any octet is simply the sum of the place values of every bit set to 1.

Binary to Decimal

Line the 8 bits under the place-value table and add up the place values wherever there is a 1. For 10101100: the 1s sit under 128, 32, 8, and 4, so 128 + 32 + 8 + 4 = 172. For 11100011: 128 + 64 + 32 + 2 + 1 = 227.

Decimal to Binary

Use the "highest column that fits" subtraction method, working left to right. For each column, ask: does this place value fit into the number I have left? If it fits, write a 1 and subtract that place value; if it does not, write a 0 and move on. Once the remainder hits 0, every remaining column is 0.

Figure 2.2: The "highest column that fits" decimal-to-binary process

flowchart TD Start["Start with decimal value
Place value = 128"] Q{"Does place value fit
into remaining number?"} Yes["Write 1
Subtract place value
from remaining"] No["Write 0"] Next{"More columns left?"} Done["Done: 8-bit binary octet"] Start --> Q Q -->|"Yes, it fits"| Yes Q -->|"No, too big"| No Yes --> Next No --> Next Next -->|"Yes, move to next
place value (half)"| Q Next -->|"No"| Done

Worked example — convert 244: 128 fits (remainder 116), 64 fits (52), 32 fits (20), 16 fits (4), 8 does not, 4 fits (0), 2 no, 1 no — giving 11110100. Check by converting back: 128 + 64 + 32 + 16 + 4 = 244.

A Shortcut Worth Memorizing

A small set of octet values recurs constantly as subnet-mask bytes. Each is formed by turning on place values from the left with no gaps:

DecimalBinarySum of place values
12810000000128
19211000000128 + 64
22411100000128 + 64 + 32
24011110000128 + 64 + 32 + 16
24811111000+ 8
25211111100+ 4
25411111110+ 2
25511111111+ 1

Visual animation — coming soon

Post-Quiz: Binary and Decimal Conversion

Reading the place values of an octet left to right (128, 64, 32, 16, 8, 4, 2, 1), what pattern relates each column to its neighbor?

Each place value is double the one to its right (and half the one to its left)
Each place value is 32 greater than the one to its right
Each place value is the square of the one to its right
The place values repeat in a cycle after the fourth column

Convert the binary octet 10101100 to decimal by summing the place values under each 1.

172
176
168
160

Using the "highest column that fits" method, what is 244 in binary?

11110100
11101100
11110010
11100100

In the decimal-to-binary subtraction method, what happens to your running total right after you write a 1 for a column?

You subtract that column's place value from the running total
You add that column's place value to the running total
You reset the running total to 128 and start over
You divide the running total in half

Subnet-mask bytes are values with contiguous 1s from the left, like 128, 192, 224, 240. Following that pattern, what is the binary for 240?

11110000
11100000
00001111
11111000
Pre-Quiz: Bitwise Thinking for Subnetting

In a subnet mask, what distinguishes the network portion from the host portion?

The 1 bits mark the network portion; the 0 bits mark the host portion
The 0 bits mark the network portion; the 1 bits mark the host portion
The first octet is always network; the last octet is always host
Even-numbered bits are network; odd-numbered bits are host

The bitwise AND operation outputs a 1 only when both input bits are 1. What is the result of 1 AND 0?

0
1
It depends on which bit is listed first
Both 0 and 1 are produced

Why does ANDing an address with its mask leave the network bits unchanged but force the host bits to 0?

Where the mask bit is 1 the address bit passes through; where the mask bit is 0 the result is always 0
AND always copies the larger of the two bits
The mask bits are added to the address bits
Host bits are removed first, then the mask is applied

Find the network address for host 192.168.10.75 using mask 255.255.255.0.

192.168.10.0
192.168.10.75
192.168.0.0
255.255.255.75

If you set aside n host bits, how many addresses can that group of bits represent?

2^n
n × 2
n^2
256 − n

Bitwise Thinking for Subnetting

Key Points

Every IPv4 address is conceptually divided into a network portion (which network it belongs to) and a host portion (which device). A subnet mask draws the boundary: its 1 bits mark network, its 0 bits mark host. The common mask 255.255.255.0 in binary is 11111111.11111111.11111111.00000000 — 24 network bits followed by 8 host bits.

Figure 2.3: How a subnet mask divides an address into network and host portions

graph TD M["Subnet Mask: 255.255.255.0"] M --> N["Mask 1 bits = Network portion"] M --> H["Mask 0 bits = Host portion"] N --> NB["First 24 bits (11111111.11111111.11111111)
Identifies which network"] H --> HB["Last 8 bits (00000000)
Identifies which device"]

The AND Operation

To find an address's network address, a host or router performs a bitwise AND between the address and its mask, comparing one bit at a time. AND outputs 1 only when both inputs are 1:

ABA AND B
111
100
010
000

The practical effect: wherever the mask bit is 1 (network), the address bit passes through unchanged; wherever the mask bit is 0 (host), the result is forced to 0. That is why AND "zeros out the host bits" and leaves the network address behind.

Figure 2.4: The bitwise AND process for finding a network address

flowchart LR IP["Address bit"] --> AND(("AND")) MB["Mask bit"] --> AND AND --> Check{"Are both bits 1?"} Check -->|"Yes (mask = 1, network)"| One["Result = 1
Address bit passes through"] Check -->|"No (mask = 0, host)"| Zero["Result = 0
Host bit erased"] One --> Net["Network Address"] Zero --> Net

Worked Example: Finding a Network Address

Find the network address for host 192.168.0.15 with mask 255.255.255.0:

Octet 1Octet 2Octet 3Octet 4
IP (192.168.0.15)11000000101010000000000000001111
Mask (255.255.255.0)11111111111111111111111100000000
Net (192.168.0.0)11000000101010000000000000000000

Octets 1-3 sit under all-ones mask bytes, so they pass through unchanged; octet 4 sits under an all-zeros mask byte, so the 00001111 (15) becomes 00000000 (0). The result is 192.168.0.0. The same logic gives 192.168.10.75 / 255.255.255.0192.168.10.0, and 140.179.240.200 / 255.255.0.0140.179.0.0.

Powers of Two

A power of two is any number you get by multiplying 2 by itself repeatedly (2^0 = 1, 2^1 = 2, up to 2^7 = 128 within an octet). An 8-bit octet holds 2^8 = 256 values; the full 32-bit space holds 2^32 ≈ 4.29 billion. In later chapters, n host bits yield 2^n addresses per subnet, and m borrowed bits create 2^m subnets. The pattern to internalize: the number of bits you set aside determines a power-of-two-sized count of possibilities.

Post-Quiz: Bitwise Thinking for Subnetting

In a subnet mask, what distinguishes the network portion from the host portion?

The 1 bits mark the network portion; the 0 bits mark the host portion
The 0 bits mark the network portion; the 1 bits mark the host portion
The first octet is always network; the last octet is always host
Even-numbered bits are network; odd-numbered bits are host

The bitwise AND operation outputs a 1 only when both input bits are 1. What is the result of 1 AND 0?

0
1
It depends on which bit is listed first
Both 0 and 1 are produced

Why does ANDing an address with its mask leave the network bits unchanged but force the host bits to 0?

Where the mask bit is 1 the address bit passes through; where the mask bit is 0 the result is always 0
AND always copies the larger of the two bits
The mask bits are added to the address bits
Host bits are removed first, then the mask is applied

Find the network address for host 192.168.10.75 using mask 255.255.255.0.

192.168.10.0
192.168.10.75
192.168.0.0
255.255.255.75

If you set aside n host bits, how many addresses can that group of bits represent?

2^n
n × 2
n^2
256 − n

Your Progress

Answer Explanations