Jump to content

Subnet

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 193.10.195.210 (talk) at 10:53, 2 September 2008 (Added link to swedish translation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

File:Subnetting.png
A graphic representation of relationships and source of the various variables representing a chunk of /24 subnets

In computer networks based on the Internet Protocol Suite, a subnetwork, or subnet, is a portion of the network's computers and network devices that have a common, designated IP address routing prefix (cf. Classless Inter-Domain Routing, CIDR).

A routing prefix is the sequence of leading bits of an IP address that precede the portion of the address used as host identifier (or rest field in early Internet terminology).

In IPv4 installations, the routing prefix is often expressed as a "subnet mask", which is a bit mask covering the number of bits used in the prefix. It is frequently expressed in quad-dotted decimal representation, e.g., 255.255.255.0 is the subnet mask for the 192.168.1.0 network with a 24-bit routing prefix (192.168.1.0/24). Subnet masks in IPv4 do not have to have consecutive bits set, e.g., a subnet mask of "11111111001100110000000000000000" (binary) is permissible, albeit of little additional value, as it does not provide for more efficient address space utilization and cannot be represented in CIDR notation. IPv6 does not use subnet masks and such non-standard routing prefixes are not possible.

The routing prefix of a subnet is often further divided into the network's network identifier and a subnet identifier. The network identifier is the leading set of address bits that is common to the prefixes of all subnets in the network. This would typically be the CIDR routing prefix of an organization's entire address space allocation. The subnet identifier consists of the remaining bits in a subnet's prefix after the network identifier. In the cited example, 192.168.0.0 is the network identifier (and 255.255.0.0 the network mask) and "1" is the subnet identifier.

In a large organization's network, without subnetting, traffic levels can grow enough that excessive rates of Ethernet packet collisions become a bottle neck due to the nature of Ethernet (cf. carrier sense multiple access with collision detection). For this reason, subnetting can be used to break the network into smaller more efficient subnets. Such subnets can be arranged hierarchically, with the organization's network address space (see also Autonomous System) partitioned into a tree-like structure. Routers are used to manage traffic and constitute borders between subnets. Communication is of specific link-local character (Ethernet broadcast) only within the smallest subnet.

A typical subnet is a physical network served by one router, for instance an Ethernet network (consisting of one or several Ethernet segments or local area networks, interconnected by network switches and network bridges) or a Virtual Local Area Network (VLAN). However, subnetting allows the network to be logically divided regardless of the physical layout of a network, since it is possible to divide a physical network into several subnets by configuring different host computers to use different routers.

While improving network performance, subnetting increases routing complexity, since each locally connected subnet is typically represented by one row in the routing tables in each connected router. However, with intelligent design of the network, routes to collections of more distant subnets within the branches of a tree-hierarchy can be aggregated by single routes.

Subnetting was originally introduced before the introduction of classful network addresses in IPv4 to allow a single larger network to have a number of smaller networks within it, controlled by several routers. Existing subnetting functionality in routers made the introduction of Classless Inter-Domain Routing seamless.

Network address and logical address

The term network address sometimes refers to logical address, i.e. network layer address such as the IP address, and sometimes to the first address (the base address) of a classful address range to an organization.

Computers and devices that are part of an internetworking network such as the Internet each have a logical address. The network address is unique to each device and can either be dynamically or statically configured. An address allows a device to communicate with other devices connected to a network. The most common network addressing scheme is IPv4. An IPv4 address consists of a 32 bit address written, for human readability, into 4 octets and a subnet mask of like size and notation. In order to facilitate the routing process the address is divided into two pieces: 1) The network prefix length that is significant for routing decisions at that particular topological point, and 2) The remaining bits that make up the host portion of the address. A host address is meaningful only when on the subnet where that host resides. This works much like a postal address where the higher order part of the network prefix (e.g., /18) would represent the city, and the host address (i.e., the remaining six bits) would represent the address of a specific house on that street. The subnet mask or CIDR suffix address is used in conjunction with the network address to determine which part of the address is the network address and which part is the host address.

Binary subnet masks

While subnet masks are often represented in dot-decimal form, their use becomes clearer in binary. Looking at a network address and a subnet mask in binary, a device can determine which part of the address is the network address and which part is the host address. To do this, it performs a bitwise "AND" operation.

Example

Dot-decimal Address Binary
IP address 192.168.5.10 11000000.10101000.00000101.00001010
Subnet Mask 255.255.255.0 11111111.11111111.11111111.00000000
Network Portion 192.168.5.0 11000000.10101000.00000101.00000000
Host Portion 0.0.0.10 00000000.00000000.00000000.00001010

Subnet masks consist of 32 bits, usually a block of ones (1) followed by a block of 0s if the subnet follows CIDR allocation methods. The last block of zeros (0) designate that part as being the host identifier. Subnet masks do not have to fill the octets. This allows a classful network to be broken down into subnets. A classful network is a network that has a subnet mask of 255.0.0.0, 255.255.0.0 or 255.255.255.0. Subnet masks can also be expressed in a shorter form, known as Classless Inter-Domain Routing (CIDR) notation, which gives the network number followed by a slash ("/") and the number of 'one' bits in the binary notation of the netmask (i.e. the number of relevant bits in the network number). For example, 192.0.2.96/24 indicates an IP address where the first 24 bits are used as network address (same as 255.255.255.0).

IPv4 classes

IPv4 addresses are broken down into three parts: the network part, the subnet part (now often considered part of the network part, although originally it was part of the rest part), and the host part. Even though classful networks are obsolete, both classful and classless networks are shown in the following table.

Class Leading bits Start End Default Subnet Mask in dotted decimal
A (CIDR /8) 0 0.0.0.0 127.255.255.255 255.0.0.0
B (CIDR /16) 10 128.0.0.0 191.255.255.255 255.255.0.0
C (CIDR /24) 110 192.0.0.0 223.255.255.255 255.255.255.0
D 1110 224.0.0.0 239.255.255.255
E 1111 240.0.0.0 255.255.255.254

While the 127.0.0.0/8 network is in the Class A area, it is designated for loopback and cannot be assigned to a network.

Class D multicasting

Class E reserved

Subnetting is the process of allocating bits from the host portion as a network portion. The above example shows the bitwise "AND" process being performed on a classful network. The following example shows bits being borrowed to turn a classful network into a subnet.

Subnetting

Example

Dot-decimal Address Binary
IP address 192.168.5.130 11000000.10101000.00000101.10000010
Subnet Mask 255.255.255.192 11111111.11111111.11111111.11000000
Network Portion 192.168.5.128 11000000.10101000.00000101.10000000

In this example two bits were borrowed from the original host portion. This is beneficial because it allows a single network portion to be split into several smaller network portions. By design IPv4 addresses are limited in number and each classful network portion is capable of supporting a finite number of hosts. A /24 suffix, such as a classful C block, for example has space for 254 hosts. If a network were to be split into four parts using a classful suffix, four different /24 addresses would have to be used to serve those networks. Using the subnetting example above, if each subnetwork were to have 62 hosts or less (see below for maths), a single /24 suffix could be split up to service the entire network while wasting the fewest host addresses.

Subnets and host count

It is possible to determine the number of hosts and subnetworks available for any subnet mask. In the above example two bits were borrowed to create subnetworks. Each bit can take the value 1 or 0, giving 4 possible subnets ()

Network Network (binary) Broadcast address
192.168.5.0/26 11000000.10101000.00000101.00000000 192.168.5.63
192.168.5.64/26 11000000.10101000.00000101.01000000 192.168.5.127
192.168.5.128/26 11000000.10101000.00000101.10000000 192.168.5.191
192.168.5.192/26 11000000.10101000.00000101.11000000 192.168.5.255


According to the RFC 950 standard the subnet values consisting of all zeros and all ones are reserved, reducing the number of available subnets by 2. However due to the inefficiencies introduced by this convention it is no longer used on the public Internet, and is only relevant when dealing with legacy equipment that does not understand CIDR. The only reason not to use the all-zeroes subnet is that it is ambiguous when the exact suffix length is not available. All CIDR-compliant routing protocols transmit both length and suffix. See RFC 1878 for a subnetting table with extensive examples.

The remaining bits after the subnet are used for addressing hosts within the subnet. In the above example the subnet mask consists of 26 bits, leaving 6 bits for the address (). This allows for 64 possible combinations (), however the all zeros value and all ones value are reserved for the network ID and broadcast address respectively, leaving 62 addresses.

In general the number of available hosts on a subnet can be calculated using the formula , where n is the number of bits used for the host portion of the address.

RFC 3021 specifies an exception to this rule when dealing with 31 bit subnet masks (i.e. 1 host bit). According to the above rule a 31 bit mask would allow for hosts. The RFC makes allowances in this case for certain types of networks (point-to-point) to disregard the network and broadcast address, allowing two host addresses to be allocated.

Possible subnets for a /24 suffix (traditional Class C):

CIDR notation Network Mask Available Networks Available Hosts per network Total usable hosts
/24 255.255.255.0 1 254 254
/25 255.255.255.128 2 126 252
/26 255.255.255.192 4 62 248
/27 255.255.255.224 8 30 240
/28 255.255.255.240 16 14 224
/29 255.255.255.248 32 6 192
/30 255.255.255.252 64 2 128
/31 255.255.255.254 128 2 * 256

* only applicable on point-to-point links

Subnetting in IPv6 networks

The primary reason for subnetting in IPv4 was efficient utilization of the relatively small address space available, particularly to enterprises. Subnetting is also used in IPv6 networks. However, in IPv6 the address space available even to end-users is so large that address space restrictions no longer exist. The smallest recommended allocation to an end-user is an address space of 80 bits (prefix /48) or in some cases 64-bits (prefix /64) for smaller networks. An IPv6 subnet always has the size of 64 bits intended for the host portion of the address. Although technically possible, smaller subnets are impractical because of the methods used for stateless autoconfiguration of network interfaces (RFC 4862). Subnetting, based on the concepts of Classless Inter-Domain Routing is however used in the routing aspects between networks.

Example routing scenario based on subnet concept

Suppose a home network consists of computers named Foo and Bar, connected to a router, and then via a cable modem to the Internet. The home network is configured as a subnet: address 17.76.99.1 is assigned to Foo, address 17.76.99.2 to Bar, and address 17.76.99.100 to the router. The subnet has been configured so that the first three octets of its members' addresses are all the same subnet id, 17.76.99, and this fact is expressed by the subnet mask 255.255.255.0 (binary 11111111 11111111 11111111 00000000) configured in the router.

When Foo sends data to amazon.com at 72.21.210.11, the router performs a logical AND of the destination amazon address with the subnet mask. It also performs a logical AND of the origin address (17.76.99.1) and recognizes that these two results are different, and therefore sends the data over the Internet, via the subnet's default gateway.

When Foo sends data to Bar, however, it determines that the results of the two AND operations are the same, therefore the destination lies within the subnet and the default gateway is not required. The data is transmitted directly from Foo to Bar within the home network.

References

  • RFC 950 Internet Standard Subnetting Procedure
  • RFC 1812 Requirements for IPv4 Routers
  • RFC 917 Utility of subnets of Internet networks
  • RFC 1101 DNS Encodings of Network Names and Other Type
  • RFC 1878 Variable Length Subnet Table For IPv4
  • Blank, Andrew G. TCP/IP Foundations Technology Fundamentals for IT Success. San Francisco, London: Sybex, Copyright 2004.
  • Lammle, Todd. CCNA Cisco Certified Network Associate Study Guide 5th Edition. San Francisco, London: Sybex, Copyright 2005.
  • Groth, David and Toby Skandier. Network + Study Guide, 4th Edition. San Francisco, London: Wiley Publishing, Inc., Copyright 2005.

See also

  • "Understanding IP Addressing - Everything You Ever Wanted To Know" (PDF). 3COM. May 2001. pp. 76 pages. 1.08 MB