Two Level Addressing in IPv4

Two level addressing : The whole purpose of IPv4 addressing is to define a destination for an Internet packet (at the network layer). When classful addressing was designed, it was assumed that the whole Internet is divided into many networks and each network connects many hosts.

In other words, the Internet was seen as a network of networks. A network was normally created by an organization that wanted to be connected to the Internet. The Internet authorities allocated a block of addresses to the organization (in class A, B, or C).

The range of addresses allocated to an organization in classful addressing was a block of addresses in Class A, B, or C.

Since all addresses in a network belonged to a single block, each address in classful addressing contains two parts: netid and hostid. The netid defines the network; the hostid defines a particular host connected to that network.

Figure shows an IPv4 address in classful addressing. If n bits in the class defines the net, then 32 − n bits defines the host. However, the value of n depends on the class the block belongs to. The value of n can be 8, 16 or 24 corresponding to classes A, B, and C respectively.

Two level addressing in classful addressing

Two level addressing can be found in other communication systems. For example, a telephone system inside the United States can be thought of as two parts: area code and local part. The area code defines the area, the local part defines a particular telephone subscriber in that area.

(626) 3581301

The area code, 626, can be compared with the netid, the local part, 3581301, can be compared to the hostid.

Extracting Information in a Block

A block is a range of addresses. Given any address in the block, we normally like to know three pieces of information about the block: the number of addresses, the first address, and the last address.

Before we can extract these pieces of information, we need to know the class of the address, which we showed how to find in the previous section. After the class of the block is found, we know the value of n, the length of netid in bits. We can now find these three pieces of information as shown in figure.

  1. The number of addresses in the block, N, can be found using N = 232-n.
  2. To find the first address, we keep the n leftmost bits and set the (32 − n) rightmost bits all to 0s.
  3. To find the last address, we keep the n leftmost bits and set the (32 − n) rightmost bits all to 1s.

Information extraction in classful addressing

An address in a block is given as 73.22.17.25. Find the number of addresses in the block, the first address, and the last address.

Solution

Since 73 is between 0 and 127, the class of the address is A. The value of n for class A is 8. Figure shows a possible configuration of the network that uses this block. Note that we show the value of n in the network address after a slash. Although this was not a common practice in classful addressing, it helps to make it a habit in classless addressing in the next section.

  1. The number of addresses in this block is N = 232-n = 224 = 16,777,216.
  2. To find the first address, we keep the leftmost 8 bits and set the rightmost 24 bits all to 0s. The first address is 73.0.0.0/8 in which 8 is the value of n. The first address is called the network address and is not assigned to any host. It is used to define the network.
  3. To find the last address, we keep the leftmost 8 bits and set the rightmost 24 bits all to 1s. The last address is 73.255.255.255. The last address is normally used for a special purpose.

An address in a block is given as 180.8.17.9. Find the number of addresses in the block, the first address, and the last address.

Solution

Since 180 is between 128 and 191, the class of the address is B. The value of n for class B is 16. Figure shows a possible configuration of the network that uses this block.

  1. The number of addresses in this block is N = 232-n = 216 = 65,536.
  2. To find the first address, we keep the leftmost 16 bits and set the rightmost 16 bits all to 0s. The first address (network address) is 18.8.0.0/16, in which 16 is the value of n.
  3. To find the last address, we keep the leftmost 16 bits and set the rightmost 16 bits all to 1s. The last address is 18.8.255.255.

An address in a block is given as 200.11.8.45. Find the number of addresses in the block, the first address, and the last address.

Solution

Since 200 is between 192 and 223, the class of the address is C. The value of n for class C is 24. Figure shows a possible configuration of the network that uses this block.

  1. The number of addresses in this block is N = 232-n = 28 = 256.
  2. To find the first address, we keep the leftmost 24 bits and set the rightmost 8 bits all to 0s. The first address is 200.11.8.0/24. The first address is called the network address.
  3. To find the last address, we keep the leftmost 24 bits and set the rightmost 8 bits all to 1s. The last address is 200.11.8.255.

Netid 200.11.8

Figure shows a hypothetical part of an internet with three networks.

Sample internet

  1. A LAN with the network address 220.3.6.0 (class C).
  2. A LAN with the network address 134.18.0.0 (class B).
  3. A switched WAN (class C), such as Frame Relay or ATM, that can be connected to many routers. We have shown three. One router connects the WAN to the left LAN, one connects the WAN to the right LAN, and one connects the WAN to the rest of the internet.

Network Address

The above three examples show that, given any address, we can find all information about the block. The first address, network address, is particularly important because it is used in routing a packet to its destination network.

For the moment, let us assume that an internet is made of m networks and a router with m interfaces. When a packet arrives at the router from any source host, the router needs to know to which network the packet should be sent; the router needs to know from which interface the packet should be sent out. When the packet arrives at the network, it reaches its destination host using another strategy that we discuss in later.

Figure shows the idea. After the network address has been found, the router consults its routing table to find the corresponding interface from which the packet should be sent out. The network address is actually the identifier of the network; each network is identified by its network address.

The network address is the identifier of a network.

Network Mask

The methods we described previously for extracting the network address are mostly used to show the concept. The routers in the Internet normally use an algorithm to extract the network address from the destination address of a packet. To do this, we need a network mask.

A network mask or a default mask in classful addressing is a 32-bit number with n leftmost bits all set to 1s and (32 − n) rightmost bits all set to 0s. Since n is different for each class in classful addressing, we have three default masks in classful addressing as shown in figure.

Network mask

To extract the network address from the destination address of a packet, a router uses the AND operation described in the previous section.

When the destination address (or any address in the block) is ANDed with the default mask, the result is the network address.

The router applies the AND operation on the binary (or hexadecimal representation) of the address and the mask, but when we show an example, we use the short cut discussed before and apply the mask on the dotted-decimal notation.

The default mask can also be used to find the number of addresses in the block and the last address in the block, but we discuss these applications in classless addressing.

Finding a network address using the default mask

A router receives a packet with the destination address 201.24.67.32. Show how the router finds the network address of the packet.

Solution

We assume that the router first finds the class of the address and then uses the corresponding default mask on the destination address, but we need to know that a router uses another strategy as we will discuss in the next. Since the class of the address is B, we assume that the router applies the default mask for class B, 255.255.0.0 to find the network address.

Destination address    → 201.24.67.32
Default mask                → 255.255.0.0
Network address         → 201.24.0.0

We have used the first short cut as described in the previous section. The network address is 201.24.0.0 as expected.

Read More Topics
Packet Switching at Network Layer
Wireless LANs
Functions of Layer in the OSI Model
The Open System Interconnection (OSI) Model
Glossary for Computer Network

About the author

Santhakumar Raja

Hi, This blog is dedicated to students to stay update in the education industry. Motivates students to become better readers and writers.

View all posts

Leave a Reply