Intuition The one core idea
A router looks at where a packet wants to go (a number), compares that number's leading bits against a list of network "postcodes", and picks the most detailed match to decide the exit door. Everything on this page — bits, addresses, masks, prefixes, the AND operation — exists only to make that one sentence precise and fast.
Before you can read the parent note Routing — forwarding & routing tables , you need every symbol it silently assumes. We build each from zero: plain meaning → picture → why the topic needs it . Read top to bottom; nothing appears before it is earned.
A bit is a single box that holds either 0 or 1 . That is the entire alphabet computers use. "Bit" is short for bi nary digit .
Picture a row of light switches. Each switch is a bit: off = 0 , on = 1 . A group of switches side by side spells out a number in binary — base two instead of the base ten you count in.
Why the topic needs it: IP addresses, masks, and prefixes are all just rows of these switches. "Longest prefix match" literally means "how many leading switches agree". Without bits, none of it is defined.
A byte is a bundle of exactly 8 bits . Eight switches can show 2 8 = 256 different patterns, i.e. the numbers 0 through 255 .
An IPv4 address is 32 bits — four bytes in a row. Because 32 raw ones and zeros are painful to read, we write each byte as a normal decimal number and glue them with dots. This is dotted-decimal notation.
Worked example The same address, two costumes
10 00001010 . 20 00010100 . 30 00011110 . 40 00101000
reads as 10.20.30.40. Same 32 switches, friendlier clothing.
Why this step? Humans read 10.20.30.40; the router reasons in the 32 bits underneath. You must be able to flip between the two.
Why the topic needs it: Every packet carries a 32-bit destination address D . The parent note's D is exactly this row of 32 switches.
Intuition The neighbourhood-and-house picture
Think of a full postal address: the first part names the neighbourhood (which street block), the last part names the exact house . An IP address splits the same way: some leading bits name the network , the remaining bits name the host inside it. Routers only care about the neighbourhood — get the packet to the right block and let local delivery finish it.
Definition Prefix and prefix length
A prefix is the network part of an address, written as an address plus a slash number: 192.168.1.0/24. The number after the slash is the prefix length L — how many leading bits belong to the network. The parent writes this as P / L : P is the prefix, L its length.
Why the topic needs it: A forwarding table stores prefixes, not single addresses. 192.168.1.0/24 covers a whole block of 256 addresses in one line. "Longest prefix match" is a contest over these L values.
A subnet mask M is a 32-bit pattern of L ones followed by ( 32 − L ) zeros . The ones sit over the network bits; the zeros sit over the host bits. It is a stencil that says "these positions matter, those don't".
Why the topic needs it: The parent's matching test uses M to erase host bits. Without the mask you cannot separate "which neighbourhood" from "which house".
AND , written ∧ , compares two rows of bits position by position . A position is 1 only if both inputs are 1 there; otherwise it is 0 .
Intuition Why AND is the right tool here — and not addition or OR
We need an operation that keeps the network bits and wipes the host bits . AND-ing against the mask does exactly that: where the mask is 1 (network) the original bit survives; where the mask is 0 (host) it is erased to 0 . Addition would carry and mangle bits; OR would set bits instead of clearing them. AND is the unique "stencil" operator. That is why the parent chose it.
Worked example Erasing host bits
Address 10.20.30.40, mask /16 (255.255.0.0 ):
( 10.20.30.40 ) ∧ ( 255.255.0.0 ) = 10.20.0.0
The last two bytes (30 and 40 ) sat under mask zeros, so they vanished. What survived, 10.20.0.0, is the network. Why this step? It reveals which neighbourhood the address lives in, ready to compare against a stored prefix.
Now every symbol in that line is earned:
D = the 32-bit destination (Section 2),
P / L = a stored prefix and its length (Section 3),
M = the stencil built from L (Section 4),
∧ = the erase operation (Section 5).
Intuition Longest prefix = pickiest = smallest neighbourhood
A bigger L means more network bits fixed, so fewer host bits free, so a smaller, more precise neighbourhood. Among all prefixes that match, the one with the largest L pins down the destination most exactly — that is the winner. This is why the parent says "longest is pickiest".
Definition The two planes
The control plane is the "thinking room": routing protocols run here and build the rich routing table . The data plane is the "doing room": it holds the lean forwarding table and moves every packet at full speed. See Control Plane vs Data Plane for the deep dive.
Why the topic needs it: The parent's whole "two books" idea is this split. The routing table lives in the control plane; the forwarding table (FIB) lives in the data plane.
IPv4 address: 32 bits, dotted decimal
Network part vs host part
Subnet mask M: L ones then zeros
Bitwise AND erases host bits
Match test: D and M equals P and M
Forwarding decision: pick exit door
Control plane vs data plane
Each arrow means "you must own the top box before the bottom box makes sense." Follow it and you arrive exactly at the parent note's forwarding decision.
Test yourself — you should be able to answer each without peeking.
What is a bit and what two values can it hold? The smallest unit of information; it holds either 0 or 1.
How many bits are in a byte, and what range of numbers can one byte show? 8 bits; values 0 through 255 (that is 2 8 = 256 patterns).
How many bits make an IPv4 address, and how do we write it for humans? 32 bits, written as four bytes in dotted-decimal like 10.20.30.40.
What does the prefix length L in P/L count? The number of leading bits that belong to the network part.
What shape does a subnet mask M have for a given L ? L ones followed by 32 − L zeros.
What does bitwise AND with a 0 do to a bit? With a 1? AND with 0 forces the bit to 0 (erases it); AND with 1 keeps the bit unchanged.
Why do we AND the address with the mask instead of adding? AND keeps network bits and cleanly erases host bits; addition would carry and corrupt the bits.
State the match condition for address D against prefix P / L . ( D ∧ M ) = ( P ∧ M ) , where M is the mask built from L .
Does a larger prefix length mean a bigger or smaller network? Smaller — more network bits means fewer host bits.
Which plane holds the forwarding table? The data plane (the fast "doing" room).