Chapter 01 · Addresses01 / 20

An address is 32 bits

Every device on a network has an IP address. IPv4, the version most of the internet still runs on, uses a plain 32-bit number. Nobody wants to read 11000000101010000000000100010111, so we cut it into four 8-bit octets and write each one in decimal, with dots in between: 192.168.1.23.

An octet runs from 00000000 (0) to 11111111 (255). Read it like any number: each position is worth twice the one on its right, 128 64 32 16 8 4 2 1. So 11000000 is 128 + 64 = 192.

Your turn: click any bit to flip it and watch its octet change. An address really is just a number: this one is 3,232,235,799.

Your turn
python3in the real world
>>> import ipaddress
>>> ip = ipaddress.ip_address('192.168.1.23')
>>> int(ip)
3232235799
>>> f'{int(ip):032b}'
'11000000101010000000000100010111'