Computer Networks

IP Addresses: the postal codes of the internet

Every second, billions of packets find their way to the right computer among billions of devices. How? Thanks to IP addresses - the unique "postal codes" of the internet.

  • **Geo-blocking:** Netflix determines the viewer's country by IP and blocks content accordingly
  • **DDoS attacks:** Knowing a server's IP allows directing traffic at it
  • **Troubleshooting:** `ping 8.8.8.8` - the first step in network diagnostics

Предварительные знания

  • Switches

IPv4 address structure

An **IPv4 address** is a 32-bit number that uniquely identifies a device on a network. It's like a postal address for a computer: without it, the letter (packet) won't arrive.

The 32 bits are divided into **4 octets** (8 bits each). Each octet is a number from 0 to 255. This provides approximately 4.3 billion unique addresses (2³² = 4,294,967,296).

Why 32 bits? In the 1980s, 4 billion addresses seemed infinite. Today IPv4 addresses are exhausted - that's why IPv6 was introduced with 128 bits (340 undecillion addresses).

How many unique addresses can IPv4 have?

Dotted-decimal notation

**Dotted-decimal notation** is the standard way to write IPv4 addresses. Four decimal numbers separated by dots: `192.168.1.1`. This is convenient for humans, although computers work with binary representation.

Each octet is independent. Going from 192.168.1.255 to the next address gives 192.168.2.0 - like an odometer in a car where 999 rolls over to 1000.

**Tip:** An IP like `192.168.x.x` or `10.x.x.x` is a private address - not routed on the internet. `8.8.8.8` or `1.1.1.1` are public.

Which of these IPv4 addresses is invalid?

Binary representation

Computers store IPs as **32 consecutive bits**. Understanding binary representation is critical for working with subnets, masks, and troubleshooting.

**Quick method:** memorize the key numbers - 128, 192, 224, 240, 248, 252, 254, 255. These are sums of powers of two from left to right, and are commonly seen in subnet masks.

In interviews, converting an IP to binary by hand is a common task. The values 255, 128, 192, 224 appear in subnet masks constantly - worth knowing by heart.

What is the decimal value of the octet 11111111?

IP vs MAC: two types of addresses

**MAC address** (L2) - physical, burned into hardware, works in a local network. **IP address** (L3) - logical, assigned, works between networks. Both are needed to deliver a packet.

**Analogy:** MAC is like a passport serial number (immutable), IP is like a mailing address (changes with location). Delivering a letter requires both: the address for routing and the passport to identify the recipient.

When sending to another network, the destination MAC will be the MAC of the **router**, not the final recipient. The IP stays the same. The MAC changes at every hop; the IP does not.

An IP address is burned into the network card, like a MAC

An IP address is assigned in software (manually or via DHCP) and can change

MAC identifies hardware; IP identifies a logical location on the network. A laptop at home and in the office has different IPs, but the same MAC.

What happens to the MAC and IP addresses when a packet passes through a router?

Key ideas

  • **IPv4 = 32 bits** = 4 octets of 8 bits = ~4.3 billion addresses
  • **Dotted-decimal:** a human-readable notation (192.168.1.1)
  • **Binary form:** how IP is stored in a computer, critical for subnetting
  • **IP vs MAC:** IP - logical (L3, end-to-end), MAC - physical (L2, hop-by-hop)

Related topics

IP addresses are the foundation of the network layer:

  • Subnets and masks — How to divide IP space into segments
  • ARP protocol — Links IP with MAC for local delivery
  • DHCP — Automatically assigns IP addresses

Вопросы для размышления

  • Why were 4.3 billion addresses not enough for the modern internet?
  • If MAC changes at every router, how does a packet know where to go next?
  • What would happen if two devices got the same IP on the same network?

Связанные уроки

  • alg-35-bit-manipulation
IP Addresses: the postal codes of the internet

0

1

Sign In