So in this example of these devices in the same subnet or in different subnets the PC on the left has
an IP address of 10 dot one at one but one with the subnet mask of 2 4 5 2 4 5 0 0 the device on the
right has an IP address of 10 dot wander to that one with a Mosque of 5.2 for 5.0 to zero.
So the device on the left does the following when it wants to communicate with the device on the right.
It does a logical and on the network portion of the address so first determines which portion of its
address is the network portion and then it compares that to the network portion of the device that it's
wanting to communicate with.
So in this example the network portion is ten to one.
So in other words the first two octets of the address on network the device checks the first two octets
of the other device to see if it's the same as its local network portion.
And in this example they all the same.
So the device on the left will send traffic to the device on the right directly and it will not try
and send the traffic to its default gateway.
What it will do is send an up message onto the local segment requesting the MAC address associated with
IP address 10 1 to two to 1.
It will try and communicate with 10.0 one or two to one on the local segment directly and not send the
traffic to a default gateway.
And the reason for that is that the network portion of the addresses are the same.
So the local device knows that the other device is on the same or local segment as itself.
In this example the network mosque has changed its 2.5 to 4 5 2 5 5 0.
So the device on the left will do a logical and and check whether the network portion of the device
that it's wanting to communicate with is the same as its network portion.
So based on the subnet mask the local devices network portion is 10 dot 1.1.
The device it's wanting to communicate with has a network portion of 10 1 or two.
So in this case the network portion is different.
So the local host knows that the device that it's wanting to communicate with is on a different subnet
to itself.
So because these two devices on different subnets the local device will send its traffic to its configured
default gateway PCs will send traffic to their default gateways when a default gateway is configured.
In this example let's assume that a default gateway is configured and that's normally what happens in
a real world implementation.
So the PC is trying to talk to a device in a different subnet so it'll same it's traffic to its default
gateway.
So in summary the subnet mask allows the local device to determine whether the device that it's trying
to communicate with is on the same subnet as itself or if it's on a different subnet.
Now Cisco and most network vendors do not support discontiguous subnet mosques a discontiguous subnet
mask would look something like the following.
Notice in the binary we have binary ones then binary zeros then binary ones binary zeros binary ones
binary zeros and so forth and so on.
This type of discontiguous subnet mask is not supported only contiguous subnet masks are supported in
this example.
We have contiguous or continuous ones in the binary and then contiguous or continuous zeros in the binary.
Converting that to decimal gives us a value of 255 242 at 0.0.
In this example notice we have contiguous ones in binary and then contiguous zeros in binary giving
us a result in decimal of 2 5 5 2 5 5 8 1 9 2 0.
So in a subnet mask we must start with binary ones and they must be contiguous.
So you cannot have binary ones then binary zeros then binary ones and so forth and so one they must
be contiguous ones and then contiguous zeros.
So you can for argument's sake have a subnet mask something like 0.00 240.
That's not supported subnet masks have to be contiguous ones followed by contiguous zeros.
Discontiguous subnet masks are not supported and think goodness for that because it makes our lives
as a network engineer is a lot easier to have contiguous subnet masks.