IP Addressing and Subnetting

IP Addressing and Subnetting

PCBWay

You shall be learning all about IP addressing and subnetting in this tutorial.

DRex Electronics

Although you may be thinking that addressing must be a straightforward topic , hopefully by the end of this tutorial you’ll be convinced that internet addressing is not only a juicy, subtle, and interesting topic but also one that is of central importance to the internet.

Before discussing IP addressing, however, we’ll need to say a few words about how hosts and routers are connected into the network.

A host typically has only a single link into the network; when the IP in the host wants to send a datagram, it does so over this link. The boundary between the host and the physical link is called an interface. Now consider a router and its interfaces. Because a router’s job is to receive a datagram on one link and forward the datagram on some other link, a router necessarily has two or more links to which it is connected. The boundary between the router and any one of its links is also called an interface.

A router thus has multiple interfaces, one for each of its links. Because every host and router is capable of sending and receiving IP datagrams, IP requires each host and router interface to have its own IP address. Thus, an IP address is technically associated with an interface, rather than with the host or router containing that interface.

Each IP address is 32 bits long (equivalently, 4 bytes), and there are thus a total of 232 possible IP addresses. By approximating 210 by 103, it is easy to see that there are about 4 billion possible IP addresses. These addresses are typically written in so-called dotted-decimal notation, in which each byte of the address is written in its decimal form and is separated by a period (dot) from other bytes in the address.

For example, consider the IP address 193.32.216.9. The 193 is the decimal equivalent of the first 8 digits of the address; the 32 is the decimal equivalent of the second 8 bits of the address, and so on. Thus, the address 193.32.216.9 in binary notation is :

11000001  00100000  11011000  00001001

Each interface on every host and  router in the global internet must have an IP address that is globally unique (except for interfaces behind NATs). These addresses cannot be chosen in a willy-nilly manner, however. A portion of an interface’s IP address will be determined by the subnet to which it is connected.

The figure below provides an example of IP addressing and interfaces.

IP Addressing and Subnetting

In this figure, one router (with three interfaces) is used to interconnect seven hosts. Take a closer look at the IP address assigned to the host and router interfaces, as there are several things to notice.

The three hosts in the upper-left portion of the above figure, and the router interface to which they are connected, all have an IP address of the form 223.1.1.xxx. That is, they all have the same leftmost 24 bits in their IP address. The four interfaces are also interconnected to each other by a network that contains no routers. This network could be interconnected by an Ethernet LAN, in which case the interfaces would be interconnected by an Ethernet switch, or by a wireless access point. We’ll represent this routerless network connecting these hosts as a cloud for now.

In IP terms, this network interconnecting three host interfaces and one router interface forms a subnet [RFC 950]. (A subnet is also called an IP network or simply a network in the internet literature). IP addressing assigns an address to this subnet: 223.1.1.0/24, where the /24 notation, sometimes known as a subnet mask, indicates that the leftmost 24 bits of the 32 bit quantity define the subnet address.

The subnet 223.1.1.0/24 thus consists of the three host interfaces (223.1.1.1, and 223.1.1.2, and 223.1.1.3) and one router interface (223.1.1.4). Any additional hosts attached to the 223.1.1.0/24 subnet would be required to have an address of the form 223.1.xxx. There are two additional subnets shown in the figure above :the 223.1.2.0/24network and the 223.1.3.0/24subnet. The figure below illustrates the three IP subnets:

4.16

The IP definition of a subnet is not restricted to Ethernet segments that connect multiple hosts to a router interface. To get some insight here, consider the figure below (4.17), which shows three routers that are interconnected, one for each point-to-point link and one for the broadcast link that directly connects the router to a pair of hosts.

4.17

What subnets are present here? Note that there are three additional subnets in this example as well: one subnet, 223.1.9.0/24, for the interface that connect routers R1 and R2; another subnet, 223.1.8.0/24, for the interfaces that connect routers R2 and R3; and a third subnet, 223.1.7.0/24, for the interfaces that connect routers R3 and R1.  For a general interconnected system of routers and hosts, we can use the following recipe to define the subnets in the system:

To determine the subnets, detach each interface from its host or router, creating islands of isolated networks, with interfaces terminating the end points of the isolated networks. Each of these isolated networks is called a subnet.

If we apply this procedure to the interconnected system in the above figure, we get six islands of subnets.

From the discussion above, it’s clear that an organization (such as a company or academic institution) with multiple Ethernet segments and point-to-point links will have multiple subnets, with all of the devices on a given subnet having the same subnet address.

In principle, the different subnets could have quite different subnet address. In practice, however, their subnet addresses often have much in common. To understand why, let’s turn our attention to how addressing is handled in the global internet.

The internet’s address assignment strategy is known as Classless Interdomain Routing (CIDR – pronounced cider) [RFC 4632]. CIDR generalizes the notion of subnet addressing. CIDR generalizes the notion of subnet addressing. As with subnet addressing, the 32-bit IP address is divided into two parts and again has the dotted-decimal form a.d.c.d/x, where x indicates the number of bits in the first part of the address.

The x most significant bits of an address of the form a.b.c.d/x constitute the network portion of the IP address, and are often referred to as the prefix (or network prefix) of the address.

An organization is typically assigned a block of contiguous addresses, that is, a range of addresses with a  common prefix. In this case, the IP addresses of devices within the organization will share the common prefix.  Only these x leading prefix bits are considered by routers outside the organization’s network.

That is, when a router outside the organization forwards a datagram whose destination address is inside the organization, only the leading x bits of the address need to be considered. This considerably reduces the size of the forwarding table in these routers, since a single entry of the form a.b.c.d/x will be sufficient to forward packets to any destination within the organization.

The remaining 32-x bits of an address can be thought of as distinguishing the devices within the organization, all of which have the same network prefix. These are bits that will be considered when forwarding packets at routers within the organization.

These lower-order bits may (or may not) have an additional subnetting structure, such as that discussed above.  For example, suppose the first 21 bits of the CIDRized address a.b.c.d/21 specify the organization’s network prefix and are common to the IP address of all devices in that organization. The organization’s internal structure might be such that these 11 rightmost bits are used for subnetting within the organization, as discussed above. For example, a.b.c.d/24 might refer to a specific subnet within the organization.

Before CIDR was adopted, the network portions of an IP address were constrained to be 8,16, or 24 bits in length, and an addressing scheme known as classful addressing, since subnets with 8-, 16- , and 24-bit subnet addresses were known  as class A, B and C networks, respectively.

The requirement that the subnet portion of an IP address be exactly 1,2, or 3 bytes long turned out to be problematic for supporting the rapidly growing number of organizations with small and medium-sized subnets. A class C(/24) subnet could accommodate only up to 28-2 = 254 hosts (two of the 28=256 addresses are reserved for special use)- too small for many organizations. However, a class B(/16) subnet, which supports upto 65,634hosts, was too large. Under classful addressing, an organization with, say 2,000 hosts was typically allotted a class B(/16) subnet address. This led to a rapid depletion of the class B address space and poor utilization of the assigned address space. For example, the organization that used a class B address for its 2,000 hosts was allocated enough of the address space for up to 65,534 interfaces – leaving more than 63,000 addresses that could not be used by other organizations.

We would be remiss if we did not mentions yet another type of IP address, the IP broadcast address 255.255.255.255. When a host sends a datagram with destination address 255.255.255.255, the message is delivered to all hosts on the same subnet. Routers optionally forward the message into neighbouring subnets as well (although they usually don’t).