| Subnet Masks To decide whether the source and destination hosts
are on the same network looks easy: just make a comparison between the two
network IDs of the two addresses. For example consider the following two addresses:
- Source
200.100.55.101
- Destination
200.100.66.72
-
- These are class C networks, so the source address has
a network ID of 200.100.55.101, and the destination has network ID of 200.100.66.72.
Thus they are on different networks. Or are they ? One of the consequences of having
no more class A and class B address blocks is that many large corporations can handle
their addressing needs only by obtaining multiple blocks of class C address. So it's
entirely possible that the 200.100.55.101 and 200.100.66.72 networks IDs belong to
the same company and could therefore be part of the same network! If so, IP should look at
only the first two quads(200.100) to determine whether the address on the same network.
So how does IP know to compare the first one, two,
or three quads? by using a subnet mask. A subnet is a subsection of a network that uses
related IP addressees. On a class C network, for example, you could define the first 127
addresses to be on one subnet and the second 127 addresses to be on another subnet. On a
larger scale, from the point of view of the internet - which you think of as being the
network- each class A, B and C networks is a subnet.
The subnet mask is a 32-bit value that usually
expressed in the same dotted-decimal notation used by IP addresses. The purpose of the
subnet mask is to let IP separate the network ID (or, as you saw in preceding
example, part of the network ID) from the full IP address and thus determine whether
source and destination are on the same network
This table spells out the default subnet
masks for each type of network class.
Network |
Subnet Mask |
Bit Value |
| Class A |
255.0.0.0 |
11111111 00000000 00000000 00000000 |
| Class B |
255.255.0.0 |
11111111 11111111 00000000 00000000 |
| Class C |
255.255.255.0 |
11111111 11111111 11111111 00000000 |
When IP applies the subnet mask to an IP address, the
part of that mask is all 0's strips off the corresponding section of the address. consider
the following example:
|
IP Address |
Mask |
Results |
| Source |
205.208.113.2 |
255.255.255.0 |
205.208.113.0 |
| Destination |
205.208.113.50 |
205.208.113.50 |
205.208.113.50 |
The mask produces the same result, so these two addresses are on the same
network. Now consider the example we used earlier. In this case we need to use a
nonstandard mask of 255.255.0.0:
|
IP address |
Mask |
Result |
| Source |
200.100.55.101 |
255.255.0.0 |
200.100.0.0 |
| Destination |
200.100.66.72 |
255.255.0.0 |
200.100.0.0 |
How subnet Mask works ?
The operation of the subnet is a bit more complex. than we have
let on. It's actually a two step processes. In the first step, the IP addresses are both
compared bit by bit with the subnet mask using a Boolean AND operation- if both are 1, a 1
returned; otherwise, a 0 is returned:
| Source |
|
| 205.208.113.2 |
11001101 11010000 01110001 00000010 |
| 255.255.255.0 |
11111111 11111111 11111111 00000000 |
| Result of AND |
11001101 11010000 01110001 00000000 |
| Destination |
|
| 205.208.113.50 |
11001101 11010000 01110001 00110010 |
| 255.255.255.0 |
11111111 11111111 11111111 00000000 |
| Result of AND |
11001101 11010000 01110001 00000000 |
Now the two results are compared bit by bit a Boolean Exclusive or (xoR)
operation if the both bits are 0 or 1 , a 0 is returned; otherwise; a 1 is returned:
| Source Result |
11001101 11010000 01110001 00000000 |
| Destination Result |
11001101 11010000 01110001 00000000 |
| Result of XOR |
00000000 00000000 00000000 00000000 |
I f the results of the xoR operation is all
0's, the source and destination are on the same network. |