Search This Blog

Wednesday, February 16, 2011

IP Subnet Mask

A subnet mask tells a computer or a router how to divide a range of IP addresses into the network part and the host part.

Given:

Address = 131.108.2.160

Subnet Mask = 255.255.255.0

Subnet = 131.108.2.0


In this example, without a subnet mask the address would be treated as class B and the network number would be 131.108. But because someone supplied a subnet mask of 255.255.255.0, the network number is actually 131.108.2.
These days, routers and computers always use subnet masks if they are supplied. If there is no subnet mask for an address, then the class A, B, C scheme is used.

Remember that a network mask determines which portion of an IP address identifies the network and which portion identifies the host, while a subnet mask describes which portion of an address refers to the subnet and which part refers to the host.

IP Subnetting

As it turns out, dividing IP addresses into classes A, B and C is not flexible enough. In particular, it does not make efficient use of the available IP addresses and it does not give network administrators enough control over their internal LAN configurations.
In this diagram, the class B network 131.108 is split (probably into 256 subnets), and a router connects the 131.108.2 subnet to the 131.108.3 subnet.

Types of IPv4 addresses

The Internet standards define the following types of IPv4 addresses:

  • Unicast. Assigned to a single network interface located on a specific subnet on the network and used for one-to-one communications.

  • Multicast. Assigned to one or more network interfaces located on various subnets on the network and used for one-to-many communications.

  • Broadcast. Assigned to all network interfaces located on a subnet on the network and used for one-to-everyone-on-a-subnet communications.

IPv4 unicast addresses

The IPv4 unicast address identifies an interface’s location on the network in the same way a street address identifies a house on a city block. Just as a street address must identify a unique residence, an IPv4 unicast address must be globally unique to the network and have a uniform format.

Each IPv4 unicast address includes a network ID and a host ID.

  • The network ID (also known as a network address) is the fixed portion of an IPv4 unicast address that identifies the set of interfaces that are located on the same physical or logical network segment as bounded by IPv4 routers. A network segment on TCP/IP networks is also known as a subnet. All systems on the same physical or logical subnet must use the same network ID and the network ID must be unique to the entire TCP/IP network.

  • The host ID (also known as a host address) is the variable portion of an IPv4 unicast address that is used to identify a network node’s interface on a subnet. The host ID must be unique to the network ID.

If the network ID is unique to the TCP/IP network and the host ID is unique to the network ID, then the entire IPv4 unicast address consisting of the network ID and host ID is unique to the entire TCP/IP network.

IPv4 multicast addresses

IPv4 multicast addresses are used for single-packet, one-to-many delivery. On an IPv4 multicast-enabled intranet, an IPv4 packet addressed to an IPv4 multicast address is forwarded by routers to the subnets on which there are hosts listening to the traffic sent to the IPv4 multicast address. IPv4 multicast provides an efficient one-to-many delivery service for many types of communication.

IPv4 multicast addresses are defined by the class D Internet address class: 224.0.0.0/4. IPv4 multicast addresses range from 224.0.0.0 through 239.255.255.255. IPv4 multicast addresses for the 224.0.0.0/24 address prefix (224.0.0.0 through 224.0.0.255) are reserved for local subnet multicast traffic.

IPv4 broadcast addresses

IPv4 uses a set of broadcast addresses to provide a one-to-everyone-on-the-subnet delivery service. Packets sent to IPv4 broadcast addresses are processed by all the interfaces on the subnet. The following are the different types of IPv4 broadcast addresses:

  • Network broadcast. Formed by setting all the host bits to 1 for a classful address prefix. An example of a network broadcast address for the classful network ID 131.107.0.0/16 is 131.107.255.255. Network broadcasts are used to send packets to all interfaces of a classful network. IPv4 routers do not forward network broadcast packets.

  • Subnet broadcast. Formed by setting all the host bits to 1 for a classless address prefix. An example of a network broadcast address for the classless network ID 131.107.26.0/24 is 131.107.26.255. Subnet broadcasts are used to send packets to all hosts of a classless network. IPv4 routers do not forward subnet broadcast packets. For a classful address prefix, there is no subnet broadcast address, only a network broadcast address. For a classless address prefix, there is no network broadcast address, only a subnet broadcast address.

  • All-subnets-directed broadcast. Formed by setting all the original classful network ID host bits to 1 for a classless address prefix. A packet addressed to the all-subnets-directed broadcast was defined to reach all hosts on all of the subnets of a subnetted class-based network ID. An example of an all-subnets-directed broadcast address for the subnetted network ID 131.107.26.0/24 is 131.107.255.255. The all-subnets-directed broadcast is the network broadcast address of the original classful network ID. IPv4 routers can forward all-subnets-directed broadcast packets, but the use of the all-subnets-directed broadcast address is deprecated in RFC 1812.

  • Limited broadcast. Formed by setting all 32 bits of the IPv4 address to 1 (255.255.255.255). The limited broadcast address is used for one-to-everyone delivery on the local subnet when the local network ID is unknown. IPv4 nodes typically only use the limited broadcast address during an automated configuration process such as Bootstrap Protocol (BOOTP) or DHCP. For example, with DHCP, a DHCP client must use the limited broadcast address for all traffic sent until the DHCP server acknowledges the use of the offered IPv4 address configuration. IPv4 routers do not forward limited broadcast packets.

Introduction To IPv4-addressing

IP addresses in IPv4 are 32 bits long, and are often written in dotted decimal notation, where each byte is represented by a decimal number between 0 and 255, and these values are separated by a period (a full stop), for example 192.168.11.4 The address for a specific host must have a unique 32-bit address and this in composed from a network prefix and a host part. All of the hosts within a network share a common network prefix, and each host within a network must have a unique host part of the overall address. The boundary between the network part and the host part of the address can occur at different places within the overall 32-bit address, and where this boundary lies for a specific host is defined by the mask for the address. Traditionally these addresses have been defined by network prefix ending on each of the byte boundaries within the addressing field:

  • Class A addresses use the most significant byte for the network part, the three remaining byte for the host part of the address
  • Class B addresses use the most significant two bytes for the network part, and the remaining bytes for the host part of the address
  • Class C addresses use the most significant three bytes for the network part, and the remaining byte for the host part of the address
  • Class D addresses are special addresses reserved for multicast; many hosts can listen on the same multicast address for packets sent from one sender