• Subnet mask uses the same format and representation technique as IP addresses.
• Subnet mask has binary is in all bits specifying the network and subnet-work fields, and binary Os in all bits specifying the host field.
• A subnet address is created by borrowing the bits from host field.
• Subnet mask bits should come from the high-order (left most) bits of the host field.
• Various types of subnet mask exist for class Band C subnets.
• The default subnet mask for a class B address that has no subnetting is 255.255.0.0, while the subnet mask for a class B address 171.16.0.0 that specifies eight bits of subnetting is 255.255.255.0. The reason for this is that eight bits of subnetting or 28 – 2 (1 for the network address and 1 for the broadcast address) = 254 subnets possible, with 28 – 2 = 254 hosts per subnet.
• The subnet mask for a class C address 192.168.2.0 that specifies five bits of subnetting is 255.255.255.248 with five bits available for subnetting, 25 – 2 = 30 subnets possible, with 23 – 2 = 6 hosts per subnet.
How subnet masks are used to determine the network number
• The router performs a set process to determine the network (or more specifically, the subnetwork) address.
• First, the router extracts the IP destination address from the incoming packet and retrieves the internal subnet mask.
• It then performs a logical AND operation to obtain the network number. In logical AND operation, 1 “ANDed” with 1 yields 1 and 1 “ANDed” with 0 yields 0.
• This causes the host portion of the IP destination address to be removed, while the destination network number remains.
• The router then looks up the destination network number and matches it with an outgoing interface.
• Finally, it forwards the frame to the destination IP address.
• Figure shows that when a logical AND of the destination IP address and the subnet mask is performed, the sub-network number remains, which the router uses to forward the packet.