Skip to content
Skip to main content

About this free course

Download this course

Share this free course

Protocols in multi-service networks
Protocols in multi-service networks

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

3.5.1 IPv4 Addresses

The allocation of addresses on the Internet is controlled by the Internet Assigned Numbers Authority (IANA), although authority is delegated to several local registries. IPv4 addresses may be interpreted in two ways. Initially, they were divided into distinct ranges of addresses called classes, but this proved to be inflexible and now a more flexible scheme, called classless addressing, dominates IPv4 internetworks. I shall describe both ways of interpreting IPv4 addresses because the limitation of the first interpretation leads naturally to the need for the second interpretation. The formats of the four allocated classes of IPv4 addresses are shown in Figure 21 and their ranges are listed in Table 6. The values in the table follow the standard dotted-decimal convention of splitting each 32-bit address into four bytes, and expressing the values of the bytes as denary numbers separated by full stops.

Figure 22
Figure 22 IPv4 Internet address formats
Table 6: IPv4 Internet address ranges
ClassRange
LowestHighest
A0.0.0.0127.255.255.255
B128.0.0.0191.255.255.255
C192.0.0.0223.255.255.255
D224.0.0.0239.255.255.255

Addresses in the range 240.0.0.0 to 255.255.255.255 are reserved for future use.

IPv4 address classes A to C identify single hosts, and are called unicast addresses. Looking at Figure 22, you can see that the IPv4 addresses consist of three parts: a prefix identifying the class of address, the address of a network, and the address of a host within the network. For instance, a class C address is identified by the prefix 110, the network address consists of 21 bits, and the host address consists of eight bits. This means that, in principle, there can be 221 =  2097152 networks in an internetwork with class C addresses, and each single network can have 28 =  256 hosts connected to it. In practice, some addresses are reserved and cannot be allocated to networks or hosts.

SAQ 11

To which class does the IPv4 address 157.107.34.5 belong?

Answer

The most direct approach to this question is by reference to Table 6. The IPv4 address 157.107.34.5 is within the address range for class B. You could also have answered this question by expressing the first byte of the address as a binary number and then identifying the prefix. In this case 157 is equal to the binary number 10011101 which is a class B address since the first two bits are 10.

Class D addresses are allocated to groups of hosts rather than single hosts. The group is identified by a single 28-bit address, called a multicast address, and the datagram is delivered to all the hosts in the group. Some multicast addresses are reserved for specific groups of hosts, such as all routers connected to a LAN. Other multicast groups can be constructed by hosts sending appropriate management messages. Multicast datagrams are routed through an internetwork by special multicasting routers.

The main benefit of multicasting is that routers can optimise the distribution of datagrams to avoid unnecessary duplication. For instance, if a host wishes to send a single datagram to 100 destinations by unicasting, it has to send 100 copies of the datagram. However, if all the 100 destinations belong to a single multicast group, the originating host can send a single multicast datagram and the routers will duplicate the datagram only where necessary to deliver it to destinations with which they have different interfaces. This reduces the total number of copies of the datagram that exist in the internetwork.

The division of IPv4 unicast addresses into three classes is not a very efficient way of allocating addresses. A network with, say, 300 hosts would have to be given a class B address, which allocates 16 bits to host addresses and therefore can accommodate 216 =  65536 hosts. However, only 300 of these addresses would be allocated – the rest would be wasted. A classless addressing scheme has therefore been introduced to reduce the inefficiency in the original IPv4 addressing scheme.

Classless IPv4 addresses are written in the same dotted-decimal notation as the original addressing scheme, but are followed by a forward slash and the number of bits in the network part of the address, which precedes the host address. For example, the classless address 196.19.0.48/16 identifies the network address as 196.19 (11000100 00010011) and the host address within the network as 0.48 (00000000 00110000).

The routing of IPv4 datagrams is based on the network address component of the IPv4 destination address. The network address can be conveniently isolated by using the simple Boolean operator AND with a binary number which has ones in all bit positions of the network address component. This process is called masking and the binary number used to isolate the network address component is called a bit mask. For example, the network address in the IP address 196.19.0.48/16 can be isolated by the bit mask 255.255.0.0. The bit masks are set up in each router as part of the routing functions of an internetwork.

The unit team hope you will find spreadsheets very useful during your study of this unit. The following activity and SAQ ask you to use fairly simple spreadsheets.

The worksheet ‘IPv4 classes’ in the spreadsheet ‘Protocols’ converts IPv4 addresses expressed as 32-bit binary numbers to dotted-decimal numbers. The spreadsheet supplied below is set up to convert the upper and lower addresses in the four classes of addresses. Use this spreadsheet to confirm the address ranges in Table 6.

Some calculators, such as the Windows calculator, convert between binary and denary numbers, and you may like to check the answers in the spreadsheet. If you are unfamiliar with binary numbers you may find it worthwhile using this spreadsheet to convert other binary numbers.

Click on the 'View document' link below to open the spreadsheet. You will find it attached to a PDF.

View document [Tip: hold Ctrl and click a link to open it in a new tab. (Hide tip)]

SAQ 12

Find the bit masks and hence the network addresses for the following IPv4 classless addresses:

  • (a) 197.134.5.45/12

  • (b) 220.5.47.101/10

  • (c) 175.121.56.221/8

The worksheet ‘SAQ 6’ The worksheet SAQ 3.3 in the spreadsheet. ‘Protocols’ may be used for this SAQ. You may like to change the values in this spreadsheet to see the effects of other bit masks.

Answer

The bit masks and network addresses are given below. Various short cuts are possible but, going through all the steps, the network address is isolated by first converting the IP address to a binary number and then ANDing with the mask.

(a) The bit mask has 1s in the first 12 bit positions:

11111111 11110000 00000000 00000000

which is 255.240.0.0 in the dotted-decimal form.

The network address is isolated as follows:

The network address component is 110001011000.

(b) The bit mask has 1s in the first 10 bit positions:

11111111 11000000 00000000 00000000 (255.192.0.0)

The network address is isolated as follows:

The network address component is 1101110000.

(c) The bit mask has 1s in the first eight bit positions:

11111111 00000000 00000000 00000000

The network address is isolated as follows:

The network address component is 10101111.