|  | 10.7 | Creating a Subnet
| 10.7.2 | Determining subnet mask size

Subnet masks use the same format as IP addresses. They are 32 bits long and are divided into four octets, written in dotted decimal format. Subnet masks contain all 1s in the network bit positions (determined by the address class) as well as the desired subnet bit positions, and contain all 0s in the remaining bit positions, designating them as the host portion of an address.

By default, if you borrow no bits, the subnet mask for a Class B network would be 255.255.0.0, which is the dotted decimal equivalent of 1s in the 16 bits corresponding to the Class B network number.

If 8 bits were to be borrowed for the subnet field, the subnet mask would include 8 additional 1 bits, and would become 255.255.255.0.

For example, if the subnet mask 255.255.255.0 were associated with the Class B address 130.5.2.144 (8 bits borrowed for subnetting), the router would know to route this packet to subnet 130.5.2.0 rather than to just network 130.5.0.0

Another example is the Class C address 197.15.22.131, with a subnet mask of 255.255.255.224. With a value of 224 in the final octet (11100000 in binary), the 24 bit Class C network portion has been extended by 3 bits, to make the total 27 bits. The 131 in the last octet now presents the third usable host address in the subnet 197.15.22.128. The routers in the Internet (that don't know the subnet mask) will only worry about routing to the Class C network 197.15.22.0, while the routers inside that network, knowing the subnet mask, will be looking at 27 bits to make a routing decision.