3 IPv4 address structure
- IP and postal addresses are considered to be hierarchical, which means they contain a structure. Consider a letter with the following postal address:
32 Colony Avenue
- The address identifies the house, street and town that the postal service needs to use to deliver the letter. It also identifies the person in the house for whom the letter is intended. This is very important, as the house probably contains a number of people and they need to be able to determine who the letters is for.
- Now consider an IPv4 address: 192.168.10.10
- The address identifies the network that the packet has to be delivered to using the ‘192.168.10’ portion of the address.
- The identity of the device, or host, within the network for which the packet is intended is ‘.10’.
- Therefore, we can say that an IPv4 address contains a network and a host component.
- Because IP addresses are designed to be used by computing devices, they are actually 32-bit binary numbers, which are converted to decimal to make them easier for people to work with. To make the addresses even easier to work with, they are divided into four 8-bit blocks called octets:
- The decimal numbers within each octet can range from 0 to 255.
Activity: Decimal and binary numbers
You need to be comfortable with converting between decimal and binary numbers. Try using the excel spreadsheet to convert the following decimal numbers into binary.
- decimal and binary conversion spreadsheet [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)]
- In the example above we used colour to identify the network and host components in the IPv4 address, but this technique will not work for computing devices. Instead IP subnet masks are used. The IP subnet mask is a 32-bit binary number, and each binary ‘1’ is used to identify a network bit within the IP address itself:
- Note that the subnet mask bits are set to ‘0’ to identify the host portion of the address. A computing device will evaluate the IP address and subnet mask together, bit by bit (this is called bit wise), performing a logical ‘AND’ operation:
- The AND function will take two inputs, and if they are both ‘1’, it will output a ‘1’. Any other combination of inputs will result in a ‘0’ output.
Example: AND function
Try performing the AND function on the address and mask shown below:
- Proceed from left to right, taking 1 bit from the address, 1 bit from the mask and perform the AND function. The output will be the network address:
- Note that the network address is 192.168.10.0, not 192.168.10 as shown previously in the coloured example. This is because the network address has to be 32-bits long, but as it does not include any host information, the host component is set to the all zero condition.
- Now that you have determined the network address, you can assign individual host addresses to the devices in your network:
- Note that all the PCs in the figure above share the same network address, but have unique host addresses. The range of possible host addresses is limited by the number of binary bits within the host octet, so in theory the range is .1 to .255. However, the .255 address is reserved for broadcast transmission, when devices need to communicate simultaneously with every host in their network, and cannot be assigned to an individual host. Thus, in this example, the range of possible host addresses is .1 to .254.
- You may have noticed that each device’s address is followed by /24. This represents the subnet mask, which we have seen is very important as it defines which parts of the address relate to the network and host components.
- Writing the subnet mask out in full (255.255.255.0) can be quite repetitive, so instead, you can state the number of bits within the mask that are set to ‘1’. As 255 corresponds to 11111111 in binary, you have eight binary bits set to ‘1’ in the octet. With three octets set to 255, you have a total of 24 bits sets to ‘1’, thus the subnet mask (or prefix length) can be written as /24.
2 Network addressing
4 Assigning IPv4 addresses