background image
IP Addressing and Subnetting 251
The binary algorithm to determine the subnet number, when using difficult subnetting, is
identical to the algorithm used when there is no subnetting or basic subnetting. Again, the key
is in knowing what subnet mask is in use. The binary algorithm is as follows:
Step 1
Write down the IP address in binary.
Step 2
Write down the subnet mask used in this network, in binary,
beneath the binary IP address from Step 1.
Step 3
Record the results of the Boolean AND below the two numbers.
Step 4
Convert the result of Step 3 back into decimal, 8 bits at a time.
The biggest obstacle to understanding this algorithm is failing to realize this one fact: Binary-
decimal-binary conversion is independent of the size of the network, subnet, and host fields.
Conversion always is from one decimal number to eight binary digits, and vice versa.
Typically, an example usually helps. Consider the following binary example:
Ignoring the decimal numbers on the left, a slow examination of the binary address, mask, and
Boolean AND result shows that the conversion to binary and AND are correct as shown. The
typical difficulty is the step of conversion. Many people want to convert the 12-bit host field to
a decimal number and the 4-bit subnet field to a decimal number. Instead, for the last step
(conversion to decimal), convert the first 8-bit set to decimal (0000 1000 converted to decimal
8). Likewise, convert the second 8-bit set (the second byte) to decimal (0000 0001 converted to
decimal 1). Then convert the entire third byte to decimal (0110 0000 converted to decimal 96).
Finally, convert the entire last byte to decimal (0000 0000 converted to decimal 0). The third
byte contains the entire subnet field and part of the host field; the binary-to-decimal conversion
ignores the subnet/host boundaries, always using byte boundaries.
The following examples are shown as additional examples of deriving the subnet number when
a more difficult mask is used:
Address
8.1.100.5
0000 1000 0000 0001 0110 0100 0000 0101
Mask
255.255.240.0
1111 1111 1111 1111 1111 0000 0000 0000
Result
8.1.96.0
0000 1000 0000 0001 0110 0000 0000 0000
Address (Step 1)
130.4.100.129
1000 0010 0000 0100 0110 0100 1000 0001
Mask (Step 2)
255.255.255.128
1111 1111 1111 1111 1111 1111 1000 0000
Result (Steps 3 and 4)
130.4.100.128
1000 0010 0000 0100 0110 0100 1000 0000
Address (Step 1)
199.1.1.4
1100 0111 0000 0001 0000 0001 0000 0100
Mask (Step 2)
255.255.255.224
1111 1111 1111 1111 1111 1111 1110 0000
Result (Steps 3 and 4)
199.1.1.0
1100 0111 0000 0001 0000 0001 0000 0000
ch05.fm Page 251 Monday, March 20, 2000 5:06 PM