Binary and octets

Why does no number in an IP address go above 255?

192.168.10.77192168107711000000101010000000101001001101128064132016081412011The last octeteach bit has a place value64 + 8 + 4 + 1 = 77eight 1s: 255, the largest octet32 bits: 4,294,967,296 addressesAn IPv4 address is 32 bits. The dots split it into four 8-bit numbers so that people can read it.Eight bits count from 0 to 255, which is why no part of an address is ever 256. Each bit has a place value thatdoubles from right to left; add the values where the bit is 1. Machines compare addresses bit by bit, so masks,on the next page, and subnets only make sense in binary. You never convert all 32 bits at once, only one octet,and usually only the octet where the mask ends.

An IPv4 address is 32 bits in four octets of 8 bits; each octet is written in decimal, 0 to 255.

IPv4 addresses and masks

The mask draws one line: network on the left, host on the right

Address192.168.10.77110000001010100000001010010011011921681077Mask /26255.255.255.19211111111111111111111111111000000network: the first 26 bits → 192.168.10.64host: 6 bits6 host bits give 64 addresses: 192.168.10.64 is the network itself, 192.168.10.127 the broadcast, and 62 are left for hosts.The mask draws one line through 32 bits: network on the left, host on the right.An IPv4 address is 32 bits, written as four octets from 0 to 255. The mask’s 1 bits mark the network part; /26 says there are 26 ofthem, the same as 255.255.255.192. Two hosts are on the same network when their network parts match, which is exactly thecheck a host makes before sending: deliver it directly, or hand it to the gateway (lesson 6). Always 2 to the power of the hostbits, minus 2 for the network and broadcast addresses.

An IPv4 address is 32 bits. The subnet mask (or /prefix) marks how many belong to the network; the rest number the hosts.

IPv4 addresses and masks · Going deeper

Classes A to E, and why they were abandoned

ClassFirst octetLeading bitsDefault maskUseA1 to 1260/8 · 255.0.0.0126 huge networksB128 to 19110/16 · 255.255.0.016,384 medium networksC192 to 223110/24 · 255.255.255.0over 2 million small onesD224 to 2391110nonemulticastE240 to 2551111nonereserved, experimental(127)127/8loopback: 127.0.0.1 is “this host”Classes fixed the mask by the first octet. CIDR replaced them in 1993, but the exams and the vocabulary remain.A class A gave one organisation 16.7 million addresses whether it needed them or not; that waste is what CIDR (RFC 4632)ended, by letting any prefix length be used anywhere. “A class C” still means a /24 in everyday speech, and class D isstill how multicast addresses are recognised.

Classful addressing tied the mask to the first octet. CIDR lets any prefix length be used anywhere.

Special address ranges

Private, link-local and loopback ranges never reach the internet

addresses in each range (log scale)10.0.0.0/8private16,777,216172.16.0.0/12private1,048,576192.168.0.0/16private65,536100.64.0.0/10carrier NAT4,194,304169.254.0.0/16link-local65,536127.0.0.0/8loopback16,777,216192.0.2.0/24documentation256Some ranges never appear on the public internet: private, carrier NAT, link-local and loopback.Anyone may use the three private ranges inside their own network, so millions of homes are 192.168.1.0/24 at once; NAT,in lesson 10, translates them at the edge. A host showing 169.254.x.x gave up waiting for DHCP and picked its own address:it is the clearest sign the DHCP server was never reached. Use 192.0.2.0, 198.51.100.0 and 203.0.113.0 /24 in examples.

RFC 1918 private ranges are 10/8, 172.16/12 and 192.168/16. APIPA (169.254/16) means DHCP failed; 127/8 is loopback.

Lesson complete

You finished “IPv4 addresses”

Nicely done.

Open in a new tab