The binary number system and the structure of an IPv4 address
Sign in to read this lesson
The binary number system only has 0 and 1. A byte (octet) is 8 bits, and the bit values from right to left are 1, 2, 4, 8, 16, 32, 64, 128 (powers of 2). To convert a decimal number to binary, start on the left and see which bits add up to the number. An IPv4 address is 32 bits split into 4 octets, and can be written in decimal, binary or hexadecimal. Unlike a MAC address, an IP address is hierarchical: it has a network part and a host part.
What you will learn
- A bit has two values: 0 (off) and 1 (on). Byte = octet = 8 bits. Nibble = 4 bits.
- The values of 8 bits from left to right: 128, 64, 32, 16, 8, 4, 2, 1. The leftmost bit is the MSB (most significant bit), the rightmost the LSB (least significant bit). Each added bit doubles the value (powers of 2).
- Decimal → binary: start on the left and set the bits that fit to 1. 178 = 128 + 32 + 16 + 2 = 10110010. The highest number with 8 bits is 255 = 11111111.
- An IPv4 address is 32 bits: 4 octets × 8 bits. It can be written in decimal (192.168.1.1), binary (11000000.10101000.00000001.00000001) and hexadecimal (C0.A8.01.01). 32 bits give ~4.3 billion (4,294,967,296) addresses.
- An IP address is hierarchical (a MAC address is not): like the country and city code of a phone number, first comes the network part, then the host part. Devices in the same subnet talk to each other without a router.
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.