Networking Mathematics Reference
Number Systems
Binary, Decimal, Hexadecimal Conversion
| Decimal | Binary | Hexadecimal |
|---|---|---|
0 |
0000 |
0 |
1 |
0001 |
1 |
2 |
0010 |
2 |
3 |
0011 |
3 |
4 |
0100 |
4 |
5 |
0101 |
5 |
6 |
0110 |
6 |
7 |
0111 |
7 |
8 |
1000 |
8 |
9 |
1001 |
9 |
10 |
1010 |
A |
11 |
1011 |
B |
12 |
1100 |
C |
13 |
1101 |
D |
14 |
1110 |
E |
15 |
1111 |
F |
Powers of 2
| n | \(2^n\) |
|---|---|
0 |
1 |
1 |
2 |
2 |
4 |
3 |
8 |
4 |
16 |
5 |
32 |
6 |
64 |
7 |
128 |
8 |
256 |
9 |
512 |
10 |
1,024 |
Critical values for networking:
| Power | Value | Use |
|---|---|---|
\(2^0\) |
1 |
Single host |
\(2^8\) |
256 |
Octet range (0-255) |
\(2^{16}\) |
65,536 |
Class B network |
\(2^{24}\) |
16,777,216 |
Class A network |
\(2^{32}\) |
4,294,967,296 |
Total IPv4 addresses |
\(2^{128}\) |
\(\approx 3.4 \times 10^{38}\) |
Total IPv6 addresses |
IPv4 Subnetting
Subnet Mask Notation
- CIDR (Classless Inter-Domain Routing)
-
A method for allocating IP addresses and routing that replaces the older classful network design. CIDR notation specifies an IP address followed by a slash and the number of network bits (e.g., 192.168.1.0/24).
| CIDR | Subnet Mask | Binary | Usable Hosts |
|---|---|---|---|
/8 |
255.0.0.0 |
11111111.00000000.00000000.00000000 |
16,777,214 |
/16 |
255.255.0.0 |
11111111.11111111.00000000.00000000 |
65,534 |
/24 |
255.255.255.0 |
11111111.11111111.11111111.00000000 |
254 |
/25 |
255.255.255.128 |
11111111.11111111.11111111.10000000 |
126 |
/26 |
255.255.255.192 |
11111111.11111111.11111111.11000000 |
62 |
/27 |
255.255.255.224 |
11111111.11111111.11111111.11100000 |
30 |
/28 |
255.255.255.240 |
11111111.11111111.11111111.11110000 |
14 |
/29 |
255.255.255.248 |
11111111.11111111.11111111.11111000 |
6 |
/30 |
255.255.255.252 |
11111111.11111111.11111111.11111100 |
2 |
/31 |
255.255.255.254 |
11111111.11111111.11111111.11111110 |
2 (P2P) |
/32 |
255.255.255.255 |
11111111.11111111.11111111.11111111 |
1 (host) |
Host Calculation Formula
The subtraction of 2 accounts for the network address and broadcast address.
Where \(n\) = number of host bits (32 - prefix length)
Subnet Calculation Formula
Where \(n\) is the number of bits borrowed from the host portion.
Where \(n\) = number of borrowed bits
Network and Broadcast Address
- Network Address
-
The first address in a subnet, where all host bits are 0. This address identifies the network itself and cannot be assigned to a host. Calculated by performing a bitwise AND between the IP address and subnet mask.
- Broadcast Address
-
The last address in a subnet, where all host bits are 1. Packets sent to this address are delivered to all hosts on the subnet. Calculated by performing a bitwise OR between the network address and the wildcard mask.
VLSM (Variable Length Subnet Masking)
- VLSM (Variable Length Subnet Masking)
-
A technique that allows a network to be divided into subnets of different sizes. Unlike fixed-length subnetting, VLSM allocates address space efficiently by matching subnet size to actual requirements, minimizing wasted addresses.
VLSM Design Process
-
List networks by size (largest first)
-
Assign smallest subnet that fits each requirement
-
Allocate sequentially to avoid overlap
IPv6 Addressing
Address Structure
- IPv6 Address Structure
-
A 128-bit address written as eight groups of four hexadecimal digits separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). The address space is divided into a global routing prefix (typically 48 bits), subnet ID (16 bits), and interface ID (64 bits).
IPv6: 128 bits total
├── Global Routing Prefix: 48 bits (ISP assigned)
├── Subnet ID: 16 bits (65,536 subnets)
└── Interface ID: 64 bits (host portion)
IPv6 Notation Rules
-
Leading zeros in each group can be omitted
-
One sequence of consecutive all-zero groups can be replaced with
::
IPv6 Prefix Lengths
| Prefix | Use | Addresses |
|---|---|---|
/32 |
ISP allocation |
\(2^{96}\) |
/48 |
Site allocation |
\(2^{80}\) |
/64 |
Single subnet |
\(2^{64}\) |
/128 |
Single host |
1 |
IPv6 Address Types
| Type | Prefix | Example |
|---|---|---|
Global Unicast |
2000::/3 |
2001:db8::/32 |
Link-Local |
fe80::/10 |
fe80::1 |
Unique Local |
fc00::/7 |
fd00::/8 |
Multicast |
ff00::/8 |
ff02::1 (all nodes) |
Loopback |
::1/128 |
::1 |
Bitwise Operations
AND Operation (Subnet Calculation)
AND Truth Table
| A | B | A AND B |
|---|---|---|
0 |
0 |
0 |
0 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
1 |
Result is 1 only when both inputs are 1.
Used to find network address:
IP: 11000000.10101000.00001010.01000011 (192.168.10.67)
Mask: 11111111.11111111.11111111.11000000 (/26)
AND: 11000000.10101000.00001010.01000000 (192.168.10.64)
OR Operation (Broadcast Calculation)
OR Truth Table
| A | B | A OR B |
|---|---|---|
0 |
0 |
0 |
0 |
1 |
1 |
1 |
0 |
1 |
1 |
1 |
1 |
Result is 1 when either input is 1.
Used with inverted mask to find broadcast:
Network: 11000000.10101000.00001010.01000000 (192.168.10.64)
Wildcard: 00000000.00000000.00000000.00111111 (0.0.0.63)
OR: 11000000.10101000.00001010.01111111 (192.168.10.127)
Wildcard Mask
Wildcard masks are the inverse of subnet masks, used in ACLs and OSPF configurations.
Quick Reference Tables
Subnet Cheat Sheet
| CIDR | Mask | Hosts | Subnets from /24 | Block Size | Magic Number |
|---|---|---|---|---|---|
/24 |
.0 |
254 |
1 |
256 |
256 |
/25 |
.128 |
126 |
2 |
128 |
128 |
/26 |
.192 |
62 |
4 |
64 |
64 |
/27 |
.224 |
30 |
8 |
32 |
32 |
/28 |
.240 |
14 |
16 |
16 |
16 |
/29 |
.248 |
6 |
32 |
8 |
8 |
/30 |
.252 |
2 |
64 |
4 |
4 |
/31 |
.254 |
2 |
128 |
2 |
2 |
/32 |
.255 |
1 |
256 |
1 |
1 |
Private Address Ranges (RFC 1918)
| Class | Range | CIDR | Hosts |
|---|---|---|---|
A |
10.0.0.0 - 10.255.255.255 |
10.0.0.0/8 |
16,777,214 |
B |
172.16.0.0 - 172.31.255.255 |
172.16.0.0/12 |
1,048,574 |
C |
192.168.0.0 - 192.168.255.255 |
192.168.0.0/16 |
65,534 |
Special Addresses
| Address | CIDR | Purpose |
|---|---|---|
0.0.0.0 |
/8 |
This network |
127.0.0.0 |
/8 |
Loopback |
169.254.0.0 |
/16 |
Link-local (APIPA) |
224.0.0.0 |
/4 |
Multicast |
255.255.255.255 |
/32 |
Broadcast |