Nauka adresowania IPv4
Klasy, maski, CIDR, podsieci, broadcast i hosty — z wizualizacją na poziomie bitów.
IPv4 Basics
An IPv4 address is 32 bits, written as 4 octets (0–255) separated by dots: 192.168.1.10. Each octet = 8 bits.
Every device on an IP network needs a unique address + a subnet mask that tells the network portion vs the host portion.
Total IPv4 space = 2³² ≈ 4.29 billion addresses. Due to exhaustion, IPv6 and NAT (Network Address Translation) are widely used.
Address Classes
CIDR & Subnet Masks
CIDR (Classless Inter-Domain Routing) writes the prefix length after a slash, e.g. /26 = first 26 bits are network.
Mask /24 = 255.255.255.0 → 256 addresses, 254 usable hosts.
Formula: usable hosts = 2^(32 − prefix) − 2.
Wildcard mask = inverse of subnet mask (used in ACLs): /24 → 0.0.0.255.
Binary System
Computers store IP addresses in binary (base‑2). Each octet has 8 bits with weights:
To convert a decimal octet → binary, subtract the largest power of 2 that fits, mark 1, repeat with the remainder, mark 0 when a weight doesn't fit.
Example: 192 = 128 + 64 → 11000000.
Bitwise operations
The router determines the network address using bitwise AND between the IP and the mask. Truth table:
OR is used to build broadcast; NOT builds the wildcard mask.
Subnetting & VLSM
Subnetting = borrowing host bits to create more, smaller networks. Each borrowed bit doubles the number of subnets and halves the hosts.
VLSM (Variable Length Subnet Masks) lets you assign different prefix lengths per subnet to avoid wasting addresses — start with the LARGEST subnet first.
